8 years, 8 months ago.

STM Nucleo "No space left on device" when copying binary to /media/*/NUCLEO under Linux

Hello, I'm developing on the NUCLEO-F401RE under Linux using 'gcc-arm-none-eabi' for building. When built, I simply copy the .bin file to /media/*/NUCLEO/ for flashing. This usually works, but eventually it has done a full round of overwriting flash and then I get:

Flashing failing:

cp -f  *.bin /media/*/NUCLEO/
cp: error writing '/media/xxx/NUCLEO/xxx.bin': No space left on device
cp: failed to extend '/media/xxx/NUCLEO/xxx.bin': No space left on device

This is the size of the program:

131588  Aug 12 13:15 xxx.bin
583459  Aug 12 13:15 xxx.elf
370199  Aug 12 13:15 xxx.hex
2782097 Aug 12 13:15 xxx.map

After I unplug, reset the nucleo and plug back in again it works for a while. Any idea on how I can fix this otherwise?

Hi, can I ask if you're using linux in a virtual machine or natively?

posted by Brian Daniels 12 Aug 2015

Natively.

To be more precise, I had this problem already during an early stage, where my program was still very small. I noticed that, the bigger the program became, the more frequent this problem occurs. Therefore, I concluded, that by copying the bin file to a freshly mounted Nucleo board, it starts by writing it to the beginning of the flash memory. With each subsequent copy, it seems to delete the old, but starts writing the new where the old had ended. This is good for the lifetime of the flash memory. However, there seems to be a bug when it reaches the flash’s size (the end), which causes it to freeze. Only a cold start seems to fix this (whereupon it starts at the beginning again). Those are my two cents.

posted by L. Volpato 13 Aug 2015

I'm avoiding this problem now by using st-flash from https://github.com/texane/stlink

In my case, it works like this:

st-flash example:

st-flash --reset write yourfile.bin 0x8000000

As a nice side-effect the tool also gave me information about the flash layout of my NUCLEO-F401RE (I used >500KB of trash for this):

st-flash output for the NUCLEO-F401RE:

st-flash --reset write trash.bin 0x8000000
2015-08-13T15:23:33 INFO src/stlink-common.c: Loading device parameters....
2015-08-13T15:23:33 INFO src/stlink-common.c: Device connected is: F4 device (Dynamic Efficency), id 0x????????
2015-08-13T15:23:33 INFO src/stlink-common.c: SRAM size: 0x18000 bytes (96 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 16384 bytes
2015-08-13T15:23:33 INFO src/stlink-common.c: Attempting to write 520464 (0x7f110) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Sector:0x0 Size:0x4000
EraseFlash - Sector:0x1 Size:0x4000
EraseFlash - Sector:0x2 Size:0x4000
EraseFlash - Sector:0x3 Size:0x4000
EraseFlash - Sector:0x4 Size:0x10000
EraseFlash - Sector:0x5 Size:0x20000
EraseFlash - Sector:0x6 Size:0x20000
EraseFlash - Sector:0x7 Size:0x20000
2015-08-13T15:23:41 INFO src/stlink-common.c: Finished erasing 8 pages of 131072 (0x20000) bytes
2015-08-13T15:23:41 INFO src/stlink-common.c: Starting Flash write for F2/F4/L4
2015-08-13T15:23:41 INFO src/stlink-common.c: Successfully loaded flash loader in sram
2015-08-13T15:23:46 INFO src/stlink-common.c: Starting verification of write complete
2015-08-13T15:23:49 INFO src/stlink-common.c: Flash written and verified! jolly good!

Flash page at addr: 0x08000000 erased
Flash page at addr: 0x08004000 erased
Flash page at addr: 0x08008000 erased
Flash page at addr: 0x0800c000 erased
Flash page at addr: 0x08010000 erased
Flash page at addr: 0x08020000 erased
Flash page at addr: 0x08040000 erased
Flash page at addr: 0x08060000 erased
enabling 32-bit flash writes
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 28944
*** Finished ***

Conclusion: The bug still exists, but there's a way around it.

posted by L. Volpato 14 Aug 2015

FYI, i just realize that after remount the board, the memory is flushed. so i can flash it using mbed compile -f again. sure... st-flash is amazing with st-utils debug command, but the parameter is too long to type.

posted by Ibn Hidayat 27 Sep 2019
Be the first to answer this question.