NEW ARCHITECTURE:
[Your PC] β WiFi β [ESP8266] β Serial β [Arduino R4 Minima]
β β
Web Server HTTP Client
(Flask) (Polls for updates)
- PC Server (Flask) - Hosts firmware files and provides REST API
- ESP8266 (NodeMCU) - Polls server, downloads firmware, programs Arduino
- Arduino R4 Minima - Target device to be programmed
- NodeMCU ESP8266
- Arduino R4 Minima
- 1Β΅F capacitor (for reset control)
- 4.6kΞ© resistor (pull-down on Arduino RESET)
- Jumper wires
- USB cables for initial programming
- Python 3.7+ (for PC server)
- PlatformIO (for firmware builds)
- This project repository
ESP8266 (NodeMCU) Arduino R4 Minima
βββββββββββββββββ βββββββββββββββββ
TX (GPIO1) βββββββ RX (D0)
RX (GPIO3) βββββββ TX (D1)
D1 (GPIO5) βββ€ββββ RESET (via 1Β΅F capacitor)
GND ββββββββ GND
RESET β[4.6kΞ©]β GND (pull-down resistor)
Important Notes:
- The capacitor creates a pulse on RESET when D1 goes HIGH
- The pull-down resistor keeps RESET stable when D1 is LOW
- Both devices must share a common ground
- Power each device via its own USB connection (don't cross power!)
cd /Users/muditatrey/Documents/PlatformIO/Projects/GmBH/server
pip3 install -r requirements.txtEdit src/esp8266_programmer.cpp and update these lines:
// Line 9-10: Your WiFi credentials
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
// Line 13: Your PC's IP address on the network
const char* serverHost = "192.168.1.100"; // Replace with your PC's IPTo find your PC's IP address:
- macOS:
ifconfig | grep "inet " | grep -v 127.0.0.1 - Linux:
ip addr show - Windows:
ipconfig
cd /Users/muditatrey/Documents/PlatformIO/Projects/GmBH
# Build ESP8266 firmware
~/.platformio/penv/bin/pio run -e esp8266_programmer
# Upload to ESP8266 (connect via USB)
~/.platformio/penv/bin/pio run -e esp8266_programmer -t upload
# Monitor serial output to verify connection
~/.platformio/penv/bin/pio device monitor -e esp8266_programmerYou should see:
=== ESP8266 Arduino Remote Programmer ===
Device ID: AABBCCDDEEFF
WiFi connected!
IP Address: 192.168.1.150
Server: http://192.168.1.100:5000
Waiting for firmware updates...
# Build Arduino R4 firmware (.bin file will be created)
~/.platformio/penv/bin/pio run -e uno_r4_minimaThe firmware binary will be saved to:
.pio/build/uno_r4_minima/firmware.bin
cd /Users/muditatrey/Documents/PlatformIO/Projects/GmBH/server
python3 firmware_server.pyYou should see:
============================================================
π Arduino R4 Minima Firmware Server
============================================================
π Firmware directory: /Users/muditatrey/Documents/PlatformIO/Projects/GmBH/server/firmware
π Server starting on http://0.0.0.0:5000
π‘ Web interface: http://localhost:5000
π API endpoint: http://<your-pc-ip>:5000/api/firmware/check
============================================================
- Open browser to
http://localhost:5000 - Click "Choose File" and select
.pio/build/uno_r4_minima/firmware.bin - Enter version number (e.g., "1.0.0")
- Click "Upload Firmware"
- Wait 30 seconds - ESP8266 will automatically detect and download the update!
cd /Users/muditatrey/Documents/PlatformIO/Projects/GmBH
curl -X POST http://localhost:5000/api/firmware/upload \
-F "[email protected]/build/uno_r4_minima/firmware.bin" \
-F "version=1.0.0" \
-F "description=LED blink test"- ESP8266 polls PC server every 30 seconds via
/api/firmware/check - Server responds with firmware metadata (version, size, MD5 hash)
- ESP8266 compares MD5 hash with current firmware
- If different, ESP8266 downloads firmware via
/api/firmware/download - Firmware saved to ESP8266's LittleFS filesystem
- ESP8266 enters bootloader mode on Arduino (double-tap reset)
- Firmware sent to Arduino over serial connection
- Arduino reset to run new firmware
- Status reported back to PC server
~/.platformio/penv/bin/pio device monitor -e esp8266_programmerThe Flask server shows real-time logs of ESP8266 activity:
π‘ Device [AABBCCDDEEFF]: downloading - New firmware detected
π‘ Device [AABBCCDDEEFF]: flashing - Starting flash process
π‘ Device [AABBCCDDEEFF]: success - Firmware update complete
The current implementation has a CRITICAL limitation:
The Arduino R4 Minima uses a Renesas RA4M1 ARM Cortex-M4 processor, NOT the traditional AVR architecture. This means:
β STK500 protocol won't work (traditional Arduino bootloader) β AVRdude won't work (AVR programming tool) β Simple serial programming won't work (requires specific bootloader)
β What the current system CAN do:
- Connect ESP8266 to WiFi
- Poll PC server for updates
- Download firmware files
- Store firmware on ESP8266
- Reset Arduino R4
- Send data over serial to Arduino
β What it CANNOT do (yet):
- Actually FLASH the firmware to Arduino R4's program memory
- Use the Arduino R4's built-in bootloader remotely
The Arduino R4 Minima has a built-in Renesas DA16200 WiFi module. You can:
- Add WiFi and OTA update capabilities directly to your Arduino code
- Use Arduino's
WiFiS3library andOTAUpdatelibrary - Arduino updates itself without needing the ESP8266
Example Arduino OTA code:
#include <WiFiS3.h>
#include <OTAUpdate.h>
void setup() {
WiFi.begin("SSID", "PASSWORD");
OTAUpdate.begin(); // Enable OTA updates
}
void loop() {
OTAUpdate.poll(); // Check for updates
// Your code here
}Use Arduino Uno, Nano, or Mega instead:
- These use AVR processors with STK500 bootloader
- Can be programmed over serial using standard protocols
- The ESP8266 programmer code would work with minimal modifications
The Arduino R4 uses the bossac tool for programming:
- Would require porting bossac to ESP8266 (very complex)
- Or using an external SWD programmer connected to ESP8266
- Beyond the scope of this project
- Check SSID and password in
esp8266_programmer.cpp - Ensure ESP8266 is in range of router
- Use 2.4GHz WiFi (ESP8266 doesn't support 5GHz)
- Verify PC's firewall allows port 5000
- Ensure PC and ESP8266 are on same network
- Test server with:
curl http://<pc-ip>:5000/api/firmware/check - Check serverHost IP address in ESP8266 code
- Check file size (must fit in ESP8266's LittleFS)
- Verify .bin file is correct format
- Try re-uploading via web interface
- Check physical connections (TXβRX, GND)
- Verify capacitor and resistor values
- Test reset by pressing Arduino's reset button
- Check baud rate matches (115200 for both)
GmBH/
βββ platformio.ini # PlatformIO configuration
βββ src/
β βββ esp8266_programmer.cpp # ESP8266 client code
β βββ arduino_target.cpp # Arduino test firmware
βββ server/
β βββ firmware_server.py # Python Flask server
β βββ requirements.txt # Python dependencies
β βββ firmware/ # (created automatically)
β βββ firmware.bin # Latest uploaded firmware
β βββ metadata.json # Firmware metadata
- Modify Arduino code in
src/arduino_target.cpp - Build firmware:
~/.platformio/penv/bin/pio run -e uno_r4_minima - Upload to server via web interface at
http://localhost:5000 - Wait ~30 seconds for ESP8266 to detect and download
- Monitor progress in ESP8266 serial monitor
- Verify new code is running on Arduino
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Web interface |
/api/firmware/check |
GET | Check for firmware availability |
/api/firmware/download |
GET | Download firmware binary |
/api/firmware/upload |
POST | Upload new firmware |
/api/firmware/metadata |
GET | Get firmware details |
/api/firmware/delete |
DELETE | Delete current firmware |
/api/device/report |
POST | ESP8266 status reporting |
{
"available": true,
"version": "1.0.0",
"size": 33928,
"md5": "a1b2c3d4e5f6...",
"timestamp": "2025-11-01T10:30:00",
"description": "LED blink test"
}- Research Renesas RA4M1 bootloader protocol
- Implement bossac commands for ESP8266
- Or add WiFi to Arduino and use native OTA updates
- Or switch to AVR Arduino for simpler programming
- Add firmware rollback capability
- Implement firmware signing/verification
- Add multiple device support
- Create mobile app for firmware upload
- Add scheduled update times
- Implement firmware A/B partitions
- Arduino R4 Minima Documentation
- ESP8266 Arduino Core
- PlatformIO Documentation
- bossac Tool
- Flask Documentation
This project is for educational purposes. Use at your own risk.