Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

TG0WDT_SYS_RESET immediately after waking from deep sleep

I am struggling with getting deep sleep to work.

With a Huzzah32 dev board, the device can be put to sleep and configured to wake from GPIO, but when it does wake from GPIO it immediately gets reset by WDT. From what I have read on other forums it has to do with the flash memory not turning on fast enough (hence the "flash read err, 1000" on the 5th line of the trace below) and the solution is to increase CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=0 in SDKCONFIG to 500 of 1000 to give the flash memory enough time to start-up.

However, adding the following line to my mos.yml file has no effect on SDKCONFIG:
build_vars:
ESP_IDF_SDKCONFIG_OPTS: "${build_vars.ESP_IDF_SDKCONFIG_OPTS} CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=1000"

Any ideas on how to fix this? Why are "build_vars" being ignored when building?

Comments

  • [Oct 6 08:19:20.989] ets Jun 8 2016 00:22:57
    [Oct 6 08:19:20.989]
    [Oct 6 08:19:20.989] rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    [Oct 6 08:19:20.989] Wake count 1
    [Oct 6 08:19:20.989] flash read err, 1000
    [Oct 6 08:19:20.989] ets_main.c 371
    [Oct 6 08:19:21.655] ets Jun 8 2016 00:22:57
    [Oct 6 08:19:21.655]
    [Oct 6 08:19:21.655] rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    [Oct 6 08:19:21.655] configsip: 0, SPIWP:0xee
    [Oct 6 08:19:21.655] clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    [Oct 6 08:19:21.655] mode:DIO, clock div:2
    [Oct 6 08:19:21.656] load:0x3fff0010,len:4
    [Oct 6 08:19:21.656] load:0x3fff0014,len:5084
    [Oct 6 08:19:21.656] load:0x40078000,len:0
    [Oct 6 08:19:21.656] load:0x40078000,len:13040
    [Oct 6 08:19:21.656] entry 0x40078b44
    [Oct 6 08:19:21.746] [0;33mW (45) boot: PRO CPU has been reset by WDT.[0m
    [Oct 6 08:19:21.746] [0;33mW (46) boot: WDT reset info: PRO CPU PC=0x9926ca1b[0m
    [Oct 6 08:19:21.746] [0;33mW (46) boot: WDT reset info: APP CPU PC=0x2a39c7dc[0m
    [Oct 6 08:19:21.747] [0;32mI (63) boot: ESP-IDF v1.0-2193-g953c4b6 2nd stage bootloader[0m
    [Oct 6 08:19:21.747] [0;32mI (83) boot: compile time 05:38:17[0m
    [Oct 6 08:19:21.747] [0;32mI (95) boot: Enabling RNG early entropy source...[0m
    [Oct 6 08:19:21.747] [0;32mI (112) boot: SPI Speed : 40MHz[0m
    [Oct 6 08:19:21.747] [0;32mI (125) boot: SPI Mode : DIO[0m
    [Oct 6 08:19:21.747] [0;32mI (137) boot: SPI Flash Size : 4MB[0m
    [Oct 6 08:19:21.747] [0;32mI (150) boot: Partition Table:[0m
    [Oct 6 08:19:21.747] [0;32mI (161) boot: ## Label Usage Type ST Offset Length Flags[0m
    [Oct 6 08:19:21.747] [0;32mI (186) boot: 0 nvs WiFi data 01 02 00009000 00004000 00000000[0m
    [Oct 6 08:19:21.747] [0;32mI (212) boot: 1 otadata OTA data 01 00 0000d000 00002000 00000000[0m
    [Oct 6 08:19:21.747] [0;32mI (238) boot: 2 app_0 OTA app 00 10 00010000 00180000 00000000[0m
    [Oct 6 08:19:21.747] [0;32mI (263) boot: 3 fs_0 SPIFFS 01 82 00190000 00040000 00000000[0m
    [Oct 6 08:19:21.797] [0;32mI (289) boot: 4 app_1 OTA app 00 11 001d0000 00180000 00000000[0m
    [Oct 6 08:19:21.797] [0;32mI (315) boot: 5 fs_1 SPIFFS 01 82 00350000 00040000 00000000[0m
    [Oct 6 08:19:21.797] [0;32mI (340) boot: End of partition table[0m
    [Oct 6 08:19:21.797] [0;32mI (353) boot: OTA data 0: seq 0x00000001, st 0x10, CRC 0x157a2b85, valid? 1[0m
    [Oct 6 08:19:21.797] [0;32mI (377) boot: OTA data 1: seq 0x00000000, st 0x00, CRC 0x00000000, valid? 0[0m
    [Oct 6 08:19:21.797] [0;32mI (400) boot: Disabling RNG early entropy source...[0m
    [Oct 6 08:19:21.797] [0;32mI (417) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1efe0 (126944) map[0m
    [Oct 6 08:19:21.848] [0;32mI (582) esp_image: segment 1: paddr=0x0002f008 vaddr=0x3ffc0000 size=0x01008 ( 4104) load[0m
    [Oct 6 08:19:21.848] [0;32mI (587) esp_image: segment 2: paddr=0x00030018 vaddr=0x400d0018 size=0x8b41c (570396) map[0m
    [Oct 6 08:19:22.063] [0;32mI (1214) esp_image: segment 3: paddr=0x000bb43c vaddr=0x3ffc1008 size=0x019ec ( 6636) load[0m
    [Oct 6 08:19:22.063] [0;32mI (1223) esp_image: segment 4: paddr=0x000bce30 vaddr=0x40080000 size=0x00400 ( 1024) load[0m
    [Oct 6 08:19:22.063] [0;32mI (1237) esp_image: segment 5: paddr=0x000bd238 vaddr=0x40080400 size=0x10100 ( 65792) load[0m
    [Oct 6 08:19:22.161] [0;32mI (1345) esp_image: segment 6: paddr=0x000cd340 vaddr=0x400c0000 size=0x00060 ( 96) load[0m
    [Oct 6 08:19:22.161] [0;32mI (1346) esp_image: segment 7: paddr=0x000cd3a8 vaddr=0x50000000 size=0x00014 ( 20) load[0m
    [Oct 6 08:19:22.161] [0;32mI (1396) cpu_start: Pro cpu up.[0m
    [Oct 6 08:19:22.161] [0;32mI (1396) cpu_start: Single core mode[0m
    [Oct 6 08:19:22.161] [0;32mI (1398) heap_init: Initializing. RAM available for dynamic allocation:[0m
    [Oct 6 08:19:22.161] [0;32mI (1413) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1432) heap_init: At 3FFB3000 len 00005000 (20 KiB): DRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1451) heap_init: At 3FFBBB28 len 00002000 (8 KiB): DRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1470) heap_init: At 3FFC8280 len 00017D80 (95 KiB): DRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1490) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1509) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1529) heap_init: At 40090500 len 0000FB00 (62 KiB): IRAM[0m
    [Oct 6 08:19:22.161] [0;32mI (1549) cpu_start: Pro cpu start user code[0m
    [Oct 6 08:19:22.168] [0;32mI (1606) cpu_start: Starting scheduler on PRO CPU.[0m
    [Oct 6 08:19:22.180] mg_lwip_if_init 0x3ffb7f9c Mongoose init
    [Oct 6 08:19:22.180] esp32_mgos_init smart_button 1.0 (20171006-053822/???)
    [Oct 6 08:19:22.192] esp32_mgos_init Mongoose OS 2017100605 (20171006-053822/???)
    [Oct 6 08:19:22.192] esp32_mgos_init ESP-IDF v1.0-2193-g953c4b6
    [Oct 6 08:19:22.202] esp32_mgos_init Boot partition: app_0; flash: 4M; RAM: 255144 total, 217284 free
    [Oct 6 08:19:22.211] mgos_vfs_dev_open esp32part ({"label": "fs_0", "subtype": 130}) -> 0x3ffca7f4
    [Oct 6 08:19:22.221] mgos_vfs_mount Mount SPIFFS @ / (dev 0x3ffca7f4, opts {"encr": false}) -> 0x3ffca804
    [Oct 6 08:19:22.294] mgos_vfs_mount /: size 233681, used: 30622, free: 203059
    [Oct 6 08:19:22.353] mgos_sys_config_init MAC: 30AEA40BB528
    [Oct 6 08:19:22.358] mgos_sys_config_init WDT: 30 seconds
    [Oct 6 08:19:22.363] mgos_wifi_set_config WiFi mode: AP
    [Oct 6 08:19:22.369] esp32_wifi_set_mode WiFi mode: AP
    [Oct 6 08:19:22.376] E (3079) wifi: esp_wifi_set_mode 778 wifi is not init
    [Oct 6 08:19:22.390] I (3089) wifi: wifi firmware version: 4acbf1f
    [Oct 6 08:19:22.390] I (3089) wifi: config NVS flash: enabled
    [Oct 6 08:19:22.390] I (3099) wifi: config nano formating: disabled
    [Oct 6 08:19:22.411] [0;32mI (3099) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m
    [Oct 6 08:19:22.430] I (3129) wifi: Init dynamic tx buffer num: 32
    [Oct 6 08:19:22.430] I (3129) wifi: Init data frame dynamic rx buffer num: 64
    [Oct 6 08:19:22.430] I (3139) wifi: Init management frame dynamic rx buffer num: 64
    [Oct 6 08:19:22.438] I (3139) wifi: wifi driver task: 3ffcb804, prio:23, stack:4096
    [Oct 6 08:19:22.448] I (3149) wifi: Init static rx buffer num: 10
    [Oct 6 08:19:22.448] I (3159) wifi: Init dynamic rx buffer num: 0
    [Oct 6 08:19:22.454] I (3159) wifi: Init rx ampdu len mblock:7
    [Oct 6 08:19:22.460] I (3169) wifi: Init lldesc rx ampdu entry mblock:4
    [Oct 6 08:19:22.469] I (3169) wifi: wifi power manager task: 0x3ffd1cd0 prio: 21 stack: 2560
    [Oct 6 08:19:23.359] [0;32mI (4059) phy: phy_version: 359.0, e79c19d, Aug 31 2017, 17:06:07, 0, 0[0m
    [Oct 6 08:19:23.359] I (4059) wifi: mode : softAP (30:ae:a4:0b:b5:29)
    [Oct 6 08:19:23.374] event_handler event: 13
    [Oct 6 08:19:23.381] mgos_http_server_ini HTTP server started on [80]
    [Oct 6 08:19:23.386] mg_rpc_channel_mqtt 0x3ffd3158 /rpc/#
    [Oct 6 08:19:23.391] mg_rpc_channel_uart 0x3ffd339c UART0
    [Oct 6 08:19:23.397] mgos_app_init Turning light on
    [Oct 6 08:19:23.403] identify_wakeup_reas Wake up cause: Undefined
    [Oct 6 08:19:23.409] identify_wakeup_reas Wake count: 0
    [Oct 6 08:19:23.418] mgos_init Init done, RAM: 254476 total, 181400 free, 181300 min free
    [Oct 6 08:19:23.424] mongoose_poll New heap free LWM: 181208

  • SOLVED: According to the technical support at Espressif, this is due to a hardware bug with the Rev 0 ESP-32 modules, or more specifically, the flash memory. They don't start up fast enough and hence the "flash read err, 1000" when waking from deep sleep, which then triggers a "TG0WDT_SYS_RESET". The workaround is to introduce a delay when waking from deep sleep by setting the following:

    build_vars:
    ESP_IDF_SDKCONFIG_OPTS: "${build_vars.ESP_IDF_SDKCONFIG_OPTS} CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=500"

    WARNING: When setting this, make sure there is one, and ONLY one, blank space at the beginning of the line. It took me forever to figure this out. See other thread here: https://forum.mongoose-os.com/discussion/1543/

Sign In or Register to comment.