2013-11-28 10:24 AM
Hello,
We are a robotics association from ENSEIRB-MATMECA (Bordeaux, France). We are developping some boards and a template project for STM32 devices.One of our boards embed a STM32F103C4 microcontroller. We use the startup script from gcc ride7 startup_stm32f10x_ld.s.This startup script work until the line ''bl SystemInit'' is reached. Then, the system doesn't jump to SystemInit() function as he is expected to do and the bootloader is listening again (reset).Here is the link instruction:/home/kevin/ausbee-test/Software/Toolchain/arm-none-eabi/bin/arm-none-eabi-gcc -o /home/kevin/ausbee-test/Software/output/project.elf -mthumb -mcpu=cortex-m3 -Wall -Wextra -mcpu=cortex-m3 -mfix-cortex-m3-ldrd -mthumb-interwork -DSTM32F10X_LD -Wl,--gc-sections -Wl,--Map=test.map -T/home/kevin/ausbee-test/Software/System-CM3/link.ld /home/kevin/ausbee-test/Software/System-CM3/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_ld.o /home/kevin/ausbee-test/Software/System-CM3/CMSIS/CM3/CoreSupport/core_cm3.o /home/kevin/ausbee-test/Software/System-CM3/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.o /home/kevin/ausbee-test/Software/Project/src/main.oThe test.map file contain the SystemInit symbol.We use GCC ARM embedded toolchain (). Our template project work with other devices such as STM32f105.Do you have any idea where this bug come from?Thanking you in advance. #stm32-startup2013-11-28 02:11 PM
Real hard to tell without the code in hand, or some actual diagnostic output. There could be an issue with the distance of the branch too SystemInit(), or there could be something in it that causes it to fault. Ideally you'd have a Hard Fault handler which could decode the processor state at the fault and point you at a specific instruction, and register settings.
2013-11-28 03:01 PM
Thank you very much for your reply. I didn't provided the code because it is the one available in CMSIS:
We don't have any JTAG or SWD but I have made a very simple test: if I put an infinite loop before ''bl SystemInit'' in startup_stm32f10x_ld.s, the MCU get stuck and the bootloader is not listening. If I put this loop at the beginning of SystemInit() and remove the previous one, the boot loader is listening again and again ... I concluded that the SystemInit() is not called.2013-11-28 03:21 PM
Executable code, .HEX, assume that I don't have your code or ability to build my own in exactly the fashion you have it.
Consider what you are doing in your linker script (.LD), if it's accurately describing the smaller memory in your part, and setting the stack pointer to something within the scope of that memory. At a guess I'd say the initial PUSH in SystemInit() is exploding.2013-11-29 12:12 AM
The linker script come from here:
http://m.florian.free.fr/articles/montages/stm32_template/stm32_flash.ld
Of course I have changed the values in RAM (10K) and FLASH (32K). I let the Stack_Size to 1024 and it should be enough I guess.All the project is here: If you want to try it, it works with kconfig, type ''make menuconfig''.That's weird because exactly the same configuration works on STM32F10X Connectivity Line.Thank you very much for your answers.2013-11-29 12:15 AM
2013-11-29 12:27 AM
Observe the value of _estack
https://github.com/Kev-J/ausbee/blob/master/Software/System-CM3/link.ld.in
The value expressed in the .MAP, and as the first word in .HEX/.BIN, or in SP/R13 in the debugger prior to failure.2013-11-29 03:25 PM
Problem solved! Thank you very much!
As you said, the problem was _estack. My linker script was adapted from one for a specific device so the _estack was statique at link. I just set it dynamic with: _estack = ORIGIN(RAM) + LENGTH(RAM);