mtdflash: static, verified MTD writer (per-block skip/erase/write/read-back, validates all images before writing, refuses U-Boot/env without -f). fwupdate + ota.sh flash a running camera over SSH; make-sd-update.sh builds a camupdate.env that the new bootcmd applies from the SD card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.3 KiB
Bash
Executable File
26 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Build an SD-card recovery/update set that U-Boot flashes at power-on (no Linux,
|
|
# no serial needed once the one-time bootcmd from README is set).
|
|
# ./make-sd-update.sh /path/to/sdcard parts/rtsp/app.bin parts/rtsp/dtb.bin ...
|
|
# Copies the images + writes camupdate.env. Linux renames it to camupdate.done after a
|
|
# good boot so it's only applied once. Offsets = layout-rtsp.conf (LAYOUT= overrides).
|
|
set -e
|
|
[ $# -ge 2 ] || { sed -n '2,6p' "$0"; exit 2; }
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"; LAYOUT=${LAYOUT:-$HERE/layout-rtsp.conf}
|
|
DST=$1; shift; mkdir -p "$DST"
|
|
S="sf probe 0"
|
|
for f in "$@"; do
|
|
n=$(basename "$f")
|
|
case "$n" in app*) p=APP;; dtb*) p=DTB;; kernel*) p=KERNEL;; rootfs*) p=ROOTFS;;
|
|
config*) p=CONFIG;; data*) p=DATA;; *) echo "unknown partition for $n"; exit 1;; esac
|
|
set -- $(awk -v p=$p '$1==p {print $2, $3}' "$LAYOUT"); off=$1; size=$2
|
|
[ -n "$off" ] || { echo "$p not in $LAYOUT"; exit 1; }
|
|
[ $(wc -c < "$f") -le $((size)) ] || { echo "$n bigger than $p"; exit 1; }
|
|
cp "$f" "$DST/$n"
|
|
S="$S; setenv filesize 0; fatload mmc 0 \${loadaddr} $n; sf update \${loadaddr} $off \${filesize}"
|
|
echo " $n -> $p @ $off"
|
|
done
|
|
printf 'sdscript=%s\n' "$S" > "$DST/camupdate.env"
|
|
rm -f "$DST/camupdate.done"
|
|
echo "wrote $DST/camupdate.env"
|