update: improve documentation and restructure code for modular hardware integration, add CAN communication to HAL, and update KiCad layouts

This commit is contained in:
2026-01-23 22:02:14 +01:00
parent 1de40085fb
commit 0c0b62e2ed
18 changed files with 486 additions and 219 deletions

View File

@@ -5,24 +5,47 @@ draft: false
description: "a description"
tags: ["firmeware", "upload"]
---
# Prebuild
1. Download image from
2. todo something espflash tool here
# From source
# From Source
## Preconditions
* rustup with current version
* espup with current version
* npm /npx
* Connect the board via usb to the computer
* Ensure the esp is running (eg not in deepsleep if prior version was installed)
# Compiling and uploading
1. Clone the gitea
2. go to the rust/src_webroot
3. npm -i
4. cd ..
5. cargo run
* **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).
Depending on the setup of the cargo runner, either a OTA image is build or the firmware is directly flashed to the esp.
## 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.*
Note: If the bootloader is currently booting from ota_2, flashing ota_1 via usb will not make it switch. You might need to manually erase it in this case prior.
### 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.