Open bobobo1618 opened 2 weeks ago
Hi @bobobo1618! We appreciate you submitting your first issue for our open-source project. 🌟
Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙
I've just had a try on the commit you mentioned on stm32h747i_disco with the following samples/subsys/fs/littlefs
, and it works as expected:
*** Booting Zephyr OS build v3.7.0-1440-g34206f5505b5 ***
Sample program to r/w files on littlefs
Area 0 at 0x0 on qspi-nor-flash-1@90000000 for 67108864 bytes
I: LittleFS version 2.9, disk version 2.1
I: FS at qspi-nor-flash-1@90000000:0x0 is 8192 0x2000-byte blocks with 512 cycle
I: sizes: rd 32 ; pr 32 ; ca 256 ; la 64
E: WEST_TOPDIR/modules/fs/littlefs/lfs.c:1374: Corrupted dir pair at {0x0, 0x1}
W: can't mount (LFS -84); formatting
I: /lfs1 mounted
/lfs1 mount: 0
/lfs1: bsize = 32 ; frsize = 8192 ; blocks = 8192 ; bfree = 8190
Listing dir /lfs1 ...
/lfs1/boot_count read count:0 (bytes: 0)
/lfs1/boot_count write new boot count 1: [wr:1]
I: Test file: /lfs1/pattern.bin not found, create one!
------ FILE: /lfs1/pattern.bin ------
01 55 55 55 55 55 55 55 02 55 55 55 55 55 55 55
This should help as a base to investigate the issue you're facing, at least on STM32H7. I'll need some time to explore the status on STM32U5 (which seems to be a different issue, from the log you report).
Thanks for investigating! Your log indicates that you're using flash though, not a MicroSD: Area 0 at 0x0 on qspi-nor-flash-1@90000000 for 67108864 bytes
. You need to do something like this to use the SD card: west build -b nucleo_h743zi samples/subsys/fs/littlefs -- -DCONF_FILE=prj_blk.conf
.
However I was able to make this example as well as fs_sample
work on both my boards (though the H743ZI needs the clock for sdmmc1 set to HSI48 still).
I'll close this for now and reopen if I'm able to write some code to cleanly reproduce the problem.
I narrowed down the problem to CONFIG_PM=y
. When this is present, SDMMC is not functional.
I have a repro branch here where I've modified samples/fs/fs_sample
to reproduce the issue.
Output:
*** Booting Zephyr OS build v3.7.0-1626-gdcec6d3cfb8f ***
[00:00:00.015,000] <inf> main: Block count 123596800
Sector size 512
Memory Size(MB) 60350
[00:00:02.024,000] <err> stm32_sdmmc: sd read error 32
[00:00:02.030,000] <err> fs: fs mount error (-5)
Error mounting disk.
[00:00:02.038,000] <err> fs: fs not mounted (mp == 0x20000008)
Finished.
Your log indicates that you're using flash though, not a MicroSD:
Oops, my bad. I've forgot there were 2 options to make it work.
I narrowed down the problem to CONFIG_PM=y. When this is present, SDMMC is not functional.
Good, let's investigate that. However, I'll move the issue to Enhancements
as nothing has been done for PM support on this driver.
Do I understand correctly that getting this to work with PM would mostly consist of adding device_busy_set and device_busy_clear calls to the relevant places in the stm32 sdmmc driver? Or is there likely to be more to it than that?
If it's relatively straightforward, I can take a stab at it.
pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
and pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES);
to disable/re-enable the stop modes when I need the SDMMC peripheral seems to be enough to get things working reliably for my application, in case anyone runs into this and wants a quick fix.
Describe the bug
Attempts to use
stm32-sdmmc
in various ways have failed.To Reproduce
sdmmc1
node in Device Tree like so:For NUCLEO-H743ZI2, it's also necessary to update the clock, as by default the clock is not 48MHz but 480MHz, which causes an error at runtime:
Attempt to mount then read or write the SD card. A minimal snippet from my larger program that does this:
Expected behavior Mount, reads and writes should all work without any problems.
Impact Showstopper for me for the STM32 series, works fine on other MCUs/boards (e.g. ATSAMD21 via SPI, LPC55S69 via SDMMC).
Logs and console output
STM32U5:
STM32H7:
Environment (please complete the following information):
Additional context I've tested a few different cards and they have the same problems.
I've tried different clocks and bus widths.
I've tried to disable the internal pullups since there are already pullups on the breakout board. I added the following to my DTS overlay:
I've looked at the signals with my oscilloscope and with the STM32U5, I see things happening on the CLK and CMD lines but nothing happening on the data lines. I haven't investigated the STM32H7 as deeply because it's not the MCU I'm interested in, just one I happened to have on hand.
I haven't tried eMMC modules (none on hand).
I'd love to test with a board that has a MicroSD slot already available but ST doesn't have any such STM32U5 boards.