Skip to content

Commit c862a62

Browse files
committed
Fix CMSIS-RTOS2 interface when stack is allocated dynamically (regression from previous change).
1 parent f20683c commit c862a62

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

build/example/blinky_c-cmsis-rtos2-prio/example.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ int main(int argc, char* argv[])
248248

249249
osKernelInitialize();
250250
osThreadNew(app_main, NULL, NULL);
251-
252251
if (osKernelGetState() == osKernelReady) {
253252
osKernelStart();
254253
}

build/example/project/eclipse/stm/blinky-cmsis-rtos2-prio-stm32f407g-disc1/.cproject

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
104104
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
105105
</option>
106+
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.928086894" name="Language standard" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.c11" valueType="enumerated"/>
106107
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.121388447" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
107108
</tool>
108109
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.990087452" name="GNU Arm Cross C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
@@ -133,6 +134,7 @@
133134
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
134135
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
135136
</option>
137+
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.1073497478" name="Language standard" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.cpp11" valueType="enumerated"/>
136138
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1033288883" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
137139
</tool>
138140
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.748818968" name="GNU Arm Cross C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
@@ -284,6 +286,7 @@
284286
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
285287
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
286288
</option>
289+
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.1797662171" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.c11" valueType="enumerated"/>
287290
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1578028994" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
288291
</tool>
289292
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.689201451" name="GNU Arm Cross C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
@@ -311,6 +314,7 @@
311314
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
312315
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
313316
</option>
317+
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.1366966857" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.cpp11" valueType="enumerated"/>
314318
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1709785757" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
315319
</tool>
316320
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.1905149858" name="GNU Arm Cross C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
@@ -464,6 +468,7 @@
464468
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
465469
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
466470
</option>
471+
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.319734450" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.std.c11" valueType="enumerated"/>
467472
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.901229203" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
468473
</tool>
469474
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.519004615" name="GNU Arm Cross C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler">
@@ -491,6 +496,7 @@
491496
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
492497
<listOptionValue builtIn="false" value="HSE_VALUE=8000000"/>
493498
</option>
499+
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.1959063858" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std" value="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.std.cpp11" valueType="enumerated"/>
494500
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1259684314" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
495501
</tool>
496502
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.2049176525" name="GNU Arm Cross C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">

deps/target/stm32fx/include/cortexm/exception-handlers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <stdint.h>
3232

3333
#if defined(DEBUG)
34-
#define __DEBUG_BKPT() asm volatile ("bkpt 0")
34+
#define __DEBUG_BKPT() __asm volatile ("bkpt 0")
3535
#endif
3636

3737
// ----------------------------------------------------------------------------

interop/cmsis/rtos2/src/cmsis_os2_stk.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ static T *PlacementNewOrHeap(void *mem, size_t size, const Args &... args)
460460

461461
if ((mem != nullptr) && (size >= sizeof(T)))
462462
{
463-
obj = new (mem) T(args...);
463+
obj = new (mem) T(args...);
464464
obj->m_cb_owned = false;
465465
}
466466
else
467467
{
468468
obj = new (std::nothrow) T(args...);
469469
// m_cb_owned is already true from the constructor default
470-
STK_ASSERT(obj != nullptr);
470+
STK_ASSERT(obj != nullptr);
471471
}
472472

473473
return obj;
@@ -844,24 +844,22 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr
844844
th->m_name = (attr != nullptr) ? attr->name : nullptr;
845845
th->m_join_state = (is_joinable ? StkThread::JoinState::Joinable : StkThread::JoinState::Detached);
846846

847-
size_t stack_words = CMSIS_STK_DEFAULT_STACK_WORDS;
848-
849847
// stack configuration
850848
if (attr != nullptr)
851849
{
852-
stack_words = stk::Max<size_t>(attr->stack_size / sizeof(stk::Word), CMSIS_STK_MIN_STACK_WORDS);
853-
854850
if ((attr->stack_mem != nullptr) && (attr->stack_size != 0U))
855851
{
856852
th->m_stack = static_cast<stk::Word *>(attr->stack_mem);
857-
th->m_stack_size = stack_words;
853+
th->m_stack_size = stk::Max<size_t>(attr->stack_size / sizeof(stk::Word), CMSIS_STK_MIN_STACK_WORDS);
858854
th->m_stack_owned = false;
859855
}
860856
}
861857

862858
// allocate stack memory if not caller-provided
863859
if (th->m_stack == nullptr)
864860
{
861+
const size_t stack_words = CMSIS_STK_DEFAULT_STACK_WORDS;
862+
865863
th->m_stack = new (std::nothrow) stk::Word[stack_words];
866864
STK_ASSERT(th->m_stack != nullptr);
867865

0 commit comments

Comments
 (0)