Calling _start() hangs my STM32F4
I'm doing a really basic example to prove to myself that I understand what is happening, and successfully proving to myself that I do not :-) At it's simplest I have written a 'blink' application which blinks LEDs on the Discovery board. I am compiling with minimal switches (-g -mcpu=cortex_m4 -mthumb ) I'm linking with minimum switches (-T blink.ld -Map blink.map -o blink.elf) I have two source files, startup.s which is the .section isr_vector in it and defines the ISR vectors, blink.c has main() and Reset_Handler which simply calls main(). The .ld script is a renamed copy of the share/arm-
Works fine, Reset_Handler is the defined ENTRY in gcc.ld and if it then calls main() the code runs as expected.
I wanted to verify that initialized data worked (or didn't). So I added a global 'int delay_timer = 100000;' to the blink.c file.
On reset it has random data in it. I can stop in GDB, initialize it, and the code works as expected. I can initialize it from Reset_Handler and the code works as expected, what I can't do is have Reset_Handler call _start() and get data initialized. Instead it spins in the hard fault area.
I called start because I've seen several references to 'if you call _start it is handled for you' but that isn't working for me, so I'm wondering what I'm missing. In the LD script is a commented out section which reads:
/* To copy multiple ROM to RAM sections,
* uncomment .copy.table section and,
* define __STARTUP_
/*
.copy.table :
{
. = ALIGN(4);
LONG (__etext)
LONG (__data_start__)
LONG (__data_end__ - __data_start__)
LONG (__etext2)
LONG (__data2_start__)
LONG (__data2_end__ - __data2_start__)
} > FLASH
*/
Uncommenting it causes the linker to fail on the LD script with 'invalid data statement', if it worked I could imagine that pre-initializing the data would be a simple act of copying from __copy_
I feel like I'm really close on this, but it is just outside the documentation.
--Chuck
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Chuck McManis for more information if necessary.