bmorcelli / M5Stick-Launcher

App launcher for M5StickC, M5StickC Plus, M5StickC Plus 2 and M5Cardputer
MIT License
221 stars 20 forks source link

Device restarts itself while running WebUI #31

Closed Mr-PauI closed 3 months ago

Mr-PauI commented 3 months ago

I'm aware that there is a button to cause a restart, but it seems as I try to connect, randomly and frequently it has begun to just restart itself. I was running 2.0.0, updated to 2.0.1 but it made no difference. The change to my device that I have made that would possibly effect this would be the number of files in the root directory. It is almost impossible for me to use the WebUI at this point, and has occurred mid file upload causing only partial files to be written to the sdcard.

Is there a hard limit on the number of files we can list with the WebUI? Browsing using the SD interface, and the OTA m5burner functions still work as normal. This restart issue however is frustrating my attempts to test iterations of my firmware wirelessly. It generally happens within 30 seconds after connecting to the WebUI. I switched browsers/machines but the issue still persists (chrome/opera).

After 4 consecutive restarts I was able to get a file listing to appear, some of the ROM names I've used for testing have '!' '(' ')' '[' and ']' characters present; deleted a few of the ROMs from the SD card menu on the device. It will not let me delete anything from the WebUI. Sharing the details incase they are related; I plan to use another SD card in hopes that it resolves the issue for now and will keep the restarting one incase it is helpful. TeamGroup 32gig SDHC purchased at local shop, not some random company online, so I doubt it is the sdcards quality causing this. Nothing here I dont mind sharing, and I hope it is just me with this issue. Name Size

gb_p3.bin 677.97 kB
AudioSpectrum.bin 264.99 kB
M5Launcher.txt 47 B
gb_p4.bin 677.95 kB
gbconfig.dat 12 B
monowav.dat 0 B
Bruce-0.7.bin 149.87 kB
Pokemon Blue.sav 32.00 kB
Street Fighter II (UE) [S][!].gb 512.00 kB
Legend of Zelda, The - Link's Awakening (U) (V1.2) [!].gb 512.00 kB
Evil-Cardputer 1.1.7.bin 150.17 kB
Mega Man V (U) [S][!].gb 512.00 kB
Donkey Kong Land (U) [S][!].gb 512.00 kB
EvilPortal.bin 149.78 kB
Final Fantasy Legend III (USA).sav 8.00 kB
Gameboy.bin 265.00 kB
Super Mario Land 2 - 6 Golden Coins (USA, Europe) (Rev B).sav 8.00 kB
M5Card_WebRadio.ino.bin 265.16 kB
Tetris (World) (Rev A).sav 0 B
F-1 Race (World).gb 128.00 kB
Marauder.bin 149.86 kB
Street Racer (USA, Europe).gb 128.00 kB
F-1 Race (World).sav 512 B
MicroHydra 0.10.bin 149.94 kB
Donkey Kong Land (U) [S][!].sav 8.00 kB
Mega Man V (U) [S][!].sav 0 B
Nemo-EN-2.6.bin 149.83 kB
Legend of Zelda, The - Link's Awakening (U) (V1.sav 8.00 kB
Super Mario Land (World) (Rev A).sav 0 B
UserDemo.bin 149.87 kB
Street Racer (USA, Europe).sav 0 B
Tetris (Japan) (En).gb 32.00 kB
Wario Land - Super Mario Land 3 (World).gb 512.00 kB
gb_cardputer.ino.bin 732.11 kB
Final Fantasy Legend III (USA).gb 256.00 kB
Pokemon - Red Version (USA, Europe) (SGB Enhanced).gb 63.00 kB
Pokemon Red (UE) [S][!].gb 1.00 MB
Tetris (World) (Rev A).gb 32.00 kB
Donkey Kong (World) (Rev A) (SGB Enhanced).gb 512.00 kB
Donkey Kong (World) (Rev A) (SGB Enhanced).sav 8.00 kB
Wario Land - Super Mario Land 3 (World).sav 8.00 kB
Pokemon Blue.gb 767.00 kB
Super Mario Land (World) (Rev A).gb 64.00 kB
Super Mario Land 2 - 6 Golden Coins (USA, Europe) (Rev B).gb 512.00 kB
Arcade Classics - Battlezone & Super Breakout (USA, Europe) (SGB Enhanced).gb 63.00 kB
Balloon Kid (USA, Europe).gb 128.00 kB
Super Mario Land 2 - 6 Golden Coins (USA, Europe) (Rev B).qsv 24.46 kB
Arcade Classic No. 1 - Asteroids & Missile Command (USA, Europe) (SGB Enhanced).gb 128.00 kB
Pokemon Red (UE) [S][!].sav 32.00 kB
gb-wordyl_1.0.3_mbc5_en.gb 32.00 kB
gb-wordyl_1.sav 8.00 kB
Ultima - Runes of Virtue (USA).gb 128.00 kB
Final Fantasy Adventure (USA).gb 256.00 kB
Ultima - Runes of Virtue (USA).sav 512 B
Tetris (Japan) (En).sav 0 B
Final Fantasy Legend, The (USA).gb 128.00 kB
Final Fantasy Legend, The (USA).sav 512 B
Pokemon - Yellow Version - Special Pikachu Edition (USA, Europe).gb 1.00 MB
Pokemon - Yellow Version - Special Pikachu Edition (USA, Europe).sav 32.00 kB
Pokemon - Gold Version (UE) [C][!].gb 2.00 MB
Pokemon - Gold Version broken.gb 415.00 kB
Pokemon - Gold Version (UE) [C][!].sav 32.00 kB
Final Fantasy Legend II (USA).gb 256.00 kB
Kirby's Pinball Land (USA, Europe).gb 256.00 kB
Kirby's Pinball Land (USA, Europe).sav 512 B
Final Fantasy Legend II (USA).sav 8.00 kB
Pokemon - Silver Version (UE) [C][!].gbc 2.00 MB
Star Wars - Super Return of the Jedi (U) [S][!].gb 512.00 kB

