esp-adf icon indicating copy to clipboard operation
esp-adf copied to clipboard

hardcoded sdcard spi pins (AUD-3833)

Open tacrazymage opened this issue 2 years ago • 8 comments

The problem

the SPI pin numbers hardcoded in "./components/esp_peripherals/lib/sdcard/sdcard.c" as it shown below.

#define PIN_NUM_MISO 2 #define PIN_NUM_MOSI 15 #define PIN_NUM_CLK 14 #define PIN_NUM_CS 13

should we make it configurable using Kconfig file?

tacrazymage avatar May 22 '22 14:05 tacrazymage

also the sdcard_mount function not working when the mode==SD_MODE_SPI (runtime crash)

tacrazymage avatar May 23 '22 10:05 tacrazymage

Hi @tacrazymage

The reason is that these sdcard pins are fixed on the official development board.

If you want to support spi mode, you need to modify the initialization function audio_board_sdcard_init in your board hal.

HengYongChao avatar May 24 '22 02:05 HengYongChao

Also, in sdcard_mount function , spi mode code is not working.

spi port is not initialized,and should use esp_vfs_fat_sdspi_mount but not esp_vfs_fat_sdmmc_mount to mount.

danny2jenny avatar May 27 '22 04:05 danny2jenny

you need to modify the initialization function audio_board_sdcard_init in your board hal.

as far as I know (and now I test it again) #define keyword is preprocessor and preprocessors instructs the compiler to do required pre-processing before the actual compilation (and also before linking)

so there is no way defining pin numbers in board hal overwrites ones defined here: ./components/esp_peripherals/lib/sdcard/sdcard.c

tacrazymage avatar May 29 '22 08:05 tacrazymage

@HengYongChao if nobody assigned to this, I can make a PR (fixing #define and esp_vfs_fat_sdmmc_mount) just let me know

tacrazymage avatar May 29 '22 08:05 tacrazymage

@danny2jenny did you managed to play mp3 from sdcard in spi mode? I correct the sdcard_mount function code but when I run "pipeline play sdcard music" example, it panics due to dead lock ocured in spi master

tacrazymage avatar May 30 '22 13:05 tacrazymage

@HengYongChao if nobody assigned to this, I can make a PR (fixing #define and esp_vfs_fat_sdmmc_mount) just let me know

Yes please, if you can give the PR.

HengYongChao avatar Jun 08 '22 03:06 HengYongChao

This question/feature request keeps popping up, and should be fixed. The module code should not be board related, and as such, is a bug. Why was this PR closed?

and-elf avatar Sep 17 '22 07:09 and-elf