[STM32F407VGT6] How to erase flash fs?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
vbolshakov
Posts: 8
Joined: Sun Aug 25, 2019 8:50 am

[STM32F407VGT6] How to erase flash fs?

Post by vbolshakov » Thu Sep 05, 2019 6:24 pm

I compile micropython to DIY MORE STM32-407 board (with STM32F407VGT6 MCU) using STM32F4DISC as starting point.
My mpconfigboard.h available at https://pastebin.com/A6J2XcLb

Almost all works without problem, but content of flash filesystem is garbage. I can format it from PC and all OK till next firmware update.

What wrong with my config?

User avatar
Roberthh
Posts: 1569
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: [STM32F407VGT6] How to erase flash fs?

Post by Roberthh » Thu Sep 05, 2019 6:46 pm

You must not write the file system both from the PC and from MicroPython at the same time. The PC caches the FS is not awayr of changes made by MicroPython. And if you write from the PC, take care to unmount (eject) it before you unplug the device.
You can format the flash from Micropython at the REPL prompt by:

import uos
uos.VfsFat.mkfs("/flash")

Unmount (eject) the flash drive from the PC before you do that.
P.S.: Because of this continuous risk of damaging the file system I do not enable the device a flash drive. Instead I use tools like pyboard.py, rshell or ampy to transfer files. In case of a LAN connection, you can use Webrepl, rshell of ftp.

vbolshakov
Posts: 8
Joined: Sun Aug 25, 2019 8:50 am

Re: [STM32F407VGT6] How to erase flash fs?

Post by vbolshakov » Thu Sep 05, 2019 6:48 pm

There is garbage after flashing.
Also noted that after flashing STM32F4DISC-20190529-v1.11.dfu to STM32F4DISC i got same problems - there is filenames on FS, but content is garbage.

vbolshakov
Posts: 8
Joined: Sun Aug 25, 2019 8:50 am

Re: [STM32F407VGT6] How to erase flash fs?

Post by vbolshakov » Thu Sep 05, 2019 6:59 pm

And flash formatting not working...

>>> import uos
>>> uos.VfsFat.mkfs("/flash")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'readblocks'

User avatar
Roberthh
Posts: 1569
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: [STM32F407VGT6] How to erase flash fs?

Post by Roberthh » Thu Sep 05, 2019 7:33 pm

Your're right. Looks Like I'm lost in versions an dialects. Then you can still erase flash with make erase and re-flash the firmware. That's the crowbar method.

vbolshakov
Posts: 8
Joined: Sun Aug 25, 2019 8:50 am

Re: [STM32F407VGT6] How to erase flash fs?

Post by vbolshakov » Thu Sep 05, 2019 7:45 pm

There is a note somewhere about flash fs part not erased on firmware upgrade to save it content...

Finaly found solution - USER button press and hold while reseting board cleared flash fs. Tried this method before, but able may be not holding long enough or released in wrong moment.

vbolshakov
Posts: 8
Joined: Sun Aug 25, 2019 8:50 am

Re: [STM32F407VGT6] How to erase flash fs?

Post by vbolshakov » Thu Sep 05, 2019 8:06 pm

Boot modes are:
...
3. Green and orange LED together, *filesystem reset*: resets the flash
filesystem to its factory state, then boots in safe mode.

So with only one LED with invers controll very hard to get this mode...

User avatar
dhylands
Posts: 3212
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: [STM32F407VGT6] How to erase flash fs?

Post by dhylands » Thu Sep 05, 2019 10:09 pm

If your mpconfigboard.h file only defines LED1 and doesn't define LED2, then the code will use a slightly different behaviour. Instead it will flash the LED 1, 2, or 3 times.

See: https://github.com/micropython/micropyt ... ain.c#L328

vbolshakov
Posts: 8
Joined: Sun Aug 25, 2019 8:50 am

Re: [STM32F407VGT6] How to erase flash fs?

Post by vbolshakov » Fri Sep 06, 2019 10:21 am

Thank you. I already found this part, but don't understand why i can't catch right moment.
For one STM32F4DISCOVERY, that work strange i plan to build firmware with explicitly format flash fs on boot.

Post Reply