Public Access
Support both Nano bootloaders for flashing over WiFi
- Uploader sends 'FLASH <baud>' first; the ESP32 restarts the Nano and bridges at that baud rate, then answers OK - --baud=auto (default) tries 57600 (old ATmegaBOOT) then 115200 (Optiboot) - Optional nano_reset GPIO (NPN to Nano RESET) pulses reset after power on, needed for Optiboot which skips the bootloader after a power cycle - Clear errors for outdated ESP32 firmware and missing wires - README: bootloader table, reset wire, troubleshooting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bea5b9daa1
commit
cefb76c1ad
8 files changed
+220
-77
No files matched your search
@@ -5,14 +5,16 @@
|
||||
|
||||
// WiFi to serial bridge for flashing the Nano from the PC (pio run -e nano_ota -t upload).
|
||||
//
|
||||
// When a TCP client connects, onStart() is called to restart the Nano into its bootloader.
|
||||
// After that, bytes are copied between the TCP connection and the Nano's serial port
|
||||
// The uploader (tools/nano_net_upload.py) connects and first sends one line:
|
||||
// FLASH <baud>\n
|
||||
// with the baud rate of the Nano's bootloader (57600 old bootloader, 115200 Optiboot).
|
||||
// onStart(baud) then restarts the Nano into its bootloader, the bridge answers "OK\n",
|
||||
// and from then on bytes are copied between the TCP connection and the Nano's serial port
|
||||
// until the client disconnects or is idle too long. onEnd() is then called.
|
||||
// The uploader on the PC side is tools/nano_net_upload.py.
|
||||
class NanoFlashBridge
|
||||
{
|
||||
public:
|
||||
NanoFlashBridge(uint16_t port, HardwareSerial &serial, void (*onStart)(), void (*onEnd)());
|
||||
NanoFlashBridge(uint16_t port, HardwareSerial &serial, void (*onStart)(uint32_t baud), void (*onEnd)());
|
||||
|
||||
void begin();
|
||||
|
||||
@@ -21,16 +23,19 @@ public:
|
||||
bool handle();
|
||||
|
||||
private:
|
||||
// Max wait for the FLASH line after connecting
|
||||
static const uint32_t HEADER_TIMEOUT = 2000;
|
||||
// Give up when no data moves in either direction for this long
|
||||
static const uint32_t IDLE_TIMEOUT = 10000;
|
||||
|
||||
WiFiServer _server;
|
||||
WiFiClient _client;
|
||||
HardwareSerial &_serial;
|
||||
void (*_onStart)();
|
||||
void (*_onStart)(uint32_t baud);
|
||||
void (*_onEnd)();
|
||||
bool _active = false;
|
||||
uint32_t _last_activity = 0;
|
||||
|
||||
uint32_t _readHeader(WiFiClient &client);
|
||||
void _end();
|
||||
};
|
||||
Reference in new issue
Block a user