Edzelf / ESP32-Radio

Internet radio based on ESP32, VS1053 and a TFT screen.
GNU General Public License v3.0
976 stars 229 forks source link

Wifi found, device crashes and device goes back to default AP - endless loop #319

Closed Gulpman closed 4 years ago

Gulpman commented 4 years ago

Hi, I wanted to set up the project and start with nothing connected to the ESP32, to check the general functionality but am not successful.

So when the device boots up it seems to write everything correctly into nvs, boots up again, seems to connect to my network correctly but then crashes and after that is not capable to connect to the net again.

When I do a reset on the ESP32 device, it connects to the network again, crashes and then again gets back to the default AP (ESP32Radio).

Is it neccessary to connect everything (VS1053, display) befor testing?

Here's the log file stripped down to the interesting stuff: ` D: Command: volume with parameter 72 D: Slow SPI, Testing VS1053 read/write registers... D: VS1053 not properly installed! D: Connect to WiFi D: Connected to MYGUESTNETWORK D: IP = 192.168.178.149 D: Start server for commands D: Network found. Starting mqtt and OTA D: MDNS responder started D: Rotary encoder is enabled D: STOP requested D: New preset/file requested (6/0) from icecast.omroep.nl:80/radio1-bb-mp3 D: Connect to new host icecast.omroep.nl:80/radio1-bb-mp3 D: Connect to icecast.omroep.nl on port 80, extension /radio1-bb-mp3 D: Connected to server D: Duration mp3loop 1 D: Switch to HEADER D: Headerline: Content-Type: audio/mpeg D: audio/mpeg seen. D: Headerline: icy-br:192 D: Headerline: ice-audio-info: samplerate=48000;channels=2;bitrate=192 D: Headerline: icy-br:192 D: Headerline: icy-genre:Talk D: Headerline: icy-metadata:1 D: Headerline: icy-name:NPO Radio1 D: Headerline: icy-pub:0 D: Headerline: icy-url:http://www.radio1.nl D: Headerline: Server: Icecast 2.4.0-kh13 D: Headerline: Cache-Control: no-cache, no-store D: Headerline: Access-Control-Allow-Origin: * D: Headerline: Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type D: l-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type seen. D: Headerline: Access-Control-Allow-Methods: GET, OPTIONS, HEAD D: Headerline: Connection: Close D: Headerline: Expires: Mon, 26 Jul 1997 05:00:00 GMT D: Headerline: icy-metaint:16000 D: Switch to DATA, bitrate is 192, metaint is 16000 D: Duration mp3loop 71 D: Song stopped correctly after 0 msec D: Duration mp3loop 400 D: Metadata block 96 bytes D: Streamtitle found, 82 bytes D: StreamTitle='NPO Radio 1 - De Perstribune: Paul de Leeuw en Sarina Wiegman - MAX'; D: SPI semaphore not taken within 270 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 280 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 290 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 300 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 310 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk [LEAVING OUT THE 10 TICKS INTERVALS UNTIL SOMETHING DIFFERENT IN THE LOG] D: SPI semaphore not taken within 740 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 750 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 760 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 270 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 280 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk D: SPI semaphore not taken within 290 ticks by CPU 1, id hspec D: Semaphore is claimed by chunk E (16610) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (16610) task_wdt: - IDLE0 (CPU 0) E (16610) task_wdt: Tasks currently running: E (16610) task_wdt: CPU 0: Playtask E (16610) task_wdt: CPU 1: loopTask E (16610) task_wdt: Aborting. abort() was called at PC 0x400e5613 on core 0

Backtrace: 0x4008cc58:0x3ffbe170 0x4008ce89:0x3ffbe190 0x400e5613:0x3ffbe1b0 0x40084f25:0x3ffbe1d0 0x400e170a:0x3ffd80a0 0x400df619:0x3ffd80c0 0x400d24d4:0x3ffd80e0 0x40089369:0x3ffd8100

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:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1044 load:0x40078000,len:8896 load:0x40080400,len:5816 entry 0x400806ac

