How to format file system?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
AmirJ
Posts: 18
Joined: Tue Sep 03, 2019 9:48 am

How to format file system?

Post by AmirJ » Sun Sep 08, 2019 8:30 am

How to format esp32 or esp8266 file system for repair and remove all Files? (damaged files)

Online
kevinkk525
Posts: 439
Joined: Sat Feb 03, 2018 7:02 pm

Re: How to format file system?

Post by kevinkk525 » Sun Sep 08, 2019 8:37 am

esptool.py --port /dev/ttyS3 erase_flash

Adapt your port of course.
You have to flash the firmware again afterwards.

User avatar
AmirJ
Posts: 18
Joined: Tue Sep 03, 2019 9:48 am

Re: How to format file system?

Post by AmirJ » Sun Sep 08, 2019 9:11 am

kevinkk525 wrote:
Sun Sep 08, 2019 8:37 am
esptool.py --port /dev/ttyS3 erase_flash

Adapt your port of course.
You have to flash the firmware again afterwards.
Thank you.
in this way you use a computer.
but i want do by ESP32 itself.
is it possible?
To do this by the ESP32 itself?

Online
kevinkk525
Posts: 439
Joined: Sat Feb 03, 2018 7:02 pm

Re: How to format file system?

Post by kevinkk525 » Sun Sep 08, 2019 9:16 am

i don't think that is possible. The esp can't erase itself.
Not sure it can erase the fat filesystem where you store your files but haven't heard of that either.

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

Re: How to format file system?

Post by Roberthh » Sun Sep 08, 2019 9:49 am

You can format the file system from by python commands once the ESP32 is started, with:

Code: Select all

import uos
uos.VfsFat.mkfs(bdev)
bdev is instantiated by the boot script and refers to the block storage device in the flash. Note that this erases ALL files on the flash, including potentially the script that erase the file system. This script will continue to run, since at that time it is loaded to RAM. But this script must rebuild the files needed for the next reboot.

User avatar
AmirJ
Posts: 18
Joined: Tue Sep 03, 2019 9:48 am

Re: How to format file system?

Post by AmirJ » Fri Sep 20, 2019 5:11 am

Thank you

Good. it worked.

Post Reply