Compare commits
4 Commits
52cf46d7f8
...
1b9c79b559
Author | SHA1 | Date | |
---|---|---|---|
1b9c79b559 | |||
37e1e861d3 | |||
cce39319d9 | |||
6391054c23 |
112
.github/workflows/providers/gitea-release.yml
vendored
112
.github/workflows/providers/gitea-release.yml
vendored
@ -4,15 +4,12 @@ on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
gitea_ref_name:
|
||||
description: 'Gitea ref name'
|
||||
required: true
|
||||
type: string
|
||||
gitea_server_url:
|
||||
description: 'Gitea server URL'
|
||||
required: true
|
||||
type: string
|
||||
gitea_repository:
|
||||
description: 'Gitea repository'
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
@ -23,109 +20,106 @@ jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install System Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3 python3-venv build-essential curl git
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Set up Python Virtual Environment
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
python -m pip install --upgrade pip
|
||||
pip install platformio esptool
|
||||
|
||||
echo "Verifying installations:"
|
||||
platformio --version
|
||||
python3 --version
|
||||
esptool.py version
|
||||
|
||||
- name: Build Firmware
|
||||
run: |
|
||||
source venv/bin/activate
|
||||
echo "Building SPIFFS..."
|
||||
# Build SPIFFS first
|
||||
platformio run -t buildfs
|
||||
|
||||
echo "Building firmware..."
|
||||
# Then build firmware
|
||||
platformio run
|
||||
|
||||
- name: Create Release Files
|
||||
- name: Prepare Release Files
|
||||
run: |
|
||||
source venv/bin/activate
|
||||
echo "Creating release files..."
|
||||
cd .pio/build/esp32dev
|
||||
|
||||
# Get bootloader
|
||||
BOOTLOADER_PATH=$(find ~/.platformio -name "bootloader_dio_40m.bin" | head -n 1)
|
||||
if [ ! -f "$BOOTLOADER_PATH" ]; then
|
||||
echo "Error: bootloader not found!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Using bootloader from: $BOOTLOADER_PATH"
|
||||
cp "$BOOTLOADER_PATH" bootloader.bin
|
||||
|
||||
# Create OTA update binary (firmware only)
|
||||
cp firmware.bin filaman_ota.bin
|
||||
|
||||
# Create full binary
|
||||
echo "Creating full binary..."
|
||||
esptool.py --chip esp32 merge_bin \
|
||||
-o filaman_full.bin \
|
||||
--flash_mode dio \
|
||||
--flash_freq 40m \
|
||||
--flash_size 4MB \
|
||||
-o .pio/build/esp32dev/filaman_full.bin \
|
||||
0x1000 .pio/build/esp32dev/bootloader.bin \
|
||||
0x8000 .pio/build/esp32dev/partitions.bin \
|
||||
0x10000 .pio/build/esp32dev/firmware.bin \
|
||||
0x3D0000 .pio/build/esp32dev/spiffs.bin
|
||||
0x1000 bootloader.bin \
|
||||
0x8000 partitions.bin \
|
||||
0x10000 firmware.bin \
|
||||
0x3D0000 spiffs.bin
|
||||
|
||||
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/filaman_ota.bin
|
||||
# Verify results
|
||||
echo "File sizes:"
|
||||
ls -l bootloader.bin partitions.bin firmware.bin spiffs.bin filaman_full.bin filaman_ota.bin
|
||||
|
||||
echo "Firmware info:"
|
||||
esptool.py --chip esp32 image_info firmware.bin
|
||||
|
||||
echo "Full binary first 16 bytes:"
|
||||
hexdump -C -n 16 filaman_full.bin
|
||||
|
||||
- name: Read CHANGELOG.md
|
||||
id: changelog
|
||||
run: |
|
||||
VERSION=$(echo "${{ inputs.gitea_ref_name }}" | sed 's/^v//')
|
||||
CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/ {p=0} p" CHANGELOG.md)
|
||||
VERSION=${GITHUB_REF_NAME#v}
|
||||
CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/{p=0} p" CHANGELOG.md)
|
||||
echo "CHANGES<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
echo "CHANGELOG CONTENT:"
|
||||
echo "$CHANGELOG"
|
||||
if [ -z "$CHANGELOG" ]; then
|
||||
echo "No changelog found for version $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Create Release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_REF_NAME: ${{ inputs.gitea_ref_name }}
|
||||
GITEA_SERVER_URL: ${{ inputs.gitea_server_url }}
|
||||
GITEA_REPOSITORY: ${{ inputs.gitea_repository }}
|
||||
CHANGELOG: ${{ steps.changelog.outputs.CHANGES }}
|
||||
run: |
|
||||
echo "Debug environment:"
|
||||
echo "GITEA_REF_NAME: ${GITEA_REF_NAME}"
|
||||
echo "GITEA_SERVER_URL: ${GITEA_SERVER_URL}"
|
||||
echo "GITEA_REPOSITORY: ${GITEA_REPOSITORY}"
|
||||
echo "CHANGELOG: ${CHANGELOG}"
|
||||
|
||||
TAG="${GITEA_REF_NAME}"
|
||||
API_URL="${GITEA_SERVER_URL}/api/v1"
|
||||
REPO="${GITEA_REPOSITORY}"
|
||||
|
||||
echo "Creating release for ${TAG} on ${REPO}..."
|
||||
TAG="${{ inputs.gitea_ref_name }}"
|
||||
API_URL="${{ inputs.gitea_server_url }}/api/v1"
|
||||
REPO="${{ inputs.gitea_repository }}"
|
||||
|
||||
# Create release
|
||||
RESPONSE=$(curl -k -s \
|
||||
-X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\",\"body\":\"${CHANGELOG}\"}" \
|
||||
-d "{
|
||||
\"tag_name\":\"${TAG}\",
|
||||
\"name\":\"Release ${TAG}\",
|
||||
\"body\":\"${{ steps.changelog.outputs.CHANGES }}\"
|
||||
}" \
|
||||
"${API_URL}/repos/${REPO}/releases")
|
||||
|
||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1)
|
||||
UPLOAD_URL=$(echo "$RESPONSE" | grep -o '"upload_url":"[^"]*' | cut -d':' -f2- | tr -d '"')
|
||||
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
echo "Release created with ID: $RELEASE_ID"
|
||||
|
||||
# Upload files
|
||||
for file in "filaman_full.bin" "filaman_ota.bin"; do
|
||||
# Upload binaries
|
||||
for file in filaman_full.bin filaman_ota.bin; do
|
||||
echo "Uploading $file..."
|
||||
curl -k -s \
|
||||
-X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@.pio/build/esp32dev/$file" \
|
||||
"${UPLOAD_URL}?name=$file"
|
||||
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
||||
done
|
||||
else
|
||||
echo "Failed to create release. Response:"
|
||||
|
@ -1,5 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
## [1.2.76] - 2025-02-20
|
||||
### Added
|
||||
- enhance OTA update process with improved file verification and new OTA data initialization
|
||||
|
||||
### Changed
|
||||
- update webpages for version v1.2.76
|
||||
- streamline Gitea release workflow and remove obsolete OTA data initialization script
|
||||
|
||||
|
||||
## [1.2.75] - 2025-02-20
|
||||
### Changed
|
||||
- update webpages for version v1.2.75
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||
<div class="logo-text">
|
||||
<h1>FilaMan<span class="version">v1.2.75</span></h1>
|
||||
<h1>FilaMan<span class="version">v1.2.76</span></h1>
|
||||
<h4>Filament Management Tool</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -9,7 +9,7 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[common]
|
||||
version = "1.2.75"
|
||||
version = "1.2.76"
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
@ -65,6 +65,7 @@ build_flags =
|
||||
-DCONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x1000
|
||||
-DCONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
-DCONFIG_PARTITION_TABLE_MD5=y
|
||||
-DBOOT_APP_PARTITION_OTA_0=1
|
||||
|
||||
extra_scripts =
|
||||
scripts/extra_script.py
|
||||
|
25
src/ota.cpp
25
src/ota.cpp
@ -7,7 +7,6 @@
|
||||
#include "scale.h"
|
||||
#include "nfc.h"
|
||||
|
||||
const uint8_t ESP_MAGIC = 0xE9;
|
||||
static bool tasksAreStopped = false;
|
||||
|
||||
void stopAllTasks() {
|
||||
@ -22,37 +21,55 @@ void stopAllTasks() {
|
||||
}
|
||||
|
||||
void handleOTAUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
|
||||
static size_t contentLength = 0;
|
||||
|
||||
if (!index) {
|
||||
Serial.printf("Update Start: %s\n", filename.c_str());
|
||||
if (request->contentLength() == 0) {
|
||||
contentLength = request->contentLength();
|
||||
Serial.printf("Update Start: %s (size: %u bytes)\n", filename.c_str(), contentLength);
|
||||
|
||||
if (contentLength == 0) {
|
||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"Invalid file size\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Stoppe alle Tasks vor dem Update
|
||||
if (!tasksAreStopped && (RfidReaderTask || BambuMqttTask || ScaleTask)) {
|
||||
stopAllTasks();
|
||||
tasksAreStopped = true;
|
||||
}
|
||||
|
||||
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) {
|
||||
// Für full.bin keine Magic Byte Prüfung
|
||||
bool isFullImage = (contentLength > 0x300000);
|
||||
if (!isFullImage && data[0] != 0xE9) {
|
||||
Serial.printf("Wrong magic byte: 0x%02X (expected 0xE9)\n", data[0]);
|
||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"Invalid firmware format\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Bei full.bin UPDATE_SIZE_UNKNOWN verwenden
|
||||
if (!Update.begin(isFullImage ? UPDATE_SIZE_UNKNOWN : contentLength)) {
|
||||
Update.printError(Serial);
|
||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA could not begin\"}");
|
||||
return;
|
||||
}
|
||||
Serial.printf("Starting %s update\n", isFullImage ? "full" : "firmware");
|
||||
}
|
||||
|
||||
// Schreibe Update-Daten
|
||||
if (Update.write(data, len) != len) {
|
||||
Update.printError(Serial);
|
||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA write failed\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Update abschließen
|
||||
if (final) {
|
||||
if (!Update.end(true)) {
|
||||
Update.printError(Serial);
|
||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA end failed\"}");
|
||||
return;
|
||||
}
|
||||
Serial.println("Update successful, restarting...");
|
||||
request->send(200, "application/json", "{\"status\":\"success\",\"message\":\"Update successful! Device will restart...\",\"restart\":true}");
|
||||
delay(500);
|
||||
ESP.restart();
|
||||
|
Loading…
x
Reference in New Issue
Block a user