forked from openwrt/openwrt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ath79: move image check for devices with RedBoot
Don't comence the switch to RAMFS when the image format is wrong. This led to rebooting the device, which could lead to false impression that upgrade succeded. Being here, factor out the code responsible for upgrading RedBoot devices to separate file. Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
- Loading branch information
Showing
2 changed files
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
platform_check_image_redboot_fis() { | ||
if [ "$(get_magic_word "$1")" != "7379" ]; then | ||
v "Unknown image format, aborting!" | ||
return 1 | ||
else | ||
return 0 | ||
fi | ||
} | ||
|
||
platform_do_upgrade_redboot_fis() { | ||
local append | ||
local sysup_file="$1" | ||
local kern_part="$2" | ||
|
||
if [ "$(get_magic_word "$sysup_file")" = "7379" ]; then | ||
local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$') | ||
|
||
[ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP" | ||
|
||
if grep -q "mtd1.*loader" /proc/mtd; then | ||
tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \ | ||
mtd -r $append write - loader:firmware | ||
|
||
else | ||
local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c) | ||
|
||
tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \ | ||
mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs | ||
fi | ||
fi | ||
} |