Unable to initialize / hot swap sd card during run time

Hi

I have a system which needs to be run for 10days continuously. I have and SD card to log data during this period.

I need to verify the SD card data in between, so I send data from Bluetooth to alert my system that i am going to unmount and remove my SD card and also for mounting the SD card after I insert it back to SD card slot.

The cards gets detected easily and is accessible during initialization. 

int res = fs_unmount(&mp); is the command I use for mounting and detecting the sd card.
But after hot swap the SD card card gets detected but fails to respond due to sd card read timeout error. Kindly provide any suggestion so that I can effectively swap SD cards during runtime.
below is the snippet of the overlay file.
&spi4 {
    status ="okay";
    cs-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>,<&gpio1 12 GPIO_ACTIVE_LOW>;

    sdhc0: sdhc@0 {
       
        compatible = "zephyr,sdhc-spi-slot";
        reg = <0>;
        status = "okay";
        mmc {
            compatible = "zephyr,sdmmc-disk";
            status = "okay";
        };
        spi-max-frequency = < 24000000 >;
   
    };
Parents
  • Hi Reshma

    It should be fine using the Zephyr drivers functions to reinit SPIM. 

    After some more digging I found this thread that seems to report a similar behavior as what you see here. There was a bug where this timeout was always set to 0, but that should have been fixed as of NCS 2.0.0 from what I can tell. Can you double check to see what the timeout is in your spi_context.h file, as that is the only place in the SDK on my end that prints "Timeout waiting for transfer complete".

    The timeout value should be 200ms by default I believe, so please make sure it's not 0.

    Best regards,

    Simon

Reply
  • Hi Reshma

    It should be fine using the Zephyr drivers functions to reinit SPIM. 

    After some more digging I found this thread that seems to report a similar behavior as what you see here. There was a bug where this timeout was always set to 0, but that should have been fixed as of NCS 2.0.0 from what I can tell. Can you double check to see what the timeout is in your spi_context.h file, as that is the only place in the SDK on my end that prints "Timeout waiting for transfer complete".

    The timeout value should be 200ms by default I believe, so please make sure it's not 0.

    Best regards,

    Simon

Children
Related