D: Starting ESP32-radio running on CPU 1 at 240 MHz. Version Mon, 25 Mar 2020 10:45:00 GMT. Free memory 294132 D: Display type is DUMMYTFT D: Partition nvs found, 20480 bytes D: Read 46 keys from NVS D: pin_ir set to 35 D: pin_enc_clk set to 25 D: pin_enc_dt set to 26 [LEAVING OUT NON INTERESTING sets] D: gpio_14 will execute stop D: gpio_17 will execute resume D: gpio_34 will execute station = icecast.omroep.nl:80/radio1-bb-mp3 D: Enable pin 35 for IR D: Start display D: SD Card Mount Failed! D: Create list with acceptable WiFi networks D: Added MYGUESTNETWORK to list of networks D: Added MYNETWORK to list of networks D: End adding networks D: Scan Networks D: Scan completed D: Number of available networks: 11 D: 1 - MYGUESTNETWORK Signal: -68 dBm, Encryption WPA2_PSK, Acceptable D: 2 - XXXXXXXXXXXXXX Signal: -77 dBm, Encryption WPA_WPA2_PSK, D: 3 - XXXXXXXXXXXXXXXX Signal: -77 dBm, Encryption WPA_WPA2_PSK, D: 4 - XXXXXXXXXX Signal: -84 dBm, Encryption WPA_WPA2_PSK, D: 5 - XXXXXXXXXXXXX Signal: -84 dBm, Encryption ????, D: 6 - MYREALNETWORK Signal: -86 dBm, Encryption WPA2_PSK, Acceptable [...] D: Command: tonehf with parameter 0 D: Command: tonela with parameter 0 D: Command: tonelf with parameter 0 D: Command: volume with parameter 72 D: Slow SPI, Testing VS1053 read/write registers... D: VS1053 not properly installed! D: Connect to WiFi D: WiFi Failed! Trying to setup AP with name ESP32Radio and password ESP32Radio. D: IP = 192.168.4.1 D: Start server for commands D: Rotary encoder is enabled D: STOP requested D: Song stopped correctly after 0 msec D: Rotation count -1 D: Rotation count -1 D: Rotation count -1 D: Rotation count -1 ` And then the loop could be started from the beginning.

Just to ensure I flashed everything correctly, here's the output from flashing (from the Arduino IDE Console): ` C:\Users\sascha\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1/esptool.exe --chip esp32 --port COM7 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\sascha\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/partitions/boot_app0.bin 0x1000 C:\Users\sascha\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 C:\Users\sascha\AppData\Local\Temp\arduino_build_147255/Esp32_radio.ino.bin 0x8000 C:\Users\sascha\AppData\Local\Temp\arduino_build_147255/Esp32radio.ino.partitions.bin esptool.py v2.6 Serial port COM7 Connecting........ Chip is ESP32D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None MAC: 3c:71:bf:1d:5d:84 Uploading stub... Running stub... Stub running... Changing baud rate to 921600 Changed. Configuring flash size... Auto-detected Flash size: 4MB Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %) Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 3449.3 kbit/s)... Hash of data verified. Compressed 15856 bytes to 10276...

Writing at 0x00001000... (100 %) Wrote 15856 bytes (10276 compressed) at 0x00001000 in 0.1 seconds (effective 868.8 kbit/s)... Hash of data verified. Compressed 878496 bytes to 493416...

Writing at 0x00010000... (3 %) Writing at 0x00014000... (6 %) Writing at 0x00018000... (9 %) Writing at 0x0001c000... (12 %) Writing at 0x00020000... (16 %) Writing at 0x00024000... (19 %) Writing at 0x00028000... (22 %) Writing at 0x0002c000... (25 %) Writing at 0x00030000... (29 %) Writing at 0x00034000... (32 %) Writing at 0x00038000... (35 %) Writing at 0x0003c000... (38 %) Writing at 0x00040000... (41 %) Writing at 0x00044000... (45 %) Writing at 0x00048000... (48 %) Writing at 0x0004c000... (51 %) Writing at 0x00050000... (54 %) Writing at 0x00054000... (58 %) Writing at 0x00058000... (61 %) Writing at 0x0005c000... (64 %) Writing at 0x00060000... (67 %) Writing at 0x00064000... (70 %) Writing at 0x00068000... (74 %) Writing at 0x0006c000... (77 %) Writing at 0x00070000... (80 %) Writing at 0x00074000... (83 %) Writing at 0x00078000... (87 %) Writing at 0x0007c000... (90 %) Writing at 0x00080000... (93 %) Writing at 0x00084000... (96 %) Writing at 0x00088000... (100 %) Wrote 878496 bytes (493416 compressed) at 0x00010000 in 8.2 seconds (effective 855.9 kbit/s)... Hash of data verified. Compressed 3072 bytes to 128...

Writing at 0x00008000... (100 %) Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 1365.3 kbit/s)... Hash of data verified.

