43 Commits

Author SHA1 Message Date
judge 961f5748c6 Merge branch 'refactor/mqtt-data-serialization' into legacy/v3-support 2026-05-17 12:47:09 +02:00
judge a66843a455 move all mqtt publishing functions to mqtt module 2026-05-10 21:00:55 +02:00
judge 379808e659 refctor: TankInfo structure (consistent layout)
- fix: use tagged enum serialization for TankError
- fix: rename TankInfo fields for consistent naming (volume_ml, pct, water_temp_c)
- renamed some fields for better clarity on contained value
2026-05-10 21:00:53 +02:00
judge e2b2734301 refactor: PlantInfo structure (consistent layout)
- fix: use tagged enum serialization for MoistureSensorError and PumpError
- fix: flatten PlantInfo sensors to SensorTelemetry with top-level moisture_pct
2026-05-10 21:00:52 +02:00
judge 43a0c3c274 refactor: BatteryInfo structure (consistent layout)
- use tagged enum serialization for BatteryError
- flatten BatteryInfo telemetry with consistent field names and typed error
2026-05-10 21:00:50 +02:00
judge 2b83d99820 fix: serialize firmware/state as JSON instead of Debug format 2026-05-10 21:00:47 +02:00
judge 4cc70f96de Merge branch 'fix/stay-alive-webserver-spawn' into legacy/v3-support 2026-05-10 20:59:50 +02:00
judge c90174be27 fix actually spawn async task for webserver when entering stay_alive mode 2026-05-10 20:49:43 +02:00
judge b569fa4b04 Merge branch 'fix/reenable-plant-watering-wtf-empire-this-should-never-have-happend' into legacy/v3-support 2026-05-10 19:47:27 +02:00
judge f71ca7ec6d activate plant watering code again
for some idiotic the most critical part of the code was disabled and
commited that should not have happend!
2026-05-10 19:41:51 +02:00
judge 28f7ae20ef Merge branch 'fix/ota-update' into legacy/v3-support 2026-05-10 17:36:32 +02:00
judge 52049c456e update read_up_to_bytes_from_request with more robust implementation 2026-05-10 17:22:45 +02:00
judge e3b7648a3f website update version display and ota handler 2026-05-10 16:45:06 +02:00
judge 08ee9018cf website add toast service for notifications 2026-05-10 16:44:30 +02:00
judge c2929a65ae enable ota_update webserver path again
take latest ota code from `develop` branch and apply to legacy branch
2026-05-10 16:34:26 +02:00
judge 0b386b0ca3 Merge branch 'feature/build-scripts-from-develop' into legacy/v3-support 2026-05-10 14:39:37 +02:00
judge 0ab1ea3635 build: add build artifacts to .gitignore 2026-05-10 14:39:24 +02:00
judge ae73f12d1c build: add image_build.sh and erase_ota.sh scripts 2026-05-10 14:39:22 +02:00
judge cfe1c2c6d8 build: add flash.sh and all.sh scripts 2026-05-10 14:39:20 +02:00
judge 578379c0d9 build: remove webpack integration from build.rs and add always-rebuild sentinel 2026-05-10 14:39:19 +02:00
judge 2ff219a1cb build: add reusable build_website.sh script 2026-05-10 14:39:16 +02:00
judge 96023c8dc3 Merge branch 'refactor/mkstatic-util' into legacy/v3-support 2026-05-10 14:04:25 +02:00
judge 7497a8c05d refactor: create util module with shared mk_static
- use crate::util::mk_static in network module
- use crate::util::mk_static in mqtt module
- use crate::util::mk_static in hal module
- remove dead mk_static macro from esp module
2026-05-10 14:01:57 +02:00
judge d3d8d829be Merge branch 'refactor/network-module' into legacy/v3-support 2026-05-10 13:38:24 +02:00
judge 6889ba4561 refactor: move try_connect_wifi_sntp_mqtt to network module 2026-05-10 13:34:34 +02:00
judge 18095349f3 refactor: move wifi to network module 2026-05-10 13:34:32 +02:00
judge 3d8fd893f5 refactor: move wifi_ap to network module 2026-05-10 13:34:30 +02:00
judge 1bea7ef2f4 refactor: move sntp to network module 2026-05-10 13:34:28 +02:00
judge f5b9674840 refactor: move run_dhcp to network module 2026-05-10 13:34:25 +02:00
judge 6f22881007 refactor: move net_task to network module 2026-05-10 13:34:23 +02:00
judge 1d8af1b6c4 refactor: create network module
- move NetworkMode and SntpMode enums
2026-05-10 13:33:52 +02:00
judge 2c532359fc Merge branch 'refactor/mqtt-module' into legacy/v3-support 2026-05-10 01:59:07 +02:00
judge 53819484fb refactor: move Solar struct to mqtt module 2026-05-10 01:48:22 +02:00
judge 1151d099cf refactor: move PumpInfo struct to mqtt module 2026-05-10 01:48:20 +02:00
judge 3feaacd460 refactor: create mqtt module with core MQTT statics and tasks 2026-05-10 01:48:10 +02:00
judge e15e78cc26 rename deepsleep to deep_sleep_ms for clarity on expected duration
in main deep sleep was larger than required by a factor of 1000, fixed
this an renamed function to make expected duration count size obvious
from the name
2026-05-05 22:02:46 +02:00
judge d9aa96a3cb add containerized dev tools legacy branch 2026-05-05 21:47:41 +02:00
judge ecf989b859 relax wifi connect parameters for more reliable wifi connection 2026-05-05 01:38:07 +02:00
judge db401aac55 get most stuff working again, by upgrading to newer esp-hal version
this involved adding a lot of code from the develop branch step by step
there are still some bugs, but at least i can get into the web interface
and configure stuff again \o/ … measuring and pumping is working as well
2026-05-04 23:46:27 +02:00
judge ecb7707357 fix: add gpio_pad_hold on GPIO21 to prevent boot ROM from reconfiguring shift register enable pin 2026-05-04 02:31:49 +02:00
judge 4cf7a1c94f counter limit 0 is invalid set None instead 2026-05-04 01:50:06 +02:00
judge 9155676e06 commit Cargo.lock to make legacy version compile reproducably 2026-05-04 01:50:02 +02:00
EmpirePhoenix e05f3d768f Add mcutie MQTT client implementation and improve library structure
- Integrated `mcutie` library as a core MQTT client for device communication.
- Added support for Home Assistant entities (binary sensor, button) via MQTT.
- Implemented buffer management, async operations, and packet encoding/decoding.
- Introduced structured error handling and device registration features.
- Updated `Cargo.toml` with new dependencies and enabled feature flags for `serde` and `log`.
- Enhanced logging macros with configurable options (`defmt` or `log`).
- Organized codebase into modules (buffer, components, IO, publish, etc.) for better maintainability.

