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:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
gitea_ref_name:
|
gitea_ref_name:
|
||||||
description: 'Gitea ref name'
|
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
gitea_server_url:
|
gitea_server_url:
|
||||||
description: 'Gitea server URL'
|
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
gitea_repository:
|
gitea_repository:
|
||||||
description: 'Gitea repository'
|
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
secrets:
|
secrets:
|
||||||
@ -23,109 +20,106 @@ jobs:
|
|||||||
create-release:
|
create-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install System Dependencies
|
- name: Set up Python
|
||||||
run: |
|
uses: actions/setup-python@v4
|
||||||
sudo apt-get update
|
with:
|
||||||
sudo apt-get install -y python3 python3-venv build-essential curl git
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Set up Python Virtual Environment
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 -m venv venv
|
python -m pip install --upgrade pip
|
||||||
source venv/bin/activate
|
|
||||||
pip install --upgrade pip
|
|
||||||
pip install platformio esptool
|
pip install platformio esptool
|
||||||
|
|
||||||
echo "Verifying installations:"
|
|
||||||
platformio --version
|
|
||||||
python3 --version
|
|
||||||
esptool.py version
|
|
||||||
|
|
||||||
- name: Build Firmware
|
- name: Build Firmware
|
||||||
run: |
|
run: |
|
||||||
source venv/bin/activate
|
# Build SPIFFS first
|
||||||
echo "Building SPIFFS..."
|
|
||||||
platformio run -t buildfs
|
platformio run -t buildfs
|
||||||
|
# Then build firmware
|
||||||
echo "Building firmware..."
|
|
||||||
platformio run
|
platformio run
|
||||||
|
|
||||||
- name: Create Release Files
|
- name: Prepare Release Files
|
||||||
run: |
|
run: |
|
||||||
source venv/bin/activate
|
cd .pio/build/esp32dev
|
||||||
echo "Creating release files..."
|
|
||||||
|
# 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 \
|
esptool.py --chip esp32 merge_bin \
|
||||||
|
-o filaman_full.bin \
|
||||||
--flash_mode dio \
|
--flash_mode dio \
|
||||||
--flash_freq 40m \
|
--flash_freq 40m \
|
||||||
--flash_size 4MB \
|
--flash_size 4MB \
|
||||||
-o .pio/build/esp32dev/filaman_full.bin \
|
0x1000 bootloader.bin \
|
||||||
0x1000 .pio/build/esp32dev/bootloader.bin \
|
0x8000 partitions.bin \
|
||||||
0x8000 .pio/build/esp32dev/partitions.bin \
|
0x10000 firmware.bin \
|
||||||
0x10000 .pio/build/esp32dev/firmware.bin \
|
0x3D0000 spiffs.bin
|
||||||
0x3D0000 .pio/build/esp32dev/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
|
- name: Read CHANGELOG.md
|
||||||
id: changelog
|
id: changelog
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(echo "${{ inputs.gitea_ref_name }}" | sed 's/^v//')
|
VERSION=${GITHUB_REF_NAME#v}
|
||||||
CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/ {p=0} p" CHANGELOG.md)
|
CHANGELOG=$(awk "/## \\[$VERSION\\]/{p=1;print;next} /## \\[/{p=0} p" CHANGELOG.md)
|
||||||
echo "CHANGES<<EOF" >> $GITHUB_OUTPUT
|
echo "CHANGES<<EOF" >> $GITHUB_OUTPUT
|
||||||
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||||
echo "EOF" >> $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
|
- name: Create Release
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
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: |
|
run: |
|
||||||
echo "Debug environment:"
|
TAG="${{ inputs.gitea_ref_name }}"
|
||||||
echo "GITEA_REF_NAME: ${GITEA_REF_NAME}"
|
API_URL="${{ inputs.gitea_server_url }}/api/v1"
|
||||||
echo "GITEA_SERVER_URL: ${GITEA_SERVER_URL}"
|
REPO="${{ inputs.gitea_repository }}"
|
||||||
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}..."
|
|
||||||
|
|
||||||
# Create release
|
# Create release
|
||||||
RESPONSE=$(curl -k -s \
|
RESPONSE=$(curl -k -s \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-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")
|
"${API_URL}/repos/${REPO}/releases")
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | cut -d':' -f2 | head -n1)
|
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
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
echo "Release created with ID: $RELEASE_ID"
|
echo "Release created with ID: $RELEASE_ID"
|
||||||
|
|
||||||
# Upload files
|
# Upload binaries
|
||||||
for file in "filaman_full.bin" "filaman_ota.bin"; do
|
for file in filaman_full.bin filaman_ota.bin; do
|
||||||
echo "Uploading $file..."
|
echo "Uploading $file..."
|
||||||
curl -k -s \
|
curl -k -s \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary "@.pio/build/esp32dev/$file" \
|
--data-binary "@.pio/build/esp32dev/$file" \
|
||||||
"${UPLOAD_URL}?name=$file"
|
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Failed to create release. Response:"
|
echo "Failed to create release. Response:"
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# 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
|
## [1.2.75] - 2025-02-20
|
||||||
### Changed
|
### Changed
|
||||||
- update webpages for version v1.2.75
|
- update webpages for version v1.2.75
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div style="display: flex; align-items: center; gap: 2rem;">
|
<div style="display: flex; align-items: center; gap: 2rem;">
|
||||||
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
<img src="/logo.png" alt="FilaMan Logo" class="logo">
|
||||||
<div class="logo-text">
|
<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>
|
<h4>Filament Management Tool</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
version = "1.2.75"
|
version = "1.2.76"
|
||||||
|
|
||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@ -65,6 +65,7 @@ build_flags =
|
|||||||
-DCONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x1000
|
-DCONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x1000
|
||||||
-DCONFIG_PARTITION_TABLE_OFFSET=0x8000
|
-DCONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||||
-DCONFIG_PARTITION_TABLE_MD5=y
|
-DCONFIG_PARTITION_TABLE_MD5=y
|
||||||
|
-DBOOT_APP_PARTITION_OTA_0=1
|
||||||
|
|
||||||
extra_scripts =
|
extra_scripts =
|
||||||
scripts/extra_script.py
|
scripts/extra_script.py
|
||||||
|
25
src/ota.cpp
25
src/ota.cpp
@ -7,7 +7,6 @@
|
|||||||
#include "scale.h"
|
#include "scale.h"
|
||||||
#include "nfc.h"
|
#include "nfc.h"
|
||||||
|
|
||||||
const uint8_t ESP_MAGIC = 0xE9;
|
|
||||||
static bool tasksAreStopped = false;
|
static bool tasksAreStopped = false;
|
||||||
|
|
||||||
void stopAllTasks() {
|
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) {
|
void handleOTAUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
|
||||||
|
static size_t contentLength = 0;
|
||||||
|
|
||||||
if (!index) {
|
if (!index) {
|
||||||
Serial.printf("Update Start: %s\n", filename.c_str());
|
contentLength = request->contentLength();
|
||||||
if (request->contentLength() == 0) {
|
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\"}");
|
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"Invalid file size\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stoppe alle Tasks vor dem Update
|
||||||
if (!tasksAreStopped && (RfidReaderTask || BambuMqttTask || ScaleTask)) {
|
if (!tasksAreStopped && (RfidReaderTask || BambuMqttTask || ScaleTask)) {
|
||||||
stopAllTasks();
|
stopAllTasks();
|
||||||
tasksAreStopped = true;
|
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);
|
Update.printError(Serial);
|
||||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA could not begin\"}");
|
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA could not begin\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Serial.printf("Starting %s update\n", isFullImage ? "full" : "firmware");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Schreibe Update-Daten
|
||||||
if (Update.write(data, len) != len) {
|
if (Update.write(data, len) != len) {
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA write failed\"}");
|
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA write failed\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update abschließen
|
||||||
if (final) {
|
if (final) {
|
||||||
if (!Update.end(true)) {
|
if (!Update.end(true)) {
|
||||||
Update.printError(Serial);
|
Update.printError(Serial);
|
||||||
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA end failed\"}");
|
request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"OTA end failed\"}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Serial.println("Update successful, restarting...");
|
||||||
request->send(200, "application/json", "{\"status\":\"success\",\"message\":\"Update successful! Device will restart...\",\"restart\":true}");
|
request->send(200, "application/json", "{\"status\":\"success\",\"message\":\"Update successful! Device will restart...\",\"restart\":true}");
|
||||||
delay(500);
|
delay(500);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user