main() not called from _start()

Asked by Mark Freeman on 2017-12-01

Trying to compile a very simple blinking LED C program for a bare metal Cortex M4 (Nordic nRF52832) however, main() is never reached. If I modify the startup code to call main() instead of _start() then main executes and the LED blinks as expected.

This problem occurs using V4.9.3 of the toolchain and also with the latest toolchain downloaded from ARM. However, using the custom toolchain provided with the EmBitz IDE the test program works as expected and the LED blinks?

I guess I must be missing a compiler/linker directive or linking against the wrong crto in the ARM-NONE-EABI toolchain??? I'm guessing the custom toolchain was compiled in such a way to work around this?? I'm using the following complier/linker options:

-DNRF52
-DNRF52832
-DBOARD_PCA10040
-D__NO_SYSTEM_INIT
-mthumb
-mcpu=cortex-m4
-mfloat-abi=softfp
-mfpu=fpv4-sp-d16
-ffunction-sections
-Wall
-O0
-ffunction-sections
-fdata-sections
-fno-strict-aliasing
-fno-builtin

Does anyone have any ideas what could prevent _start() from calling main()?

Thanks!

Question information

Language:
English Edit question
Status:
Open
For:
GNU ARM Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
2017-12-01
Last reply:

Can you help with this problem?

Provide an answer of your own, or ask Mark Freeman for more information if necessary.

To post a message you must log in.