cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging STM32F4 from SRAM

Mohammad A
Senior
Posted on April 07, 2017 at 15:08

I am trying to program and debug from SRAM but it seems that I'm not doing something right.

This is what I do to start debugging:

  • I use TrueStudio to generate ld script to compile and assemble for SRAM.
  • BOOT0 and BOOT1 pins are pulled HIGH.
  • Then I start texan's st-util from terminal.
  • when st-link is connected to board, I start arm-none-eabi-gdb followed by location of ELF file.
  • then these commands in the gdb interface:
    • target remote localhost:4242
    • load
    • continue

it does not work.

When I try to do the samething in TrueStudio debugger, I see that it is looking for some creppy address which I don't know where they are supposed to be. something like 0x78a212b .

What steps have I forgotten to do? Reference manual has mentioned that

When the device boots from SRAM, in the application initialization code, you have to

relocate the vector table in SRAM using the NVIC exception table and the offset register.

but I don't know what I am supposed to add inside the code.

#gcc #debug #stmf4 #gdb #linker #sram
1 REPLY 1
Posted on April 07, 2017 at 15:46

In Keil I'd use a debugger script to download the code, and make sure the IROM/IRAM pointed to different areas of SRAM.

I haven't used SRAM like this in a while, but the F1 parts had some undocumented behaviour with respect to the Vector Table, and Reset Handler. ie It jumped to a specific address, not the Initial PC vector.

I would suggest you make a small FLASH based loader/monitor which can provide some interactive control (options, download .HEX to RAM, etc) and transfer control to the RAM based code using that. In things like Keil that would definitely let you 'run to main()' on the RAM based code, and step through the code, if that level of understanding was required.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..