Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da9859571b | ||
|
|
52603fb097 | ||
|
|
974ffadb1c | ||
|
|
eb4c3d1657 | ||
|
|
456b4f0b9a | ||
|
|
a338c9f65f | ||
|
|
fbf2e9a7c1 | ||
|
|
1377abe248 | ||
|
|
551225d308 | ||
|
|
7f2e3f6dad |
@@ -20,25 +20,60 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Firmware
|
name: Build Firmware
|
||||||
|
needs: [cppcheck, flawfinder, gitleaks]
|
||||||
runs-on: anvil
|
runs-on: anvil
|
||||||
container:
|
container:
|
||||||
image: docker.io/espressif/idf:v5.3
|
image: docker.io/espressif/idf:v5.3
|
||||||
|
volumes:
|
||||||
|
- /var/cache/ccache:/ccache
|
||||||
|
env:
|
||||||
|
CCACHE_DIR: /ccache
|
||||||
|
IDF_CCACHE_ENABLE: 1
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: |
|
run: |
|
||||||
git clone --depth=1 --branch=${{ github.ref_name }} \
|
git clone --depth=1 --branch=${{ github.ref_name }} \
|
||||||
https://oauth2:${{ github.token }}@git.mymx.me/${{ github.repository }}.git .
|
https://oauth2:${{ github.token }}@git.mymx.me/${{ github.repository }}.git .
|
||||||
|
|
||||||
|
- name: Setup ccache
|
||||||
|
run: |
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends ccache
|
||||||
|
ccache --zero-stats
|
||||||
|
ccache --show-config | grep -E "(cache_dir|max_size)"
|
||||||
|
|
||||||
- name: Build firmware
|
- name: Build firmware
|
||||||
run: |
|
run: |
|
||||||
. /opt/esp/idf/export.sh
|
. /opt/esp/idf/export.sh
|
||||||
cd get-started/csi_recv_router
|
cd get-started/csi_recv_router
|
||||||
idf.py build
|
idf.py build
|
||||||
|
|
||||||
|
- name: Show ccache stats
|
||||||
|
run: ccache --show-stats
|
||||||
|
|
||||||
- name: Show binary size
|
- name: Show binary size
|
||||||
run: |
|
run: |
|
||||||
ls -lh get-started/csi_recv_router/build/*.bin
|
ls -lh get-started/csi_recv_router/build/*.bin
|
||||||
|
|
||||||
|
- name: Check firmware size
|
||||||
|
run: |
|
||||||
|
BIN="get-started/csi_recv_router/build/csi_recv_router.bin"
|
||||||
|
MAX_SIZE=1966080 # 0x1E0000 = 1920 KB partition
|
||||||
|
WARN_PERCENT=85
|
||||||
|
|
||||||
|
SIZE=$(stat -c%s "$BIN")
|
||||||
|
PERCENT=$((SIZE * 100 / MAX_SIZE))
|
||||||
|
|
||||||
|
echo "Firmware: $((SIZE/1024)) KB / $((MAX_SIZE/1024)) KB ($PERCENT%)"
|
||||||
|
|
||||||
|
if [ $SIZE -gt $MAX_SIZE ]; then
|
||||||
|
echo "::error::Firmware exceeds partition size!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $PERCENT -gt $WARN_PERCENT ]; then
|
||||||
|
echo "::warning::Firmware using $PERCENT% of partition"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Upload firmware artifact
|
- name: Upload firmware artifact
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/artifacts
|
mkdir -p /tmp/artifacts
|
||||||
@@ -56,11 +91,10 @@ jobs:
|
|||||||
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true' || startsWith(github.ref, 'refs/tags/v')
|
||||||
container:
|
container:
|
||||||
image: docker.io/espressif/idf:v5.3
|
image: docker.io/espressif/idf:v5.3
|
||||||
options: --network host
|
options: --network=host
|
||||||
steps:
|
steps:
|
||||||
- name: Install tools
|
- name: Install tools
|
||||||
run: |
|
run: apt-get update && apt-get install -y --no-install-recommends git curl jq netcat-openbsd
|
||||||
apt-get update && apt-get install -y --no-install-recommends netcat-openbsd curl jq
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: |
|
run: |
|
||||||
@@ -73,6 +107,19 @@ jobs:
|
|||||||
cd get-started/csi_recv_router
|
cd get-started/csi_recv_router
|
||||||
idf.py build
|
idf.py build
|
||||||
|
|
||||||
|
- name: Validate version tag
|
||||||
|
run: |
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
# Extract version from binary metadata
|
||||||
|
BIN_VER=$(strings get-started/csi_recv_router/build/csi_recv_router.bin | grep -oP '^v\d+\.\d+(\.\d+)?' | head -1)
|
||||||
|
|
||||||
|
echo "Git tag: $TAG"
|
||||||
|
echo "Binary version: $BIN_VER"
|
||||||
|
|
||||||
|
if [ "$TAG" != "$BIN_VER" ]; then
|
||||||
|
echo "::warning::Tag ($TAG) differs from binary ($BIN_VER)"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create release and upload firmware
|
- name: Create release and upload firmware
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ github.token }}
|
GITEA_TOKEN: ${{ github.token }}
|
||||||
@@ -110,8 +157,8 @@ jobs:
|
|||||||
- name: Deploy via OTA
|
- name: Deploy via OTA
|
||||||
run: |
|
run: |
|
||||||
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
SENSORS="muddy-storm:192.168.129.29 amber-maple:192.168.129.30 hollow-acorn:192.168.129.31"
|
||||||
FIRMWARE_PATH="get-started/csi_recv_router/build/csi_recv_router.bin"
|
|
||||||
OTA_PORT=8899
|
OTA_PORT=8899
|
||||||
|
EXPECTED_VERSION="${{ github.ref_name }}"
|
||||||
|
|
||||||
# Get runner IP (first non-loopback interface)
|
# Get runner IP (first non-loopback interface)
|
||||||
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
RUNNER_IP=$(hostname -I | awk '{print $1}')
|
||||||
@@ -129,19 +176,65 @@ jobs:
|
|||||||
# Verify server is running
|
# Verify server is running
|
||||||
curl -sI "http://localhost:${OTA_PORT}/csi_recv_router.bin" | head -1
|
curl -sI "http://localhost:${OTA_PORT}/csi_recv_router.bin" | head -1
|
||||||
|
|
||||||
# Deploy to each sensor
|
# Deploy to all sensors in parallel
|
||||||
|
echo "=== Deploying to all sensors in parallel ==="
|
||||||
for entry in $SENSORS; do
|
for entry in $SENSORS; do
|
||||||
NAME="${entry%%:*}"
|
NAME="${entry%%:*}"
|
||||||
IP="${entry##*:}"
|
IP="${entry##*:}"
|
||||||
echo "=== Deploying to $NAME ($IP) ==="
|
echo "OTA $FIRMWARE_URL" | nc -u -w 2 "$IP" 5501 &
|
||||||
echo "OTA $FIRMWARE_URL" | nc -u -w 2 "$IP" 5501 || true
|
done
|
||||||
sleep 45
|
wait
|
||||||
|
|
||||||
|
# Monitor progress
|
||||||
|
echo "=== Monitoring OTA progress (timeout: 90s) ==="
|
||||||
|
TIMEOUT=90
|
||||||
|
INTERVAL=5
|
||||||
|
ELAPSED=0
|
||||||
|
|
||||||
|
while [ $ELAPSED -lt $TIMEOUT ]; do
|
||||||
|
sleep $INTERVAL
|
||||||
|
ELAPSED=$((ELAPSED + INTERVAL))
|
||||||
|
|
||||||
|
echo "--- Progress check at ${ELAPSED}s ---"
|
||||||
|
ALL_UPDATED=true
|
||||||
|
|
||||||
|
for entry in $SENSORS; do
|
||||||
|
NAME="${entry%%:*}"
|
||||||
|
IP="${entry##*:}"
|
||||||
|
|
||||||
|
# Query sensor version via UDP STATUS command
|
||||||
|
RESPONSE=$(echo "STATUS" | nc -u -w 1 "$IP" 5501 2>/dev/null || echo "")
|
||||||
|
VERSION=$(echo "$RESPONSE" | grep -oP 'version=\K[^ ]+' || echo "offline")
|
||||||
|
|
||||||
|
if [ "$VERSION" = "$EXPECTED_VERSION" ]; then
|
||||||
|
echo " $NAME: ✓ $VERSION"
|
||||||
|
elif [ "$VERSION" = "offline" ] || [ -z "$VERSION" ]; then
|
||||||
|
echo " $NAME: ⟳ updating..."
|
||||||
|
ALL_UPDATED=false
|
||||||
|
else
|
||||||
|
echo " $NAME: $VERSION (waiting for $EXPECTED_VERSION)"
|
||||||
|
ALL_UPDATED=false
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$ALL_UPDATED" = true ]; then
|
||||||
|
echo "=== All sensors updated to $EXPECTED_VERSION ==="
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Stop HTTP server
|
# Stop HTTP server
|
||||||
kill $HTTP_PID 2>/dev/null || true
|
kill $HTTP_PID 2>/dev/null || true
|
||||||
|
|
||||||
echo "=== Deployment complete ==="
|
# Final status
|
||||||
|
echo "=== Final sensor status ==="
|
||||||
|
for entry in $SENSORS; do
|
||||||
|
NAME="${entry%%:*}"
|
||||||
|
IP="${entry##*:}"
|
||||||
|
RESPONSE=$(echo "STATUS" | nc -u -w 1 "$IP" 5501 2>/dev/null || echo "")
|
||||||
|
VERSION=$(echo "$RESPONSE" | grep -oP 'version=\K[^ ]+' || echo "offline")
|
||||||
|
echo " $NAME: $VERSION"
|
||||||
|
done
|
||||||
|
|
||||||
cppcheck:
|
cppcheck:
|
||||||
name: C/C++ Static Analysis
|
name: C/C++ Static Analysis
|
||||||
@@ -201,27 +294,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run gitleaks
|
- name: Run gitleaks
|
||||||
run: gitleaks detect --source . --verbose --redact
|
run: gitleaks detect --source . --verbose --redact
|
||||||
|
|
||||||
shellcheck:
|
|
||||||
name: Shell Script Analysis
|
|
||||||
runs-on: anvil
|
|
||||||
container:
|
|
||||||
image: docker.io/koalaman/shellcheck-alpine:stable
|
|
||||||
steps:
|
|
||||||
- name: Install git
|
|
||||||
run: apk add --no-cache git
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
run: |
|
|
||||||
git clone --depth=1 --branch=${{ github.ref_name }} \
|
|
||||||
https://oauth2:${{ github.token }}@git.mymx.me/${{ github.repository }}.git .
|
|
||||||
|
|
||||||
- name: Find and check shell scripts
|
|
||||||
run: |
|
|
||||||
SCRIPTS=$(find . -name "*.sh" -type f 2>/dev/null || true)
|
|
||||||
if [ -n "$SCRIPTS" ]; then
|
|
||||||
echo "Checking: $SCRIPTS"
|
|
||||||
echo "$SCRIPTS" | xargs shellcheck --severity=warning
|
|
||||||
else
|
|
||||||
echo "No shell scripts found, skipping"
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
#include "esp_https_ota.h"
|
#include "esp_https_ota.h"
|
||||||
#include "esp_partition.h"
|
#include "esp_partition.h"
|
||||||
|
#include "esp_chip_info.h"
|
||||||
#include "esp_http_client.h"
|
#include "esp_http_client.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
@@ -1532,14 +1533,13 @@ static int cmd_handle(const char *cmd, char *reply, size_t reply_size)
|
|||||||
/* Partition info */
|
/* Partition info */
|
||||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||||
uint32_t part_size = running ? running->size : 0;
|
uint32_t part_size = running ? running->size : 0;
|
||||||
uint32_t app_size = 0;
|
|
||||||
if (running) {
|
/* Chip info */
|
||||||
esp_app_desc_t desc;
|
esp_chip_info_t chip_info;
|
||||||
if (esp_ota_get_partition_description(running, &desc) == ESP_OK) {
|
esp_chip_info(&chip_info);
|
||||||
/* App size not directly available, use partition size */
|
const char *chip_model = (chip_info.model == CHIP_ESP32S3) ? "ESP32S3" :
|
||||||
app_size = part_size;
|
(chip_info.model == CHIP_ESP32C3) ? "ESP32C3" :
|
||||||
}
|
(chip_info.model == CHIP_ESP32) ? "ESP32" : "ESP32xx";
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(reply, reply_size,
|
snprintf(reply, reply_size,
|
||||||
"OK STATUS uptime=%s uptime_s=%lld heap=%lu rssi=%d channel=%d tx_power=%d rate=%d csi_rate=%d"
|
"OK STATUS uptime=%s uptime_s=%lld heap=%lu rssi=%d channel=%d tx_power=%d rate=%d csi_rate=%d"
|
||||||
@@ -1547,7 +1547,8 @@ static int cmd_handle(const char *cmd, char *reply, size_t reply_size)
|
|||||||
" temp=%.1f csi_count=%lu boots=%lu rssi_min=%d rssi_max=%d"
|
" temp=%.1f csi_count=%lu boots=%lu rssi_min=%d rssi_max=%d"
|
||||||
" csi_mode=%s hybrid_n=%d auth=%s flood_thresh=%d/%d powersave=%s"
|
" csi_mode=%s hybrid_n=%d auth=%s flood_thresh=%d/%d powersave=%s"
|
||||||
" presence=%s pr_score=%.4f chanscan=%s"
|
" presence=%s pr_score=%.4f chanscan=%s"
|
||||||
" nvs_used=%lu nvs_free=%lu nvs_total=%lu part_size=%lu",
|
" nvs_used=%lu nvs_free=%lu nvs_total=%lu part_size=%lu"
|
||||||
|
" built=%s_%s idf=%s chip=%sr%dc%d",
|
||||||
uptime_str, (long long)up, (unsigned long)heap, rssi, channel, (int)s_tx_power_dbm,
|
uptime_str, (long long)up, (unsigned long)heap, rssi, channel, (int)s_tx_power_dbm,
|
||||||
s_send_frequency, actual_rate,
|
s_send_frequency, actual_rate,
|
||||||
s_hostname, app_desc->version,
|
s_hostname, app_desc->version,
|
||||||
@@ -1564,7 +1565,9 @@ static int cmd_handle(const char *cmd, char *reply, size_t reply_size)
|
|||||||
(unsigned long)nvs_stats.used_entries,
|
(unsigned long)nvs_stats.used_entries,
|
||||||
(unsigned long)nvs_stats.free_entries,
|
(unsigned long)nvs_stats.free_entries,
|
||||||
(unsigned long)nvs_stats.total_entries,
|
(unsigned long)nvs_stats.total_entries,
|
||||||
(unsigned long)part_size);
|
(unsigned long)part_size,
|
||||||
|
app_desc->date, app_desc->time, app_desc->idf_ver,
|
||||||
|
chip_model, chip_info.revision, chip_info.cores);
|
||||||
return strlen(reply);
|
return strlen(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=
|
|||||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=
|
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compiler options
|
# Compiler options (size optimization saves ~75 KB)
|
||||||
#
|
#
|
||||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# FreeRTOS
|
# FreeRTOS
|
||||||
|
|||||||
Reference in New Issue
Block a user