8000 mimxrt: Spend a few words about littlfs file system and MSC access. · micropython/micropython@48d46bb · GitHub
[go: up one dir, main page]

Skip to content

Commit 48d46bb

Browse files
committed
mimxrt: Spend a few words about littlfs file system and MSC access.
Since the board may have been formatted with littlfs, the FS device different when attached to a PC. And: fix typos.
1 parent 8c5dc48 commit 48d46bb

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

docs/mimxrt/quickref.rst

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ External drive mode
544544
On some boards a mode is enabled, that mounts the board's internal file system as
545545
external USB drive, called MSC support. Data of that drive can be accessed and changed by the PC.
546546
In that state, access to the internal drive by the MicroPython is limited to
547-
readonly mode, avoiding file corruption. Changes made by the PC to the file system may not be visible
547+
read-only mode, avoiding file corruption. Changes made by the PC to the file system may not be visible
548548
at the board until the drive is ejected by the PC or a soft reset of the board
549549
is made.
550550

@@ -566,15 +566,40 @@ The external drive mode can be enabled of disabled by calling mimxrt.usb_mode().
566566
These command must be placed into boot.py. They get effective after the next hard reset or
567567
power cycle.
568568

569-
The readonly state of the local file system access can be told by an IOCTL call of the file
570-
system's block device. ::
569+
The read-only state of the local file system access can be told by an IOCTL call of the file
570+
system's block device.::
571571

572572
import mimxrt
573573

574574
bdev = mimxrt.Flash()
575575
readonly = bdev.ioctl(7, 0)
576576

577-
If the drive is in readonly state, bdev.ioctl(7, 0) returns `True`.
577+
If the drive is in read-only state, bdev.ioctl(7, 0) returns `True`.
578+
579+
The file system of the board has to be of FAT type for mounting and using with standard PC
580+
tools. But FAT is not enforced at the board. If the board's file system is littlefs, MSC
581+
mode is disable by default. If enabled in boot.py, the file system will be attached to the
582+
PC and will be accessible as a drive (e.g. /dev/sdc usign Linux), but by default
583+
there is no file access. In that case, the files are locally still writable.
584+
Changing the board's file system to FAT can be done then by formatting it from the PC.
585+
Alternatively, you can erase the root sector. Then, the FAT file system will be
586+
created at the next power-up. For erasing the root sector, write::
587+
588+
from mimxrt import Flash
589+
Flash().ioctl(6, 0)
590+
591+
Using littlefs-fuse for Linux you can mount the board's littlefs file system to the PC.
592+
See: https://github.com/littlefs-project/littlefs-fuse
593+
The block_size if 4096, the block_count depends on the size of the filesystem. e.g.::
594+
595+
# mounting the lfs2 file system of a Teensy 4.1 board at the PC
596+
mkdir mount
597+
sudo ./lfs --block_size=4096 --block_count=1791 -o allow_other -o nonempty /dev/sdc mount
598+
cd mount
599+
ls -l
600+
601+
In that case, the exclusive write access is NOT enforced. So be careful to only write
602+
to the file system by the PC.
578603

579604

580605
Transferring files

0 commit comments

Comments
 (0)
0