How do I add sdcard multi partition support on esp32 or esp32 s3?

dudu2022
Posts: 3
Joined: Mon Oct 09, 2023 10:45 am

How do I add sdcard multi partition support on esp32 or esp32 s3?

Postby dudu2022 » Mon Oct 09, 2023 10:49 am

Is there any chance to add sdcard multi partition support on ESP32 or esp32 s3?

I noticed that stm32 supports sdcard multi partition
https://github.com/micropython/micropython/issues/2730

Any suggestions will be thanks

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: How do I add sdcard multi partition support on esp32 or esp32 s3?

Postby ESP_Sprite » Mon Oct 09, 2023 2:52 pm

Do you mean under ESP-IDF, or do you mean under MicroPython? (Asking as you post in the ESP-IDF forum but your STM32 link refers to MicroPython.)

dudu2022
Posts: 3
Joined: Mon Oct 09, 2023 10:45 am

Re: How do I add sdcard multi partition support on esp32 or esp32 s3?

Postby dudu2022 » Tue Oct 10, 2023 1:27 am

ESP_Sprite wrote:
Mon Oct 09, 2023 2:52 pm
Do you mean under ESP-IDF, or do you mean under MicroPython? (Asking as you post in the ESP-IDF forum but your STM32 link refers to MicroPython.)
I mean esp-idf.
Is there any example about sdcard multi partition in esp-idf.
If yes, I will add to micropython by myself. Thanks

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: How do I add sdcard multi partition support on esp32 or esp32 s3?

Postby ESP_Sprite » Tue Oct 10, 2023 4:40 am

It should. If you look at the documentation, it tells you to call f_mount to mount the fatfs filesystem. That call has an argument for the logical drive, which I think maps to the partition.

dudu2022
Posts: 3
Joined: Mon Oct 09, 2023 10:45 am

Re: How do I add sdcard multi partition support on esp32 or esp32 s3?

Postby dudu2022 » Tue Oct 10, 2023 9:45 am

ESP_Sprite wrote:
Tue Oct 10, 2023 4:40 am
It should. If you look at the documentation, it tells you to call f_mount to mount the fatfs filesystem. That call has an argument for the logical drive, which I think maps to the partition.
It seems that it is impossible to mount multi partitions using APIs such as esp_vfs_fat_sdmmc_mount etc.Do we have to modify it ourselves?

Is there any available example for reference, thanks

I tried to mount one more time in the esp_vfs_fat_sdmmc_mount function, and set the mount point to "sdcard2", but the system reported an error when mounting the file system.
This is the code I added after v4.4/components/fatfs/vfs/vfs_fat_sdmmc.c#L253C6-L253C6 https://github.com/espressif/esp-idf/bl ... 3C6-L253C6

Code: Select all

    err = mount_prepare_mem("/sdcard2", &pdrv, &dup_path, &card);
    if (err != ESP_OK) {
        ESP_LOGE(TAG, "mount_prepare failed");
        return err;
    }
    err = mount_to_vfs_fat(mount_config, card, pdrv, dup_path);
    CHECK_EXECUTE_RESULT(err, "mount_to_vfs failed");
    if (out_card != NULL) {
        *out_card = card;
    }
    if (s_card == NULL) {
        //store the ctx locally to be back-compatible
        s_card = card;
        s_pdrv = pdrv;
        s_base_path = dup_path;
    } else {
        free(dup_path);
    }
这个是报错信息:

Code: Select all

D (6631) sdmmc_common: sdmmc_init_host_frequency: using 20000 kHz bus frequency
D (6641) sdmmc_periph: slot=1 host_div=8 card_div=0 freq=20000kHz
D (6641) vfs_fat_sdmmc: using pdrv=0
D (6651) vfs_fat_sdmmc: using pdrv=1
Guru Meditation Error: Core  0 panic'ed (IllegalInstruction). Exception was unhandled.

Core  0 register dump:
PC      : 0x5482471b  PS      : 0x00060130  A0      : 0x820136da  A1      : 0x3fcf3bc0  
A2      : 0x3fcea354  A3      : 0x3fcf3bf0  A4      : 0x00000001  A5      : 0x00060523
A6      : 0x3fcf3dd0  A7      : 0x3fcea3e0  A8      : 0x820130d6  A9      : 0x3fcf3d20  
A10     : 0x3fce9724  A11     : 0x3fcf3bf0  A12     : 0x00000001  A13     : 0x3fc9bef4
A14     : 0x3fc9d6d4  A15     : 0x3fc94aa8  SAR     : 0x0000001c  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0x00000000


Backtrace: 0x54824718:0x3fcf3bc0 |<-CORRUPTED




ELF file SHA256: a0fa01317fb84717

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x28 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403756e8
0x403756e8: esp_restart_noos at /mnt/g/code_2023/vincibot/submodule/esp-idf/components/esp_system/port/soc/esp32s3/system_internal.c:158 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x1664
load:0x403c9700,len:0xbb8
load:0x403cc700,len:0x2f74
entry 0x403c9954
I (29) boot: ESP-IDF v4.4.2-190-g33b464e9db-dirty 2nd stage bootloader
I (29) boot: compile time 16:03:04
I (29) boot: chip revision: 0
I (33) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode       : DIO

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: How do I add sdcard multi partition support on esp32 or esp32 s3?

Postby ESP_Sprite » Wed Oct 11, 2023 3:59 am

dudu2022 wrote:
Tue Oct 10, 2023 9:45 am
It seems that it is impossible to mount multi partitions using APIs such as esp_vfs_fat_sdmmc_mount etc.Do we have to modify it ourselves?
As the documentation for that call says: it's a convenience function that rolls up a whole bunch of otherwise available steps into one. If you can't use it because it doesn't match your use case, you need to implement the things it does manually. (Specifically note that this means you should not need to mess with the ESP-IDF source code.)

Who is online

Users browsing this forum: No registered users and 95 guests