Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build problem for stm32f411re #38

Open
dimitri1949 opened this issue Dec 5, 2023 · 4 comments
Open

build problem for stm32f411re #38

dimitri1949 opened this issue Dec 5, 2023 · 4 comments

Comments

@dimitri1949
Copy link

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.
build error for 411re

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

@gillesxr
Copy link

gillesxr commented Dec 7, 2023

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.

@dimitri1949
Copy link
Author

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

@dimitri1949
Copy link
Author

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

@dimitri1949
Copy link
Author

dimitri1949 commented Dec 7, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants