cancel
Showing results for 
Search instead for 
Did you mean: 

st-util segmentation fault when loading flash

mats23
Associate II
Posted on July 01, 2014 at 16:47

Hi!

I am trying to load my program onto the flash of a STM32F429I-DISCOboard using stlink 1.0.0-1and 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
2 REPLIES 2
Posted on July 01, 2014 at 17:48

Perhaps you should be asking the developers of this code directly? Or venues they participate in. Make sure you have the most current source, use/review that and any technical documentation and change logs that suggest if it supports the parts you are attempting to use it with.

Do the ST supplied Windows tools work properly?

The 1MB part uses non-uniform block sizes, the 2MB parts replicate this odd arrangement at the 1MB boundary also.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
mats23
Associate II
Posted on July 02, 2014 at 11:47

Clive1,

thanks for your reply!

It would probably be better to ask the developers as you suggest. I will try to find a way to reach them.

I use the latest software as far as I can see and it should support the device I use.

I tried with the ''ST Visual Programmer'' in Windows as you suggested, and it seems to be able to program the flash with the firmware that fails on the st-util in Linux.

So, for the time being this will be my way forward, i.e. to program the flash from Windows.

Many thanks for your help!

/Mats