summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTony Ambardar <itugrok@yahoo.com>2023-11-13 17:14:07 -0800
committerHauke Mehrtens <hauke@hauke-m.de>2023-11-26 18:37:20 +0100
commitcd5e0134b6bd2e34ad237d985da99c5307816c93 (patch)
treecde6aef80f55a888861d2919f952a7ff9adf5cf8 /scripts
parentb16e14a220fcab19e3145328057e7188f00b6a17 (diff)
downloadopenwrt-cd5e0134b6bd2e34ad237d985da99c5307816c93.tar.gz
openwrt-cd5e0134b6bd2e34ad237d985da99c5307816c93.tar.bz2
openwrt-cd5e0134b6bd2e34ad237d985da99c5307816c93.zip
image: fix Linksys image alignment and simplify footer creation
Current factory image sizes for Linksys devices are 256-byte aligned. This is not an issue writing factory images from the OpenWrt or Linksys GUIs, but can lead to failures using a TFTP client from the Linksys bootloader: NAND write: device 1 offset 0x2800000, size 0xc00100 Attempt to write to non page aligned data NAND write to offset 2800000 failed -22 0 bytes written: ERROR Simplify Linksys footer creation by migrating to a makefile build recipe, and pre-pad the footer (with 0xFF) to ensure the final image is $(PAGESIZE) aligned. Finally, remove the old linksys-image.sh script no longer needed. Linksys footer details are given below for future reference. The 256-byte footer is appended to factory images and tested by both the Linksys Upgrader (observed in EA6350v3) and OpenWrt sysupgrade. Footer format: .LINKSYS. Checked by Linksys upgrader before continuing. (9 bytes) <VERSION> Upgrade version number, unchecked so arbitrary. (8 bytes) <TYPE> Model of device, space padded (0x20). (15 bytes) <CRC> CRC checksum of factory image to flash. (8 bytes) <padding> Padding ('0' + 0x20 * 7) (8 bytes) <signature> Signature of signer, unchecked so arbitrary. (16 bytes) <padding> Padding with nulls (0x00) (192 bytes) Link: https://github.com/openwrt/openwrt/pull/11405#issuecomment-1358510123 Link: https://github.com/openwrt/openwrt/pull/11405#issuecomment-1587517739 Reported-by: Stijn Segers <foss@volatilesystems.org> Reported-by: Wyatt Martin <wawowl@gmail.com> Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/linksys-image.sh64
1 files changed, 0 insertions, 64 deletions
diff --git a/scripts/linksys-image.sh b/scripts/linksys-image.sh
deleted file mode 100755
index d251b5da8e..0000000000
--- a/scripts/linksys-image.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2018 Oceanic Systems (UK) Ltd
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-# Maintained by: Ryan Pannell <ryan [at] o s u k l .com> <github.com/Escalion>
-#
-# Write Linksys signature for factory image
-# This is appended to the factory image and is tested by the Linksys Upgrader - as observed in civic.
-# The footer is 256 bytes. The format is:
-# .LINKSYS. This is detected by the Linksys upgrader before continuing with upgrade. (9 bytes)
-# <VERSION> The version number of upgrade. Not checked so use arbitrary value (8 bytes)
-# <TYPE> Model of target device, padded (0x20) to (15 bytes)
-# <CRC> CRC checksum of the image to flash (8 byte)
-# <padding> Padding ('0' + 0x20 *7) (8 bytes)
-# <signature> Signature of signer. Not checked so use arbitrary value (16 bytes)
-# <padding> Padding (0x00) (192 bytes)
-
-## version history
-# * version 1: initial commit
-
-set -e
-
-ME="${0##*/}"
-
-usage() {
- echo "Usage: $ME <type> <in filename>"
- [ "$IMG_OUT" ] && rm -f "$IMG_OUT"
- exit 1
-}
-
-[ "$#" -lt 3 ] && usage
-
-TYPE=$1
-
-tmpdir="$( mktemp -d 2> /dev/null )"
-if [ -z "$tmpdir" ]; then
- # try OSX signature
- tmpdir="$( mktemp -t 'ubitmp' -d )"
-fi
-
-if [ -z "$tmpdir" ]; then
- exit 1
-fi
-
-trap "rm -rf $tmpdir" EXIT
-
-IMG_TMP_OUT="${tmpdir}/out"
-
-IMG_IN=$2
-IMG_OUT="${IMG_IN}.new"
-
-[ ! -f "$IMG_IN" ] && echo "$ME: Not a valid image: $IMG_IN" && usage
-
-dd if="${IMG_IN}" of="${IMG_TMP_OUT}"
-CRC=$(printf "%08X" $(dd if="${IMG_IN}" bs=$(stat -c%s "${IMG_IN}") count=1|cksum| cut -d ' ' -f1))
-
-printf ".LINKSYS.01000409%-15s%-8s%-8s%-16s" "${TYPE}" "${CRC}" "0" "K0000000F0246434" >> "${IMG_TMP_OUT}"
-
-dd if=/dev/zero bs=1 count=192 conv=notrunc >> "${IMG_TMP_OUT}"
-
-cp "${IMG_TMP_OUT}" "${IMG_OUT}"