Skip to content

Emmcio module - #11257

Draft
FoamyGuy wants to merge 9 commits into
adafruit:mainfrom
FoamyGuy:emmcio_module
Draft

Emmcio module#11257
FoamyGuy wants to merge 9 commits into
adafruit:mainfrom
FoamyGuy:emmcio_module

Conversation

@FoamyGuy

Copy link
Copy Markdown
Collaborator

adds emmcio module with support for auto-mounting at /sd.

Some changes based on feedback in the prior PR:

  • Error messages are refactored to use existing strings instead of new ones
  • removed scsi inquiry product id for emmc LUN
  • removed automount crumb fallback
  • removed automount_status(), it had no analogy in sdcardio or sdioio.

Currently compile tested only. Testing on hardware requires SP-1 board def which I'm working on next and then will make a local merged branch to validate the behavior of this branch. Will un-draft after it's tested

Question from previous PR review:

Instead of using SPI directly, could you use the common_hal abstraction and put this in shared modules?

The module isn't speaking SPI. It's the 1-bit MMC bus: a clock, a bidirectional CMD line, and a bidirectional DAT0 line. SPIM3 is being used as a raw shift-and-clock engine on a single wire, not as a SPI primary/controller. MOSI and MISO are the same pin, rebound per transfer. The DMA transfer happens mid-frame, between bit-banged phases.

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Getting better! Do we really need to guard so heavily against the emmc not coming up? Since it's on the board I'd expect it to just work.

#if CIRCUITPY_EMMC_USB

#ifndef CIRCUITPY_EMMC_MOUNT_PATH
#define CIRCUITPY_EMMC_MOUNT_PATH "/sd"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we sure we want this? Or should it be /emmc?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I had it as /emmc at first and changed it to /sd to be consistent with Yoto devices after it was mentioned that I should try to model this on the work that done in them. Personally I have no strong opinion which it uses.

Comment thread shared-bindings/emmcio/__init__.c
Comment thread shared-bindings/emmcio/__init__.c Outdated
Comment thread shared-bindings/emmcio/__init__.c Outdated

void emmcio_reset(void) {
// The supervisor's mount outlives the VM, so its card stays up.
if (emmcio_is_automounted()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if it'd be better to test against the default pins being defined. That way you don't need to test at runtime.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think checking the pins at compile time might not be sufficient. This call finding out whether the emmc is mounted by the supervisor currently, not merely whether the pins exist that could be used to mount it. The user could have disabled automount in settings.toml which would make mmcio_is_automounted() return false, but a compile time check against pins couldn't know about that being disabled in settings.toml.

Comment thread ports/nordic/common-hal/emmcio/EMMC.c Outdated
return 1; // card never left busy
}
if (!self->cmd2_resp) {
return 2; // no CID

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use a macro to make these readable. I suspect you have them elsewhere as macros already.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Used a macro and improved this in the latest commit. I found some named constants instead of hard-coded numbers to use as well.

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