Closed attie-argentum closed 4 months ago
Hello @attie-argentum,
Thank you for this report, can you please share the reference and type of the SD card.
With regards.
Hi @KRASTM,
I've primarily been using a SanDisk Extreme (32 GB, U3, UHS-I), but have also tried on a fairly generic 2GB Transcend card.
I've had a lot of problems with consumer cards (Sandisk, Samsung, etc.). SwissBit references are more stable. My case is not the truth ^^
ST Internal Reference: 179876
Hello @attie-argentum,
Pending the official fix, there is a work around that may help you to unblock the situation.
First you initialize your SD card with 1 bit bus width within the function HAL_SD_Init()
. After that you can use the function HAL_SD_ConfigWideBusOperation
with SDMMC_BUS_WIDE_4B
.
I hope it will be useful. With regards.
Hi @KRASTM,
Thanks for the potential workaround... unfortunately this has exposed another (unexpected) issue in SD_FindSCR()
, where the loop below appears to exist cleanly after zero or one calls to SDMMC_ReadFIFO()
... am I correct to expect 2 here?
For me, this leaves the scr[2]
buffer in SD_WideBus_Enable()
with the following contents... the first results in HAL_SD_ERROR_REQUEST_NOT_APPLICABLE
, and the second results in a crash later in Zephyr (see below), even though there is now a non-zero SCR value present, and it appears to succeed.
00 00 00 00 00 00 00 00
or
00 00 00 00 43 84 35 02
Hello @attie-argentum,
In fact, I have already tested an example with an eval board, and it's working fine. Juste be sure that the value of BusWide is 1bit within the structure SD_HandleTypeDef while initializing the SD Card. After that you can change the config to 4bit with HAL_SD_ConfigWideBusOperation
.
With regards.
Many thanks for this patch... I've finally got around to testing it(!) - though unfortunately it still doesn't work with Zephyr. I manually applied 5f7138a2bfb8a7e76a3ac7c3d39314ec365145f8 onto zephyrproject-rtos/hal_stm32, but no joy. I will investigate further at some point, but I'm very busy at the moment.
uart:~$ fs mount fat /SD:
Error mounting FAT fs. Error Code [-5]
[00:00:00.562,000] <err> stm32_sdmmc: sd read error 36
[00:00:00.562,000] <err> fs: fs mount error (-5)
I'll raise an issue, as I suspect this may now be a Zephyr driver issue.
Describe the set-up
I'm using a NUCLEO-L476RG with Zephyr (
f51c8ee739
).Describe the bug
While trying to use a 4-bit SD/MMC bus, the system locks up... when using 1-bit bus the system works fine.
On investigation, it seems that this driver will never communicate the changed bus width with the card, resulting in a breakdown in
stm32_sdmmc_access_read()
.HAL_SD_ConfigWideBusOperation()
?How To Reproduce
.../samples/subsys/shell/shell_module/prj.conf
as below..../samples/subsys/shell/shell_module/boards/
cmake -GNinja -S ./zephyr/samples/subsys/shell/shell_module/ -B ./sdmmc_repro -DBOARD=nucleo_l476rg -DCONFIG_LOG_MODE_IMMEDIATE=y
ninja -C ./sdmmc_repro/
st-flash --reset --connect-under-reset write ./sdmmc_repro/zephyr/zephyr.bin 0x08000000
fs mount fat /SD:
, and note that the system "hangs"`.../samples/subsys/shell/shell_module/prj.conf`
```patch diff --git samples/subsys/shell/shell_module/prj.conf samples/subsys/shell/shell_module/prj.conf index 41d51f8e22..98567901fd 100644 --- samples/subsys/shell/shell_module/prj.conf +++ samples/subsys/shell/shell_module/prj.conf @@ -1,5 +1,6 @@ CONFIG_PRINTK=y CONFIG_SHELL=y +CONFIG_SHELL_STACK_SIZE=16384 CONFIG_LOG=y CONFIG_LOG_CMDS=y CONFIG_INIT_STACKS=y @@ -15,3 +16,24 @@ CONFIG_THREAD_RUNTIME_STATS=y CONFIG_THREAD_RUNTIME_STATS_USE_TIMING_FUNCTIONS=y CONFIG_STATS=y CONFIG_STATS_SHELL=y + +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_I2C=y +CONFIG_I2C_SHELL=y + +CONFIG_DISK_DRIVERS=y +CONFIG_DISK_DRIVER_SDMMC=y +CONFIG_SDHC=y +CONFIG_FILE_SYSTEM=y +CONFIG_FILE_SYSTEM_SHELL=y +CONFIG_FILE_SYSTEM_SHELL_TEST_COMMANDS=y +CONFIG_FILE_SYSTEM_SHELL_BUFFER_SIZE=0x2000 +CONFIG_FAT_FILESYSTEM_ELM=y +CONFIG_FS_FATFS_MOUNT_MKFS=n +CONFIG_FS_FATFS_EXFAT=y + +CONFIG_CAN=y +CONFIG_CAN_SHELL=y + +CONFIG_GPIO_SHELL=y ````.../samples/subsys/shell/shell_module/boards/nucleo_l476rg.overlay`
```dts /delete-node/ &spi3; &sdmmc1 { bus-width = <4>; clk-div = <0>; pinctrl-0 = < &sdmmc1_ck_pc12 &sdmmc1_cmd_pd2 &sdmmc1_d0_pc8 &sdmmc1_d1_pc9 &sdmmc1_d2_pc10 &sdmmc1_d3_pc11 >; pinctrl-names = "default"; status = "okay"; }; &clk_msi { msi-range = <11>; /* ~48 MHz */ status = "okay"; }; ```