diff --git a/demos/host/host_cmsis_rtx/.cproject b/demos/host/host_cmsis_rtx/.cproject
index c4fc91b9..dcedaeec 100644
--- a/demos/host/host_cmsis_rtx/.cproject
+++ b/demos/host/host_cmsis_rtx/.cproject
@@ -187,7 +187,7 @@
-
+
diff --git a/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt b/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
index 477d33f0..78a9652d 100644
--- a/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
+++ b/demos/host/host_cmsis_rtx/host_cmsis_rtx.uvopt
@@ -212,6 +212,16 @@
+
+
+ OS Support\Event Viewer
+ 35904
+
+
+ OS Support\RTX Tasks and System
+ 35905
+
+
@@ -407,10 +417,10 @@
1
0
0
- 19
+ 0
0
- 78
- 93
+ 1
+ 1
0
..\src\main.c
main.c
@@ -489,7 +499,7 @@
0
0
0
- 137
+ 138
145
0
..\src\msc_app.c
@@ -759,10 +769,10 @@
1
0
0
- 35
+ 17
0
- 364
- 366
+ 356
+ 373
0
..\..\..\tinyusb\host\usbh.c
usbh.c
@@ -957,12 +967,12 @@
4
34
1
- 0
+ 1
0
- 29
+ 0
0
- 217
- 225
+ 1
+ 1
0
..\..\..\vendor\cmsis_rtos_rtx\RTX_Conf_CM.c
RTX_Conf_CM.c
@@ -989,7 +999,7 @@
lpc43xx
- 0
+ 1
0
0
0
@@ -1063,10 +1073,10 @@
1
0
0
- 0
+ 68
0
- 0
- 0
+ 105
+ 120
0
..\..\..\mcu\lpc43xx\CMSIS_LPC43xx_DriverLib\src\system_LPC43xx.c
system_LPC43xx.c
@@ -1097,7 +1107,7 @@
0
0
0
- 144
+ 139
151
0
..\..\..\mcu\lpc43xx\keil\startup_LPC43xx.s
diff --git a/demos/host/host_freertos/.cproject b/demos/host/host_freertos/.cproject
index 34fb85ab..b4cc30b7 100644
--- a/demos/host/host_freertos/.cproject
+++ b/demos/host/host_freertos/.cproject
@@ -1,25 +1,23 @@
-
-
-
+
-
+
-
-
+
+
@@ -79,7 +77,7 @@
-
+
@@ -99,25 +97,24 @@
-
-
+
-
-
+
+
@@ -177,7 +174,7 @@
-
+
@@ -197,7 +194,6 @@
-
@@ -348,7 +344,7 @@
-
+
@@ -365,25 +361,24 @@
-
+
-
-
+
+
-
diff --git a/demos/host/src/main.c b/demos/host/src/main.c
index b8500405..d3bf1032 100644
--- a/demos/host/src/main.c
+++ b/demos/host/src/main.c
@@ -89,6 +89,10 @@ void os_none_start_scheduler(void)
int main(void)
{
+#if TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
+ osKernelInitialize(); // CMSIS RTX requires kernel init before any other OS functions
+#endif
+
board_init();
print_greeting();
@@ -109,10 +113,7 @@ int main(void)
#elif TUSB_CFG_OS == TUSB_OS_NONE
os_none_start_scheduler();
#elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
- while(1)
- {
- osDelay(osWaitForever); // CMSIS RTX osKernelStart already started, main() is a task
- }
+ osKernelStart();
#else
#error need to start RTOS schduler
#endif
diff --git a/tinyusb/osal/osal_common.h b/tinyusb/osal/osal_common.h
index 0cf712e2..3f1bfe08 100644
--- a/tinyusb/osal/osal_common.h
+++ b/tinyusb/osal/osal_common.h
@@ -56,7 +56,7 @@ enum
{
OSAL_TIMEOUT_NOTIMEOUT = 0, // for use within ISR, return immediately
OSAL_TIMEOUT_NORMAL = 10*5, // default is 10 msec, FIXME CMSIS-RTX easily timeout with 10 msec
- OSAL_TIMEOUT_WAIT_FOREVER = 0x0EEEEEEE
+ OSAL_TIMEOUT_WAIT_FOREVER = 0xFFFFFFFF
};
static inline uint32_t osal_tick_from_msec(uint32_t msec) ATTR_CONST ATTR_ALWAYS_INLINE;
diff --git a/vendor/cmsis_rtos_rtx/INC/RTX_CM_lib.h b/vendor/cmsis_rtos_rtx/INC/RTX_CM_lib.h
index ae6c076a..b5935fa0 100644
--- a/vendor/cmsis_rtos_rtx/INC/RTX_CM_lib.h
+++ b/vendor/cmsis_rtos_rtx/INC/RTX_CM_lib.h
@@ -115,6 +115,9 @@ _declare_box8 (mp_stk, OS_STKSIZE*4, OS_TASK_CNT-OS_PRIV_CNT+1);
uint32_t const mp_stk_size = sizeof(mp_stk);
/* Memory pool for user specified stack allocation (+main, +timer) */
+#ifdef __CODE_RED
+__attribute__ (( section(".data.$RAM2") )) // overflow RamLoc32
+#endif
uint64_t os_stack_mem[2+OS_PRIV_CNT+(OS_STACK_SZ/8)];
uint32_t const os_stack_sz = sizeof(os_stack_mem);
@@ -234,6 +237,7 @@ __attribute__((used)) void _mutex_release (OS_ID *mutex) {
* RTX Startup
*---------------------------------------------------------------------------*/
+#if osFeature_MainThread
/* Main Thread definition */
extern int main (void);
osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 1, 4*OS_MAINSTKSIZE };
@@ -373,6 +377,8 @@ __noreturn __stackless void __cmain(void) {
#endif
+#endif
+
/*----------------------------------------------------------------------------
* end of file
diff --git a/vendor/cmsis_rtos_rtx/INC/cmsis_os.h b/vendor/cmsis_rtos_rtx/INC/cmsis_os.h
index ea4d77cb..17cc7177 100644
--- a/vendor/cmsis_rtos_rtx/INC/cmsis_os.h
+++ b/vendor/cmsis_rtos_rtx/INC/cmsis_os.h
@@ -141,7 +141,7 @@ used throughout the whole project.
/// \note MUST REMAIN UNCHANGED: \b osFeature_xxx shall be consistent in every CMSIS-RTOS.
-#define osFeature_MainThread 1 ///< main thread 1=main can be thread, 0=not available
+#define osFeature_MainThread 0 ///< main thread 1=main can be thread, 0=not available
#define osFeature_Pool 1 ///< Memory Pools: 1=available, 0=not available
#define osFeature_MailQ 1 ///< Mail Queues: 1=available, 0=not available
#define osFeature_MessageQ 1 ///< Message Queues: 1=available, 0=not available
diff --git a/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c b/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
index 011df7cb..7577414d 100644
--- a/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
+++ b/vendor/cmsis_rtos_rtx/RTX_Conf_CM.c
@@ -55,14 +55,14 @@
// Defines default stack size for threads with osThreadDef stacksz = 0
// Default: 200
#ifndef OS_STKSIZE
- #define OS_STKSIZE 50
+ #define OS_STKSIZE 200
#endif
// Main Thread stack size [bytes] <64-4096:8><#/4>
// Defines stack size for main thread.
// Default: 200
#ifndef OS_MAINSTKSIZE
- #define OS_MAINSTKSIZE 50
+ #define OS_MAINSTKSIZE 200
#endif
// Number of threads with user-provided stack size <0-250>
@@ -76,7 +76,7 @@
// Defines the combined stack size for threads with user-provided stack size.
// Default: 0
#ifndef OS_PRIVSTKSIZE
- #define OS_PRIVSTKSIZE 1024
+ #define OS_PRIVSTKSIZE (8*1024)
#endif
// Check for stack overflow