ramapcsx2 / gbs-control

GNU General Public License v3.0
793 stars 111 forks source link

Randomly no image when powering on GBS-C #480

Open nyanpasu64 opened 1 year ago

nyanpasu64 commented 1 year ago

In custom passthrough mode (and IIRC fixed passthrough), connected to a Wii over component, randomly when I power on the GBS and ESP, the GBS-C will fail to initialize and display an image. When I connected to the ESP over serial after the fact, it did not respond to serial commands. I do not know what went wrong during the boot process, as I did not have a USB serial console connected.

I'll have to get a boot log capture before debugging further. I tried plugging in the GBS at various points during Wii startup, but could not replicate the issue.

nyanpasu64 commented 1 year ago

Plugged in the GBS-C power 10+ seconds after Wii, and get no image. The Arduino serial monitor woke up after plugging in power, but I see no activity on the USB serial port, no \nstartup text (unsure if it's seen in normal startup or the USB serial connection doesn't wake up in time) and no <reset> text, and sending text over serial does nothing. I cannot access gbscontrol.local in a browser, and sshing into OpenWRT and running iwinfo wlan1 assoclist (2.4 GHz) shows only my Wii connected rather than GBS-C. My phone shows no hosted AP SSID either. Hitting the Reset button on the ESP board fixes the problem, first printing some serial noise followed by \nstartup etc.

I'll have to figure out where in the boot process this stalled. I don't know if the Arduino serial monitor would've woken up like it did, if Serial.begin(115200) had never run.

If the ESP8266 is hung, I'm not sure why the hardware watchdog timer wouldn't reset it to a known good state. Either it's stuck in an infinite loop or softlocked state which feeds the watchdog to prevent a reset, or it failed to startup altogether (possibly due to a low-voltage brownout start?) and software debugging is futile. I may or may not have gotten this issue prior to installing my cooling fan, I don't remember and it's hard to rule out intermittent issues (eg. unplugging the fan and rebooting dozens of times).

nyanpasu64 commented 1 year ago

my primary suspicion is that the esp failed to power up altogether. unfortunately I have less information than I like, since early prints are lost during even successful boots.

i edited my code to flash the led 5 times on setup(). Next time I encounter a black screen, if the LED flashes the ESP dies after setup() starts. If it never flashes, there's a hardware problem or a crash in the code that runs before setup() (either ESP SDK code or a static variable's constructor, ugh).

nyanpasu64 commented 1 year ago

i edited my code to flash the led 5 times on setup().

Haven't gotten any image loss in a month or so. I'm suspecting a brownout event where the GBS draws too much power for the 5V charger (or the GBS/ESP's step-down regulators) on startup, and sleeping for 500ms (or more? IDK, I could probe the voltage lines with a scope) might be enough to prevent it from ever happening.

It could also be caused by a long USB cable plugged into the ESP (with the ESP's USB 5V trace cut) with a large ferrite bead around it, causing power transmission line ripple? I doubt it's affecting power considering the ESP's 5V line is cut, but I'll try plugging that back in and see if it happens in the future it's already plugged into the GBS but just not the computer.

nyanpasu64 commented 1 year ago

Did some quick scope testing:

I'd sleep 500ms on power-up before doing any sort of intensive work on the ESP or talking to hardware.