ESP crashes when the sd card removed in the middle of write operation

venkatesha kj
Posts: 7
Joined: Thu Mar 03, 2022 6:27 am

ESP crashes when the sd card removed in the middle of write operation

Postby venkatesha kj » Fri Apr 15, 2022 2:52 pm

i am using sdmmc library for sdcard write,but the problem is when i removed the card in the middle system crashes and its keep on resettting till inserting the card.

Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandle d.

Core 0 register dump:
PC : 0x400e0793 PS : 0x00060630 A0 : 0x800e0814 A1 : 0x3f fb7040
A2 : 0x3ffb723c A3 : 0x00000800 A4 : 0x00000001 A5 : 0x00 000800
A6 : 0x00000000 A7 : 0x00000004 A8 : 0x800e0793 A9 : 0x3f fb7020
A10 : 0x00000000 A11 : 0x3ffb7054 A12 : 0x00000209 A13 : 0x00 0001b6
A14 : 0x3ffb723c A15 : 0x00000000 SAR : 0x0000001b EXCCAUSE: 0x00 00001c
EXCVADDR: 0x00000064 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xff fffffb

Backtrace:0x400e0790:0x3ffb7040 0x400e0811:0x3ffb7080 0x400d153d:0x3ffb70a0 0x40 0ef2b0:0x3ffb7130 0x400888d9:0x3ffb7150


ELF file SHA256: ac317bf8fcf3e0b4

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7580
ho 0 tail 12 room 4
load:0x40078000,len:14912
load:0x40080400,len:3688
entry 0x4008067c
I (29) boot: ESP-IDF 4.3.2 2nd stage bootloader
I (29) boot: compile time 11:44:49
I (29) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed : 40MHz
I (43) boot.esp32: SPI Mode : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (52) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (61) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 1, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0b848h ( 47176) map
I (128) esp_image: segment 1: paddr=0001b870 vaddr=3ffb0000 size=03aa8h ( 15016) load
I (134) esp_image: segment 2: paddr=0001f320 vaddr=40080000 size=00cf8h ( 3320) load
I (136) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=1f478h (128120) map
I (189) esp_image: segment 4: paddr=0003f4a0 vaddr=40080cf8 size=0bd44h ( 48452) load
I (209) esp_image: segment 5: paddr=0004b1ec vaddr=50000000 size=00010h ( 16) load
I (216) boot: Loaded app from partition at offset 0x10000
I (216) boot: Disabling RNG early entropy source...
I (229) cpu_start: Pro cpu up.
I (229) cpu_start: Starting app cpu, entry point is 0x40081b9c
I (215) cpu_start: App cpu up.
I (243) cpu_start: Pro cpu start user code
I (243) cpu_start: cpu freq: 160000000
I (244) cpu_start: Application information:
I (248) cpu_start: Project name: spi_esp32_wroom
I (254) cpu_start: App version: 1
I (258) cpu_start: Compile time: Mar 28 2022 11:43:00
I (264) cpu_start: ELF file SHA256: ac317bf8fcf3e0b4...
I (270) cpu_start: ESP-IDF: 4.3.2
I (275) heap_init: Initializing. RAM available for dynamic allocation:
I (282) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (288) heap_init: At 3FFB4460 len 0002BBA0 (174 KiB): DRAM
I (294) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (301) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (307) heap_init: At 4008CA3C len 000135C4 (77 KiB): IRAM
I (315) spi_flash: detected chip: generic
I (318) spi_flash: flash io: dio
I (323) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (333) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (343) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (353) ch: Initializing SD card
I (353) ch: Using SDMMC peripheral
I (363) ch: Mounting filesystem
I (363) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
E (393) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (393) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
E (393) ch: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card l ines have pull-up resistors in place.

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

Re: ESP crashes when the sd card removed in the middle of write operation

Postby ESP_Sprite » Sat Apr 16, 2022 1:10 am

Can you decode that backtrace? If you're using esp-idf, easiest way is to use the built-in serial monitor ('idf.py monitor') as it'll decode it for you.

sfoulk526
Posts: 2
Joined: Sat Apr 16, 2022 7:22 am

Re: ESP crashes when the sd card removed in the middle of write operation

Postby sfoulk526 » Sat Apr 16, 2022 7:41 am

Well, here's a silly question; why would you expect it to NOT fail if you remove the card in the middle of a write operation? That's called (at least in my day) a major hardware failure. You need to wait for it to finish, close any open file, and perhaps signal somehow that the card is ready to be pulled out of the device (LED, serial monitor, whatever). Maybe you're thinking of a hot-swappable disk array, which SD cards are most certainly NOT useful to implement.

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

Re: ESP crashes when the sd card removed in the middle of write operation

Postby ESP_Sprite » Sat Apr 16, 2022 10:19 am

FWIW, even if SD-cards aren't hot-swappable (and they electrically certainly are), a well-written program shouldn't crash and keep crashing if something user-controllable like removing it happens. The filesystem may get somewhat broken if it doesn't have features to rollback partially written transactions, however even a broken filesystem should not lead to a hard crash.

Who is online

Users browsing this forum: No registered users and 176 guests