This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Main not called

I'm trying to get a stripped down, simple LED blinking sample to work (like blinky) when building with GCC however main() is never called. I'm guessing I'm either using the wrong startup file or missing a compiler/linker setting? I know the hex file produced from the build process is executable because if I add a call to main() from the bottom of SystemInit() in system_nrf52.c then my code is executed and the LED blinks as expected. If I replace main() with a call to _start() then my code is not executed. So it seems that _start() is not calling main() for some reason? I have not managed to find the right source for crt0.s to see what might prevent _start() from calling main().

I am using SDK 14.2 (although the problem is the same with other versions of the SDK). I am using the 2015 Q3 version of GCC as specified in the SDK release notes. I am using gcc_startup_nrf52.s I am using the linker script blinky_gcc_nrf52.ld (non SD version). I am not building with a soft device. I am not using Keil uVision.

Compiler and linker settings: -DNRF52 -DNRF52832 -DBOARD_PCA10040 -march=armv7e-m -mcpu=cortex-m4 -mthumb -mabi=aapcs -Wall -O0 -I. -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/device -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/boards -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/hal -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/delay -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/drivers_nrf/nrf_soc_nosd -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/libraries/util -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/toolchain -IC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/toolchain/cmsis/include -LC:/NordicSDK/nRF5_SDK_14.2.0_17b948a/components/toolchain/gcc -Tblinky_gcc_nrf52.ld

Any ideas as to what I am missing?

Thanks!

Related