aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ATSAMA5D2
diff options
context:
space:
mode:
authorisiora <isiora@110e8d01-0319-4d1e-a829-52ad28d1bb01>2018-05-11 09:50:54 +0000
committerisiora <isiora@110e8d01-0319-4d1e-a829-52ad28d1bb01>2018-05-11 09:50:54 +0000
commitfe8665fe9e4bc40934ce500c7360cac09a56bcd0 (patch)
tree86831d2b5ff2ab808f7befd29bbdd2867b11090f /demos/ATSAMA5D2
parent233d1b74163238bd313b6d4bfeb3c10d520d5c66 (diff)
downloadChibiOS-fe8665fe9e4bc40934ce500c7360cac09a56bcd0.tar.gz
ChibiOS-fe8665fe9e4bc40934ce500c7360cac09a56bcd0.tar.bz2
ChibiOS-fe8665fe9e4bc40934ce500c7360cac09a56bcd0.zip
Refactory of the proxy stubs code.
Added the IOBlks proxystub. Included reliance edge test. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12019 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'demos/ATSAMA5D2')
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/.project5
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/Makefile18
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tscommon.h60
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.c123
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.h82
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.c287
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.h70
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.c139
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.h2
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/dummyredconf.h114
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/main.c66
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/mcuconf.h21
12 files changed, 838 insertions, 149 deletions
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/.project b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/.project
index bfd992455..a842483f9 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/.project
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/.project
@@ -82,6 +82,11 @@
<locationURI>CHIBIOS/os/hal/boards/ATSAMA5D2_XULT_NSEC</locationURI>
</link>
<link>
+ <name>lwip</name>
+ <type>2</type>
+ <locationURI>CHIBIOS/ext/lwip</locationURI>
+ </link>
+ <link>
<name>os</name>
<type>2</type>
<locationURI>CHIBIOS/os</locationURI>
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/Makefile b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/Makefile
index 10c6c1c35..4a0456ef9 100755
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/Makefile
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/Makefile
@@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -Og -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
@@ -121,7 +121,7 @@ include $(CHIBIOS)/os/common/startup/ARM/compilers/GCC/mk/startup_sama5d2.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/SAMA/SAMA5D2x/platform.mk
-include $(CHIBIOS)/os/hal/boards/ATSAMA5D2_XULT_NSEC/board.mk
+include $(CHIBIOS)/os/hal/boards/BV1000GT_NSEC/board.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
@@ -134,14 +134,17 @@ include $(CHIBIOS)/os/hal/lib/streams/streams.mk
include lwip.mk
# Define linker script file here
-LDSCRIPT= $(STARTUPLD)/SAMA5D2ddr.ld
+LDSCRIPT= $(STARTUPLD)/SAMA5D2bvddr.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC) \
$(TESTSRC) \
$(CHIBIOS)/os/various/evtimer.c \
+ $(CHIBIOS)/os/various/reledge_bindings/SAMA5D2x/ch_sdmmc_reledge.c \
daemons/tssockskel.c \
+ daemons/tsdaemonskels.c \
+ daemons/tsioblksskel.c \
tsclient.c \
lwipthread.c \
main.c
@@ -176,6 +179,9 @@ ASMXSRC = $(ALLXASMSRC)
INCDIR = $(ALLINC) $(TESTINC) \
$(LWINC) \
+ $(CHIBIOS)/os/various/reledge_bindings/SAMA5D2x \
+ $(CHIBIOS)/ext/reliance-edge/include \
+ $(CHIBIOS)/ext/reliance-edge/os/chibios/include \
$(CHIBIOS)/os/various
#
@@ -206,7 +212,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# ARM-specific options here
-AOPT =
+AOPT =
# THUMB-specific options here
TOPT = -mthumb -DTHUMB
@@ -226,10 +232,10 @@ CPPWARN = -Wall -Wextra -Wundef
#
# List all user C define here, like -D_DEBUG=1
-UDEFS =
+UDEFS =
# Define ASM defines here
-UADEFS =
+UADEFS =
# List all user directories here
UINCDIR =
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tscommon.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tscommon.h
index 3a2698451..bc1c3f5f8 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tscommon.h
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tscommon.h
@@ -38,16 +38,43 @@
#define SKEL_REQ_PUTRES 3
#define SKEL_REQ_READY 4
-#define STUB_OP_SOCKET 0
-#define STUB_OP_CLOSE 1
-#define STUB_OP_CONNECT 2
-#define STUB_OP_RECV 3
-#define STUB_OP_SEND 4
-#define STUB_OP_SELECT 5
-#define STUB_OP_BIND 6
-#define STUB_OP_LISTEN 7
+/* Sockets stub defines.*/
+#define SOCK_OP_SOCKET 0
+#define SOCK_OP_CLOSE 1
+#define SOCK_OP_CONNECT 2
+#define SOCK_OP_RECV 3
+#define SOCK_OP_SEND 4
+#define SOCK_OP_SELECT 5
+#define SOCK_OP_BIND 6
+#define SOCK_OP_LISTEN 7
-#define EVT_F_SOCK_NEW_OP 1
+/* Socket new op event.*/
+#define EVT_F_SOCK_NEW_OP 1
+
+/* Sockets stub service name.*/
+#define SOCKS_SVC_NAME "TsSocksStubService"
+
+/* IOBlocks stub defines.*/
+#define IOBLKS_OP_OPEN 0
+#define IOBLKS_OP_CLOSE 1
+#define IOBLKS_OP_READ 2
+#define IOBLKS_OP_WRITE 3
+#define IOBLKS_OP_FLUSH 4
+
+/* IOBlock new op event.*/
+#define EVT_F_IOBLK_NEW_OP 2
+
+/* IOBlock stub service name.*/
+#define IOBLKS_SVC_NAME "TsIOBlksStubService"
+
+/* Sector size.*/
+#define IOBLKS_SECT_SIZE 512U
+
+/* Remote Partition size, in sectors.*/
+#define IOBLKS_PART_SIZE 96256U
+
+/* Remote partition offset, in sectors.*/
+#define IOBLKS_PART_OFFS 952320U
/*===========================================================================*/
/* Module pre-compile time settings. */
@@ -63,13 +90,16 @@
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
+typedef struct skel_ctx skel_ctx_t;
+
typedef struct skel_req {
- uint32_t req; /* getop, cpyprms, putres */
- uint32_t stub_op;
- uint32_t stub_op_code;
- uint32_t stub_op_result;
- uint32_t stub_op_p_sz[METHOD_MAX_PARAMS];
- uint32_t stub_op_p[METHOD_MAX_PARAMS];
+ uint32_t req; /* getop, cpyprms, putres */
+ uint32_t stub_op;
+ uint32_t stub_op_code;
+ uint32_t stub_op_result;
+ uint32_t stub_op_p_sz[METHOD_MAX_PARAMS];
+ uint32_t stub_op_p[METHOD_MAX_PARAMS];
+ skel_ctx_t *scp; /* the skeleton context this req come from.*/
} skel_req_t;
/*===========================================================================*/
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.c
new file mode 100644
index 000000000..fe1ee682f
--- /dev/null
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.c
@@ -0,0 +1,123 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file tsdaemonskel.c
+ * @brief Common skeletons daemon for trusted clients.
+ *
+ */
+
+#include "ch.h"
+#include "chobjfifos.h"
+#include "tsclient.h"
+#include "tsdaemonskels.h"
+#include <string.h>
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+static inline msg_t invokeStubService(skel_req_t *skreqp) {
+ msg_t r;
+
+ chMtxLock(&skreqp->scp->stub_svc_mtx);
+ r = tsInvokeServiceNoYield(skreqp->scp->stub_svc,
+ (ts_params_area_t)skreqp, sizeof *skreqp);
+ chDbgAssert(r != SMC_SVC_BUSY, "Unexpected SMC_SVC_BUSY");
+ chMtxUnlock(&skreqp->scp->stub_svc_mtx);
+ return r;
+}
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Invoke the stubs service in order to copy the 'in'
+ * parameters in the non secure memory space.
+ */
+void paramsInFromRemote(skel_req_t *skreqp) {
+ skreqp->req = SKEL_REQ_CPYPRMS;
+ (void) invokeStubService(skreqp);
+}
+
+/**
+ * @brief Invoke the stubs service in order to copy the 'out'
+ * parameters in the secure memory space and set the
+ * remote call result.
+ */
+void returnToRemote(skel_req_t *skreqp, uint32_t res) {
+ skreqp->stub_op_result = res;
+ skreqp->req = SKEL_REQ_PUTRES;
+ (void) invokeStubService(skreqp);
+ chFifoReturnObject(&skreqp->scp->skel_req_fifo, skreqp);
+}
+
+/**
+ * @brief Dispatch a request to a skeleton worker thread.
+ */
+THD_FUNCTION(TsSkelsDaemon, arg) {
+ skel_ctx_t *skel_ctx = (skel_ctx_t *)arg;
+ event_listener_t el;
+ skel_req_t *skreqp;
+ msg_t r;
+
+ chEvtRegisterMaskWithFlags(&stubsEventSource, &el, ALL_EVENTS,
+ skel_ctx->skel_eventflag);
+ chMtxObjectInit(&skel_ctx->stub_svc_mtx);
+ skel_ctx->stub_svc = (ts_service_t)tsInvokeServiceNoYield(TS_HND_DISCOVERY,
+ (ts_params_area_t)skel_ctx->stub_svc_name,
+ strlen(skel_ctx->stub_svc_name) + 1);
+
+ /* Tell to stubs service that we are ready.*/
+ skreqp = chFifoTakeObjectTimeout(&skel_ctx->skel_req_fifo, TIME_INFINITE);
+ skreqp->req = SKEL_REQ_READY;
+ skreqp->stub_op = skel_ctx->skel_eventflag;
+ tsInvokeServiceNoYield(skel_ctx->stub_svc, (ts_params_area_t)skreqp,
+ sizeof *skreqp);
+ chFifoReturnObject(&skel_ctx->skel_req_fifo, skreqp);
+
+ /* Start to receive ops from stubs.*/
+ for (;/* ever */;) {
+ chEvtWaitAny(ALL_EVENTS);
+ (void)chEvtGetAndClearFlags(&el);
+ while (true) {
+ skreqp = chFifoTakeObjectTimeout(&skel_ctx->skel_req_fifo, TIME_INFINITE);
+ skreqp->req = SKEL_REQ_GETOP;
+ skreqp->scp = skel_ctx;
+ r = invokeStubService(skreqp);
+ if (r == SMC_SVC_NHND)
+ break;
+ chFifoSendObject(&skel_ctx->skel_req_fifo, skreqp);
+ }
+ chFifoReturnObject(&skel_ctx->skel_req_fifo, skreqp);
+ }
+}
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.h
new file mode 100644
index 000000000..a8e342e4b
--- /dev/null
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsdaemonskels.h
@@ -0,0 +1,82 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
+
+ This file is part of ChibiOS.
+
+ ChibiOS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file tsdaemonskels.h
+ * @brief Common skeletons daemon macros and structures.
+ *
+ */
+
+#ifndef TSDAEMONSKELS_H
+#define TSDAEMONSKELS_H
+
+#include "ch.h"
+#include "ccportab.h"
+#include "tscommon.h"
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+#define N_MAX_SKEL_REQS 4
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+typedef struct skel_ctx {
+ objects_fifo_t skel_req_fifo;
+ msg_t skel_req_msgs[N_MAX_SKEL_REQS];
+ skel_req_t skel_reqs[N_MAX_SKEL_REQS];
+ eventflags_t skel_eventflag;
+ ts_service_t stub_svc;
+ mutex_t stub_svc_mtx;
+ const char *stub_svc_name;
+} skel_ctx_t;
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void paramsInFromRemote(skel_req_t *skreqp);
+ void returnToRemote(skel_req_t *skreqp, uint32_t res);
+ THD_FUNCTION(TsSkelsDaemon, arg);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+#endif /* TSDAEMONSKELS_H */
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.c
new file mode 100644
index 000000000..b27824501
--- /dev/null
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.c
@@ -0,0 +1,287 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file tsioblksskel.c
+ * @brief IOBlocks skeleton daemon for trusted clients.
+ *
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "chobjfifos.h"
+#include "tsclient.h"
+#include "tsdaemonskels.h"
+#include "tsioblksskel.h"
+#include "dummyredconf.h"
+#include "rederrno.h"
+#include "redostypes.h"
+#include "redosserv.h"
+#include "sama_sdmmc_lld.h"
+#include "ch_sdmmc_device.h"
+#include "ch_sdmmc_cmds.h"
+#include "ch_sdmmc_sdio.h"
+#include "ch_sdmmc_sd.h"
+#include "ch_sdmmc_mmc.h"
+#include "ch_sdmmc_reledge.h"
+#include <string.h>
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+static skel_ctx_t skel_ctx;
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/**
+ * @name IOBlocks API skeletons, in reliance edge fashion.
+ * @{
+ */
+
+/**
+ * @brief int red_open(uint8_t bVolNum, int mode)
+ */
+static void red_open(skel_req_t *skreqp) {
+ REDSTATUS result = 0;
+ uint32_t ulTries;
+ eSDMMC_RC cs;
+ SdmmcDriver *sdmmcp = NULL;
+ uint8_t bVolNum;
+ int mode;
+
+ bVolNum = (uint8_t)skreqp->stub_op_p[0];
+ mode = (int)skreqp->stub_op_p[1];
+ if (!sdmmcGetInstance(bVolNum, &sdmmcp))
+ result = -RED_EINVAL;
+ else {
+ for (ulTries = 0U; ulTries < 20U; ulTries++) {
+ cs = sd_mmc_test_unit_ready(sdmmcp);
+ if ((cs == SDMMC_OK) && (cs != SDMMC_BUSY)){
+ break;
+ }
+ chThdSleepMilliseconds(5);
+ }
+
+ if (cs == SDMMC_OK) {
+ if (mode != BDEV_O_RDONLY)
+ if (sd_mmc_is_write_protected(sdmmcp))
+ result = -RED_EROFS;
+ } else
+ result = -RED_EIO;
+ }
+
+ /* report the result and copy the 'out' parameters.*/
+ returnToRemote(skreqp, result);
+}
+
+/**
+ * @brief int red_close(uint8_t bVolNum)
+ */
+static void red_close(skel_req_t *skreqp) {
+ int result;
+
+ result = 0;
+
+ /* report the result.*/
+ returnToRemote(skreqp, result);
+}
+
+
+/**
+ * @brief int red_read(uint8_t bVolNum, uint32_t ulSectorStart, uint32_t ulSectorCount, void *pBuffer)
+ */
+static void red_read(skel_req_t *skreqp) {
+ REDSTATUS result = 0;
+ uint8_t bVolNum;
+ uint32_t ulSectorStart;
+ uint32_t ulSectorCount;
+ void *mem;
+ size_t len;
+
+ bVolNum = (uint8_t)skreqp->stub_op_p[0];
+ ulSectorStart = (uint32_t)skreqp->stub_op_p[1] + IOBLKS_PART_OFFS;
+ ulSectorCount = (uint32_t)skreqp->stub_op_p[2];
+ len = ulSectorCount * IOBLKS_SECT_SIZE;
+
+ /* Allocate the space for the receive buffer.*/
+ mem = chHeapAlloc(NULL, len);
+ if (NULL == mem) {
+ result = -RED_ENOMEM;
+ len = 0;
+ } else {
+ SdmmcDriver *sdmmcp = NULL;
+ eSDMMC_RC cs;
+
+ if (!sdmmcGetInstance(bVolNum, &sdmmcp)) {
+ result = -RED_EINVAL;
+ len = 0;
+ } else {
+ cs = SD_ReadBlocks(sdmmcp, ulSectorStart, mem, ulSectorCount);
+ if(cs != SDMMC_OK) {
+ result = -RED_EIO;
+ len = 0;
+ }
+ }
+ }
+ skreqp->stub_op_p_sz[3] = len;
+ skreqp->stub_op_p[3] = (uint32_t)mem;
+
+ /* report the result and copy 'out' parameter mem.*/
+ returnToRemote(skreqp, result);
+ if (NULL != mem)
+ chHeapFree(mem);
+}
+
+/**
+ * @brief int red_write(uint8_t bVolNum, uint32_t ulSectorStart, uint32_t ulSectorCount, const void *pBuffer)
+ */
+static void red_write(skel_req_t *skreqp) {
+ REDSTATUS result = 0;
+ uint8_t bVolNum;
+ uint32_t ulSectorStart;
+ uint32_t ulSectorCount;
+ void *dataptr;
+ size_t size;
+
+ bVolNum = (uint8_t)skreqp->stub_op_p[0];
+ ulSectorStart = (uint32_t)skreqp->stub_op_p[1] + IOBLKS_PART_OFFS;
+ ulSectorCount = (uint32_t)skreqp->stub_op_p[2];
+ size = ulSectorCount * IOBLKS_SECT_SIZE;
+
+ /* Allocate the space for the send buffer.*/
+ dataptr = chHeapAlloc(NULL, size);
+ if (NULL == dataptr) {
+ result = -RED_ENOMEM;
+ } else {
+ SdmmcDriver *sdmmcp = NULL;
+ eSDMMC_RC cs;
+
+ skreqp->stub_op_p[3] = (uint32_t)dataptr;
+
+ /* call the stub service in order to copy the
+ 'in' parameter dataptr.*/
+ paramsInFromRemote(skreqp);
+
+ if (!sdmmcGetInstance(bVolNum, &sdmmcp)) {
+ result = -RED_EINVAL;
+ } else {
+ cs = SD_WriteBlocks(sdmmcp, ulSectorStart, dataptr, ulSectorCount);
+ if (cs != SDMMC_OK)
+ result = -RED_EIO;
+ }
+
+ chHeapFree(dataptr);
+ }
+
+ /* report the result.*/
+ returnToRemote(skreqp, result);
+}
+
+/**
+ * @brief red_flush(uint8_t bVolNum);
+ */
+static void red_flush(skel_req_t *skreqp) {
+ REDSTATUS result = 0;
+ uint8_t bVolNum;
+ eSDMMC_RC cs;
+ SdmmcDriver *sdmmcp = NULL;
+
+ bVolNum = (uint8_t)skreqp->stub_op_p[0];
+ if (!sdmmcGetInstance(bVolNum, &sdmmcp))
+ result = -RED_EINVAL;
+ else {
+ cs = sd_mmc_test_unit_ready(sdmmcp);
+ if(cs != SDMMC_OK)
+ result = -RED_EIO;
+ }
+
+ /* Report the result.*/
+ returnToRemote(skreqp, result);
+}
+
+/**
+ * @brief IOBlocks Daemon. Dispatch a request to the corresponding
+ * local method.
+ */
+static THD_FUNCTION(TsIOBlksSkelDaemon, arg) {
+ objects_fifo_t *ofp = arg;
+ skel_req_t *skreqp;
+
+ for (;/* ever */;) {
+ chFifoReceiveObjectTimeout(ofp, (void **)&skreqp,
+ TIME_INFINITE);
+ switch (skreqp->stub_op_code) {
+ case IOBLKS_OP_OPEN:
+ red_open(skreqp);
+ break;
+ case IOBLKS_OP_CLOSE:
+ red_close(skreqp);
+ break;
+ case IOBLKS_OP_READ:
+ red_read(skreqp);
+ break;
+ case IOBLKS_OP_WRITE:
+ red_write(skreqp);
+ break;
+ case IOBLKS_OP_FLUSH:
+ red_flush(skreqp);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Init the IOBlocks skeleton daemon objects and create the
+ * corresponding threads.
+ */
+void tsIOBlksSkelInit(void) {
+ int i;
+ skel_ctx_t *scp;
+
+ scp = &skel_ctx;
+ chFifoObjectInit(&scp->skel_req_fifo, sizeof (skel_req_t), N_MAX_SKEL_REQS,
+ sizeof (uint8_t), scp->skel_reqs, scp->skel_req_msgs);
+ scp->skel_eventflag = EVT_F_IOBLK_NEW_OP;
+ scp->stub_svc_name = IOBLKS_SVC_NAME;
+
+ for (i = 0; i < N_IOBLKSKEL_THD; ++i)
+ chThdCreateFromHeap(NULL, 2048, "TsIOBlksSkelDaemonWrk", NORMALPRIO,
+ TsIOBlksSkelDaemon, &scp->skel_req_fifo);
+ chThdCreateFromHeap(NULL, 2048, "TsIOBlksSkelDaemon", NORMALPRIO,
+ TsSkelsDaemon, scp);
+}
+
+/** @} */
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.h
new file mode 100644
index 000000000..cb91230e5
--- /dev/null
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tsioblksskel.h
@@ -0,0 +1,70 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
+
+ This file is part of ChibiOS.
+
+ ChibiOS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file tsioblksskel.h
+ * @brief IOBlocks skeleton module macros and structures.
+ *
+ */
+
+#ifndef TSIOBLKSSKEL_H
+#define TSIOBLKSSKEL_H
+
+#include "ch.h"
+#include "ccportab.h"
+#include "tscommon.h"
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+#define N_IOBLKSKEL_THD 4
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void tsIOBlksSkelInit(void);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+#endif /* TSIOBLKSSKEL_H */
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.c
index 7b485675c..c3d6d3cac 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.c
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.c
@@ -23,6 +23,7 @@
#include "ch.h"
#include "chobjfifos.h"
#include "tsclient.h"
+#include "tsdaemonskels.h"
#include "tssockskel.h"
#include <string.h>
@@ -41,53 +42,13 @@
/*===========================================================================*/
/* Module local variables. */
/*===========================================================================*/
-
-static ts_service_t tsStubsService = NULL;
-static MUTEX_DECL(tsStubsServiceMtx);
-
-static objects_fifo_t skel_req_fifo;
-static msg_t skel_req_msgs[N_SOCKSKEL_THD];
-static skel_req_t skel_reqs[N_SOCKSKEL_THD] = {0};
+static skel_ctx_t skel_ctx;
/*===========================================================================*/
/* Module local functions. */
/*===========================================================================*/
/**
- * @brief Invoke the stubs service in order to copy the 'in'
- * parameters in the non secure memory space.
- */
-static void paramsInFromRemote(skel_req_t *skreqp) {
- msg_t r;
-
- skreqp->req = SKEL_REQ_CPYPRMS;
- chMtxLock(&tsStubsServiceMtx);
- r = tsInvokeServiceNoYield(tsStubsService,
- (ts_params_area_t)skreqp, sizeof *skreqp);
- chDbgAssert(r != SMC_SVC_BUSY, "Unexpected SMC_SVC_BUSY");
- chMtxUnlock(&tsStubsServiceMtx);
-}
-
-/**
- * @brief Invoke the stubs service in order to copy the 'out'
- * parameters in the secure memory space and set the
- * remote call result.
- */
-static void returnToRemote(skel_req_t *skreqp, uint32_t res) {
- msg_t r;
-
- skreqp->stub_op_result = res;
- skreqp->req = SKEL_REQ_PUTRES;
-
- chMtxLock(&tsStubsServiceMtx);
- r = tsInvokeServiceNoYield(tsStubsService,
- (ts_params_area_t)skreqp, sizeof *skreqp);
- chDbgAssert(r != SMC_SVC_BUSY, "Unexpected SMC_SVC_BUSY");
- chMtxUnlock(&tsStubsServiceMtx);
- chFifoReturnObject(&skel_req_fifo, skreqp);
-}
-
-/**
* @name Sockets API skeletons.
* @{
*/
@@ -273,46 +234,39 @@ static void l_listen(skel_req_t *skreqp) {
returnToRemote(skreqp, result);
}
-/** @} */
-
-/*===========================================================================*/
-/* Module exported functions. */
-/*===========================================================================*/
-
/**
- * @brief Dispatch a request to a local method.
+ * @brief Socket Daemon. Dispatch a request to a local method.
*/
static THD_FUNCTION(TsSockSkelDaemon, arg) {
- (void)arg;
-
+ objects_fifo_t *ofp = arg;
skel_req_t *skreqp;
for (;/* ever */;) {
- chFifoReceiveObjectTimeout(&skel_req_fifo, (void **)&skreqp,
+ chFifoReceiveObjectTimeout(ofp, (void **)&skreqp,
TIME_INFINITE);
switch (skreqp->stub_op_code) {
- case STUB_OP_SOCKET:
+ case SOCK_OP_SOCKET:
l_socket(skreqp);
break;
- case STUB_OP_CONNECT:
+ case SOCK_OP_CONNECT:
l_connect(skreqp);
break;
- case STUB_OP_CLOSE:
+ case SOCK_OP_CLOSE:
l_close(skreqp);
break;
- case STUB_OP_RECV:
+ case SOCK_OP_RECV:
l_recv(skreqp);
break;
- case STUB_OP_SEND:
+ case SOCK_OP_SEND:
l_send(skreqp);
break;
- case STUB_OP_SELECT:
+ case SOCK_OP_SELECT:
l_select(skreqp);
break;
- case STUB_OP_BIND:
+ case SOCK_OP_BIND:
l_bind(skreqp);
break;
- case STUB_OP_LISTEN:
+ case SOCK_OP_LISTEN:
l_listen(skreqp);
break;
default:
@@ -321,62 +275,29 @@ static THD_FUNCTION(TsSockSkelDaemon, arg) {
}
}
-/**
- * @brief Dispatch a request to a skeleton worker thread.
- */
-static THD_WORKING_AREA(waTsSkelsDaemon, 512);
-static THD_FUNCTION(TsSkelsDaemon, arg) {
- (void)arg;
-
- event_listener_t el;
- skel_req_t *skreqp;
- msg_t r;
-
- chEvtRegisterMaskWithFlags(&stubsEventSource, &el, ALL_EVENTS,
- EVT_F_SOCK_NEW_OP);
- tsStubsService = (ts_service_t)tsInvokeServiceNoYield(TS_HND_DISCOVERY,
- (ts_params_area_t)"TsStubsService", sizeof "TsStubsService");
-
- /* Tell to stubs service that we are ready.*/
- skreqp = chFifoTakeObjectTimeout(&skel_req_fifo, TIME_INFINITE);
- skreqp->req = SKEL_REQ_READY;
- tsInvokeServiceNoYield(tsStubsService, (ts_params_area_t)skreqp,
- sizeof *skreqp);
- chFifoReturnObject(&skel_req_fifo, skreqp);
-
- /* Start to receive ops from stubs.*/
- for (;/* ever */;) {
- chEvtWaitAny(ALL_EVENTS);
- (void)chEvtGetAndClearFlags(&el);
- while (true) {
- skreqp = chFifoTakeObjectTimeout(&skel_req_fifo, TIME_INFINITE);
- skreqp->req = SKEL_REQ_GETOP;
- chMtxLock(&tsStubsServiceMtx);
- r = tsInvokeServiceNoYield(tsStubsService, (ts_params_area_t)skreqp,
- sizeof *skreqp);
- chDbgAssert(r != SMC_SVC_BUSY, "Unexpected SMC_SVC_BUSY");
- chMtxUnlock(&tsStubsServiceMtx);
- if (r == SMC_SVC_NHND)
- break;
- chFifoSendObject(&skel_req_fifo, skreqp);
- }
- chFifoReturnObject(&skel_req_fifo, skreqp);
- }
-}
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
/**
- * @brief Init the skeletons daemon objects and create the
+ * @brief Init the socket skeletons daemon objects and create the
* corresponding threads.
*/
-void tsSkelsDaemonInit(void) {
+void tsSocksSkelInit(void) {
int i;
+ skel_ctx_t *scp;
- chFifoObjectInit(&skel_req_fifo, sizeof (skel_req_t), N_SOCKSKEL_THD,
- sizeof (uint8_t), skel_reqs, skel_req_msgs);
+ scp = &skel_ctx;
+ chFifoObjectInit(&scp->skel_req_fifo, sizeof (skel_req_t), N_MAX_SKEL_REQS,
+ sizeof (uint8_t), scp->skel_reqs, scp->skel_req_msgs);
+ scp->skel_eventflag = EVT_F_SOCK_NEW_OP;
+ scp->stub_svc_name = SOCKS_SVC_NAME;
for (i = 0; i < N_SOCKSKEL_THD; ++i)
- chThdCreateFromHeap(NULL, 2048, "TsSkelDaemonWrk", NORMALPRIO,
- TsSockSkelDaemon, NULL);
- chThdCreateStatic(waTsSkelsDaemon, sizeof waTsSkelsDaemon, NORMALPRIO,
- TsSkelsDaemon, NULL);
+ chThdCreateFromHeap(NULL, 2048, "TsSockSkelDaemonWrk", NORMALPRIO,
+ TsSockSkelDaemon, &scp->skel_req_fifo);
+ chThdCreateFromHeap(NULL, 2048, "TsSocksSkelDaemon", NORMALPRIO,
+ TsSkelsDaemon, scp);
}
+
+/** @} */
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.h
index 36637e435..a251eba0f 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.h
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/daemons/tssockskel.h
@@ -65,7 +65,7 @@
#ifdef __cplusplus
extern "C" {
#endif
- void tsSkelsDaemonInit(void);
+ void tsSocksSkelInit(void);
#ifdef __cplusplus
}
#endif
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/dummyredconf.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/dummyredconf.h
new file mode 100644
index 000000000..e2b80d2d2
--- /dev/null
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/dummyredconf.h
@@ -0,0 +1,114 @@
+/* THIS FILE WAS GENERATED BY THE DATALIGHT RELIANCE EDGE CONFIGURATION
+ UTILITY. DO NOT MODIFY.
+
+ Generated by configuration utility version 2.02
+*/
+/** @file
+*/
+#ifndef REDCONF_H
+#define REDCONF_H
+
+
+#include <string.h>
+
+#define REDCONF_READ_ONLY 0
+
+#define REDCONF_API_POSIX 1
+
+#define REDCONF_API_FSE 0
+
+#define REDCONF_API_POSIX_FORMAT 1
+
+#define REDCONF_API_POSIX_LINK 1
+
+#define REDCONF_API_POSIX_UNLINK 1
+
+#define REDCONF_API_POSIX_MKDIR 1
+
+#define REDCONF_API_POSIX_RMDIR 1
+
+#define REDCONF_API_POSIX_RENAME 1
+
+#define REDCONF_RENAME_ATOMIC 1
+
+#define REDCONF_API_POSIX_FTRUNCATE 1
+
+#define REDCONF_API_POSIX_READDIR 1
+
+#define REDCONF_API_POSIX_CWD 0
+
+#define REDCONF_NAME_MAX 12U
+
+#define REDCONF_PATH_SEPARATOR '/'
+
+#define REDCONF_TASK_COUNT 10U
+
+#define REDCONF_HANDLE_COUNT 10U
+
+#define REDCONF_API_FSE_FORMAT 0
+
+#define REDCONF_API_FSE_TRUNCATE 0
+
+#define REDCONF_API_FSE_TRANSMASKGET 0
+
+#define REDCONF_API_FSE_TRANSMASKSET 0
+
+#define REDCONF_OUTPUT 0
+
+#define REDCONF_ASSERTS 1
+
+#define REDCONF_BLOCK_SIZE 512U
+
+#define REDCONF_VOLUME_COUNT 1U
+
+#define REDCONF_ENDIAN_BIG 0
+
+#define REDCONF_ALIGNMENT_SIZE 4U
+
+#define REDCONF_CRC_ALGORITHM CRC_SLICEBY8
+
+#define REDCONF_INODE_BLOCKS 1
+
+#define REDCONF_INODE_TIMESTAMPS 1
+
+#define REDCONF_ATIME 0
+
+#define REDCONF_DIRECT_POINTERS 4U
+
+#define REDCONF_INDIRECT_POINTERS 32U
+
+#define REDCONF_BUFFER_COUNT 12U
+
+#define RedMemCpyUnchecked memcpy
+
+#define RedMemMoveUnchecked memmove
+
+#define RedMemSetUnchecked memset
+
+#define RedMemCmpUnchecked memcmp
+
+#define RedStrLenUnchecked strlen
+
+#define RedStrCmpUnchecked strcmp
+
+#define RedStrNCmpUnchecked strncmp
+
+#define RedStrNCpyUnchecked strncpy
+
+#define REDCONF_TRANSACT_DEFAULT (( RED_TRANSACT_CREAT | RED_TRANSACT_MKDIR | RED_TRANSACT_RENAME | RED_TRANSACT_LINK | RED_TRANSACT_UNLINK | RED_TRANSACT_FSYNC | RED_TRANSACT_CLOSE | RED_TRANSACT_VOLFULL | RED_TRANSACT_UMOUNT ) & RED_TRANSACT_MASK)
+
+#define REDCONF_IMAP_INLINE 0
+
+#define REDCONF_IMAP_EXTERNAL 1
+
+#define REDCONF_DISCARDS 0
+
+#define REDCONF_IMAGE_BUILDER 0
+
+#define REDCONF_CHECKER 0
+
+#define RED_CONFIG_UTILITY_VERSION 0x2000200U
+
+#define RED_CONFIG_MINCOMPAT_VER 0x1000200U
+
+#endif
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/main.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/main.c
index a142ad107..8320a69e6 100755
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/main.c
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/main.c
@@ -18,10 +18,12 @@
#include "hal.h"
#include "tsclient.h"
#include "daemons/tssockskel.h"
+#include "daemons/tsioblksskel.h"
#include "rt_test_root.h"
#include "oslib_test_root.h"
#include "chprintf.h"
#include "lwipthread.h"
+#include "sama_sdmmc_lld.h"
/*
* LED blinker thread, times are in milliseconds.
@@ -33,17 +35,17 @@ static THD_FUNCTION(Thread1, arg) {
chRegSetThreadName("blinker");
while (true) {
- palToggleLine(LINE_LED_RED);
+ palToggleLine(LINE_KEYBACK_LED_RED);
chThdSleepMilliseconds(80);
- palToggleLine(LINE_LED_RED);
+ palToggleLine(LINE_KEYBACK_LED_RED);
chThdSleepMilliseconds(120);
- palToggleLine(LINE_LED_RED);
+ palToggleLine(LINE_KEYBACK_LED_RED);
chThdSleepMilliseconds(120);
- palToggleLine(LINE_LED_RED);
+ palToggleLine(LINE_KEYBACK_LED_RED);
chThdSleepMilliseconds(120);
- palToggleLine(LINE_LED_RED);
+ palToggleLine(LINE_KEYBACK_LED_RED);
chThdSleepMilliseconds(160);
- palToggleLine(LINE_LED_RED);
+ palToggleLine(LINE_KEYBACK_LED_RED);
chThdSleepMilliseconds(600);
}
}
@@ -54,6 +56,31 @@ static const SerialConfig sdcfg = {
UART_MR_PAR_NO
};
+#define BLOCK_CNT_MAX 32u
+#define DMADL_CNT_MAX 64u
+#define BLOCK_CNT 3u
+
+CACHE_ALIGNED uint8_t data_buf[BLOCK_CNT_MAX * 512ul];
+CACHE_ALIGNED static uint32_t dma_table[DMADL_CNT_MAX * SDMMC_DMADL_SIZE];
+CACHE_ALIGNED uint8_t sdmmcbuffer[ROUND_UP_MULT(SDMMC_BUFFER_SIZE, L1_CACHE_BYTES)];
+
+static const SamaSDMMCConfig sdmmc_cfg = {
+ SDMMC_SLOT0,
+ sdmmcbuffer,
+ data_buf,
+ sizeof data_buf,
+ dma_table,
+ DMADL_CNT_MAX
+};
+
+bool sdmmcGetInstance(uint8_t index, SdmmcDriver **sdmmcp)
+{
+ (void)index;
+
+ *sdmmcp = &SDMMCD1;
+ return true;
+}
+
/*
* Application entry point.
*/
@@ -73,25 +100,38 @@ int main(void) {
/*
* Activates the serial driver 0 using the driver default configuration.
*/
- sdStart(&SD0, &sdcfg);
+ sdStart(&SD1, &sdcfg);
/*
* Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof waThread1, NORMALPRIO-1, Thread1, NULL);
- tsSkelsDaemonInit();
+ /*
+ * Init and open the sdmmc device.
+ */
+ sdmmcInit();
+ sdmmcStart(&SDMMCD1, &sdmmc_cfg);
+ if (SDMMCD1.state != MCID_INIT_ERROR) {
+ sdmmcOpenDevice(&SDMMCD1);
+ } else {
+ chprintf((BaseSequentialStream *)&SD1, "Cannot start sdmmc device.\r\n");
+ sdmmcStop(&SDMMCD1);
+ }
+
+ tsSocksSkelInit();
+ tsIOBlksSkelInit();
/*
* Call the dummy secure service
*/
- chprintf((BaseSequentialStream*)&SD0, "Calling the secure service\n\r");
+ chprintf((BaseSequentialStream*)&SD1, "Calling the secure service\n\r");
/* Retrieve the service handle by name */
tssvc = (ts_service_t) tsInvokeServiceNoYield(TS_HND_DISCOVERY,
(ts_params_area_t)"TsSimpleService", sizeof "TsSimpleService");
if ((int32_t)tssvc < 0) {
- chprintf((BaseSequentialStream*)&SD0, "Cannot get the handle of '%s': %d\r\n",
+ chprintf((BaseSequentialStream*)&SD1, "Cannot get the handle of '%s': %d\r\n",
"TsSimpleService", tssvc);
}
/*
@@ -103,11 +143,11 @@ int main(void) {
/* Invoke the service */
r = tsInvokeServiceNoYield(tssvc, (ts_params_area_t)"HELO", sizeof "HELO");
- chprintf((BaseSequentialStream*)&SD0, "Call result: %d\r\n", r);
+ chprintf((BaseSequentialStream*)&SD1, "Call result: %d\r\n", r);
#if 0
if(!palReadPad(PIOB, PIOB_USER_PB)) {
- test_execute((BaseSequentialStream *)&SD0, &rt_test_suite);
- test_execute((BaseSequentialStream *)&SD0, &oslib_test_suite);
+ test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
+ test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
}
#endif
chThdSleepMilliseconds(500);
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/mcuconf.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/mcuconf.h
index 324e467e4..49a998494 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/mcuconf.h
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/mcuconf.h
@@ -31,7 +31,7 @@
#define SAMA_MCK_SEL SAMA_MCK_PLLA_CLK
#define SAMA_MCK_PRES_VALUE 1
#define SAMA_MCK_MDIV_VALUE 3
-#define SAMA_PLLA_MUL_VALUE 83
+#define SAMA_PLLA_MUL_VALUE 41
#define SAMA_PLLADIV2_EN TRUE
#define SAMA_H64MX_H32MX_RATIO 2
@@ -57,8 +57,8 @@
/*
* SERIAL driver system settings.
*/
-#define SAMA_SERIAL_USE_UART0 TRUE
-#define SAMA_SERIAL_USE_UART1 FALSE
+#define SAMA_SERIAL_USE_UART0 FALSE
+#define SAMA_SERIAL_USE_UART1 TRUE
#define SAMA_SERIAL_USE_UART2 FALSE
#define SAMA_SERIAL_USE_UART3 FALSE
#define SAMA_SERIAL_USE_UART4 FALSE
@@ -96,6 +96,11 @@
#define SAMA_TC1_IRQ_PRIORITY 2
/*
+ * TRNG driver system settings.
+ */
+#define HAL_USE_TRNG FALSE
+
+/*
* SECUMOD driver settings.
*/
#define HAL_USE_SECUMOD FALSE
@@ -103,8 +108,8 @@
/*
* SDMMC driver settings.
*/
-#define HAL_USE_SDMMC FALSE
-
+#define HAL_USE_SDMMC TRUE
+#define PLATFORM_SDMMC_USE_SDMMC1 TRUE
/*
* UART driver system settings.
*/
@@ -140,4 +145,10 @@
#define SAMA_UART_FLEXCOM4_DMA_IRQ_PRIORITY 4
#define SAMA_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
+/*
+ * L2CC related defines.
+ */
+#define SAMA_L2CC_ASSUME_ENABLED 1
+#define SAMA_L2CC_ENABLE 0
+
#endif /* MCUCONF_H */