Leaving... Hard resetting via RTS pin... `

I have added my network to the defaultprefs.h for convenience and to be sure there is no type but that has the same effect.

Any idea what I am doing wrong? Best, Sascha

Edzelf commented 4 years ago

Defaultprefs.h has no effect on the wifi connection. It is only used when choosing the default setting in the web interface. The crash can be caused by missing hardware, but this should not effect your NVS data.

fellek commented 4 years ago

This is the same behavior I got stuck in. There was an issue at espressif Containing more specific debug Logs of this crash:

https://github.com/espressif/arduino-esp32/issues/3440

Gulpman commented 4 years ago

Defaultprefs.h has no effect on the wifi connection. It is only used when choosing the default setting in the web interface. Yes, I did not correctly express: I added it to Defaultprefs.h to have my credentials handy when pressing the default button to ensure there is no typo. Therefore for me it had the indirect effect on wifi settings to reduce possible error sources. :)

The crash can be caused by missing hardware, but this should not effect your NVS data. So I will try with he VS1053 connected.

Gulpman commented 4 years ago

This is the same behavior I got stuck in. There was an issue at espressif Containing more specific debug Logs of this crash:

espressif/arduino-esp32#3440

I wanted to downgrade the ESP32 package in the IDE but there is no single package. Any idea which package I should downgrade to test if this is the cause? The code snipplet on the thread you are referring to seems to use Wifi and WifiMulti. I didn't find out how to downgrade those. Or is there a better solution to the issue? Any clue? Thanks, Sascha

Gulpman commented 4 years ago

Defaultprefs.h has no effect on the wifi connection. It is only used when choosing the default setting in the web interface. The crash can be caused by missing hardware, but this should not effect your NVS data.

OK, fist tests can be run, if the VS1053 is connected (and no other hardware). Without the VS1053 (therefore only the ESP32 with the sketch) I could reproduce the issue on another ESP32 board.

So - issue is solved, however it would be helpful to add this to the documentation, as I think it is natural to test first with the ESP32 only and the compiled sketch running.

Thanks for your help!

Best, Sascha

Edzelf commented 4 years ago

So I took the ESP32 (WROOM-32) out of the radio and powered it up. Lots of errors, but no crash. Web interface works. Maybe it depends on the defined pins. My pins:

pin_ir = 35                                          # GPIO Pin number for IR receiver VS1838B
pin_sd_cs = 21                                       # GPIO Pin number for SD card "CS"
pin_tft_cs = 15                                      # GPIO Pin number for TFT "CS"
pin_tft_dc = 2                                       # GPIO Pin number for TFT "DC"
pin_vs_cs = 5                                        # GPIO Pin number for VS1053 "CS"
pin_vs_dcs = 16                                      # GPIO Pin number for VS1053 "DCS"
pin_vs_dreq = 4                                      # GPIO Pin number for VS1053 "DREQ"
Gulpman commented 4 years ago

So I took the ESP32 (WROOM-32) out of the radio and powered it up. Lots of errors, but no crash. Web interface works. Maybe it depends on the defined pins. My pins:

pin_ir = 35                                          # GPIO Pin number for IR receiver VS1838B
pin_sd_cs = 21                                       # GPIO Pin number for SD card "CS"
pin_tft_cs = 15                                      # GPIO Pin number for TFT "CS"
pin_tft_dc = 2                                       # GPIO Pin number for TFT "DC"
pin_vs_cs = 5                                        # GPIO Pin number for VS1053 "CS"
pin_vs_dcs = 16                                      # GPIO Pin number for VS1053 "DCS"
pin_vs_dreq = 4                                      # GPIO Pin number for VS1053 "DREQ"

Thanks for verifying. The only thing I changed in the original defaul config, was adding my WLAN network. Here's the corresponding part for the pins from my config:

pin_enc_clk = 25 # GPIO Pin number for rotary encoder "CLK" pin_enc_dt = 26 # GPIO Pin number for rotary encoder "DT" pin_enc_sw = 27 # GPIO Pin number for rotary encoder "SW" pin_ir = 35 # GPIO Pin number for IR receiver VS1838B pin_sd_cs = 21 # GPIO Pin number for SD card "CS" pin_tft_cs = 15 # GPIO Pin number for TFT "CS" pin_tft_dc = 2 # GPIO Pin number for TFT "DC" pin_vs_cs = 5 # GPIO Pin number for VS1053 "CS" pin_vs_dcs = 32 # GPIO Pin number for VS1053 "DCS" pin_vs_dreq = 4 # GPIO Pin number for VS1053 "DREQ" I can see in the config you posted, that you altered the pin_vs_dcs to 16 (in the original config it's 32). Apart from that our configs seem to be identically.

I'm using the latest version of Arduino IDE (1.8.12), all libraries and board definitions updated to the latest version.

Anyway, it runs fine now, (with the OLED connected) - only issue I'm having is that the display is not correctly displaying the content but this seems to be an issue with the chip (SSH1106). Will open an extra case for that. :)

Thanks again for investigating!

Best, Sascha