https://github.com/dkaukov/esp32-flash
Java library for flashing firmware to ESP32 devices
https://github.com/dkaukov/esp32-flash
esp32 expressif java library serial
Last synced: 5 months ago
JSON representation
Java library for flashing firmware to ESP32 devices
- Host: GitHub
- URL: https://github.com/dkaukov/esp32-flash
- Owner: dkaukov
- License: gpl-3.0
- Created: 2025-05-12T12:39:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-09T01:38:24.000Z (10 months ago)
- Last Synced: 2026-01-11T18:44:58.560Z (5 months ago)
- Topics: esp32, expressif, java, library, serial
- Language: Java
- Homepage:
- Size: 1.21 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ESP32 Flash
**ESP32 Flash** is a Java library for flashing firmware to ESP32 devices using the serial protocol implemented in the ESP32 ROM bootloader and esptool stub loader. It provides a fluent, modular, and extensible API for embedding ESP flashing logic into your own tools or UIs.
## โจ Features
* ๐งฑ **Modular Core Library** โ Just bring your own `SerialTransport`.
* ๐ **ROM & Stub Protocol Support** โ Handles both ESP32 ROM bootloader and stub loader protocols.
* ๐ฆ **Fluent API** โ Easily script multi-step flashing processes in one expressive chain.
* ๐งช **Optional Flash Verification** โ Built-in MD5 verification for written regions.
* ๐ **Callback Hooks** โ Track progress and status updates during operations.
## ๐ง You Provide the Transport
This is a library โ it does **not** bundle a serial port implementation.
You must provide a `SerialTransport` implementation suitable for your environment (e.g., JSSC, RXTX, jSerialComm, or your own).
```java
public interface SerialTransport {
int read(byte[] buffer, int length);
void write(byte[] buffer, int length);
void setControlLines(boolean dtr, boolean rts);
}
```
This keeps the core clean, platform-agnostic, and easy to integrate into desktop or embedded Java applications.
## ๐ก Example: Fluent API Usage
```java
EspFlasherApi.connect(getComPort())
.withCallBack(getCallBack())
.withBaudRate(EspFlasherApi.ESP_ROM_BAUD_HIGH, comPort::setBaudRate)
.chipDetect()
.loadStub()
.eraseFlash()
.withStub(stub -> stub
.withCompression(false)
.writeFlash(stub.getChipId().getRegion(FlashRegion.BOOTLOADER), stub.readResource("{chip}/Blink.ino.bootloader.bin"), true)
.writeFlash(stub.getChipId().getRegion(FlashRegion.PARTITION_TABLE), stub.readResource("{chip}/Blink.ino.partitions.bin"), true)
.writeFlash(stub.getChipId().getRegion(FlashRegion.APP_BOOTLOADER), stub.readResource("{chip}/boot_app0.bin"), true)
.withCompression(true)
.writeFlash(stub.getChipId().getRegion(FlashRegion.APP_0), stub.readResource("{chip}/Blink.ino.bin"), true))
.reset();
```
## ๐ฆ Project Structure
* `esp32-flash-lib` โ Core flashing library, reusable in any Java app.
* `esp32-flash-example` โ Basic runnable example showing how to integrate the library with a real serial port and flashing flow.
## โถ๏ธ Getting Started
### Requirements
* Java 11+
* Maven
### Build the Library
```bash
git clone https://github.com/dkaukov/esp32-flash.git
cd esp32-flash
mvn clean install
```
### Run the Example
```bash
cd esp32-flash-example
mvn exec:java -Dexec.mainClass="org.dkaukov.esp32.EspLoader"
```
Replace `"your.Main"` with the correct entry point in your code.
## ๐ Resources
Place your binaries (`bootloader.bin`, `partitions.bin`, `app.bin`, etc.) in your resource path or use your own binary loader.
## ๐ License
This project is licensed under the terms of the [GPL-3.0 License](LICENSE).