bmorcelli commented 3 months ago

Hey buddy.. this is odd.. but I meed some tech info

Device name:

With the errors output I'll be able to know what might be the problem

Mr-PauI commented 3 months ago

I figured more would be required, but I didn't know what you wanted. Device Name: Cardputer (sorry, shoulda known to include that); the first error, failed to remove core 1 idle task occurs immediately upon launching the webui, the reset/Guru Meditiation Error occurs when I try to connect via the web browser - MOST of the time (I'd say around 80%). As you can see, it launches the firmware last installed on the restart.

ESP-ROM:esp32s3-20210327 [ 20008][E][esp32-hal-misc.c:143] disableCore1WDT(): Failed to remove Core 1 IDLE task from WDT Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump: PC : 0x40057067 PS : 0x00060f30 A0 : 0x820242f7 A1 : 0x3fcaae30
A2 : 0x3fcd8ca8 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3fcb1d24
A6 : 0x00000000 A7 : 0x302e3233 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000001 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000013 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000000

Backtrace: 0x40057064:0x3fcaae30 |<-CORRUPTED

ELF file SHA256: ed5620c66c87decc

Rebooting... ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x2b (SPI_FAST_FLASH_BOOT) Saved PC:0x420ea81a SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3810,len:0x1024 load:0x403c9700,len:0xb7c load:0x403cc700,len:0x2dd4 entry 0x403c98a4 [boot] Turned on because (1= POWERON_RESET) (Other= Probably forced by launcher)--> 12

bmorcelli commented 3 months ago

Hello again...

disableCore1WDT(): Failed to remove Core 1 IDLE task from WDT

This first error is supposed to happen indeed, because I'm disabling all watchdogs when starting the WEBUI due to the AsyncTCP handling that was triggering the wdg timer sometimes.. so nothing to worry about that

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

In the other hand, this error is due to the ESP32 attempting to write more than a variable can store.. it is happening because there are too many files, with big names, in the same folder..

A way to deal with this limitation is would be:

It would be great if the Gameboy emulator was storing the .sav files in a separate folder, so it would avoid having lots of files in the root of SDCard, and enabling folder navigation...

I Will think in a way to deal with this limitation providing the file lists to a javascript function, handling the html response in the browser side, but it will take some time

Mr-PauI commented 3 months ago

There is a similar limitation in the Gameboy Emulator's file listing code as well. Thanks for the explanation of the problem. I was planning on rewriting the file selection logic for the gameboy emulator to dynamically repopulate a handful of local variables to prevent memory limitations from posing a limit on my file explorer. Folders exploration would allow the users to organize their roms a little better, and also solve this issue. Thanks for the suggestion, I'll add some version of a solution to my road map.

EDIT: Next major feature planned was save states, which further complicates this issue. Keeping the regular ram backups seperate from the save states (one per game, but still) is ideal. I'll have to think about my approach on this; a gb_data folder could hold all the savestates and savegames for the roms in its parent folder I suppose.

Mr-PauI commented 3 months ago

I added folder navigation to the Gameboy Emulator last night, copied your colour scheme regarding folders; hopefully this can prevent users from overloading the root directory of their SD card. Ended up using a simplified malloc()/freeall() to reuse the existing paging memory so the file listing can be up to 256 entries of 256 bytes per directory at the moment(I could list more but doubt there is a need). Thanks again for the suggestion, it was about time I rewrote that code.

bmorcelli commented 3 months ago

It was a pleasure to help you and give insights for your wonderful firmware!

I have plans to solve the problem you raised, but I'm kind of out of time lately.. Bruce is consuming a good portion of my time, I'm stuck with the Core2 project, and I'm trying something new about the io433 project, to integrate both SDCard and CC1101 in the same "HAT" for my StickC...

I hope things will be done and good in a few weeks