No USB filesystem after installing MIcroPython bootloader
-
- Posts: 1
- Joined: Fri Jul 15, 2022 3:07 am
No USB filesystem after installing MIcroPython bootloader
I just got some Pi Picos... I've been playing around with CircuitPython (which works just fine BTW) and decided to try flashing MicroPython....
I did the following:
1-Hook new Pico board up to USB port
2-Hold BootSel button
-Plug USB port into PC
-Copy rp2-pico-20220618-v1.19.1.uf2 (uPython bootloader) to D: (drive mapped to Pico bootloader FS) drive
D: drive goes away, but I never get a new drive mapped to MicroPython USB drive never appears.
The above procedure works just fine with the CircuitPython uf2.... I get a USB drive with a Lib folder and a code.py file.
I did the following:
1-Hook new Pico board up to USB port
2-Hold BootSel button
-Plug USB port into PC
-Copy rp2-pico-20220618-v1.19.1.uf2 (uPython bootloader) to D: (drive mapped to Pico bootloader FS) drive
D: drive goes away, but I never get a new drive mapped to MicroPython USB drive never appears.
The above procedure works just fine with the CircuitPython uf2.... I get a USB drive with a Lib folder and a code.py file.
Re: No USB filesystem after installing MIcroPython bootloader
MicroPython does not have MSC support by intention for most ports. The reason: it requires to use a FAT file system on the boards, which i not designed to be used on flash devices. And using it either has the high probability of file system corruption or requires dedicated switch between write access by the PC or by the board. Instead, MicroPython favors to use the Littlefs files system and at the PC the mpremote tool in combination with it's mount command.
In any case: MSC can can be enabled for the RPI Pico by a compile switch. It is enabled for instance for the Arduino Nano Connect 2040. And it can be enabled at the PyBoard series by a API call during boot.
P.S.: For Linux system, Littlefs support is available as a fuse file system.
In any case: MSC can can be enabled for the RPI Pico by a compile switch. It is enabled for instance for the Arduino Nano Connect 2040. And it can be enabled at the PyBoard series by a API call during boot.
P.S.: For Linux system, Littlefs support is available as a fuse file system.
Re: No USB filesystem after installing MIcroPython bootloader
Oh! This caught my attention.
I would love to be able to access the micropython filesystem from Linux.
I searched the documentation and actually found here this:
Code: Select all
A littlefs filesystem can be still be accessed on a PC over USB MSC using the littlefs FUSE driver. Note that you must specify both the --block_size and --block_count options to override the defaults. For example (after building the littlefs-fuse executable):
But the example given in the doc to get block-size and block_count parameters is for the pyboard.
I tried uos.statvfs('/') on an esp32. Would the obtained f_frsize and f_blocks be ok to pass to lfs parameters?
Also in the doc the example to mount the filesystem on linux is:
Code: Select all
$ ./lfs --block_size=4096 --block_count=512 -o allow_other /dev/sdb1 mnt
Does these micropython commands given in the doc:
Code: Select all
import pyb
f = pyb.Flash(start=0)
f.ioctl(1, 1) # initialise flash in littlefs raw-block mode
I must have missed something!
Re: No USB filesystem after installing MIcroPython bootloader
The block-size is indeed 4096. The block-count is file-system-size/4096, which should be 352. If you have chosen the wrong number, you'll get an error message with the right number.
To enable file system access, the port must support it. The PyBoard port does, and you have to enable it e.g. with pyb.usb_mode('VCP+MSC') (see: https://docs.micropython.org/en/latest/ ... hlight=msc). Once MSC is enabled, you will see another /dev/sd* device in Linux. It does not have to be /dev/sdb1, could be as well /dev/sdbc ..., depending on how many mass storage devices are already attached to your computer.
Raspberry Pi support MSC at the moment only for the Arduino nano 2040 connect board. You can enable it as well for the other boards, but you have to build a new firmware, by uncommenting the line
#define MICROPY_HW_USB_MSC (1)
in the board's mpyconfigboard.h. I did not try RPI Pico MSC with fuse yet, but can do so.
To enable file system access, the port must support it. The PyBoard port does, and you have to enable it e.g. with pyb.usb_mode('VCP+MSC') (see: https://docs.micropython.org/en/latest/ ... hlight=msc). Once MSC is enabled, you will see another /dev/sd* device in Linux. It does not have to be /dev/sdb1, could be as well /dev/sdbc ..., depending on how many mass storage devices are already attached to your computer.
Raspberry Pi support MSC at the moment only for the Arduino nano 2040 connect board. You can enable it as well for the other boards, but you have to build a new firmware, by uncommenting the line
#define MICROPY_HW_USB_MSC (1)
in the board's mpyconfigboard.h. I did not try RPI Pico MSC with fuse yet, but can do so.
Re: No USB filesystem after installing MIcroPython bootloader
Edit: Looking through the RP2 implementation, using MSC currently enforces a FAT file system for the board. That's done in main.c by executing _boot_fat.py instead of _boot.py. So you would have to change that as well.
Tested it and it worked. My mount command was:
sudo ./lfs --block_size=4096 --block_count=352 -o allow_other -o nonempty /dev/sdc mount
with mount being my mount point. But be careful. The PC is the master, and changes made by the PC are not always visible at the board. And do not write at the board while it is mounted. There is no protection against trouble.
Unmounting does not work from the PC file manager, if you mounted using sudo. You have to do that in the command line.
Tested it and it worked. My mount command was:
sudo ./lfs --block_size=4096 --block_count=352 -o allow_other -o nonempty /dev/sdc mount
with mount being my mount point. But be careful. The PC is the master, and changes made by the PC are not always visible at the board. And do not write at the board while it is mounted. There is no protection against trouble.
Unmounting does not work from the PC file manager, if you mounted using sudo. You have to do that in the command line.
Re: No USB filesystem after installing MIcroPython bootloader
Thanks Roberthh I understand now
I'm gonna try that. I'll report here.
Have a good day
I'm gonna try that. I'll report here.
Have a good day
Re: No USB filesystem after installing MIcroPython bootloader
I have tested it for the rp2/PICO and it works very well.
I have tested both FAT and littleFS.
As you mentioned to enable mass storage I have uncommented the line
#define MICROPY_HW_USB_MSC (1)
in the board's mpyconfigboard.h then build a new firmware. This build defaults to FAT filesystem.
To build a littleFS firmware I set MICROPY_VFS_FAT to 0 in mpconfigport.h (then main.c runs _boot.py instead of _boot_fat.py)Then the lfs mount command is working as expected.
As you mentioned entering wrong number for block_count brings an error message with the right number.
A good trick to get it!
MicroPython keeps surprising me with features that I discover. I love it!
With this mass storage (FAT or littleFS) I'm able to configure my favourite editor: geany with 3 windows:
- the mounted file system
- the edit window
- a terminal window where I run rshell
I get a "Thonny" like app where I can edit and run code on the pico. Awesome!
Here under is a screenshot
As you said:
I did not try to write to the filesystem from the REPL while mounted on the PC, I usely don't need, I take note of being careful.
I must try now:
Doing the same for the PICO_W (should be easy only the block_count will change I think)
Doing the same for ESP8266 and ESP32 (I already check and it seems different)
Thanks again
I have tested both FAT and littleFS.
As you mentioned to enable mass storage I have uncommented the line
#define MICROPY_HW_USB_MSC (1)
in the board's mpyconfigboard.h then build a new firmware. This build defaults to FAT filesystem.
To build a littleFS firmware I set MICROPY_VFS_FAT to 0 in mpconfigport.h (then main.c runs _boot.py instead of _boot_fat.py)
Code: Select all
// #define MICROPY_VFS_FAT (1)
#define MICROPY_VFS_FAT (0)
As you mentioned entering wrong number for block_count brings an error message with the right number.
A good trick to get it!
MicroPython keeps surprising me with features that I discover. I love it!
With this mass storage (FAT or littleFS) I'm able to configure my favourite editor: geany with 3 windows:
- the mounted file system
- the edit window
- a terminal window where I run rshell
I get a "Thonny" like app where I can edit and run code on the pico. Awesome!
Here under is a screenshot
As you said:
Yes, changes are not always visible in the MicroPython REPL when done on the PC. I have to exit and open again the REPL to see the changes.But be careful. The PC is the master, and changes made by the PC are not always visible at the board. And do not write at the board while it is mounted. There is no protection against trouble.
I did not try to write to the filesystem from the REPL while mounted on the PC, I usely don't need, I take note of being careful.
I must try now:
Doing the same for the PICO_W (should be easy only the block_count will change I think)
Doing the same for ESP8266 and ESP32 (I already check and it seems different)
Thanks again
- Attachments
-
- ScreenshotGeanyPicoFatRshell.png (140.67 KiB) Viewed 4895 times
Re: No USB filesystem after installing MIcroPython bootloader
It os not possible for ESP8266 and ESP32, because they connect through a usb/uart bridge. Only ESP32-C3 may be possible, because it has built-in USB. But someone has to port the code for MSC support.
Re: No USB filesystem after installing MIcroPython bootloader
But yes of course, I had forgotten this CH340/CH341 bridge. Of course it's hardware limitation.
Re: No USB filesystem after installing MIcroPython bootloader
The ESP32-C3 has the bridge built in, but it's still a bridge, no full USB.
See here:
https://docs.espressif.com/projects/esp ... nsole.html
"the USB Serial/JTAG Controller is a fixed function device, implemented entirely in hardware. This means it cannot be reconfigured to perform any function other than to provide a serial channel and JTAG debugging functionality."
A big fail, IMHO.
I have built Micropython for Pico with MSC, but I would appreciate if that was made available as download option.
Regards,
Dietmar