AnsweredAssumed Answered

SD Card only works when debugging?

Question asked by Will L on Nov 12, 2019
Latest reply on Nov 25, 2019 by Kerry Zhou

I have software that uses the SD card/MMC drivers from NXP to communicate with an SD card.

  • If I boot the software while a debug session is running, and then issue the command (over the serial port) to initialize the card and read a block, everything works fine.
  • If I power cycle the board (which breaks the debug connection), the driver hangs after the serial command is issued.
  • If I then connect a debugger using the "attach" option and look, the CPU is stuck in the following code snippet



                     error = USDHC_TransferNonBlocking(base, &s_usdhc1Handle, &dmaConfig, content);

                  } while (error == kStatus_USDHC_BusyTransferring);

                  which is lines 267-270 of SDMMCHOST1_TransferFunction() in sdmmc\port\fsl_sdmmc_host.c

  • If I then use the debugger to restart the software and run, it can read the card fine.
  • If I start a new debug session - including flashing code down to the chip - and then immediately terminate the session before releasing the CPU from reset, the software boots, and I can read the card without hanging.

What is the debugger doing that doesn't happen during non-debug execution?  How do I fix/get around this?

I've tried dumping various hardware registers to try to see differences between the two cases, but nothing obvious stands out.

I'm using an MIMXRT1052 on a custom carrier board.