[ADAFRUIT_F405_EXPRESS] mkfs

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
CarlFK
Posts: 11
Joined: Sun Aug 16, 2020 6:18 am

[ADAFRUIT_F405_EXPRESS] mkfs

Post by CarlFK » Sun Sep 13, 2020 9:38 pm

How do I fix a corrupted fs?

I have this:

Code: Select all

import os, pyb

flash = pyb.Flash()
os.umount('/flash')
os.VfsFat(flash)
os.mount(flash, '/flash')
I suspect I need to unmount it from the OS first, but I'd like some expert advice on this as I seem to be floundering on my own.

I am also curious why it is getting corrupted, but as long as I can fix it I am less concerned at this point.
here is what I see in dmesg when it breaks:

Code: Select all

[769301.624124] usb 3-2.2: new full-speed USB device number 63 using xhci_hcd
[769301.726417] usb 3-2.2: New USB device found, idVendor=f055, idProduct=9800
[769301.726421] usb 3-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[769301.726424] usb 3-2.2: Product: Pyboard Virtual Comm Port in FS Mode
[769301.726426] usb 3-2.2: Manufacturer: MicroPython
[769301.726428] usb 3-2.2: SerialNumber: 20553687424D
[769301.727145] usb-storage 3-2.2:1.0: USB Mass Storage device detected
[769301.729332] scsi host6: usb-storage 3-2.2:1.0
[769301.729816] cdc_acm 3-2.2:1.1: ttyACM0: USB ACM device
[769302.756673] scsi 6:0:0:0: Direct-Access     MicroPy  pyboard Flash    1.00 PQ: 0 ANSI: 2
[769302.757091] sd 6:0:0:0: Attached scsi generic sg2 type 0
[769302.757316] sd 6:0:0:0: [sdc] 480 512-byte logical blocks: (246 kB/240 KiB)
[769302.757477] sd 6:0:0:0: [sdc] Write Protect is off
[769302.757479] sd 6:0:0:0: [sdc] Mode Sense: 03 00 00 00
[769302.757646] sd 6:0:0:0: [sdc] No Caching mode page found
[769302.757651] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[769302.763514]  sdc: sdc1
[769302.764623] sd 6:0:0:0: [sdc] Attached SCSI removable disk
[769303.008314] FAT-fs (sdc1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[769303.079401] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)
[769303.079405] FAT-fs (sdc1): Filesystem has been set read-only
[769303.079409] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)
[769303.079411] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)
[769303.081381] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)
[769303.081384] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)
[769303.092506] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)
[769303.092510] FAT-fs (sdc1): error, fat_get_cluster: invalid cluster chain (i_pos 48)

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [ADAFRUIT_F405_EXPRESS] mkfs

Post by jimmo » Tue Sep 15, 2020 12:12 am

CarlFK wrote:
Sun Sep 13, 2020 9:38 pm
I have this:

...
I think you also need a mkfs in there somewhere, also you need to specify start=0 in pyb.Flash()

(The detail as to why start=0 is complicated and an unfortunate backwards compatibility thing. pyb.Flash() is the virtual device that is presented to USB MSC, i.e. it includes a virtual partition table etc, and some part of it is backed by the actual flash storage on the chip).

This works for me:

Code: Select all

os.umount('/flash')
flash = pyb.Flash(start=0)
os.VfsFat.mkfs(flash)
os.mount(flash, '/flash')
os.chdir('/flash')
os.listdir()
CarlFK wrote:
Sun Sep 13, 2020 9:38 pm
I suspect I need to unmount it from the OS first,
Yes, definitely.

CarlFK
Posts: 11
Joined: Sun Aug 16, 2020 6:18 am

Re: [ADAFRUIT_F405_EXPRESS] mkfs

Post by CarlFK » Wed Sep 23, 2020 10:14 pm

Trying to clean up the fs, files are still here:

Code: Select all

 
 carl@twist:~/src/evezor/Edge_Boards/poc$ ls /media/carl/PYBFLASH
b2.py     bundle.py        driver.py  main.py        mapo.json  zorg.py
board.py  commission.json  edge.py    manifest.json  ocan.py

carl@twist:~/src/evezor/Edge_Boards/poc$ pumount /media/carl/PYBFLASH

MicroPython v1.13 on 2020-09-07; Adafruit Feather STM32F405 with STM32F405RG

>>> import os
>>> import pyb
>>> flash = pyb.Flash()
>>> os.umount('/flash')
>>> os.VfsFat(flash)
<VfsFat>
>>> os.mount(flash, '/flash')

carl@twist:~/src/evezor/Edge_Boards/poc$ pmount /media/carl/PYBFLASH
Error: could not determine real path of the device: No such file or directory

>>> import machine
>>> machine.reset()

carl@twist:~/src/evezor/Edge_Boards/poc$ ls /media/carl/PYBFLASH
b2.py     bundle.py        driver.py  main.py        mapo.json  zorg.py
board.py  commission.json  edge.py    manifest.json  ocan.py


User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: [ADAFRUIT_F405_EXPRESS] mkfs

Post by jimmo » Thu Sep 24, 2020 2:08 am

CarlFK wrote:
Wed Sep 23, 2020 10:14 pm
Trying to clean up the fs, files are still here:
You need to set `start=0` in `pyb.Flash(start=0)`

Post Reply