Stm32f769 discovery kit unstable with little filesystem

Hello !

First time around here, so I am not sure if this is where that post should be. Feel free to move or let me know where to move it to if not.

It is my first time with microcontrollers, and I have gotten a stm32f769 discovery kit to try doing a project of mine.

I’ve been trying to use the little filesystem as per the mbed-os-examples-filesystem. I have not modified the code in any way, merely compiled it using mbed-cli utility and gcc 10.2.1 – I also tried gcc 9.2, and gcc 11.1…

It appears that the whole thing isn’t very stable however. Sometimes it will run the demo without any problem, then the next time I press the reset button on my board, the cod will either fail to create a file, either fail to create the filesystem, fail to init the block device, fail mounting it, or opening the root directory… It might work but more often than not it crashes with error 4001 or 4004.

I’m trying to use the qspi on the discovery kit, and I cannot get it to behave. If I set force reformat to false, the filesystem ends up not working maybe at the 2nd or the 3rd run, 4 if I’m lucky.

Here is an example. Between the 2 runs I only pressed reset, and made sure the first run was finished before and the program had exited.

--- Terminal on /dev/ttyACM0 - 9600,8,N,1 ---
--- Mbed OS filesystem example ---
Mounting the filesystem... OK
formatting... OK
Opening "/fs/numbers.txt"... Fail :(
No file found, creating a new file... OK
Writing numbers (10/10)... OK
Seeking file... OK
Incrementing numbers (10/10)... OK
Closing "/fs/numbers.txt"... OK
Opening the root directory... OK
root directory:
    .
    ..
    numbers.txt
Closing the root directory... OK
Opening "/fs/numbers.txt"... OK
numbers:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
Closing "/fs/numbers.txt"... OK
Unmounting... OK
Mbed OS filesystem example done!
--- Mbed OS filesystem example ---
Mounting the filesystem... OK
formatting... Fail :(


++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Location: 0x8000573
Error Value: 0x0
Current Thread: main Id: 0x2000265C Entry: 0x8002B11 StackSize: 0x1000 StackMem: 0x20001638 SP: 0x20002574
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=DISCO_F769NI
-- MbedOS Error Info --
error:  (-4001)

Did anyone ever experience this ? I have cloned the very latest of mbed-os and mbed-os-examples-filesystem, but also tried other versions, with always the same results and inconsistency. I also sometimes manage to get an acertion failure.

I’d honestly appreciate any help with this, as I must admit little filesystem doesn’t seem very convincing right now…

So, after investigating more, I found out that there’s a littlefs v2 that seems to exist. It is unclear which one I should use, but trying out v2 instead seems to give slightly better results:

  • The filesystem does not get corrupted or broken at the first try anymore, and if the force reformat is set to false it reacts as it should and indeed appends a number to the file at every run.
  • On the other hand, it still fails when trying to erase the block device.
--- Mbed OS filesystem example ---
Mounting the filesystem... OK
formatting... OK
Opening "/fs/numbers.txt"... Fail :(
No file found, creating a new file... OK
Writing numbers (10/10)... OK
Seeking file... OK
Incrementing numbers (10/10)... OK
Closing "/fs/numbers.txt"... OK
Opening the root directory... OK
root directory:
    .
    ..
    numbers.txt
Closing the root directory... OK
Opening "/fs/numbers.txt"... OK
numbers:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
Closing "/fs/numbers.txt"... OK
Unmounting... OK
Mbed OS filesystem example done!
Initializing the block device... OK
Erasing the block device... Fail :(
++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Location: 0x80002F9
Error Value: 0x0
Current Thread: shared_event_queue Id: 0x20005BA4 Entry: 0x80066C1 StackSize: 0x800 StackMem: 0x20005BE8 SP: 0x20006314 
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=DISCO_F769NI
-- MbedOS Error Info --
error:  (-4001)

At least this error is 100% reproducible by now, so it at least is something !
Though my question still stand, what is the difference between littlefs and littlefsv2 ? Which one should I try to use ?

Also, how do I go about debugging why the erase doesn’t work ? It runs for a few seconds maybe 20, and then crashes like this.

Any help would be appreciated.

After yet some more investigating, I found how to enable tracing in mbed and managed to figure out that it cannot erase more than 16 MB, which is a quarter of my flash. I guess my solution will be to slice the block device, which is a shame.

When attempting to erase the full 64 MB of flash with the little filesystem example and using littlefs v2, it ends up attempting to use 4-bytes addressing despite it being not supported – that is what makes that 4001 error.

Unless someone knows how to fix this, it definitely seems like this won’t work with the entire flash…

[ERR ][QSPIF]: Attempted to use 4-byte address but 4-byte addressing is not supported
[ERR ][QSPIF]: QSPI Erase - Updating 4-byte addressing extended address register failed
[ERR ][QSPIF]: QSPI Erase command failed!

Checking the source code for the qspi block device, it looks like it should not even attempt to use 4-bytes addressing, as this was explicitly disabled for the macronix chips.
Anyone knows what is happening here ?