Unable to remount SD-Card after physically ejecting without rebooting

Hi there,

I'm using an nRF 52840 with SD-Card connected over SPI. I've attached a runnable project that compiles with NCS V2.1.1. The challenge is as follows.

We need the SD-Card to be shut down. For this, we're using a high-side FET and we're suspending the SPI peripheral through Zephyr's power management API to prevent backfeeding through MOSI/MISO. As the SDHC driver from Zephyr makes the CS-pin logically low (which is high) when the card is unmounted, this results in the SD-card backfeeding through the FET.

We're working around this by manually controlling the CS-pin from the application; set it to an active state (0V as it's active low) on boot and never touch it again. We don't provide the cs-gpios in the devicetree to make sure it isn't overriden by the driver. This all in all is already quite the hassle, but it goes on.

After having manually removed the SD-card and re-insterting it, we're unable to remount the sd-card. Even if we keep the CS-line asserted at all times, and the FET providing power to the sd-card at all times.

So in short; we want to know how we can eject, insert, mount, unmount, eject, insert, mount, etc. without rebooting once.

Kind regards,

Jochem

5428.low_power_sdcard.zip

Parents
  • Hi,

     

    We're working around this by manually controlling the CS-pin from the application; assert it on boot and never touch it again.

    Could you share a log of this assert?

    Have you scoped (using a logic analyzer) the SPI pins to see if they behave as you intend them to?

     

    Kind regards,

    Håkon

  • Hi Håkon,

    I meant to assert the pin a high value. No in the sense of an assert triggering or anything. We just make the pin low on boot and never touch it again. I'll replace the text in the original post to prevent confusion.

    Yes, the SPI pins behave as I intend them too.

    The application just fails to mount the SD-card after I have physically removed it from its socket. The nRF then needs a reboot for it to be possible to mount again. I would like this to not be a requirement and be able to physically remove and reinsert it again, without having to reboot the nRF.

    Please note that mounting, unmounting and remounting works fine, as long as the SD-card is not physically removed.

    Kind regards,

    Jochem

Reply
  • Hi Håkon,

    I meant to assert the pin a high value. No in the sense of an assert triggering or anything. We just make the pin low on boot and never touch it again. I'll replace the text in the original post to prevent confusion.

    Yes, the SPI pins behave as I intend them too.

    The application just fails to mount the SD-card after I have physically removed it from its socket. The nRF then needs a reboot for it to be possible to mount again. I would like this to not be a requirement and be able to physically remove and reinsert it again, without having to reboot the nRF.

    Please note that mounting, unmounting and remounting works fine, as long as the SD-card is not physically removed.

    Kind regards,

    Jochem

Children
Related