fix legacy dependecencies and compatiblity with mcutie vendored lib

fix shit i hate this
2026-05-04 01:48:22 +02:00
169 changed files with 8494 additions and 8132 deletions
+9
View File
@@ -8,6 +8,15 @@ target
Cargo.lock
node_modules/
rust/src/webserver/bundle.js
rust/src/webserver/bundle.js.gz
rust/src/webserver/index.html
rust/src/webserver/index.html.gz
rust/src_webpack/bundle.js
rust/src_webpack/bundle.js.gz
rust/src_webpack/index.html
rust/src_webpack/index.html.gz
rust/build/
rust/image.bin
rust/target/
rust/Cargo.lock
rust/src_webpack/node_modules/

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

@@ -2,9 +2,9 @@
set -euo pipefail
CONTAINER_NAME="localhost/wch-dev-tools:latest"
CONTAINER_NAME="localhost/esp-plant-dev-tools:latest"
CONTAINER_TOOLS_BASEDIR="$(dirname "$(readlink -f "$0")")"
pushd "$CONTAINER_TOOLS_BASEDIR"
podman build -t "$CONTAINER_NAME" -f "../wch-tools.Containerfile" .
podman build -t "$CONTAINER_NAME" -f "esp-plant-dev-tools.Containerfile" .
popd
+16
View File
@@ -0,0 +1,16 @@
FROM debian:latest
RUN apt update -y && apt upgrade -y && apt install unzip curl xz-utils nodejs -y
RUN cd /root && \
curl -L -o xpack-riscv-toolchain.tar.gz "https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v14.2.0-3/xpack-riscv-none-elf-gcc-14.2.0-3-linux-x64.tar.gz" && \
mkdir xpack-toolchain && \
tar -xvf xpack-riscv-toolchain.tar.gz -C xpack-toolchain --strip-components=1 && \
mv xpack-toolchain/bin/* /usr/local/bin && \
mv xpack-toolchain/lib/ /usr/local && \
mv xpack-toolchain/lib64/ /usr/local && \
mv xpack-toolchain/libexec /usr/local && \
mv xpack-toolchain/riscv-none-elf /usr/local && \
rm -rf xpack-toolchain xpack-riscv-toolchain.tar.gz
RUN apt install npm -y
+5 -5
View File
@@ -2,8 +2,9 @@
set -euo pipefail
CONTAINER_IMAGE="localhost/wch-dev-tools:latest"
CONTAINER_IMAGE="localhost/esp-plant-dev-tools:latest"
CONTAINER_TOOLS_BASEDIR="$(dirname "$(readlink -f "$0")")"
PLANTCTL_PROJECT_DIR="$(readlink -f "$CONTAINER_TOOLS_BASEDIR/..")"
function _fatal {
echo -e "\e[31mERROR\e[0m $(</dev/stdin)$*" 1>&2
@@ -12,8 +13,7 @@ function _fatal {
declare -a PODMAN_ARGS=(
"--rm" "-i" "--log-driver=none"
"--network=host"
"--pid=host"
"-v" "$PLANTCTL_PROJECT_DIR:$PLANTCTL_PROJECT_DIR:rw"
"-v" "$PWD:$PWD:rw"
"-w" "$PWD"
)
@@ -22,8 +22,8 @@ declare -a PODMAN_ARGS=(
if ! podman image exists "$CONTAINER_IMAGE"; then
#attempt to build container
"$CONTAINER_TOOLS_BASEDIR/build-wch-tools-container.sh" 1>&2 ||
"$CONTAINER_TOOLS_BASEDIR/build-esp-plant-dev-tools.sh" 1>&2 ||
_fatal "faild to build local image, cannot continue! … please ensure you have an internet connection"
fi
podman run "${PODMAN_ARGS[@]}" --entrypoint riscv-none-elf-gdb-py3 "$CONTAINER_IMAGE" "$@"
podman run "${PODMAN_ARGS[@]}" --entrypoint npm "$CONTAINER_IMAGE" "$@"
Executable
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
CONTAINER_IMAGE="localhost/esp-plant-dev-tools:latest"
CONTAINER_TOOLS_BASEDIR="$(dirname "$(readlink -f "$0")")"
PLANTCTL_PROJECT_DIR="$(readlink -f "$CONTAINER_TOOLS_BASEDIR/..")"
function _fatal {
echo -e "\e[31mERROR\e[0m $(</dev/stdin)$*" 1>&2
exit 1
}
declare -a PODMAN_ARGS=(
"--rm" "-i" "--log-driver=none"
"-v" "$PLANTCTL_PROJECT_DIR:$PLANTCTL_PROJECT_DIR:rw"
"-v" "$PWD:$PWD:rw"
"-w" "$PWD"
)
[[ -t 1 ]] && PODMAN_ARGS+=("-t")
if ! podman image exists "$CONTAINER_IMAGE"; then
#attempt to build container
"$CONTAINER_TOOLS_BASEDIR/build-esp-plant-dev-tools.sh" 1>&2 ||
_fatal "faild to build local image, cannot continue! … please ensure you have an internet connection"
fi
podman run "${PODMAN_ARGS[@]}" --entrypoint npx "$CONTAINER_IMAGE" "$@"
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
CONTAINER_IMAGE="localhost/esp-plant-dev-tools:latest"
CONTAINER_TOOLS_BASEDIR="$(dirname "$(readlink -f "$0")")"
PLANTCTL_PROJECT_DIR="$(readlink -f "$CONTAINER_TOOLS_BASEDIR/..")"
function _fatal {
echo -e "\e[31mERROR\e[0m $(</dev/stdin)$*" 1>&2
exit 1
}
declare -a PODMAN_ARGS=(
"--rm" "-i" "--log-driver=none"
"-v" "$PLANTCTL_PROJECT_DIR:$PLANTCTL_PROJECT_DIR:rw"
"-v" "$PWD:$PWD:rw"
"-w" "$PWD"
)
[[ -t 1 ]] && PODMAN_ARGS+=("-t")
if ! podman image exists "$CONTAINER_IMAGE"; then
#attempt to build container
"$CONTAINER_TOOLS_BASEDIR/build-esp-plant-dev-tools.sh" 1>&2 ||
_fatal "faild to build local image, cannot continue! … please ensure you have an internet connection"
fi
podman run "${PODMAN_ARGS[@]}" --entrypoint riscv-none-elf-gcc "$CONTAINER_IMAGE" "$@"
-2
View File
@@ -34,5 +34,3 @@ _autosave-*
# Autorouter files (exported from Pcbnew)
fp-info-cache
*.zip
netlist.ipc
@@ -1 +0,0 @@
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
@@ -1 +0,0 @@
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
@@ -1 +0,0 @@
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
@@ -1 +0,0 @@
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
@@ -1 +0,0 @@
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
@@ -1,4 +0,0 @@
(fp_lib_table
(version 7)
(lib (name "Sensor")(type "KiCad")(uri "/home/empire/workspace/PlantCtrl/board/modules/Sensors/Sensors/Sensor.pretty")(options "")(descr ""))
)
@@ -1,71 +0,0 @@
P CODE 00
P UNITS CUST 0
P arrayDim N
317GND VIA MD0118PA00X+040551Y-024902X0236Y0000R000S3
317GND VIA MD0118PA00X+054232Y-022933X0236Y0000R000S3
317GND VIA MD0118PA00X+053346Y-021949X0236Y0000R000S3
317GND VIA MD0118PA00X+040846Y-019980X0236Y0000R000S3
317GND VIA MD0118PA00X+041043Y-025787X0236Y0000R000S3
317GND VIA MD0118PA00X+040059Y-019980X0236Y0000R000S3
317GND VIA MD0118PA00X+044291Y-025787X0236Y0000R000S3
317GND VIA MD0118PA00X+046654Y-025000X0236Y0000R000S3
317GND VIA MD0118PA00X+041240Y-021949X0236Y0000R000S3
317GND VIA MD0118PA00X+043307Y-020768X0236Y0000R000S3
317GND VIA MD0118PA00X+039961Y-022539X0236Y0000R000S3
317GND VIA MD0118PA00X+049606Y-021260X0236Y0000R000S3
317GND VIA MD0118PA00X+043898Y-024803X0236Y0000R000S3
317GND VIA MD0118PA00X+044587Y-023917X0236Y0000R000S3
317GND VIA MD0118PA00X+041142Y-024016X0236Y0000R000S3
317GND VIA MD0118PA00X+052461Y-022835X0236Y0000R000S3
317GND VIA MD0118PA00X+053642Y-024016X0236Y0000R000S3
317GND VIA MD0118PA00X+047835Y-026378X0236Y0000R000S3
317GND VIA MD0118PA00X+042618Y-020669X0236Y0000R000S3
317GND VIA MD0118PA00X+049409Y-022047X0236Y0000R000S3
317GND VIA MD0118PA00X+042520Y-022441X0236Y0000R000S3
317GND VIA MD0118PA00X+048622Y-022835X0236Y0000R000S3
327GND R_slop-1 A01X+053967Y-020177X0315Y0374R180S2
327NET-(U1-RS) R_slop-2 A01X+053317Y-020177X0315Y0374R180S2
3173_3V U6 -1 D0394PA00X+039016Y-019370X0669Y0669R000S0
317(U6-VBAT-PAD2) U6 -2 D0394PA00X+039016Y-020370X0669Y0000R000S0
317-(U6-SDA-PAD3) U6 -3 D0394PA00X+039016Y-021370X0669Y0000R000S0
317-(U6-SCL-PAD4) U6 -4 D0394PA00X+039016Y-022370X0669Y0000R000S0
317ENABLE_CAN U6 -5 D0394PA00X+039016Y-023370X0669Y0000R000S0
317CAN+ U6 -6 D0394PA00X+039016Y-024370X0669Y0000R000S0
317CAN- U6 -7 D0394PA00X+039016Y-025370X0669Y0000R000S0
317GND U6 -8 D0394PA00X+039016Y-026370X0669Y0000R000S0
317GND U6 -9 D0394PA00X+071260Y-034252X0669Y0669R000S0
317GND U6 -10 D0394PA00X+055512Y-031299X0669Y0669R000S0
317GND U6 -11 D0394PA00X+038780Y-034252X0669Y0669R000S0
317GND U6 -12 D0394PA00X+055512Y-020669X0669Y0669R000S0
317GND U6 -13 D0394PA00X+071260Y-019094X0669Y0669R000S0
327NET-(QP_1-G) QP_1 -1 A01X+047835Y-021280X0354Y0315R000S2
3273_3V QP_1 -2 A01X+047835Y-022028X0354Y0315R000S2
327CAN_POWER QP_1 -3 A01X+048622Y-021654X0354Y0315R000S2
327CAN_POWER R5 -1 A01X+047835Y-022904X0315Y0374R090S2
327NET-(I1-A) R5 -2 A01X+047835Y-023553X0315Y0374R090S2
327NET-(QP_1-G) R6 -1 A01X+046654Y-021329X0315Y0374R090S2
3273_3V R6 -2 A01X+046654Y-021978X0315Y0374R090S2
327NET-(QP_1-G) R7 -1 A01X+045669Y-021329X0315Y0374R090S2
327NET-(Q1-D) R7 -2 A01X+045669Y-021978X0315Y0374R090S2
317CAN_POWER J1 -1 D0374PA00X+055197Y-025394X0669Y0768R270S0
317NET-(J1-PIN_2) J1 -2 D0374PA00X+055197Y-024409X0669Y0768R270S0
317NET-(J1-PIN_3) J1 -3 D0374PA00X+055197Y-023425X0669Y0768R270S0
317GND J1 -4 D0374PA00X+055197Y-022441X0669Y0768R270S0
327NET-(Q1-G) Q1 -1 A01X+043819Y-021280X0354Y0315R000S2
327GND Q1 -2 A01X+043819Y-022028X0354Y0315R000S2
327NET-(Q1-D) Q1 -3 A01X+044606Y-021654X0354Y0315R000S2
327CAN+ U1 -1 A01X+050295Y-020707X0768Y0236R000S2
327GND U1 -2 A01X+050295Y-021207X0768Y0236R000S2
327CAN_POWER U1 -3 A01X+050295Y-021707X0768Y0236R000S2
327CAN- U1 -4 A01X+050295Y-022207X0768Y0236R000S2
327(U1-VREF-PAD5) U1 -5 A01X+052244Y-022207X0768Y0236R000S2
327NET-(J1-PIN_2) U1 -6 A01X+052244Y-021707X0768Y0236R000S2
327NET-(J1-PIN_3) U1 -7 A01X+052244Y-021207X0768Y0236R000S2
327NET-(U1-RS) U1 -8 A01X+052244Y-020707X0768Y0236R000S2
327NET-(Q1-G) R8 -1 A01X+042520Y-021329X0315Y0374R090S2
327GND R8 -2 A01X+042520Y-021978X0315Y0374R090S2
327GND I1 -1 A01X+047835Y-025541X0384Y0551R270S2
327NET-(I1-A) I1 -2 A01X+047835Y-024803X0384Y0551R270S2
327NET-(Q1-G) R4 -1 A01X+040846Y-023346X0315Y0374R180S2
327ENABLE_CAN R4 -2 A01X+040197Y-023346X0315Y0374R180S2
999
@@ -1,32 +0,0 @@
;;; .doomrc --- doom runtime config -*- mode: emacs-lisp; lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'doom) ; be silent, byte-compiler
(after! dape
(add-to-list
'dape-configs
`(gdb-dap-openocd
ensure (lambda (config)
(dape-ensure-command config)
(let* ((default-directory
(or (dape-config-get config 'command-cwd)
default-directory))
(command (dape-config-get config 'command))
(output (shell-command-to-string (format "%s --version" command)))
(version (save-match-data
(when (string-match "GNU gdb \\(?:(.*) \\)?\\([0-9.]+\\)" output)
(string-to-number (match-string 1 output))))))
(unless (>= version 14.1)
(user-error "Requires gdb version >= 14.1"))))
modes ()
command-cwd dape-command-cwd
command "gdb"
command-args ("--interpreter=dap")
:request nil
:program nil
:args []
:stopAtBeginningOfMainSubprogram nil))
)
;;; .doomrc ends here
-8
View File
@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
-10
View File
@@ -1,10 +0,0 @@
# ESP-IDF build artifacts
build/
.sdkconfig*
CMakeFiles/
CMakeCache.txt
cmake-build-*/
*.log
*.bin
*.elf
*.map
-8
View File
@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/bootloader.iml" filepath="$PROJECT_DIR$/.idea/bootloader.iml" />
</modules>
</component>
</project>
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../website/themes/blowfish" vcs="Git" />
</component>
</project>
-11
View File
@@ -1,11 +0,0 @@
cmake_minimum_required(VERSION 3.16)
# Minimal ESP-IDF project to build only the bootloader
# You must have ESP-IDF installed and IDF_PATH exported.
# Pin the target to ESP32-C6 to ensure correct bootloader build
# (must be set before including project.cmake)
set(IDF_TARGET "esp32c6")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(custom_bootloader)
-43
View File
@@ -1,43 +0,0 @@
Custom ESP-IDF Bootloader (Rollback Enabled)
This minimal project builds a custom ESP-IDF bootloader with rollback support enabled.
You can flash it later alongside a Rust firmware using `espflash`.
What this provides
- A minimal ESP-IDF project (CMake) that can build just the bootloader.
- Rollback support enabled via sdkconfig.defaults (CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y).
- A sample OTA partition table (partitions.csv) suitable for OTA and rollback (otadata + two OTA slots).
- A convenience script to build the bootloader for the desired target.
Requirements
- ESP-IDF installed and set up (IDF_PATH exported, Python env activated).
- A selected target (esp32, esp32s3, esp32c3, etc.).
Build
1) Ensure ESP-IDF is set up:
source "$IDF_PATH/export.sh"
2) Pick a target (examples):
idf.py set-target esp32
# or use the script:
./build_bootloader.sh esp32
3) Build only the bootloader:
idf.py bootloader
# or using the script (which also supports setting target):
./build_bootloader.sh esp32
Artifacts
- build/bootloader/bootloader.bin
Using with espflash (Rust)
- For a no_std Rust firmware, you can pass this custom bootloader to espflash:
espflash flash --bootloader build/bootloader/bootloader.bin \
--partition-table partitions.csv \
<your-app-binary-or-elf>
Notes
- Rollback logic requires an OTA layout (otadata + at least two OTA app partitions). The provided partitions.csv is a starting point; adjust sizes/offsets to match your needs.
- This project doesnt build an application; it exists solely to produce a bootloader with the right configuration.
- If you need different log verbosity or features, run `idf.py menuconfig` and then diff/port the changes back into sdkconfig.defaults.
- Targets supported depend on your ESP-IDF version. Use `idf.py set-target <chip>` or `./build_bootloader.sh <chip>`.
-41
View File
@@ -1,41 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# Build script for custom ESP-IDF bootloader with rollback enabled.
# Requirements:
# - ESP-IDF installed
# - IDF_PATH exported
# - Python env prepared (the usual ESP-IDF setup)
# Usage:
# ./build_bootloader.sh [esp32|esp32s3|esp32c3|esp32s2|esp32c2|esp32c6|esp32h2]
# If target is omitted, the last configured target will be used.
TARGET=${1:-}
if [[ -z "${IDF_PATH:-}" ]]; then
echo "ERROR: IDF_PATH is not set. Please install ESP-IDF and export the environment (source export.sh)." >&2
exit 1
fi
# shellcheck source=/dev/null
source "$IDF_PATH/export.sh"
if [[ -n "$TARGET" ]]; then
idf.py set-target "$TARGET"
fi
# Ensure sdkconfig.defaults is considered (ESP-IDF does this automatically).
# Build only the bootloader.
idf.py bootloader
echo
BOOTLOADER_BIN="build/bootloader/bootloader.bin"
if [[ -f "$BOOTLOADER_BIN" ]]; then
echo "Bootloader built: $BOOTLOADER_BIN"
echo "You can use this with espflash via:"
echo " espflash flash --bootloader $BOOTLOADER_BIN [--partition-table partitions.csv] <your-app-binary>"
else
echo "ERROR: Bootloader binary not found. Check build logs above." >&2
exit 2
fi
cp build/bootloader/bootloader.bin ../rust/bootloader.bin
-1
View File
@@ -1 +0,0 @@
idf_component_register(SRCS "dummy.c" INCLUDE_DIRS ".")
-4
View File
@@ -1,4 +0,0 @@
// This file intentionally left almost empty.
// ESP-IDF expects at least one component; the bootloader build does not use this.
void __unused_dummy_symbol(void) {}
-6
View File
@@ -1,6 +0,0 @@
nvs, data, nvs, , 16k,
otadata, data, ota, , 8k,
phy_init, data, phy, , 4k,
ota_0, app, ota_0, , 3968k,
ota_1, app, ota_1, , 3968k,
storage, data, littlefs,, 8M,
1 nvs data nvs 16k
2 otadata data ota 8k
3 phy_init data phy 4k
4 ota_0 app ota_0 3968k
5 ota_1 app ota_1 3968k
6 storage data littlefs 8M
-2385
View File
File diff suppressed because it is too large Load Diff
-17
View File
@@ -1,17 +0,0 @@
# Target can be set with: idf.py set-target esp32|esp32s3|esp32c3|...
# If not set via idf.py, ESP-IDF may default to a target; it's recommended to set it explicitly.
# Explicitly pin target to ESP32-C6
CONFIG_IDF_TARGET="esp32c6"
CONFIG_IDF_TARGET_ESP32C6=y
CONFIG_IDF_TARGET_ARCH_RISCV=y
# Bootloader configuration
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
# Slightly faster boot by skipping GPIO checks unless you need that feature
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
# Partition table config is not required to build bootloader, but shown for clarity when you build full app later
# CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
# CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -10,7 +10,7 @@ rustflags = [
target = "riscv32imac-unknown-none-elf"
[target.riscv32imac-unknown-none-elf]
#runner = "espflash flash --monitor --bootloader bootloader.bin --chip esp32c6 --baud 921600 --partition-table partitions.csv"
runner = "espflash flash --monitor --chip esp32c6 --baud 921600 --partition-table partitions.csv"
#runner = "espflash flash --monitor --baud 921600 --partition-table partitions.csv -b no-reset" # Select this runner in case of usb ttl
#runner = "espflash flash --monitor"
#runner = "cargo runner"
+2931
View File
File diff suppressed because it is too large Load Diff
+44 -80
View File
@@ -1,3 +1,4 @@
[package]
edition = "2021"
name = "plant-ctrl2"
@@ -13,6 +14,19 @@ test = false
bench = false
doc = false
[package.metadata.cargo_runner]
# The string `$TARGET_FILE` will be replaced with the path from cargo.
command = [
"cargo",
"espflash",
"save-image",
"--chip",
"esp32c6",
"image.bin",
"--partition-table",
"partitions.csv"
]
#this strips the bootloader, we need that tho
#strip = true
@@ -37,82 +51,44 @@ partition_table = "partitions.csv"
[dependencies]
# Shared CAN API
canapi = { path = "canapi" }
#ESP stuff
esp-bootloader-esp-idf = { version = "0.2.0", features = ["esp32c6"] }
esp-hal = { version = "=1.0.0-rc.0", features = [
"esp32c6",
"log-04",
"unstable",
"rt"
] }
log = "0.4.27"
log = "0.4.28"
esp-bootloader-esp-idf = { version = "0.5.0", features = ["esp32c6", "log-04"] }
esp-hal = { version = "1.1.0", features = ["esp32c6", "log-04"] }
esp-rtos = { version = "0.3.0", features = ["esp32c6", "embassy", "esp-radio"] }
esp-backtrace = { version = "0.19.0", features = ["esp32c6", "panic-handler", "println", "colors", "custom-halt"] }
esp-println = { version = "0.17.0", features = ["esp32c6", "log-04", "auto"] }
esp-storage = { version = "0.9.0", features = ["esp32c6"] }
esp-radio = { version = "0.18.0", features = ["esp32c6", "log-04", "wifi", "unstable"] }
esp-alloc = { version = "0.10.0", features = ["esp32c6", "internal-heap-stats"] }
embassy-net = { version = "0.7.1", default-features = false, features = [
"dhcpv4",
"log",
"medium-ethernet",
"tcp",
"udp",
"proto-ipv4",
"dns"
] }
embedded-io = "0.6.1"
embedded-io-async = "0.6.1"
esp-alloc = "0.8.0"
esp-backtrace = { version = "0.17.0", features = [
"esp32c6",
"exception-handler",
"panic-handler",
"println",
"colors",
"custom-halt"
] }
esp-println = { version = "0.15.0", features = ["esp32c6", "log-04"] }
# for more networking protocol support see https://crates.io/crates/edge-net
embassy-executor = { version = "0.7.0", features = [
"log",
"task-arena-size-64",
"nightly"
] }
embassy-time = { version = "0.5.0", features = ["log"], default-features = false }
esp-hal-embassy = { version = "0.9.0", features = ["esp32c6", "log-04"] }
esp-storage = { version = "0.7.0", features = ["esp32c6"] }
# Async runtime (Embassy core)
embassy-executor = { version = "0.10.0", features = ["log", "nightly"] }
embassy-time = { version = "0.5.1", features = ["log"], default-features = false }
embassy-sync = { version = "0.8.0", features = ["log"] }
esp-wifi = { version = "0.15.0", features = [
"builtin-scheduler",
"esp-alloc",
"esp32c6",
"log-04",
"smoltcp",
"wifi",
] }
smoltcp = { version = "0.12.0", default-features = false, features = [
"alloc",
"log",
"medium-ethernet",
"multicast",
"proto-dhcpv4",
"proto-ipv6",
"proto-dns",
"proto-ipv4",
"socket-dns",
"socket-icmp",
"socket-raw",
"socket-tcp",
"socket-udp",
] }
#static_cell = "2.1.1"
# Networking and protocol stacks
embassy-net = { version = "0.8.0", features = ["dhcpv4", "log", "medium-ethernet", "tcp", "udp", "proto-ipv4", "dns", "proto-ipv6"] }
sntpc = { version = "0.6.1", default-features = false, features = ["log", "embassy-socket", "embassy-socket-ipv6"] }
edge-dhcp = "0.7.0"
edge-nal = "0.6.0"
edge-nal-embassy = "0.8.1"
edge-http = { version = "0.7.0", features = ["log"] }
esp32c6 = { version = "0.23.2" }
# Hardware abstraction traits and HAL adapters
embedded-hal = "1.0.0"
embedded-hal-bus = { version = "0.3.0" }
embedded-storage = "0.3.1"
embassy-embedded-hal = "0.6.0"
nb = "1.1.0"
#Hardware additional driver
#bq34z100 = { version = "0.3.0", default-features = false }
lib-bms-protocol = { git = "https://gitea.wlandt.de/judge/ch32-bms.git", default-features = false }
onewire = "0.4.0"
#strum = { version = "0.27.0", default-feature = false, features = ["derive"] }
measurements = "0.11.0"
ds323x = "0.6.0"
#json
@@ -127,35 +103,23 @@ strum_macros = "0.27.0"
unit-enum = "1.4.1"
pca9535 = { version = "2.0.0" }
ina219 = { version = "0.2.0" }
embedded-storage = "=0.3.1"
portable-atomic = "1.11.1"
embassy-sync = { version = "0.7.2", features = ["log"] }
async-trait = "0.1.89"
bq34z100 = { version = "0.4.0", default-features = false }
edge-dhcp = "0.6.0"
edge-nal = "0.5.0"
edge-nal-embassy = "0.6.0"
static_cell = "2.1.1"
edge-http = { version = "0.6.1", features = ["log"] }
littlefs2 = { version = "0.6.1", features = ["c-stubs", "alloc"] }
littlefs2-core = "0.1.1"
bytemuck = { version = "1.23.2", features = ["derive", "min_const_generics", "pod_saturating", "extern_crate_alloc"] }
deranged = "0.5.3"
embassy-embedded-hal = "0.5.0"
bincode = { version = "2.0.1", default-features = false, features = ["derive"] }
sntpc = { version = "0.6.0", default-features = false, features = ["log", "embassy-socket", "embassy-socket-ipv6"] }
option-lock = { version = "0.3.1", default-features = false }
#stay in sync with mcutie version here!
measurements = "0.11.1"
heapless = { version = "0.7.17", features = ["serde"] }
mcutie = { version = "0.3.0", default-features = false, features = ["log", "homeassistant"] }
nb = "1.1.0"
embedded-can = "0.4.1"
mcutie = { path = "./src/mcutie_3_0_0/", default-features = false, features = ["log"] }
[patch.crates-io]
mcutie = { git = 'https://github.com/empirephoenix/mcutie.git' }
#bq34z100 = { path = "../../bq34z100_rust" }
[build-dependencies]
+20 -10
View File
@@ -1,12 +1,22 @@
rm ./src/webserver/index.html.gz
rm ./src/webserver/bundle.js.gz
set -e
cd ./src_webpack/
npx webpack build
cp index.html.gz ../src/webserver/index.html.gz
cp bundle.js.gz ../src/webserver/bundle.js.gz
cd ../
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
"${SCRIPT_DIR}/build_website.sh"
cargo build --release
espflash save-image --bootloader bootloader.bin --partition-table partitions.csv --chip esp32c6 target/riscv32imac-unknown-none-elf/release/plant-ctrl2 image.bin
espflash flash --monitor --bootloader bootloader.bin --chip esp32c6 --baud 921600 --partition-table partitions.csv target/riscv32imac-unknown-none-elf/release/plant-ctrl2
espflash save-image \
--bootloader "${SCRIPT_DIR}/bootloader.bin" \
--partition-table "${SCRIPT_DIR}/partitions.csv" \
--chip esp32c6 \
target/riscv32imac-unknown-none-elf/release/plant-ctrl2 \
"${SCRIPT_DIR}/image.bin"
espflash flash --monitor \
--bootloader "${SCRIPT_DIR}/bootloader.bin" \
--chip esp32c6 \
--baud 921600 \
--partition-table "${SCRIPT_DIR}/partitions.csv" \
target/riscv32imac-unknown-none-elf/release/plant-ctrl2
Binary file not shown.
+3
View File
@@ -49,5 +49,8 @@ fn linker_be_nice() {
fn main() {
linker_be_nice();
// Non-existent path causes Cargo to always re-run this script,
// keeping VERGEN_BUILD_TIMESTAMP fresh on every build.
println!("cargo:rerun-if-changed=ALWAYS_REBUILD_SENTINEL");
let _ = EmitBuilder::builder().all_git().all_build().emit();
}
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WEBPACK_DIR="${SCRIPT_DIR}/src_webpack"
WEBSERVER_DIR="${SCRIPT_DIR}/src/webserver"
rm -f "${WEBSERVER_DIR}/index.html.gz"
rm -f "${WEBSERVER_DIR}/bundle.js.gz"
rm -f "${WEBPACK_DIR}/index.html.gz"
rm -f "${WEBPACK_DIR}/bundle.js.gz"
rm -f "${WEBPACK_DIR}/index.html"
rm -f "${WEBPACK_DIR}/bundle.js"
pushd "${WEBPACK_DIR}"
npm install
npx webpack build
cp index.html.gz "${WEBSERVER_DIR}/index.html.gz"
cp bundle.js.gz "${WEBSERVER_DIR}/bundle.js.gz"
popd
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "canapi"
version = "0.1.0"
edition = "2021"
[lib]
name = "canapi"
path = "src/lib.rs"
[features]
default = []
[dependencies]
bincode = { version = "2.0.1", default-features = false, features = ["derive"] }
-138
View File
@@ -1,138 +0,0 @@
#![no_std]
//! CAN bus API shared crate for PlantCtrl sensors and controller.
//! Addressing and messages are defined here to be reused by all bus participants.
use bincode::{Decode, Encode};
/// Total plants supported by addressing (0..=15)
pub const MAX_PLANTS: u8 = 16;
/// Sensors per plant: 0..=1 => A/B
#[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)]
#[repr(u8)]
pub enum SensorSlot {
A = 0,
B = 1,
}
impl SensorSlot {
pub const fn from_index(idx: u8) -> Option<Self> {
match idx {
0 => Some(SensorSlot::A),
1 => Some(SensorSlot::B),
_ => None,
}
}
}
/// Legacy sensor base address kept for compatibility with existing code.
/// Each plant uses SENSOR_BASE_ADDRESS + plant_index (0..PLANT_COUNT-1).
/// 11-bit standard ID space, safe range.
pub const SENSOR_BASE_ADDRESS: u16 = 1000;
/// Typed topics within the SENSOR_BASE space.
/// Additional offsets allow distinct message semantics while keeping plant-indexed layout.
pub mod id {
use crate::{SensorSlot, MAX_PLANTS, SENSOR_BASE_ADDRESS};
/// Number of plants addressable per sensor slot group
pub const PLANTS_PER_GROUP: u16 = MAX_PLANTS as u16; // 16
/// Offset applied for SensorSlot::B within a message group
pub const B_OFFSET: u16 = PLANTS_PER_GROUP; // 16
// Message group base offsets relative to SENSOR_BASE_ADDRESS
pub const MOISTURE_DATA_OFFSET: u16 = 0; // periodic data from sensor (sensor -> controller)
pub const IDENTIFY_CMD_OFFSET: u16 = 32; // identify LED command (controller -> sensor)
// Convenience constants for per-slot base offsets
pub const IDENTIFY_CMD_OFFSET_A: u16 = IDENTIFY_CMD_OFFSET + 0;
pub const IDENTIFY_CMD_OFFSET_B: u16 = IDENTIFY_CMD_OFFSET + B_OFFSET;
#[inline]
pub const fn plant_id(message_type_offset: u16, sensor: SensorSlot, plant: u16) -> u16 {
match sensor {
SensorSlot::A => SENSOR_BASE_ADDRESS + message_type_offset + plant,
SensorSlot::B => SENSOR_BASE_ADDRESS + message_type_offset + B_OFFSET + plant,
}
}
/// Kinds of message spaces recognized by the addressing scheme.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MessageKind {
MoistureData, // sensor -> controller
IdentifyCmd, // controller -> sensor
}
/// Try to classify a received 11-bit standard ID into a known message kind and extract plant and sensor slot.
/// Returns (kind, plant, slot) on success.
#[inline]
pub const fn classify(id: u16) -> Option<(MessageKind, u8, SensorSlot)> {
// Ensure the ID is within our base space
if id < SENSOR_BASE_ADDRESS {
return None;
}
let rel = id - SENSOR_BASE_ADDRESS;
// Helper: decode within a given group offset
const fn decode_in_group(rel: u16, group_base: u16) -> Option<(u8, SensorSlot)> {
if rel < group_base { return None; }
let inner = rel - group_base;
if inner < PLANTS_PER_GROUP { // A slot
Some((inner as u8, SensorSlot::A))
} else if inner >= B_OFFSET && inner < B_OFFSET + PLANTS_PER_GROUP { // B slot
Some(((inner - B_OFFSET) as u8, SensorSlot::B))
} else {
None
}
}
// Check known groups in order
if let Some((plant, slot)) = decode_in_group(rel, MOISTURE_DATA_OFFSET) {
return Some((MessageKind::MoistureData, plant, slot));
}
if let Some((plant, slot)) = decode_in_group(rel, IDENTIFY_CMD_OFFSET) {
return Some((MessageKind::IdentifyCmd, plant, slot));
}
None
}
/// Returns Some((plant, slot)) regardless of message kind, if the id falls into any known group; otherwise None.
#[inline]
pub const fn extract_plant_slot(id: u16) -> Option<(u8, SensorSlot)> {
match classify(id) {
Some((_kind, plant, slot)) => Some((plant, slot)),
None => None,
}
}
/// Check if an id corresponds exactly to the given message kind, plant and slot.
#[inline]
pub const fn is_identify_for(id: u16, plant: u8, slot: SensorSlot) -> bool {
id == plant_id(IDENTIFY_CMD_OFFSET, slot, plant as u16)
}
#[inline]
pub const fn is_moisture_data_for(id: u16, plant: u8, slot: SensorSlot) -> bool {
id == plant_id(MOISTURE_DATA_OFFSET, slot, plant as u16)
}
}
/// Periodic moisture data sent by sensors.
/// Fits into 5 bytes with bincode-v2 (no varint): u8 + u8 + u16 = 4, alignment may keep 4.
#[derive(Debug, Clone, Copy, Encode, Decode)]
pub struct MoistureData {
pub plant: u8, // 0..MAX_PLANTS-1
pub sensor: SensorSlot, // A/B
pub hz: u16, // measured frequency of moisture sensor
}
/// Request a sensor to report immediately (controller -> sensor).
#[derive(Debug, Clone, Copy, Encode, Decode)]
pub struct MoistureRequest {
pub plant: u8,
pub sensor: SensorSlot, // target sensor (sensor filters by this)
}
/// Control a sensor's identify LED, if received by sensor, blink for a few seconds
#[derive(Debug, Clone, Copy, Encode, Decode)]
pub struct IdentifyLed {}
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cargo espflash erase-parts otadata --partition-table "${SCRIPT_DIR}/partitions.csv"
+13 -9
View File
@@ -1,11 +1,15 @@
rm ./src/webserver/index.html.gz
rm ./src/webserver/bundle.js.gz
set -e
cd ./src_webpack/
npx webpack build
cp index.html.gz ../src/webserver/index.html.gz
cp bundle.js.gz ../src/webserver/bundle.js.gz
cd ../
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
"${SCRIPT_DIR}/build_website.sh"
cargo build --release
espflash flash --monitor --bootloader bootloader.bin --chip esp32c6 --baud 921600 --partition-table partitions.csv target/riscv32imac-unknown-none-elf/release/plant-ctrl2
espflash flash --monitor \
--bootloader "${SCRIPT_DIR}/bootloader.bin" \
--chip esp32c6 \
--baud 921600 \
--partition-table "${SCRIPT_DIR}/partitions.csv" \
target/riscv32imac-unknown-none-elf/release/plant-ctrl2
+15 -11
View File
@@ -1,13 +1,17 @@
rm image.bin
rm ./src/webserver/index.html.gz
rm ./src/webserver/bundle.js.gz
set -e
cd ./src_webpack/
npx webpack build
cp index.html.gz ../src/webserver/index.html.gz
cp bundle.js.gz ../src/webserver/bundle.js.gz
cd ../
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rm -f "${SCRIPT_DIR}/image.bin"
"${SCRIPT_DIR}/build_website.sh"
set -e
cargo build --release
espflash save-image --bootloader bootloader.bin --partition-table partitions.csv --chip esp32c6 target/riscv32imac-unknown-none-elf/release/plant-ctrl2 image.bin
espflash save-image \
--bootloader "${SCRIPT_DIR}/bootloader.bin" \
--partition-table "${SCRIPT_DIR}/partitions.csv" \
--chip esp32c6 \
target/riscv32imac-unknown-none-elf/release/plant-ctrl2 \
"${SCRIPT_DIR}/image.bin"

Some files were not shown because too many files have changed in this diff Show More