-
Notifications
You must be signed in to change notification settings - Fork 1.5k
bcm2711/sdio: Support for EMMC interfaces on the BCM2711 #17245
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
acassis
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.
Nice work @linguini1 ! Kudos!!!
acassis
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.
Please update the Documentation/ to include this new feature. Also include board profile "sd" example explaining how to use
That's my intention, there is an SD config currently. I just want to try and get stress testing passed before I write the docs. |
|
Great work @linguini1 :-) Would that solution work also on rPI-Zero-2W? I have only this board to test :-P I found some info here: https://groups.google.com/g/bcm2835/c/vrpnf1Py-Mg
I can either try to just run the firmware from rPI-4B on rPI-Zero-2W or buy 4B are there any specific hardware version / model / release to consider @linguini1 ? :-) |
Unfortunately I don't think so, I believe your board has a different SoC. I think I might be on my own to troubleshoot this unless anyone can spot something wrong with the implementation! |
|
Okay I have ordered rPI 4B 8GB and 5 8GB to have testing boards.. but right now working on priority stuff so will test in a free moment next week+ :-) |
5d1e7b4 to
121b5aa
Compare
ad99c9e to
ff5b93d
Compare
acassis
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.
I'm approving since it works for some SDCards, but maybe you should include "depends on EXPERIMENT" to BCM2711_EMMC. This way users will reduce the expectations on this driver.
Good idea! I always forget about this Kconfig option, I just marked as experimental (with lots of warnings) in the documentation. I will do that! Hopefully having the experimental feature which works at about 80% will leave room for other contributors to figure out the remaining issues/stabilize over time. |
This initial implementation sets up support for the EMMC interfaces on the BCM2711. Only EMMC2 is tested since it is the interface of interest (connects to uSD card). MMCSD communication is functional and the boot partition of the SD card can be mounted and interacted with. Insertion/removal interrupts do not fire after initial boot, and sdstress fails with any byte size larger than 1023. 32GB card works perfectly, while 64GB card exhibits strange behaviour when interacting with VFAT filesystem. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
The documentation is now updated to reflect the new EMMC support. I have also improved the format to match the standard board documentation template, and included better support descriptions for features that have varying levels of implementation. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
|
I dont have the board yet.. just wondering if there are two SD card slots? If the OS/RTOS boots from SD then this will allow accessing files from the same card? I have somewhere small eMMC board with 16GB (or 32GB) NAND for VisionFive2 SBC but not sure if there is a slot here for that and if that fits the connector on rPI 4B? :-P |
There is only one microSD slot, which this patch aims to support. That is the same SD that the system boots from, so this patch allows users to access the boot partition after boot (totally fine to read/write). I plan to add support for two partitions later for users who don't want to mess around on the same partition as the boot files. To my knowledge, the EMMC1 interface connects to the SDIO controllable WiFi chip. There is also a third SDHCI interface which I haven't supported yet that allows another external SD card, I believe connected through the GPIO pins. |
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.
Thank you @linguini1 amazing work, great description, documentation, and testing!! :-)
I have ordered the boards and will be able to test next week with rPI 4B 8GB and SanDisk HighEndurance 64GB and Patriot EP 64GB cards but you have my go already :-)
Thank you!
I look forward to it! If you encounter any issues in your testing please open bug issues (I will do the same for my 64GB card after this is merged so I don't forget about it). Those issues still need more triaging, unfortunately school is getting busy again so I'll have to tackle them slowly and one-by-one. More people triaging is very helpful and appreciated! |
|
Okay I have the rPI 4B 8GB and a moment to test :-) I also got rPI 5 8GB just in case :-P
|
|
Thank you for testing @cederom ! It looks like things are working well with a variety of different cards as long as the operations are 1023 bytes or less. I think this is a limitation of the write FIFO in the controller, as the write-ready interrupts don't seem to be behaving as I expected they would. I will spend some time later to try to fix this transfer size issue but I haven't had any luck so far. It might be a while. |
|
Thank You for porting NuttX to rPI 4B @linguini1 this is hard and amazing work kudos!! :-) I have now setup and I know how to use it let me know when you need more testing :-) During this tests I found some related improvements:
|
I really appreciate your time testing! Great finds as well :) |
Summary
This initial implementation sets up support for the EMMC interfaces on the BCM2711. Only EMMC2 is tested since it is the interface of interest (connects to uSD card). MMCSD communication is functional and the boot partition of the SD card can be mounted and interacted with. Stress testing fails, insertion/removal events only work right after boot.
Closes #16948.
Closes #16949.
NOTE: Card insertion/removal events may not be possible with this implementation. I have followed the SD host controller simplified specification section 3.1 (SD card detection), but I have not gotten any results. I am leaving it alone for now.
NOTE: This is a draft PR for initial review. I still have some changes to make to stabilize this feature. I can't seem to get card insertion/removal interrupts to fire, although I see that they exist in the RPi Linux code and other projects. I've configured them the same way as other interrupts but no luck beyond initial boot.
Does anyone know how to support 8-bit transfer? The controller is capable of that, but the widebus functionality of the NuttX upper-half driver only seems to allow 1b or 4b modes.
Impact
Users can now interact with the micro-SD card through NuttX! Right now they are able to mount the boot partition, however I will also add support for mounting two separate partitions on the micro SD card so that a disk filesystem exists.
Testing
Tested using all the code included in this PR:
/dev/mmcsd0is mounted and that logs from the driver indicate correct operation/dev/mmcsd0to NuttX at/sdand verify that I can see all of the files in the card withlscata file in the SD cardechoto a file on the SD card to create a new oneSuccessful mount
Listing the SD card boot partition:
Using
catto see file contents of test.txt:Using
echoto append to test.txt:The
sdstresstest passes, so long as I configure it with the byte parameter as 1023 or less. The moment I make it 1024 bytes or larger, I get a lot of errors. I would imagine that this is something to do with the block gaps/the maximum supported transfer size being 1KB.1023 byte stress test output:
Output of stress test when above 1023 bytes:
After this, it hangs. Following a reboot, here are the contents of the created
stress/directory:For whatever reason, very strange behaviour occurs when using a 64GB Sandisk card. Sometimes there is a data CRC failure after boot and the FAT filesystem never mounts, even when re-attempted, due to this error. Other times, the FAT filesystem mounts but attempting to create a file on the card causes
sendcmdto be called with CMD13 repeatedly until the watchdog times out. I cannot figure out why this is happening for only the 64GB card.