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

zynq7000: add SD card storage driver #433

Merged
merged 2 commits into from
Nov 16, 2023
Merged

zynq7000: add SD card storage driver #433

merged 2 commits into from
Nov 16, 2023

Conversation

jmaksymowicz
Copy link
Contributor

@jmaksymowicz jmaksymowicz commented Oct 19, 2023

Adds a storage driver for SD memory cards. Data can be read through a block device or a JFFS2 partition can be mounted through an emulated MTD character device.

Description

The driver uses the SD Host Controller built into the Zynq 7000 platform to communicate with the SD card. Accesses to the card (for both block and MTD device files) are passed through libcache. Partitions are dectected automatically upon card insertion using MBR partition scheme (typical on SD cards). Separate device files are created for each partition. Card removal results in partitions being unmounted and device files being removed. No "safe eject" functionality has been implemented yet.

The MTD device is described as "emulated" as there is no way to implement a fully featured MTD driver for an SD card. Driver supports JFFS2 and ext2 filesystems. The driver also allows root filesystem to be mounted during startup.

Driver supports SD and SDHC cards of any size (up to 2 TB permitted by the standard), but due to limitations of libstorage and libcache on this platform only the first 4 GB of the card are addressable. Any partition on the card that starts or ends beyond 4 GB will not work. This can be remedied by partitioning the card on a host PC to ensure all partitions fit within the first 4 GB of the card's capacity.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

The driver was tested on a variety of microSD cards ranging in size from 256 MB to 16 GB and implementing SD Specification v1.01, v1.1 and v2.0.

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: armv7a9-zynq7000-zturn

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.h Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.h Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdstorage_dev.c Outdated Show resolved Hide resolved
Copy link
Member

@agkaminski agkaminski left a comment

Choose a reason for hiding this comment

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

Partial review only for now, I only pointed a one example of a given problem, there are more instances of each one in the code

storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdstorage_srv.c Outdated Show resolved Hide resolved
@jmaksymowicz jmaksymowicz force-pushed the RTOS-630 branch 3 times, most recently from 19bf57d to 997d2b4 Compare November 8, 2023 13:47
Copy link

github-actions bot commented Nov 8, 2023

Unit Test Results

5 989 tests   5 348 ✔️  28m 41s ⏱️
   333 suites     641 💤
       1 files           0

Results for commit 820adde.

♻️ This comment has been updated with latest results.

storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdcard.c Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdstorage_dev.h Outdated Show resolved Hide resolved
storage/zynq7000-sdcard/sdstorage_srv.c Outdated Show resolved Hide resolved
Copy link
Member

@agkaminski agkaminski left a comment

Choose a reason for hiding this comment

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

LGTM

@agkaminski agkaminski merged commit 2e5b9d3 into master Nov 16, 2023
30 checks passed
@agkaminski agkaminski deleted the RTOS-630 branch November 16, 2023 12:08
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