Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD card driver crash due to lack of get_dma_info function pointer after idf v5.3 #507

Closed
fangpenlin opened this issue Jan 8, 2025 · 0 comments · Fixed by #508
Closed
Labels
bug Something isn't working

Comments

@fangpenlin
Copy link
Contributor

Bug description

Run a sample SD MMC card example app like this one with idf SDK v5.3

https://github.com/esp-rs/esp-idf-svc/blob/6453bedd5967ebc3bcb7d240492a0d5164e818c2/examples/sd_mmc.rs

The SD card driver crashed due to lack of get_dma_info function pointer. Here's the traceback:

Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x00000000  PS      : 0x00060f30  A0      : 0x8204406d  A1      : 0x3fc98a20
A2      : 0x3fc9a89c  A3      : 0x3fc9a92c  A4      : 0x0000012a  A5      : 0x3fc98a28  
A6      : 0x3fc98a54  A7      : 0x00000000  A8      : 0x82045b74  A9      : 0x3fc98a10
A10     : 0x00000001  A11     : 0x3fc98a54  A12     : 0x00000000  A13     : 0x3fc98aa0
A14     : 0x4e313238  A15     : 0x00000009  SAR     : 0x00000004  EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0xffffffff  


Backtrace: 0xfffffffd:0x3fc98a20 0x4204406a:0x3fc98a90 0x420435c6:0x3fc98ac0 0x420094d3:0x3fc98ae0 0x42005670:0x3fc98c10 0x4205f947:0x3fc99030 0x420051bc:0x3fc99050 0x42021404:0x3fc99070 0x4202139c:0x3fc990a0 0x42029d20:0x3fc990d0 0x420051ac:0x3fc99100 0x42005cc7:0x3fc99130 0x42009873:0x3fc99150 0x42061357:0x3fc99170
0x4204406a - sdmmc_init_sd_scr
    at C:\ws\e5\target\xtensa-esp32s3-espidf\debug\build\esp-idf-sys-b97786dd2e36b573\out\build\C:/ws/e5/.embuild/espressif/esp-idf/v5.3.2/components/sdmmc\sdmmc_sd.c:71
0x420435c6 - sdmmc_card_init
    at C:\ws\e5\target\xtensa-esp32s3-espidf\debug\build\esp-idf-sys-b97786dd2e36b573\out\build\C:/ws/e5/.embuild/espressif/esp-idf/v5.3.2/components/sdmmc\sdmmc_init.c:112
0x420094d3 - esp_idf_hal::sd::sdcard::SdCardDriver<esp_idf_hal::sd::mmc::SdMmcHostDriver>::new_mmc
    at C:\Users\_\.cargo\registry\src\index.crates.io-6f17d22bba15001f\esp-idf-hal-0.45.0\src\sd.rs:426
0x42005670 - esp_idf_svc_ws_client_cross_thread_bug::main
    at C:\ws\e5\src\main.rs:24
0x4205f947 - core::ops::function::FnOnce::call_once
    at C:\Users\_\.rustup\toolchains\esp\lib\rustlib\src\rust\library\core\src\ops\function.rs:250
0x420051bc - std::rt::lang_start::{{closure}}
    at C:\Users\-\.rustup\toolchains\esp\lib\rustlib\src\rust\library\std\src\rt.rs:164
0x42021404 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
    at C:\Users\_\.rustup\toolchains\esp\lib\rustlib\src\rust\library\core\src\ops\function.rs:284
0x4202139c - std::panic::catch_unwind
    at C:\Users\_\.rustup\toolchains\esp\lib\rustlib\src\rust\library\std\src\panic.rs:345
0x42029d20 - std::panic::catch_unwind
    at C:\Users\_\.rustup\toolchains\esp\lib\rustlib\src\rust\library\std\src\panic.rs:345
0x420051ac - std::rt::lang_start
    at C:\Users\_\.rustup\toolchains\esp\lib\rustlib\src\rust\library\std\src\rt.rs:163
0x42005cc7 - main
    at ??:??
0x42009873 - app_main
    at C:\Users\_\.cargo\registry\src\index.crates.io-6f17d22bba15001f\esp-idf-sys-0.36.0\src\start.rs:46
0x42061357 - main_task
    at C:\ws\e5\target\xtensa-esp32s3-espidf\debug\build\esp-idf-sys-b97786dd2e36b573\out\build\C:/ws/e5/.embuild/espressif/esp-idf/v5.3.2/components/freertos\app_startup.c:208

gdb where:

(gdb) where
#0  0x40374400 in _init ()
#1  0x42045bd0 in sdmmc_send_cmd_send_scr (card=0x3fc9a89c, out_scr=0x3fc9a92c) at C:/ws/e5/.embuild/espressif/esp-idf/v5.3.2/components/sdmmc/sdmmc_cmd.c:332
#2  0x420440c9 in sdmmc_init_sd_scr (card=0x3fc9a89c) at C:/ws/e5/.embuild/espressif/esp-idf/v5.3.2/components/sdmmc/sdmmc_sd.c:71
#3  0x42043625 in sdmmc_card_init (config=<optimized out>, card=0x3fc9a89c) at C:/ws/e5/.embuild/espressif/esp-idf/v5.3.2/components/sdmmc/sdmmc_init.c:112
#4  0x42009532 in esp_idf_hal::sd::sdcard::SdCardDriver<esp_idf_hal::sd::mmc::SdMmcHostDriver>::new_mmc (host=..., configuration=0x3fc98ca8) at src/sd.rs:426
#5  0x4200567f in esp_idf_svc_ws_client_cross_thread_bug::main () at src/main.rs:24

print out the get_dma_info pointer, it's 0x0:

(gdb) p card->host.get_dma_info
$4 = (esp_err_t (*)(int, esp_dma_mem_info_t *)) 0x0
  • Would you like to work on a fix? [y/n] y

I am working on a PR in a minute

To Reproduce

Clone my reproduce PR and build

https://github.com/LaunchPlatform/esp-idf-hal-sd-get-info-dma-bug

You may need to adjust gpiopin based on your ESP32 environment

Expected behavior

SD card sample code should works

Environment

  • Crate (esp-idf-hal) version: v5.3.2
  • Target device (MCU): esp32s3
  • OS: Windows11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant