AnsweredAssumed Answered

st-util segmentation fault when loading flash

Question asked by m_gustafsson on Jul 1, 2014
Latest reply on Jul 2, 2014 by m_gustafsson
Hi!
I am trying to load my program onto the flash of a STM32F429I-DISCO board using stlink 1.0.0-1 and its st-util feature.
Most of the time it works just fine, but sometimes I get a segmentation fault error from st-util when loading the flash.  

My guess is that this happens when the size of my code is larger than some kind of limit as I can remove some code and get the loading to work again. If for example the size of my "text" section is 121696 it goes just fine, but if it is increased to 140436 loading fails with a segmentation fault.

When I look at the output of st-util it looks like it loads the flash first in 4 sectors with a size of 0x4000 bytes each at adresses 0x8000000, 0x8004000, 0x8008000 and 0x800C000. After that it loads 0x10000 bytes at the address 0x8010000. When loading the smaller size of program it works up to this point. When loading the larger program it now tries to load a new sector with the size 0x20000 bytes at 0x8020000 and this is where I get the segmentation fault.

Below are some of the st-util output, it was preceded by writings to sector 0x0, 0x1 and 0x2 similar to the writing to sector 0x3:

2014-07-01T15:17:10 INFO src/stlink-common.c: Attempting to write 16384 (0x4000) bytes to stm32 address: 134266880 (0x800c000)
EraseFlash - Sector:0x3 Size:0x4000
Flash page at addr: 0x0800c000 erased
2014-07-01T15:17:10 INFO src/stlink-common.c: Finished erasing 1 pages of 16384 (0x4000) bytes
2014-07-01T15:17:10 INFO src/stlink-common.c: Starting Flash write for F2/F4
2014-07-01T15:17:10 INFO src/stlink-common.c: Successfully loaded flash loader in sram
size: 16384
2014-07-01T15:17:11 INFO src/stlink-common.c: Starting verification of write complete
2014-07-01T15:17:11 INFO src/stlink-common.c: Flash written and verified! jolly good!
2014-07-01T15:17:11 INFO src/stlink-common.c: Attempting to write 65536 (0x10000) bytes to stm32 address: 134283264 (0x8010000)
EraseFlash - Sector:0x4 Size:0x10000
Flash page at addr: 0x08010000 erased
2014-07-01T15:17:12 INFO src/stlink-common.c: Finished erasing 1 pages of 65536 (0x10000) bytes
2014-07-01T15:17:12 INFO src/stlink-common.c: Starting Flash write for F2/F4
2014-07-01T15:17:12 INFO src/stlink-common.c: Successfully loaded flash loader in sram
size: 32768
size: 32768
2014-07-01T15:17:14 INFO src/stlink-common.c: Starting verification of write complete
2014-07-01T15:17:15 INFO src/stlink-common.c: Flash written and verified! jolly good!
2014-07-01T15:17:15 INFO src/stlink-common.c: Attempting to write 131072 (0x20000) bytes to stm32 address: 134348800 (0x8020000)
EraseFlash - Sector:0x5 Size:0x20000
Flash page at addr: 0x08020000 erased
2014-07-01T15:17:16 INFO src/stlink-common.c: Finished erasing 1 pages of 131072 (0x20000) bytes
2014-07-01T15:17:16 INFO src/stlink-common.c: Starting Flash write for F2/F4
2014-07-01T15:17:16 INFO src/stlink-common.c: Successfully loaded flash loader in sram
size: 32768
size: 32768
Segmentation fault

When loading the flash I start st-util and then load from gdb with:
$ st-util
$ arm-none-eabi-gdb out/disco.elf
(gdb) target extended localhost:4242
(gdb) load

As I understand it the 32F429I has got 2048 kbytes of flash, starting at 0x8000000, so there should be plenty of space left.
Why does the loader not load all pages with the same size, e.g. 0x4000 bytes? Have I done anything wrong in my memory mapping setup maybe?
Any other idea what my problem might be?

Many thanks for any suggestions.

/Mats







Outcomes