Compare commits
11 Commits
legacy/v3-
...
45e948636b
| Author | SHA1 | Date | |
|---|---|---|---|
| 45e948636b | |||
| 083573de4a | |||
| e5c5f31112 | |||
| 7f3910bcd0 | |||
| 712e8c8b8f | |||
| 4ba68182e5 | |||
| a3cdd92af8 | |||
| 894be7c373 | |||
| 0ddf6a6886 | |||
| 27b18df78e | |||
| 9c6dcc465e |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -8,15 +8,6 @@ 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/
|
||||
|
||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
||||
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
|
||||
29
bin/npm
29
bin/npm
@@ -1,29 +0,0 @@
|
||||
#!/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 npm "$CONTAINER_IMAGE" "$@"
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/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
board/.gitignore
vendored
2
board/.gitignore
vendored
@@ -34,3 +34,5 @@ _autosave-*
|
||||
|
||||
# Autorouter files (exported from Pcbnew)
|
||||
fp-info-cache
|
||||
*.zip
|
||||
netlist.ipc
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
1
board/modules/3v3/fabrication-toolkit-options.json
Normal file
1
board/modules/3v3/fabrication-toolkit-options.json
Normal file
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
||||
1
board/modules/LightOut/fabrication-toolkit-options.json
Normal file
1
board/modules/LightOut/fabrication-toolkit-options.json
Normal file
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
||||
1
board/modules/MPPT/fabrication-toolkit-options.json
Normal file
1
board/modules/MPPT/fabrication-toolkit-options.json
Normal file
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
||||
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
||||
@@ -0,0 +1 @@
|
||||
{"EXTRA_LAYERS": "", "ALL_ACTIVE_LAYERS": false, "EXTEND_EDGE_CUT": false, "ALTERNATIVE_EDGE_CUT": false, "AUTO TRANSLATE": true, "AUTO FILL": true, "EXCLUDE DNP": false}
|
||||
4
board/modules/Sensors_can/Sensors/fp-lib-table
Normal file
4
board/modules/Sensors_can/Sensors/fp-lib-table
Normal file
@@ -0,0 +1,4 @@
|
||||
(fp_lib_table
|
||||
(version 7)
|
||||
(lib (name "Sensor")(type "KiCad")(uri "/home/empire/workspace/PlantCtrl/board/modules/Sensors/Sensors/Sensor.pretty")(options "")(descr ""))
|
||||
)
|
||||
71
board/modules/Sensors_can/Sensors/production/netlist.ipc
Normal file
71
board/modules/Sensors_can/Sensors/production/netlist.ipc
Normal file
@@ -0,0 +1,71 @@
|
||||
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
|
||||
32
board/modules/Sensors_can/ch32-sensor/.doomrc
Normal file
32
board/modules/Sensors_can/ch32-sensor/.doomrc
Normal file
@@ -0,0 +1,32 @@
|
||||
;;; .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
board/modules/Sensors_can/ch32-sensor/.idea/.gitignore
generated
vendored
Normal file
8
board/modules/Sensors_can/ch32-sensor/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
11
board/modules/Sensors_can/ch32-sensor/.idea/ch32-sensor.iml
generated
Normal file
11
board/modules/Sensors_can/ch32-sensor/.idea/ch32-sensor.iml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<?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
bootloader/.gitignore
vendored
Normal file
10
bootloader/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# ESP-IDF build artifacts
|
||||
build/
|
||||
.sdkconfig*
|
||||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
cmake-build-*/
|
||||
*.log
|
||||
*.bin
|
||||
*.elf
|
||||
*.map
|
||||
8
bootloader/.idea/.gitignore
generated
vendored
Normal file
8
bootloader/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
8
bootloader/.idea/bootloader.iml
generated
Normal file
8
bootloader/.idea/bootloader.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?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
bootloader/.idea/modules.xml
generated
Normal file
8
bootloader/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?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
bootloader/.idea/vcs.xml
generated
Normal file
7
bootloader/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?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
bootloader/CMakeLists.txt
Normal file
11
bootloader/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
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
bootloader/README.md
Normal file
43
bootloader/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
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 doesn’t 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
bootloader/build_bootloader.sh
Executable file
41
bootloader/build_bootloader.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/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
bootloader/main/CMakeLists.txt
Normal file
1
bootloader/main/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
idf_component_register(SRCS "dummy.c" INCLUDE_DIRS ".")
|
||||
4
bootloader/main/dummy.c
Normal file
4
bootloader/main/dummy.c
Normal file
@@ -0,0 +1,4 @@
|
||||
// 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
bootloader/partitions.csv
Normal file
6
bootloader/partitions.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
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,
|
||||
|
2385
bootloader/sdkconfig
Normal file
2385
bootloader/sdkconfig
Normal file
File diff suppressed because it is too large
Load Diff
17
bootloader/sdkconfig.defaults
Normal file
17
bootloader/sdkconfig.defaults
Normal file
@@ -0,0 +1,17 @@
|
||||
# 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"
|
||||
2214
bootloader/sdkconfig.old
Normal file
2214
bootloader/sdkconfig.old
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ rustflags = [
|
||||
target = "riscv32imac-unknown-none-elf"
|
||||
|
||||
[target.riscv32imac-unknown-none-elf]
|
||||
runner = "espflash flash --monitor --chip esp32c6 --baud 921600 --partition-table partitions.csv"
|
||||
#runner = "espflash flash --monitor --bootloader bootloader.bin --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
rust/Cargo.lock
generated
2931
rust/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
124
rust/Cargo.toml
124
rust/Cargo.toml
@@ -1,4 +1,3 @@
|
||||
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "plant-ctrl2"
|
||||
@@ -14,19 +13,6 @@ 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
|
||||
|
||||
@@ -51,44 +37,82 @@ partition_table = "partitions.csv"
|
||||
|
||||
|
||||
[dependencies]
|
||||
# Shared CAN API
|
||||
canapi = { path = "canapi" }
|
||||
#ESP stuff
|
||||
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"] }
|
||||
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"
|
||||
|
||||
# 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"] }
|
||||
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"] }
|
||||
|
||||
# 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
|
||||
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"
|
||||
embedded-hal = "1.0.0"
|
||||
embedded-storage = "0.3.1"
|
||||
embassy-embedded-hal = "0.6.0"
|
||||
nb = "1.1.0"
|
||||
embedded-hal-bus = { version = "0.3.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
|
||||
@@ -103,23 +127,35 @@ 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 }
|
||||
measurements = "0.11.1"
|
||||
|
||||
#stay in sync with mcutie version here!
|
||||
heapless = { version = "0.7.17", features = ["serde"] }
|
||||
mcutie = { path = "./src/mcutie_3_0_0/", default-features = false, features = ["log"] }
|
||||
mcutie = { version = "0.3.0", default-features = false, features = ["log", "homeassistant"] }
|
||||
nb = "1.1.0"
|
||||
embedded-can = "0.4.1"
|
||||
|
||||
|
||||
|
||||
[patch.crates-io]
|
||||
mcutie = { git = 'https://github.com/empirephoenix/mcutie.git' }
|
||||
#bq34z100 = { path = "../../bq34z100_rust" }
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
30
rust/all.sh
30
rust/all.sh
@@ -1,22 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
"${SCRIPT_DIR}/build_website.sh"
|
||||
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 ../
|
||||
|
||||
cargo build --release
|
||||
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
|
||||
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
|
||||
|
||||
Binary file not shown.
@@ -49,8 +49,5 @@ 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();
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/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
rust/canapi/Cargo.toml
Normal file
14
rust/canapi/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[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
rust/canapi/src/lib.rs
Normal file
138
rust/canapi/src/lib.rs
Normal file
@@ -0,0 +1,138 @@
|
||||
#![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 {}
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/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"
|
||||
@@ -1,15 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
"${SCRIPT_DIR}/build_website.sh"
|
||||
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 ../
|
||||
|
||||
cargo build --release
|
||||
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
|
||||
espflash flash --monitor --bootloader bootloader.bin --chip esp32c6 --baud 921600 --partition-table partitions.csv target/riscv32imac-unknown-none-elf/release/plant-ctrl2
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
#!/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"
|
||||
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 ../
|
||||
|
||||
set -e
|
||||
cargo build --release
|
||||
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 save-image --bootloader bootloader.bin --partition-table partitions.csv --chip esp32c6 target/riscv32imac-unknown-none-elf/release/plant-ctrl2 image.bin
|
||||
|
||||
@@ -6,9 +6,11 @@ use core::str::Utf8Error;
|
||||
use embassy_embedded_hal::shared_bus::I2cDeviceError;
|
||||
use embassy_executor::SpawnError;
|
||||
use embassy_sync::mutex::TryLockError;
|
||||
use embedded_storage::nor_flash::NorFlashErrorKind;
|
||||
use esp_hal::i2c::master::ConfigError;
|
||||
use esp_hal::pcnt::unit::{InvalidHighLimit, InvalidLowLimit};
|
||||
use esp_radio::wifi::WifiError;
|
||||
use esp_hal::twai::EspTwaiError;
|
||||
use esp_wifi::wifi::WifiError;
|
||||
use ina219::errors::{BusVoltageReadError, ShuntVoltageReadError};
|
||||
use littlefs2_core::PathError;
|
||||
use onewire::Error;
|
||||
@@ -45,7 +47,6 @@ pub enum FatError {
|
||||
SpawnError {
|
||||
error: SpawnError,
|
||||
},
|
||||
OTAError,
|
||||
PartitionError {
|
||||
error: esp_bootloader_esp_idf::partitions::Error,
|
||||
},
|
||||
@@ -61,6 +62,9 @@ pub enum FatError {
|
||||
ExpanderError {
|
||||
error: String,
|
||||
},
|
||||
CanBusError {
|
||||
error: EspTwaiError,
|
||||
},
|
||||
SNTPError {
|
||||
error: sntpc::Error,
|
||||
},
|
||||
@@ -92,10 +96,10 @@ impl fmt::Display for FatError {
|
||||
FatError::DS323 { error } => write!(f, "DS323 {:?}", error),
|
||||
FatError::Eeprom24x { error } => write!(f, "Eeprom24x {:?}", error),
|
||||
FatError::ExpanderError { error } => write!(f, "ExpanderError {:?}", error),
|
||||
FatError::SNTPError { error } => write!(f, "SNTPError {error:?}"),
|
||||
FatError::OTAError => {
|
||||
write!(f, "OTA missing partition")
|
||||
FatError::CanBusError { error } => {
|
||||
write!(f, "CanBusError {:?}", error)
|
||||
}
|
||||
FatError::SNTPError { error } => write!(f, "SNTPError {:?}", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,24 +139,6 @@ impl<T> ContextExt<T> for Option<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> ContextExt<T> for Result<T, E>
|
||||
where
|
||||
E: fmt::Debug,
|
||||
{
|
||||
fn context<C>(self, context: C) -> Result<T, FatError>
|
||||
where
|
||||
C: AsRef<str>,
|
||||
{
|
||||
match self {
|
||||
Ok(value) => Ok(value),
|
||||
Err(err) => Err(FatError::String {
|
||||
error: format!("{}: {:?}", context.as_ref(), err),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl From<Error<Infallible>> for FatError {
|
||||
fn from(error: Error<Infallible>) -> Self {
|
||||
FatError::OneWireError { error }
|
||||
@@ -194,12 +180,6 @@ impl From<SpawnError> for FatError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sntpc::Error> for FatError {
|
||||
fn from(value: sntpc::Error) -> Self {
|
||||
FatError::SNTPError { error: value }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<esp_bootloader_esp_idf::partitions::Error> for FatError {
|
||||
fn from(value: esp_bootloader_esp_idf::partitions::Error) -> Self {
|
||||
FatError::PartitionError { error: value }
|
||||
@@ -312,10 +292,27 @@ impl From<InvalidHighLimit> for FatError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<chrono::format::ParseError> for FatError {
|
||||
fn from(value: chrono::format::ParseError) -> Self {
|
||||
FatError::String {
|
||||
error: format!("Parsing error: {value:?}"),
|
||||
impl From<nb::Error<EspTwaiError>> for FatError {
|
||||
fn from(value: nb::Error<EspTwaiError>) -> Self {
|
||||
match value {
|
||||
nb::Error::Other(can_error) => FatError::CanBusError { error: can_error },
|
||||
nb::Error::WouldBlock => FatError::String {
|
||||
error: "Would block".to_string(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NorFlashErrorKind> for FatError {
|
||||
fn from(value: NorFlashErrorKind) -> Self {
|
||||
FatError::String {
|
||||
error: value.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<sntpc::Error> for FatError {
|
||||
fn from(value: sntpc::Error) -> Self {
|
||||
FatError::SNTPError { error: value }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::fat_error::{FatError, FatResult};
|
||||
use crate::hal::Box;
|
||||
use alloc::string::String;
|
||||
use async_trait::async_trait;
|
||||
use bq34z100::{Bq34z100g1, Bq34z100g1Driver, Flags};
|
||||
use embassy_embedded_hal::shared_bus::blocking::i2c::I2cDevice;
|
||||
@@ -11,7 +10,7 @@ use esp_hal::Blocking;
|
||||
use measurements::Temperature;
|
||||
use serde::Serialize;
|
||||
|
||||
#[async_trait]
|
||||
#[async_trait(?Send)]
|
||||
pub trait BatteryInteraction {
|
||||
async fn state_charge_percent(&mut self) -> FatResult<f32>;
|
||||
async fn remaining_milli_ampere_hour(&mut self) -> FatResult<u16>;
|
||||
@@ -37,12 +36,6 @@ pub struct BatteryInfo {
|
||||
pub temperature: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum BatteryError {
|
||||
NoBatteryMonitor,
|
||||
CommunicationError(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum BatteryState {
|
||||
Unknown,
|
||||
@@ -51,7 +44,7 @@ pub enum BatteryState {
|
||||
|
||||
/// If no battery monitor is installed this implementation will be used
|
||||
pub struct NoBatteryMonitor {}
|
||||
#[async_trait]
|
||||
#[async_trait(?Send)]
|
||||
impl BatteryInteraction for NoBatteryMonitor {
|
||||
async fn state_charge_percent(&mut self) -> FatResult<f32> {
|
||||
// No monitor configured: assume full battery for lightstate logic
|
||||
@@ -105,7 +98,7 @@ pub struct BQ34Z100G1 {
|
||||
pub battery_driver: Bq34z100g1Driver<I2cDev, Delay>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
#[async_trait(?Send)]
|
||||
impl BatteryInteraction for BQ34Z100G1 {
|
||||
async fn state_charge_percent(&mut self) -> FatResult<f32> {
|
||||
self.battery_driver
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user