bare-metal-programming-guide
bare-metal-programming-guide copied to clipboard
build problem for stm32f411re
Hi! I have Nucleo-64 stm32f411re and MikroelEktronica+ stm32f407zg boards, adapting example code to f411re and f407zg worked perfectly with 2023 February version with manually added include directory and startup.c (modified obviously).
Current examples with SOURCES += cmsis_f4/Source/Templates/gcc/startup_stm32f411xe.s do not build
with errors:
in func. LoopFillZerobss in startup_stm32f411xe.s -- undefined reference to SysInit
in __libc_init_array.. -- undefined reference to _init
It seems that some path is now broken since startup_stm32f411xe.s and startup_stm32f429xx.s look very similar.
Also copying 200MB of files every time when new version of a project is created seems inefficient. I copied cmsis_core and cmsis_f4 directories (dowdloaded by git clone..) to d:\gcc-arm\Work\ directory, but how to modify Makefile to access them is a mystery for me, pleaser help.
Best regards dimitri1949
Hello!
A quick fix is to add a blank _init function in the main.c file.
void _init(void) {}
To access to CMSIS from a Makefile:
Create a variable in the Makefile, i.e. CMSIS_CORE_PATH=d:\gcc-arm\Work\cmsis_core
, and use it with $(CMSIS_CORE_PATH)
.
BR gillesxr.
Hello and thanks for your help!
With void _init(void) {} in main -- compiled without errors, but did not work when flashed, obviously. Without _init in main -- in function __libc_init_array..init.c (.text.__libc_init_array+0x14) -- undefined reference to '_init' error. This is a version of a project with local cmsis_core and cmsis_f4 directories downloaded by 'git clone' as in original example for stm32f429 (it compiles without problems).
With another project version (without local cmsis_core and cmsis_f4 directories) i used CMSIS_CORE_PATH=d:\gcc-arm\Work\cmsis_core CMSIS_PATH=d:\gcc-arm\Work\cmsis_f4 .... firmware.elf: $(CMSIS_CORE_PATH) $(CMSIS_PATH) hal.h link.ld Makefile $(SOURCES) arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -o $@ as you suggested, with exactly the same result. So it seems that PATH setting works, but ld.exe do not see correct '_init' as with stm32f429. And this is linker error actually. Some h file is broken? I compared startup_stm32f429xx.s and startup_stm32f411xe.s and only differences i see are interrupt handlers, more for 429. I have also μe+ stm32f407zg and Wiz550web.stm32f103rb boards, i will try with them. I am sure problem must be close to startup_stm32f411xe.s, because last winter project version with startup.c works.
BR Dimitri
Hello!
I modified step-5-cmsis example project for stm32f411 from scratch, essentially changing only: hal.h: #include "stm32f429xx.h" -> stm32f411xe.h UART3 -> UART6
main.c: led -> LED_PA5
link.ld: MEMORY { /* stm32f411re */ flash(rx) : ORIGIN = 0x08000000, LENGTH = 512K sram(rwx) : ORIGIN = 0x20000000, LENGTH = 128K }
MakeFile: SOURCES += cmsis_f4/Source/Templates/gcc/startup_stm32f429xx.s -> SOURCES += cmsis_f4/Source/Templates/gcc/startup_stm32f411xe.s
and now it works! So all problems where my fault!
BR Dimitri
Hello!
void _init(void) {} was actually sitting in the end of syscalls.c file!
I was careless!
I modified step-5-cmsis example project to stm32f411re from scratch, essentially changing only: hal.h: #include "stm32f429xx.h" -> stm32f411xe.h UART3 -> UART6
main.c: led -> LED_PA5
link.ld: MEMORY { /* stm32f411re */ flash(rx) : ORIGIN = 0x08000000, LENGTH = 512K sram(rwx) : ORIGIN = 0x20000000, LENGTH = 128K }
MakeFile: SOURCES += cmsis_f4/Source/Templates/gcc/startup_stm32f429xx.s -> SOURCES += cmsis_f4/Source/Templates/gcc/startup_stm32f411xe.s
and now it works! So all problems where my fault!
I will now try it with cmsis_core and cmsis_f4 in d:\gcc-arm\Work\
BR Dimitri
On Thu, 7 Dec 2023 at 12:14, gillesxr @.***> wrote:
Hello!
A fast fix is to add a blank _init function in the main.c file. void _init(void) {}
To access to CMSIS from a Makefile: Create a variable in the Makefile, i.e. CMSIS_CORE_PATH=d:\gcc-arm\Work\cmsis_core, and use it with $(CMSIS_CORE_PATH).
BR gillesxr.
— Reply to this email directly, view it on GitHub https://github.com/cpq/bare-metal-programming-guide/issues/38#issuecomment-1845059266, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEPGCKVS6J6BZT2PWHTCUVTYIGJG3AVCNFSM6AAAAABAHXGMM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVGA2TSMRWGY . You are receiving this because you authored the thread.Message ID: @.***>