Files
PlantCtrl/website/content/Software/1737993506015-Firmware-Upload/index.md
Empire Phoenix 776db785c4 Update hardware and firmware documentation for new modules and features
- Removed outdated TODOs and legacy references in hardware documentation.
- Added details on the new CH32V203-based Sensor Module for CAN bus soil moisture sensors.
- Documented updates to the Battery Management System (CH32V203-based) replacing the older bq34z100 design.
- Refined sensor, pump, and power module descriptions with updated specifications.
- Expanded firmware documentation to include Rust-based ESP32-C6 platform details, new OTA procedure, and MQTT telemetry topics.
- Simplified toolchain setup and compilation process with updated scripts and instructions.
2026-05-05 00:50:18 +02:00

53 lines
2.1 KiB
Markdown

---
title: "Firmware Upload"
date: 2025-01-27
draft: false
description: "a description"
tags: ["firmeware", "upload"]
---
# From Source
The PlantCtrl firmware is written in Rust for the ESP32-C6 RISC-V microcontroller.
## Preconditions
* **Rust:** Current version of `rustup`.
* **ESP32 Toolchain:** `espup` installed and configured for ESP32-C6.
* **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:
**`./image.sh`**
2. The binary will be `image.bin`.
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.