Skip to content
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

sdmmc: add example for initializing sdcard #16

Merged
merged 1 commit into from
Oct 27, 2024
Merged

Conversation

jakezhu9
Copy link
Member

Hi all,

Over the past few weeks, I've developed a demo program to interface with SDHC peripherals. The current version successfully initializes the peripherals and SD cards, reads the CID register, and outputs the results. The program has been tested and runs on the development board(nezha-d1), with the output shown below:

image

Key Challenges and Solutions:

  1. SDHC Peripheral Configuration:
    Configuring SDHC peripherals involved selecting the appropriate clock source and calculating parameters accurately. The oreboot project helped as a reference. I also encountered a register operation bug that took some time to find, and it is now fixed.

794609a743e6d76ea317f96606a5818

  1. SDIO Protocol Operation:
    Implementing SD card data read and write functionality using the SDIO protocol presented complexity, particularly with version compatibility and edge cases. Since no Rust crate currently supports this, I have implemented basic initialization and CID register reading for now. Future improvements could include expanding functionality or developing a general SDIO protocol library for broader use.

  2. Flashing and Running the Program:
    After compiling, the program requires a correct image header and burning using the xfel tool. I referred to the steps in [board] Rust serial output example and light up led on 100ask-d1-h YuzukiHD/SyterKit#129 to complete.

Reference

oreboot/oreboot#636
oreboot/oreboot#701
YuzukiHD/SyterKit#143
YuzukiHD/SyterKit#129

I believe that this demo will support future boot program development and help adapt frameworks like Rust SyterKit :)

@jakezhu9
Copy link
Member Author

cc @luojia65

Copy link
Member

@luojia65 luojia65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a great achievement, thanks a lot!
LGTM

@luojia65 luojia65 merged commit 8ecc242 into rustsbi:main Oct 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants