embedded-sdmmc-rs icon indicating copy to clipboard operation
embedded-sdmmc-rs copied to clipboard

Reinitialization support

Open ost-ing opened this issue 4 years ago • 1 comments

Hey, I'm using this library in conjunction with an SDIO SDMMC controller and a removable SDCard.

I would like to be able to reinitialize this library if the user removes the SDCard and reinserts it.

What I am doing is:

  1. Initialize everything, the SDMMC and this library, with SDCard present ✅
  2. Remove the SDCard, and then reinsert it (or another card) ✅
  3. Reinitialize the SDMMC controller ✅
  4. Reinitialize this library ❌

I need to refresh the handles for the Volume, e.g:

let mut volume = self.controller.get_volume(VolumeIdx(0)).unwrap();

But I then encounter the error:

panicked at 'called Result::unwrap() on an Err value: FormatError("Invalid MBR signature")', src/drivers/sdcard.rs:117:67

Proposed solution:

Either allow the Controller and volumes to be reinitialized, or provide a means to relinquish the block device so that the Controller can be reinitialized from scratch.

Kind regards

ost-ing avatar May 14 '21 13:05 ost-ing

Ah, hot-plug. I would love to see a PR to support this!

thejpster avatar Oct 15 '21 21:10 thejpster

Closed by #80, I think. You probably need out-of-band support to know when to destroy your VolumeManager though.

thejpster avatar May 06 '23 20:05 thejpster