sdcDisconnect wait forever

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times
Contact:

sdcDisconnect wait forever

Postby wurstnase » Fri Jan 31, 2020 9:27 am

Hi,

I'm trying to find an issue with my SD-card slot.

Actually I trigger a manual disconnect from the sd-card. After some disconnects the driver will hang in a while loop:

hal_sdc.c

Code: Select all

bool sdcDisconnect(SDCDriver *sdcp) {
//...snip...//

  /* Waits for eventual pending operations completion.*/
  if (_sdc_wait_for_transfer_state(sdcp)) { // <- wait here
    sdc_lld_stop_clk(sdcp);
    sdcp->state = BLK_ACTIVE;
    return HAL_FAILED;
  }


hal_sdc.c

Code: Select all

bool _sdc_wait_for_transfer_state(SDCDriver *sdcp) {
  uint32_t resp[1];

  while (true) {
    if (sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_SEND_STATUS, // <- wait here
                                   sdcp->rca, resp) ||
        MMCSD_R1_ERROR(resp[0])) {
      return HAL_FAILED;
    }


os/hal/ports/STM32/LLD/SDIOv1/hal_sdc_lld.c

Code: Select all

bool sdc_lld_send_cmd_short_crc(SDCDriver *sdcp, uint8_t cmd, uint32_t arg,
                                uint32_t *resp) {
  uint32_t sta;

  sdcp->sdio->ARG = arg;
  sdcp->sdio->CMD = (uint32_t)cmd | SDIO_CMD_WAITRESP_0 | SDIO_CMD_CPSMEN;
  while (((sta = sdcp->sdio->STA) & (SDIO_STA_CMDREND | SDIO_STA_CTIMEOUT |
                                     SDIO_STA_CCRCFAIL)) == 0) // <- the STA stay at 0
    ;


Any idea what happend, or how I could prevent this?
\o/ Nico

User avatar
Giovanni
Site Admin
Posts: 13089
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 759 times
Been thanked: 639 times
Contact:

Re: sdcDisconnect wait forever

Postby Giovanni » Fri Jan 31, 2020 9:55 am

Hi,

Is the card always inserted during the connect/disconnect attempts?

Perhaps the driver needs a timeout during those waiting loops.

Giovanni

User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times
Contact:

Re: sdcDisconnect wait forever

Postby wurstnase » Fri Jan 31, 2020 10:23 am

Hi Giovanni,

yes the card is any time in the slot.

It could be an hardware issue, because I can see this issue mainly, when the wifi-module, close to it, will create a connection, which could draw more current in that situation.
\o/ Nico

User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times
Contact:

Re: sdcDisconnect wait forever

Postby wurstnase » Fri Jan 31, 2020 11:29 am

I should enable the CHIBIOS debug options...

The sdcDisconnect will stop, because it is not BKL_READY.
Before I make a sdcDisconnect I wait now for a sdcSync will return HAL_SUCCESS.
\o/ Nico


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 3 guests