Combined deep sleep and sdmmc causes write to fail (solved)

druffer
Posts: 2
Joined: Thu Feb 28, 2019 8:21 pm

Combined deep sleep and sdmmc causes write to fail (solved)

Postby druffer » Fri Mar 01, 2019 10:29 pm

Both the deep sleep and sdmmc examples work on their own, but when I combine them, the sdmmc write tests fail after coming out of the deep sleep. The logs below show everything working properly on reset, but when I push the button connected to the deep sleep wakeup, I get "sdmmc_write_blocks failed"

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2019.03.01 11:29:53 =~=~=~=~=~=~=~=~=~=~=~=
ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x1b (SPI_FAST_FLASH_BOOT)
ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x1b (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:0x3fff0018,len:4
load:0x3fff001c,len:6264
load:0x40078000,len:11164
load:0x40080400,len:6672
entry 0x40080764
[0;32mI (29) boot: ESP-IDF v3.3-beta1-328-gabea9e4-dirty 2nd stage bootloader[0m
[0;32mI (29) boot: compile time 10:16:03[0m
[0;32mI (39) boot: Enabling RNG early entropy source...[0m
[0;32mI (39) boot: SPI Speed : 40MHz[0m
[0;32mI (40) boot: SPI Mode : DIO[0m
[0;32mI (44) boot: SPI Flash Size : 8MB[0m
[0;32mI (48) boot: Partition Table:[0m
[0;32mI (51) boot: ## Label Usage Type ST Offset Length[0m
[0;32mI (59) boot: 0 nvs WiFi data 01 02 00009000 00006000[0m
[0;32mI (66) boot: 1 phy_init RF data 01 01 0000f000 00001000[0m
[0;32mI (74) boot: 2 factory factory app 00 00 00010000 00100000[0m
[0;32mI (81) boot: End of partition table[0m
[0;32mI (85) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0f1bc ( 61884) map[0m
[0;32mI (116) esp_image: segment 1: paddr=0x0001f1e4 vaddr=0x3ffb0000 size=0x00e2c ( 3628) load[0m
[0;32mI (118) esp_image: segment 2: paddr=0x00020018 vaddr=0x400d0018 size=0x1cfc4 (118724) map[0m
[0;32mI (164) esp_image: segment 3: paddr=0x0003cfe4 vaddr=0x3ffb0e2c size=0x010c4 ( 4292) load[0m
[0;32mI (166) esp_image: segment 4: paddr=0x0003e0b0 vaddr=0x40080000 size=0x00400 ( 1024) load[0m
[0;32mI (171) esp_image: segment 5: paddr=0x0003e4b8 vaddr=0x40080400 size=0x092dc ( 37596) load[0m
[0;32mI (195) esp_image: segment 6: paddr=0x0004779c vaddr=0x400c0000 size=0x00064 ( 100) load[0m
[0;32mI (201) boot: Loaded app from partition at offset 0x10000[0m
[0;32mI (202) boot: Disabling RNG early entropy source...[0m
[0;32mI (205) cpu_start: Pro cpu up.[0m
[0;32mI (208) cpu_start: Application information:[0m
[0;32mI (213) cpu_start: Project name: sd_card[0m
[0;32mI (218) cpu_start: App version: 1[0m
[0;32mI (223) cpu_start: Compile time: 10:15:18[0m
[0;32mI (228) cpu_start: Compile date: Feb 27 2019[0m
[0;32mI (233) cpu_start: ESP-IDF: v3.3-beta1-430-g7cdd19f-dirty[0m
[0;32mI (240) cpu_start: Starting app cpu, entry point is 0x40080f34[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (250) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (257) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (263) heap_init: At 3FFB3028 len 0002CFD8 (179 KiB): DRAM[0m
[0;32mI (269) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (276) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (282) heap_init: At 400896DC len 00016924 (90 KiB): IRAM[0m
[0;32mI (288) cpu_start: Pro cpu start user code[0m
[0;32mI (306) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
Not a deep sleep reset
[0;32mI (309) example: Initializing SD card[0m
[0;32mI (309) example: Using SDMMC peripheral[0m
[0;32mI (319) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
Name: ACLCF
Type: SDHC/SDXC
Speed: 20 MHz
Size: 121942MB
[0;32mI (389) example: Opening file[0m
[0;32mI (409) example: File written[0m
[0;32mI (419) example: Renaming file[0m
[0;32mI (429) example: Reading file[0m
[0;32mI (429) example: Read from file: 'Hello ACLCF!'[0m
[0;32mI (429) example: Card unmounted[0m
Enabling EXT1 wakeup on pin GPIO34
Entering deep sleep
ets Jun 8 2016 00:22:57

rst:0x5 (DEEPSLEEP_RESET),boot:0x1b (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:0x3fff0018,len:4
load:0x3fff001c,len:6264
load:0x40078000,len:11164
load:0x40080400,len:6672
entry 0x40080764
[0;32mI (29) boot: ESP-IDF v3.3-beta1-328-gabea9e4-dirty 2nd stage bootloader[0m
[0;32mI (29) boot: compile time 10:16:03[0m
[0;32mI (40) boot: Enabling RNG early entropy source...[0m
[0;32mI (40) boot: SPI Speed : 40MHz[0m
[0;32mI (40) boot: SPI Mode : DIO[0m
[0;32mI (44) boot: SPI Flash Size : 8MB[0m
[0;32mI (48) boot: Partition Table:[0m
[0;32mI (52) boot: ## Label Usage Type ST Offset Length[0m
[0;32mI (59) boot: 0 nvs WiFi data 01 02 00009000 00006000[0m
[0;32mI (66) boot: 1 phy_init RF data 01 01 0000f000 00001000[0m
[0;32mI (74) boot: 2 factory factory app 00 00 00010000 00100000[0m
[0;32mI (81) boot: End of partition table[0m
[0;32mI (86) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0f1bc ( 61884) map[0m
[0;32mI (116) esp_image: segment 1: paddr=0x0001f1e4 vaddr=0x3ffb0000 size=0x00e2c ( 3628) load[0m
[0;32mI (118) esp_image: segment 2: paddr=0x00020018 vaddr=0x400d0018 size=0x1cfc4 (118724) map[0m
[0;32mI (164) esp_image: segment 3: paddr=0x0003cfe4 vaddr=0x3ffb0e2c size=0x010c4 ( 4292) load[0m
[0;32mI (166) esp_image: segment 4: paddr=0x0003e0b0 vaddr=0x40080000 size=0x00400 ( 1024) load[0m
[0;32mI (172) esp_image: segment 5: paddr=0x0003e4b8 vaddr=0x40080400 size=0x092dc ( 37596) load[0m
[0;32mI (196) esp_image: segment 6: paddr=0x0004779c vaddr=0x400c0000 size=0x00064 ( 100) [0m
[0;32mI (202) boot: Loaded app from partition at offset 0x10000[0m
[0;32mI (202) boot: Disabling RNG early entropy source...[0m
[0;32mI (205) cpu_start: Pro cpu up.[0m
[0;32mI (208) cpu_start: Application information:[0m
[0;32mI (213) cpu_start: Project name: sd_card[0m
[0;32mI (218) cpu_start: App version: 1[0m
[0;32mI (223) cpu_start: Compile time: 10:15:18[0m
[0;32mI (228) cpu_start: Compile date: Feb 27 2019[0m
[0;32mI (233) cpu_start: ESP-IDF: v3.3-beta1-430-g7cdd19f-dirty[0m
[0;32mI (240) cpu_start: Starting app cpu, entry point is 0x40080f34[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (250) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (257) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (263) heap_init: At 3FFB3028 len 0002CFD8 (179 KiB): DRAM[0m
[0;32mI (269) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (276) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (282) heap_init: At 400896DC len 00016924 (90 KiB): IRAM[0m
[0;32mI (288) cpu_start: Pro cpu start user code[0m
[0;32mI (307) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
Wake up from GPIO 34
[0;32mI (308) example: Initializing SD card[0m
[0;32mI (308) example: Using SDMMC peripheral[0m
[0;32mI (318) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
Name: ACLCF
Type: SDHC/SDXC
Speed: 20 MHz
Size: 121942MB
[0;32mI (388) example: Opening file[0m
[0;31mE (388) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109[0m
[0;31mE (388) diskio_sdmmc: sdmmc_write_blocks failed (265)[0m
[0;31mE (398) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109[0m
[0;31mE (398) diskio_sdmmc: sdmmc_write_blocks failed (265)[0m
[0;32mI (408) example: File written[0m
[0;31mE (408) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109[0m
[0;31mE (418) diskio_sdmmc: sdmmc_write_blocks failed (265)[0m
[0;32mI (428) example: Renaming file[0m
[0;31mE (428) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109[0m
[0;31mE (438) diskio_sdmmc: sdmmc_write_blocks failed (265)[0m
[0;31mE (438) example: Rename failed[0m

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Combined deep sleep and sdmmc causes write to fail

Postby ESP_igrr » Mon Mar 04, 2019 1:59 pm

This is probably caused by the 'rtc_gpio_isolate(12);` call in the deep sleep example: https://github.com/espressif/esp-idf/bl ... ain.c#L177

Since the SD card uses GPIO12, you need to call 'rtc_gpio_hold_dis(12);' once you exit the deep sleep, to re-enable this GPIO.

druffer
Posts: 2
Joined: Thu Feb 28, 2019 8:21 pm

Re: Combined deep sleep and sdmmc causes write to fail

Postby druffer » Tue Mar 05, 2019 7:22 pm

That fixed it, thanks :D

Who is online

Users browsing this forum: No registered users and 25 guests