-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
mimxrt: Add MSC support for the mimxrt port. #8820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #8820 +/- ##
==========================================
- Coverage 98.50% 98.48% -0.02%
==========================================
Files 155 155
Lines 20540 20549 +9
==========================================
+ Hits 20232 20237 +5
- Misses 308 312 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
43f8bae
to
f24a814
Compare
8c607f7
to
48d46bb
Compare
7491747
to
66f458a
Compare
c1f5a59
to
987d629
Compare
987d629
to
c50ee3a
Compare
c50ee3a
to
ea2317d
Compare
ea2317d
to
5648155
Compare
Code size report:
|
These will be needed for MSC support. The change matches the changes for the bootloader.
The DTCM section got too large.
This attribute is present on builds with MSC support, allowing _boot.py to decide about creating if and which file system.
As a benefit, it will not destroy an existing FAT partition.
Using the good implementation by @iabdalkader for RP2 and some of @alphaFred's work for the bootlaoder. Open topics: - In the descriptor the blocksize was set to 64. MIMXRT requires 512 - Adding a lock preventing local write as long as the disk is mounted. - Hyperflash has a sector size of 256k. Here, the BLOCK_SIZE == SECTOR_SIZE_BYTES is 4096, which by good luck meets the size required for SD Cards.
Enable MSC unless defined different for a board. Disable MSC for MIMXRT1050_EVK because of it's hyperflash chip.
Porting PR micropython#8814 of @iabdalkader to the mimxrt platform. - When the board is mounted to a PC, local write access is blocked. - Local write access will be re-enabled again if the disk is ejected. - If the board is not connected to a PC on start-up, local write access is enabled. - The status of the write access can be determined by bdev.ioctl(7, 0). If the device is mounted to a PAC and thus local write access is blocked, it return 1, otherwise 0. - low level write/erase using the block device calls are still possible. It is up to the user to check the device status ahead.
That way it is guaranteed, that a new file system is created before an MSC mount attempt can be made. Also: Check for readonly mode before trying mkfs.
Since remount after MSC eject does not update the file system's data in memory, keep file the system readonly until after a soft reset, which has to be done deliberately. That's neither comfortable nor elegant, but safe. Disabled MSC as default option. Disabled MSC for MIMXRT1050_EVK deliberately. Enabled MSC for MIMXRT1020_EVK, Teensy 4.1 and OLIMEX_RT1010 for testing.
To enble/disable MSC at boot time. The calls are a simplified version if pyb.usb_mode(): mimxrt.usb_mode(modestr) with modestr being either "vcp" or "vcp+msc". The call has to be placed in boot.py and requires a hard reset to get effective, since tusb_init() is executed only once after reset. As a side effect, USB is not active in boot.py. So there is not USB I/O possible in boot.py, and code running in boot.py cannot by stopped with Ctrl-C.
1. USB will be enabled BEFORE boot.py is executed, avoiding deadlocks by user written code. 2. MSC support is enabled in _boot.py according to the following rules: a) For a FAT file system, MSC will be enabled by default. b) For a LFS file system, MSC will be disabled by default. c) The setting can be overriden by a file with the name set_usb_mode.py, which can define usb_mode with the lines: usb_mode = "vcp+msc" # enable MSC or usb_mode = "vcp" # do not enable MSC If that file does not exist or is faulty, the default is used.
Including some notes about littlfs file system and MSC access. When the board is formatted with littlfs, the FS access method by the PC is different.
Assuming that with PR #9497 it will be possible to have MSC support using a Python coded driver, which can be the same for all ports using TinyUSB, I close this PR. I will keep the branch in my repository and maintain it. |
Thank you for this, I will cherry-pick it in my fork too until we see if the other PR is merged. @robert-hh I wanted to mention a storage related issue, with the port in general, so the VFS offset is fixed without checking if firmware overflows, if the firmware grows more than
|
Yes I know hat there is no automatic check. When starting 1Mbyte for code seemed huge. And the actual Teensy 4.1 build is as 580k. So you must have added a lot. |
Not really if you add WiFi driver and firmware (which is ~400K alone) LWIP, nimble etc |
…ices New methods to get list of associated stations in access point mode and get maximum number of stations that can be associated
Using the good implementation by @iabdalkader for RP2 and some of @alphaFred's work for the bootloader.
This is a build option. The PR consists of two major parts:
mimxrt: Change the MSC enable/disable setting
MSC support is not possible for device with hyperflash memory. FAT does not match with the 256k sector size of these devices. For all other devices, MSC is enabled by default.