Add EEPROM update functionality and UI enhancements

Implement a new feature to allow users to update the EEPROM via the dashboard, including the generation of necessary update files. Enhance the device action handling to support the 'eeprom_update' action for USB-connected devices, ensuring proper validation of boot order presets. Update the dashboard UI to include an EEPROM update option alongside existing actions, improving user experience. Modify related scripts to handle EEPROM updates effectively, including file management and error handling during the update process.
This commit is contained in:
nearxos
2026-02-21 16:02:08 +02:00
parent 5238d457e8
commit b39e73324f
4 changed files with 215 additions and 8 deletions

View File

@@ -152,10 +152,10 @@ if [[ -z "$target_dev" ]]; then
fi
# Ask user (dashboard): Backup or Deploy?
write_status "waiting_choice" "Device connected (USB boot mode). Choose Backup or Deploy in the dashboard." "null"
write_status "waiting_choice" "Device connected (USB boot mode). Choose Backup, Deploy, or Update EEPROM in the dashboard." "null"
echo "usb" > "$DEVICE_SOURCE_FILE" 2>/dev/null || true
echo "$target_dev" > "$CURRENT_DEVICE_FILE" 2>/dev/null || true
log "Waiting for user choice (Backup or Deploy) in dashboard; timeout ${WAIT_TIMEOUT}s..."
log "Waiting for user choice (Backup, Deploy, or Update EEPROM) in dashboard; timeout ${WAIT_TIMEOUT}s..."
for (( i = 0; i < WAIT_TIMEOUT; i += 2 )); do
sleep 2
if [[ -f "$ACTION_REQUEST_FILE" ]]; then
@@ -225,8 +225,48 @@ for (( i = 0; i < WAIT_TIMEOUT; i += 2 )); do
else
write_status "error" "Flash failed" "null" "dd failed"
fi
elif [[ "$action" == "eeprom_update" ]]; then
# Dashboard has written pieeprom.upd and pieeprom.sig to BASE_DIR; copy to eMMC boot partition
PROV_DIR="$(dirname "$STATUS_FILE")"
EEPROM_UPD="$PROV_DIR/pieeprom.upd"
EEPROM_SIG="$PROV_DIR/pieeprom.sig"
if [[ ! -f "$EEPROM_UPD" || ! -f "$EEPROM_SIG" ]]; then
log "EEPROM update files not found: $EEPROM_UPD / $EEPROM_SIG"
write_status "error" "EEPROM update failed" "null" "pieeprom.upd or pieeprom.sig not found in $PROV_DIR"
exit 1
fi
boot_part=""
for p in "${target_dev}1" "${target_dev}p1"; do
if [[ -b "$p" ]]; then
boot_part="$p"
break
fi
done
if [[ -z "$boot_part" ]]; then
log "No boot partition found for $target_dev (tried ...1 and ...p1)"
write_status "error" "EEPROM update failed" "null" "Boot partition not found"
exit 1
fi
write_status "eeprom_update" "Writing EEPROM update to boot partition…" "null"
log "Mounting $boot_part and copying EEPROM update..."
mnt=$(mktemp -d)
if mount "$boot_part" "$mnt" 2>/dev/null; then
if cp "$EEPROM_UPD" "$mnt/pieeprom.upd" && cp "$EEPROM_SIG" "$mnt/pieeprom.sig"; then
sync
log "EEPROM update written. Remove eMMC disable jumper and power cycle to apply."
write_status "done" "EEPROM update written to boot partition. Remove eMMC disable jumper and power cycle the reTerminal to apply." "100"
rm -f "$EEPROM_UPD" "$EEPROM_SIG"
( sleep 90 && write_status "idle" "Waiting for reTerminal in boot mode or network." "null" ) &
else
write_status "error" "EEPROM update failed" "null" "Failed to copy pieeprom.upd/sig"
fi
umount "$mnt" 2>/dev/null || true
else
write_status "error" "EEPROM update failed" "null" "Could not mount boot partition"
fi
rm -rf "$mnt"
else
write_status "error" "Unknown action" "null" "action_request must be 'backup' or 'deploy'"
write_status "error" "Unknown action" "null" "action_request must be 'backup', 'deploy', or 'eeprom_update'"
fi
exit 0
fi