ESP32 Detected size & WDT

For general Flowcode discussion that does not belong in the other sections.
Post Reply
mnfisher
Valued Contributor
Posts: 938
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

ESP32 Detected size & WDT

Post by mnfisher »

I just got some ESP32-WROOM boards for a project - and after getting them up and connected I made a short 'Hello World' program.

In the output I notice:
W (312) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I couldn't see any way to change this from within Flowcode - but by editing sdkconfig in the project directory - I changed

Code: Select all

CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
to

Code: Select all

# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
Which 'fixes' this message. However if I have:

Code: Select all

uart.initialise()
print("Hello World\r\n" 

and then either nothing or

Loop
   empty or delay(1 ms)
end loop
I get WDT 'errors'
E (10333) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (10333) task_wdt: - IDLE0 (CPU 0)
E (10333) task_wdt: Tasks currently running:
E (10333) task_wdt: CPU 0: main
E (10333) task_wdt: CPU 1: IDLE1
E (10333) task_wdt: Print CPU 0 (current core) backtrace
I did set the 'Auto Clear Watchdog' in project options.

If the loop contains a print then this works AOK..

Also at the start of program run I get a fair bit of info printed :
ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_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:4
load:0x3fff0034,len:6848
ho 0 tail 12 room 4
load:0x40078000,len:13108
load:0x40080400,len:3900
entry 0x40080688
I (31) boot: ESP-IDF -128-NOTFOUND 2nd stage bootloader
I (31) boot: compile time 19:52:25
I (31) boot: chip revision: 1
I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed : 40MHz
I (46) boot.esp32: SPI Mode : DIO
I (50) boot.esp32: SPI Flash Size : 2MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label Usage Type ST Offset Length
I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (79) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (86) boot: 2 factory factory app 00 00 00010000 00100000
I (94) boot: End of partition table
I (98) boot_comm: chip revision: 1, min. application chip revision: 0
I (105) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x07ee8 ( 32488) map
I (126) esp_image: segment 1: paddr=0x00017f10 vaddr=0x3ffbdb60 size=0x02128 ( 8488) load
.....
Which I'm happy with in a development system - but is there a way to 'turn it off' in a 'release' version? --- I suspect some editing of sdkconfig is the answer - but would be very good for it to be done automagically from FC??

Martin

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: ESP32 Detected size & WDT

Post by mnfisher »

Okay - a bit of googling and here is one way to kill the WDT issues... Reset the watchdog timer.

I got the code from https://forum.arduino.cc/t/esp32-a-bett ... /596889/12

Incorporated into some FC
Flowcode1.fcfx
(10.45 KiB) Downloaded 138 times
This certainly works (no WDT errors) - but seems rather 'hammer cracks nut' coding... The auto clear wdt should be the way to go ? If not is it possible to add a WDT interrupt handler and clear the WDT there (rather than having a backtrace output)

Martin

MJU20
Posts: 238
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 75 times
Been thanked: 50 times

Re: ESP32 Detected size & WDT

Post by MJU20 »

By editing the sdkconfig file -as mentioned by Martin- to the right flashsize I currently don't have a WDT overflow.

My program is running in a loop with a 40 seconds delay and until yesterday this would work because of the WDT.

I did this in the sdkconfig file

Code: Select all

CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
Changed it into:

Code: Select all

# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
Thanks Martin!

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: ESP32 Detected size & WDT

Post by lucibel »

hi eveyone,
Minimum delay must be 10ms, no matter if the flash size is set to 4mb or 2mb, if below 10ms

Code: Select all

Task watchdog got triggered
MJU20, with a 40s delay the WDT will not be triggered because all CPU power will not be affected to the task but if you adjust to below 10ms it will be triggered.
I did a test with ESP32TTGO and there is 2 solutions.
  • only replace delay by

    Code: Select all

    vTaskDelay(1);
    in C Code in your loop.
    To be able to use 1ms don't forget to adjust to 1000hz in menuconfig or in SDKconfig file to "CONFIG_FREERTOS_HZ=1000" to be able to get 1ms delay, if not, the frequency will be 100hz so min delay will be 10ms.
    On the console you will see only this, with nothing below tick rate, it me that the ESP don't reset.
    Cons1.jpg
    Cons1.jpg (15.04 KiB) Viewed 2513 times
    Xtask test.fcfx
    (12.94 KiB) Downloaded 100 times
  • Start a periodic task every 1ms using with the code below in C code

    Code: Select all

    xTaskCreatePinnedToCore(&FCM_Task1, "Task1", 2048, NULL, 3,&FCV_HANDLETASK1, 0);
    Last parameter is the CORE to use , you can choose the CORE to use for this task by replacing the last parameter by 1 for CORE1
    With this solution, you main task will not be affected by task1 so you can do others things in main task without delay. Of course in this example I add 10ms in the main task because there not others things to do.
    I added a Pin toggle on the task1 and the counter is also incremented and I added sent absolute time to console, as you can see the pin is toggle every 1ms even with 2 or more things to do. Of course if for example you want to do many things and the time is more than 1ms it will no work well
    the Pin is toggle every 1ms as you can see below. It mean that the counter is also incremented every 1ms.
    toggle 1ms.jpg
    toggle 1ms.jpg (15.23 KiB) Viewed 2513 times
the 2ng Prog will be in the next message
Do not hesitate to ask me if you have question.
Last edited by lucibel on Wed Mar 02, 2022 8:10 am, edited 2 times in total.
Seb

lucibel
Posts: 172
Joined: Thu Sep 23, 2021 3:44 pm
Location: France
Has thanked: 29 times
Been thanked: 22 times

Re: ESP32 Detected size & WDT

Post by lucibel »

Xtask test1.fcfx
(17.27 KiB) Downloaded 127 times
Absolute time is printed on console every 1ms too
5038ms then 5039ms etc...
absolut time.jpg
absolut time.jpg (13.63 KiB) Viewed 2511 times
Seb

MJU20
Posts: 238
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 75 times
Been thanked: 50 times

Re: ESP32 Detected size & WDT

Post by MJU20 »

Oh thanks guys, I didn't see this.
Looks like I didn't check the "get message when new post..."

:)

Post Reply