SDHC issues - differences between NCS Zephyr and Downstream Zephyr?

Trying to get SDHC access working with a Laird MG100 (nrf52840) using NCS Zephyr. I'm using the Zephyr `fat_fs` sample as a starting point.

Regardless of the SDCard I use, sending CMD8 to the subsystem via `sdhc_request()` always returns 0 when using NCS Zephyr.

From `\nordic\v2.3.0\zephyr\subsys\sd\sd.c`

/* Sends CMD8 during SD initialization */
static int sd_send_interface_condition(struct sd_card *card)
{
	struct sdhc_command cmd = {0};
	int ret;
	uint32_t resp;

	cmd.opcode = SD_SEND_IF_COND;
	cmd.arg = SD_IF_COND_VHS_3V3 | SD_IF_COND_CHECK;
	cmd.response_type = (SD_RSP_TYPE_R7 | SD_SPI_RSP_TYPE_R7);
	cmd.timeout_ms = CONFIG_SD_CMD_TIMEOUT;
	
	ret = sdhc_request(card->sdhc, &cmd, NULL);
	if (ret) {
		LOG_DBG("SD CMD8 failed with error %d", ret);
		/* Retry */
		return SD_RETRY;
	}
	
	if (card->host_props.is_spi) {
		resp = cmd.response[1];
	} else {
		resp = cmd.response[0];
	}
	/* 
	
	Both cmd.response[0] and cmd.response[1] are consistently 0.
	This means that the following check always fails.
	*/

	if ((resp & 0xFF) != SD_IF_COND_CHECK) {
		LOG_INF("Legacy card detected, no CMD8 support");
		/* Retry probe */
		return SD_RETRY;
	}
	if ((resp & SD_IF_COND_VHS_MASK) != SD_IF_COND_VHS_3V3) {
		/* Card does not support 3.3V */
		return -ENOTSUP;
	...
	
}


This results in overall initialization failure:

*** Booting Zephyr OS build v3.2.99-ncs2 ***
[00:00:02.078,033] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.088,195] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.098,358] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.108,520] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.118,682] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.128,845] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.139,038] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.149,200] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.159,362] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.169,525] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.179,687] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:02.189,117] <inf> sd: sd_common_init: Card does not support CMD8, assuming legacy card
[00:00:02.199,859] <err> sd: sd_check_card_type: No usable card type was found
[00:00:02.208,038] <err> sd: sd_command_init: Unusable card
[00:00:02.214,538] <err> file_io: mount_sd_card: Storage init ERROR!

[00:00:04.250,122] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.260,314] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.270,477] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.280,670] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.290,832] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.301,025] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.311,157] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.321,350] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.331,512] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.341,705] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.351,867] <inf> sd: sd_send_interface_condition: Legacy card detected, no CMD8 support
[00:00:04.361,297] <inf> sd: sd_common_init: Card does not support CMD8, assuming legacy card
[00:00:04.372,039] <err> sd: sd_check_card_type: No usable card type was found
[00:00:04.380,218] <err> sd: sd_command_init: Unusable card
[00:00:04.386,749] <err> fs: fs_mount: fs mount error (-5)
Error mounting disk.


This isn't the case when using downstream zephyr. While I still get Legacy card detected error, it seems that I'm still able to read the card.

*** Booting Zephyr OS build zephyr-v3.3.0-1195-g9a759025d912 ***
[00:00:00.356,781] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.357,574] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.358,337] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.359,100] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.359,832] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.360,595] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.361,358] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.362,121] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.362,884] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.363,647] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.364,379] <inf> sd: Legacy card detected, no CMD8 support
[00:00:00.364,410] <inf> sd: Card does not support CMD8, assuming legacy card
[00:00:06.406,860] <inf> sd: Maximum SD clock is under 25MHz, using clock of 8000000Hz


My suspicion is that there is some critical difference that I can't find between NCS Zephyr and Downstream Zephyr, though there may be some other underlying issue at work here.

Can anyone provide any insight on how to resolve this?

Cheers,


S.


Parents Reply Children
  • I just hit this bug too while porting from v2.3.0 to v2.4.1.  Micro SD card worked fine in v2.3.0 but now does not work in v2.4.1, the change that broke things might have been in 2.4.0, I skipped directly to v2.4.1.

    I am using an nRF9160 (Circuit Dojo nRF9160 Feather to be exact).

    Has there been any progress on this?

    I will need to resolve this soon so there is currently no solution and I discover one I will post my findings here.

    I can provide files from both builds, same project (needed to add CONFIG_STREAM_FLASH=y to prj.conf for OTA update support).

    I have already tried to diff the files and can not seem to find what is different.

    There are some changes, like timer0, timer1, and timer2 were changed from "okay" to "disabled" in zephyr.dts and quite a few changes to CONFIG_ items in the .config files.

    EDIT: my issue is related to this following post... when I enable the following option in prj.cong the SD card no longer works...

     RE: SDHC SPI Send Command 

    CONFIG_BOOTLOADER_MCUBOOT=y

    I think there is a GPIO conflict happening, it started after release v2.3.0... something has changed and I am trying to track down what that is now...

Related