52 lines
2.1 KiB
Markdown
52 lines
2.1 KiB
Markdown
---
|
|
title: "Firmware Upload"
|
|
date: 2025-01-27
|
|
draft: false
|
|
description: "a description"
|
|
tags: ["firmeware", "upload"]
|
|
---
|
|
# From Source
|
|
## Preconditions
|
|
* **Rust:** Current version of `rustup`.
|
|
* **ESP32 Toolchain:** `espup` installed and configured.
|
|
* **espflash:** Installed via `cargo install espflash`.
|
|
* **Node.js:** `npm` installed (for the web interface).
|
|
|
|
## Flashing via USB
|
|
1. Connect the MainBoard to your computer via USB.
|
|
2. Ensure the board is powered and not in deep sleep.
|
|
3. Build the web interface (only required once or if you changed something in `src_webpack`):
|
|
```bash
|
|
cd Software/MainBoard/rust/src_webpack
|
|
npm install
|
|
npx webpack
|
|
cd ..
|
|
```
|
|
4. Flash the firmware:
|
|
```bash
|
|
espflash flash --monitor --partition-table partitions.csv
|
|
```
|
|
*Note: If the flashing fails, you might need to put the ESP32-C6 into bootloader mode by holding the BOOT button while resetting or connecting USB.*
|
|
|
|
### Simplified Flashing with Scripts
|
|
You can use the provided bash scripts to automate the build and flash process:
|
|
* **`./flash.sh`**: Cleans temporary files, builds the web interface, compiles the firmware, and flashes it to the board.
|
|
* **`./all.sh`**: Similar to `flash.sh`, but also saves a local `image.bin` of the firmware.
|
|
|
|
## OTA (Over-the-Air) Update
|
|
You can also update the firmware wirelessly if the system is already running and connected to your network.
|
|
|
|
1. Generate the OTA binary:
|
|
```bash
|
|
cargo build --release
|
|
```
|
|
2. The binary will be at `target/riscv32imac-unknown-none-elf/release/plant-ctrl2`.
|
|
3. Open the PlantCtrl web interface in your browser.
|
|
4. Navigate to the **OTA** section.
|
|
5. Upload the `plant-ctrl2` file.
|
|
6. The system will reboot into the new firmware once the upload and verification are complete.
|
|
|
|
## Troubleshooting
|
|
* **Bootloader Partition:** If the bootloader is currently booting from `ota_2`, flashing to the factory partition via USB might not automatically switch the active partition. You can use `espflash erase-parts otadata` to reset the OTA state.
|
|
* **Serial Terminal:** Use `espflash monitor` to view the serial logs for debugging.
|