diff options
author | Roland Reinl <reinlroland+github@gmail.com> | 2024-03-30 17:59:14 +0100 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2024-03-31 19:01:20 +0200 |
commit | 0e2b7e3bd674d2dd69ed8daf483cac5509cec9f0 (patch) | |
tree | 586cbac0210fc6d8ec07fa7aa98dc699fa01041e /include | |
parent | 0682974aa8da4855ca373d195cb6365913fc1f8e (diff) |
mediatek: Moved recovery image creation to include/image-commands.mk
The recovery image is reqired for D-Link M30 as well. So I moved it to include/image-commands.mk to be able to use it for MT7622 and filogic devices.
Signed-off-by: Roland Reinl <reinlroland+github@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/image-commands.mk | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/image-commands.mk b/include/image-commands.mk index 79a64f4bc1..832c85ee70 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -244,6 +244,43 @@ define Build/copy-file cat "$(1)" > "$@" endef +# Create a header for a D-Link AI series recovery image and add it at the beginning of the image +# Currently supported: AQUILA M30, EAGLE M32 and R32 +# Arguments: +# 1: Start string of the header +# 2: Firmware version +# 3: Block start address +# 4: Block length +# 5: Device FMID +define Build/dlink-ai-recovery-header + $(eval header_start=$(word 1,$(1))) + $(eval firmware_version=$(word 2,$(1))) + $(eval block_start=$(word 3,$(1))) + $(eval block_length=$(word 4,$(1))) + $(eval device_fmid=$(word 5,$(1))) +# create $@.header without the checksum + echo -en "$(header_start)\x00\x00" > "$@.header" +# Calculate checksum over data area ($@) and append it to the header. +# The checksum is the 2byte-sum over the whole data area. +# Every overflow during the checksum calculation must increment the current checksum value by 1. + od -v -w2 -tu2 -An --endian little "$@" | awk '{ s+=$$1; } END { s%=65535; printf "%c%c",s%256,s/256; }' >> "$@.header" + echo -en "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00" >> "$@.header" + echo -en "$(firmware_version)" >> "$@.header" +# Only one block supported: Erase start/length is identical to data start/length + echo -en "$(block_start)$(block_length)$(block_start)$(block_length)" >> "$@.header" +# Only zeros + echo -en "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" >> "$@.header" +# Last 16 bytes, but without checksum + echo -en "\x42\x48\x02\x00\x00\x00\x08\x00\x00\x00\x00\x00" >> "$@.header" + echo -en "$(device_fmid)" >> "$@.header" +# Calculate and append checksum: The checksum must be set so that the 2byte-sum of the whole header is 0. +# Every overflow during the checksum calculation must increment the current checksum value by 1. + od -v -w2 -tu2 -An --endian little "$@.header" | awk '{s+=65535-$$1;}END{s%=65535;printf "%c%c",s%256,s/256;}' >> "$@.header" + cat "$@.header" "$@" > "$@.new" + mv "$@.new" "$@" + rm "$@.header" +endef + define Build/dlink-sge-image $(STAGING_DIR_HOST)/bin/dlink-sge-image $(1) $@ $@.enc mv $@.enc $@ |