A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: hard reset via RTS pin after flashing firmware (#437)

## Summary

* Disables going to sleep after uploading new firmware
* Makes developer experience easier

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< NO >**_

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

authored by

Arthur Tazhitdinov
Copilot
and committed by
GitHub
83899325 cc74039c

+22 -3
+22 -3
src/main.cpp
··· 276 276 Serial.printf("[%lu] [ ] Fonts setup\n", millis()); 277 277 } 278 278 279 + bool isUsbConnected() { 280 + // U0RXD/GPIO20 reads HIGH when USB is connected 281 + return digitalRead(UART0_RXD) == HIGH; 282 + } 283 + 284 + bool isWakeupAfterFlashing() { 285 + const auto wakeupCause = esp_sleep_get_wakeup_cause(); 286 + const auto resetReason = esp_reset_reason(); 287 + 288 + return isUsbConnected() && (wakeupCause == ESP_SLEEP_WAKEUP_UNDEFINED) && (resetReason == ESP_RST_UNKNOWN); 289 + } 290 + 279 291 void setup() { 280 292 t1 = millis(); 281 293 282 294 // Only start serial if USB connected 283 295 pinMode(UART0_RXD, INPUT); 284 - if (digitalRead(UART0_RXD) == HIGH) { 296 + if (isUsbConnected()) { 285 297 Serial.begin(115200); 298 + // Wait up to 3 seconds for Serial to be ready to catch early logs 299 + unsigned long start = millis(); 300 + while (!Serial && (millis() - start) < 3000) { 301 + delay(10); 302 + } 286 303 } 287 304 288 305 inputManager.begin(); ··· 305 322 SETTINGS.loadFromFile(); 306 323 KOREADER_STORE.loadFromFile(); 307 324 308 - // verify power button press duration after we've read settings. 309 - verifyWakeupLongPress(); 325 + if (!isWakeupAfterFlashing()) { 326 + // For normal wakeups (not immediately after flashing), verify long press 327 + verifyWakeupLongPress(); 328 + } 310 329 311 330 // First serial output only here to avoid timing inconsistencies for power button press duration verification 312 331 Serial.printf("[%lu] [ ] Starting CrossPoint version " CROSSPOINT_VERSION "\n", millis());