-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
ports/mimxrt: Add MSC support. #16591
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
|
Code size report: |
|
I could test that one. Besides that, I keep an branch for MIMXRT MSC support alive since quite a while. https://github.com/robert-hh/micropython/tree/mimxrt_msc |
|
Tried it. At the first run, it did not even compile with a Teensy 4.1 as target after setting MICROPY_HW_USB_MSC, complaining about the symbol MICROPY_HW_SDCARD_SDMMC not being set. Maybe you have that set in your environment. Having MICROPY_HW_SDCARD_SDMMC set, the board creates a new device block device at my PC. That cannot be mounted by littlefs-fuse. The Teensy's file system is littlefs, but a block device should be transparent. Is your PR by some means restricted to FAT? |
Yes, this just lets the msc disk know which SD is used for the block device if you have more than one, and since it's board-specific you need to define
You probably need to match the flash sector size, maybe try |
|
Not mounting LFS It was a problem with my PC. After reboot it worked. Maybe you get yourself MIMXRT boards and test the submission before posting a PR. |
2ec082f to
8d822bc
Compare
Is this unexpected? If you only have one SD card, you can't set the ID to 2.
As I've mentioned I have been using this code in production for year, so it's been tested, just never with an upstream board. |
|
I did a few more board tests after changing mpconfigport.h to: MIXRT1020_EVK, Teensy 4.1 and MIMXRT1176_EVK worked fine. It is a good idea to expose the inserted SD card. MIMXRT1010 and MIMXRT1015 fail for two reasons:
|
8d822bc to
d9e4945
Compare
|
@robert-hh I've incorporated both changes. As for the memory overflow, this should be fixed for individual boards if/when they enable this feature. |
|
I see that you disable MSC by default. |
Yes. If you like you can enable it by default or for certain boards if/when this PR gets merged. As for the memory, I'd lower the stack, 16KBs is good probably good enough. |
|
I did both. Rearranging the BSS to reduce gaps and decreasing the stack size. |
8e640f9 to
e2e0a50
Compare
|
@robert-hh are you happy with this PR now? |
|
Actually the PR still does not build with MIMXRT1011 and MIMXRT1015 devices with MSC enabled. The stack has to be decreased, like from 20k to 16k. Same for MIMXRT1015 |
Are you saying we should enable MSC for these boards by default? |
5cefb9c to
cf8ed98
Compare
|
@robert-hh Enabled for MIMXRT1011, MIMXRT1015 and MIMXRT1060. I've added 1060 to CI to have at least one board with MSC enabled. Note I moved |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #16591 +/- ##
=======================================
Coverage 98.59% 98.59%
=======================================
Files 167 167
Lines 21599 21599
=======================================
Hits 21295 21295
Misses 304 304 ☔ View full report in Codecov by Sentry. |
Actually no. But if it's disabled, there should be no further hiccup. I enabled MSC by default and ran a build-all script with the 1011/1015 stack changed. All boards build. The Teensy4.1 board has a MIMXRT1062 MCU, and it is already built in the CI. So you could use that one. But if you want to add a board, the MIMXRT1010 would be a good choice, because that one is always a candidate for trouble. |
|
I don't want to enable MSC by default. It's just that it should build without error if a user enables it themselves. |
|
@dpgeorge You can just drop commit number 3 which enables it for some boards, and commit number 4 which adds 1060 to CI. However, I'd leave 1060 in CI as it tests more things. |
@dpgeorge @robert-hh On second thought, if we don't add at least 1 board with MSC enabled, we'll never notice if this ever gets broken by any change. I only care about the core functionality, but this is worth mentioning. |
You can build with MSC enabled just under CI using something like |
cf8ed98 to
39482b9
Compare
|
Done. Seems to build fine. |
Add MSC support using internal flash storage or SD card. Note this is disabled by default, and can be enabled by boards if needed. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Reduced to 16KBs to allow enabling MSC. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
39482b9 to
752c167
Compare
dpgeorge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with TEENSY40 and enabling MSC. It works.
|
As a note: This feature works also with the lfs file system at the board and littlefs-fuse at the PC. |
Oh nice, I've been meaning to try this - that's great to know! |
|
Unrelated question, but does anyone know what the minimum LFSV2 volume size is? Or is there no such limitation ? For example, for FatFS it's 512 * 128 = 64K. |
|
Lfs uses at least 5 blocks (2+2+file data), with the minimal block size being 104 bytes. So yes, there is a minimal size, but that is rather small. |
|
Amazing! Thanks @robert-hh |
|
With two blocks of 96 bytes each, it's possible to create a LFS2 filesystem that has one small file. |
Summary
Add MSC support using internal flash storage or SD card. This has been sitting for a while in my fork so I figured I should send it upstream. Note this is disabled by default, and can be enabled by boards if needed.
Testing
Tested with: