marciot / esp32-dali-clock

An NTSC/PAL version of the 80s Dali Clock for the ESP32
GNU General Public License v3.0
121 stars 10 forks source link

ESP32 bootloop -- "wifi:create wifi task: failed to create task" #8

Open PCOWandre opened 10 months ago

PCOWandre commented 10 months ago

Hi!

I've tried this on a couple of different ESP32 boards and seem to be getting the same result -- a bootloop. Please be patient; my knowledge of the arduino/esp32 environment is .. limited.

Console messages:

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:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
no config file
E (10392) wifi:create wifi task: failed to create task
Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (wifi_task)
Core  1 register dump:
PC      : 0x40090cd3  PS      : 0x00060e36  A0      : 0x800900df  A1      : 0x3ffbb260
A2      : 0x3ffc0428  A3      : 0xb33fffff  A4      : 0x0000cdcd  A5      : 0x00060e23
A6      : 0x00060e23  A7      : 0x0000abab  A8      : 0xb33fffff  A9      : 0xffffffff
A10     : 0x00000037  A11     : 0x3ffb6af8  A12     : 0x00000037  A13     : 0x00060023
A14     : 0x007c0428  A15     : 0x003fffff  SAR     : 0x00000004  EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000  LBEG    : 0x4008ab09  LEND    : 0x4008ab2d  LCOUNT  : 0x8010e990

Environment:

$ arduino-cli core list
ID            Installed Latest Name
esp32:esp32   2.0.11    2.0.11 esp32
marciot commented 10 months ago

I just tried with Arduino IDE 2.2.1 and an "Adafruit ESP32 Feather" and I had no problems.

I do see a bootloop if I have an incompatible board selected, such as if I select "Adafruit ESP32 Version 2". You probably want to verify you can upload an empty sketch before you try loading the dali clock

PCOWandre commented 10 months ago

My aduino compile chain appears to be working -- I'm able to compile and upload a test sketch and it works. Also, this host is being used to handle esphome builds which uses the arduino compiler.

Is there something specific about the Feather which makes it a requirement? I've tested on three different varieties of ESP-WROOM-32 boards.

marciot commented 10 months ago

My aduino compile chain appears to be working -- I'm able to compile and upload a test sketch and it works. Also, this host is being used to handle esphome builds which uses the arduino compiler.

Is there something specific about the Feather which makes it a requirement? I've tested on three different varieties of ESP-WROOM-32 boards.

I don't think so. I have no clue why it doesn't work on your particular board. It does say that it failed to create a task, so it is failing on the following line:

    xTaskCreatePinnedToCore(wifi_task, "wifi_task", 3*1024, NULL, 0, NULL, 1);

I would maybe see if it works with that commented out. If so, then maybe comment most of the code in "wifi_task" and see whether that works. Then add code until it crashes.

marciot commented 10 months ago

The fact it says "Stack canary watchpoint triggered" may indicate the stack is too small. You could try increasing "3*1024" to something larger, like "4*1024", then increase it until the problem goes away. Maybe my board does not have that stack size check enabled and I am corrupting memory without realizing it.

PCOWandre commented 10 months ago

OK, let's give that a go.

Yep, that fixed the bootloop. I don't have time to do a proper config and test right now, but it looks like a step forward.

PCOWandre commented 10 months ago

Righteo, interesting. It doesn't crash, but

no config file
Starting access point "ESP32 Dali Clock"
E (10384) wifi:create wifi task: failed to create task
E (10387) wifi:create wifi task: failed to create task
Running AP at ESP32 Dali Clock with IP address 0.0.0.0
Go to http://0.0.0.0 to reconfigure

And no access point is visible. I assume returning an IP of 0.0.0.0 is indicative of something going wrong. EDIT: Removing the xTaskCreatePinnedToCore() just led to zero debug output, nothing happening.

M0NWY commented 8 months ago

This took me like 3 evenings of swearing to figure out, but you need to downgrade your esp32 tool chain to the one the code was originally written for. This code works fine for me on esp32 v1.0.6. and Arduino IDE 2.2.1(Latest).

marciot commented 8 months ago

OK, let's give that a go.

Yep, that fixed the bootloop. I don't have time to do a proper config and test right now, but it looks like a step forward.

Can you let me know how much you increased the stack size so I can make the fix in the code?

Jimbobnz commented 8 months ago

I too was having the same problem with the boot loop and it was resolved with the following code amendments.

void wifi_start() {
    xTaskCreatePinnedToCore(wifi_task, "wifi_task", 4*1024, NULL, 0, NULL, 0);
}

But, the WiFi access point failed to initialize correctly.

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:1 load:0x3fff0030,len:1344 load:0x40078000,len:13964 load:0x40080400,len:3600 entry 0x400805f0 no config file Starting access point "ESP32 Dali Clock" E (24863) wifi:create wifi task: failed to create task E (24863) wifi:create wifi task: failed to create task Running AP at ESP32 Dali Clock with IP address 0.0.0.0 Go to http://0.0.0.0 to reconfigure

davidchezmoa commented 7 months ago

I got the same pb the AP is not showing but I saw this :

This took me like 3 evenings of swearing to figure out, but you need to downgrade your esp32 tool chain to the one the code was originally written for. This code works fine for me on esp32 v1.0.6. and Arduino IDE 2.2.1(Latest).

and I was wondering how to downgrade Arduino IDE (v2.3.1) esp32 tool chain to the recommended v1.0.6, can someone give me some tips on that task ?

Thank you.

PCOWandre commented 7 months ago

+1 to some instructions on running such a downrev build environment.

Additionally, perhaps the author could build a PAL and NTSC binary image that can be flashed with esptool.py?

marciot commented 7 months ago

perhaps the author could build a PAL and NTSC binary image that can be flashed with esptool.py?

This is an interesting idea. The biggest issue I see with it is that one binary would need to work on all the various development boards. I don't know how realistic that is. It is possible that I would need to have one binary per SoC part number. The other issue would that I would need to provide a listing of boards and what output pin will be active. Since I don't own all boards, I would have to find a way to extract the information from the Arduino IDE itself.

Due to the effort involved, I would likely only offer the binaries to my GitHub sponsors, if it is possible at all. I'll need to investigate.

PCOWandre commented 7 months ago

I might be completely wrong here, but I imagine nearly everyone tackling this sort of project is using the bog-standard ESP-WROOM-32 dev boards that are extremely common and extremely cheap. I know there are hundreds of ESP32 boards out there, but once you rule out the ones with fancy features like displays and battery management and LoRa, there's not much real difference between WROOM modules.

PCOWandre commented 7 months ago

OK, I had a little time so I worked out the 1.0.6 ESP32 toolchain process and wrote it up here: https://gist.github.com/PCOWandre/9ae7cabe39bc2389bf806cbd3c2f5bfc

It compiles and runs without error; I need to rat around for an RCA jack to build a cable to test it and I'll save that for daylight.

EDIT: found a RCA jack in my desk drawer -- it works -- pin on my board is labelled D25.

davidchezmoa commented 7 months ago

OK, I had a little time so I worked out the 1.0.6 ESP32 toolchain process and wrote it up here: https://gist.github.com/PCOWandre/9ae7cabe39bc2389bf806cbd3c2f5bfc

It compiles and runs without error; I need to rat around for an RCA jack to build a cable to test it and I'll save that for daylight.

EDIT: found a RCA jack in my desk drawer -- it works -- pin on my board is labelled D25.

Thanks for the guide, I got a compile error despite I did select a board from "ESP32 Arduino (in Sketchbook)"

`In file included from c:\users\david\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\include\c++\8.4.0\xtensa-esp32-elf\esp32-psram\no-rtti\bits\gthr.h:151, from c:\users\david\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\include\c++\8.4.0\ext\atomicity.h:35, from c:\users\david\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\include\c++\8.4.0\memory:73, from C:\Users\david\OneDrive\Documents\Arduino\hardware\espressif\esp32\libraries\FS\src/FS.h:24, from C:\Users\david\OneDrive\Documents\Arduino\hardware\espressif\esp32\libraries\SPIFFS\src/SPIFFS.h:17, from C:\Users\david\OneDrive\Documents\Arduino\esp32-dali-clock\esp32-dali-clock\esp32-dali-clock.ino:24: c:\users\david\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\include\c++\8.4.0\xtensa-esp32-elf\esp32-psram\no-rtti\bits\gthr-default.h: In function 'int gthread_mutex_timedlock(gthread_mutex_t, const __gthread_time_t)': c:\users\david\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\include\c++\8.4.0\xtensa-esp32-elf\esp32-psram\no-rtti\bits\gthr-default.h:781:12: error: 'pthread_mutex_timedlock' was not declared in this scope return _gthrw(pthread_mutex_timedlock) (mutex, abs_timeout); ^~~~ c:\users\david\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\esp-2021r2-patch5-8.4.0\xtensa-esp32-elf\include\c++\8.4.0\xtensa-esp32-elf\esp32-psram\no-rtti\bits\gthr-default.h:781:12: note: suggested alternative: 'pthread_mutex_trylock'

exit status 1

Compilation error: exit status 1`

davidchezmoa commented 7 months ago

I finally get it working, using another computer with an older version of the IDE and no problem, the project compile without problem and the wifi is working now on the clock.

Thanks again.