I have setup a simple project to test embos with stm32f103rbt device, I just used the default settings, after changing the default complier warnings to MISRA compatible and changed the C standard to C99 and C++ to C++11 most of the errors would go away, But still there is two errors
.\Objects\marlin.axf: Error: L6218E: Undefined symbol Stack_Mem (referred from os_initsysstackinfo.o). .\Objects\marlin.axf: Error: L6218E: Undefined symbol __initial_sp (referred from os_initsysstackinfo.o).
So after searching I think I should make these symbols exported in the startup assembly file, So I tried to use these lines in the startup assembly file like this
Stack_Size EQU 0x00000400
; EXPORT the Stack_Mem and __initial_sp symbols for use in C files
EXPORT Stack_Mem
EXPORT __initial_sp
But it would generate an error like this
.\Objects\marlin.axf: error: L6002U: Could not open file .\objects\startup_stm32f10x_md.o: No such file or directory
another solution would be to comment these lines
OS_SysStackBaseAddr = (unsigned long) &Stack_Mem;
OS_SysStackSize = (unsigned int) ((unsigned long)&__initial_sp - (unsigned long)&Stack_Mem);
OS_SysStackLimit = (unsigned long) &__initial_sp;
in the OS_InitSysStackInfo function, Now the project would be build and when I try to debug it it would crash, so How should I test this os?
I assume your assembly startup file looks like this startup_stm32f10x_md.s file, with both heap and stack addresses defined as such :
And with the
__initial_sp
set in the vector table and exported as you shown usingEXPORT
.The linker error (see the Compiler Errors and Warnings Reference Guide) you have can come :
"Options for File [...]"
, and confirm that the file is considered as anAssembly file
instead of aSource file
. You might also check how the assembly is understood by the assembler by going into theAsm
panel of this window, and check that is is set onAuto Select
(e.g. if this startup file is for MDK-ADK use only, without multiple asm supported within, like it is done for some STM32 products and the ResetHandler assembly file).Regarding the crash you got after commenting :
The issue here is that the OS has no memory initialization, resulting in undefined behavior for the value those variables have. Even if you manage to start your OS tasks, at some point in the execution, without valid memory ranges it can work with, it might stackoverflow or lead to an invalid memory access / hardfault depending on the memory you tried to access.