Calling __mainCRTStartup from Reset_Handler ISR causes hardfault

Asked by Nitin on 2017-03-17

Using MSP432(Cortex M4) running freeRTOS blinky demo( simple program toggling on board LED).
Toolchains version tried : 5_3-2016q1-20160330 and 6-2017-q1-update.

Start up and linker files are provided by TI. they can be found at
Definition of Reset_Handler that causes hardfault:
void Reset_Handler(void)

if we replace _mainCRTStartup() by adding code for
1. Zero filling the bss segment
2. Call main() directly.
It works fine.

crt0 file used(obtained from linker map file): arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/crt0.o

Could you explain why this happens? Cant we use c run time code for start up instead of manually zero filling the bss?

Question information

English Edit question
Needs information
GNU ARM Embedded Toolchain Edit question
No assignee Edit question
Last query:
Last reply:

Hi Nitin,

The toolchain needs to be usable for bare-metal targets without MMU so that there is no zero page to be mapped to bss section. The init code contains instruction to zero the bss section but relies on some symbol being defined: __bss_start__ and __bss_end__.

I'd recommend using nm to check the value of these symbols in your executable.

Best regards.

Nitin (bietian) said : #2

Thank you for the reply, Thomas.
The target used does not have an MMU.
I used the nm to check if the symbols are defined. attached is a segment of the nm output:
20004208 B __bss_end__
20000070 B __bss_start__

If I add the instruction to zero the bss section in Reset_Handler , it works fine. But if I use the _mainCRTStartUp() in Reset_handler, it hardfaults. Could you provide some inputs on how to debug this issue?

Hi Nitin,

Could you try running it in GDB and show the output of "disassemble" and "bt" commands?

Best regards.

Can you help with this problem?

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

To post a message you must log in.