Skip to content
Snippets Groups Projects
Commit 2c097821 authored by Bartlomiej Grzeskowiak's avatar Bartlomiej Grzeskowiak
Browse files

iopsys-econet: Add mtd_squashfs sysupgrade


This flash layout is not supposed to be used in the future. But more
development devices will be delivered with non UBIFS flash chip.
Therefore mtd squashfs sysupgrade is added to feeds.

Signed-off-by: default avatarBartlomiej Grzeskowiak <bartlomiej.grzeskowiak@iopsys.eu>
parent 686b1016
Branches
No related tags found
1 merge request!312iopsys-econet: Add mtd_squashfs sysupgrade
platform_check_image() {
return 0
if [[ "ubifs" != "$(fw_printenv -n rootfstype)" ]]; then
#squashfs sysupgrade MUST be executed at early stage. Before including unsupported /lib/upgrade/iopsys.sh.
log sysupgrade "- Squshfs detected -"
iopsys_process_upgrade_bundle "$1" pre_upgrade || return
fi
return 0
}
platform_do_upgrade() {
......
......@@ -34,6 +34,14 @@
algo = "sha256";
};
};
squashfs {
description = "squashfs";
data = /incbin/("root.squashfs");
compression = "none";
hash@1 {
algo = "sha256";
};
};
upgrade_bundle {
description = "upgrade_bundle";
data = /incbin/("upgrade-bundle.tar.gz");
......
......@@ -86,6 +86,7 @@ define Image/Build
cp $(KDIR)/root.ubifs $(BIN_DIR)
cp $(KDIR)/root.ubifs ./
cp $(KDIR)/root.squashfs $(BIN_DIR)
cp $(KDIR)/root.squashfs $(PLATFORM_DIR)/$(SUBTARGET)
ifneq ($(CONFIG_PACKAGE_tcboot),)
#Copy compiled bootloader
cp $(KDIR)/tcboot/src/tcboot.bin $(BIN_DIR)/iopboot.bin
......@@ -101,7 +102,7 @@ endif
$(call Image/Build/GenerateUbifsFIT)
#Cleanup temporary files
rm -f $(PLATFORM_DIR)/$(SUBTARGET)/linux.7z $(PLATFORM_DIR)/$(SUBTARGET)/ecnt.dtb $(PLATFORM_DIR)/$(SUBTARGET)/root.ubifs ./root.ubifs $(PLATFORM_DIR)/$(SUBTARGET)/ubilinux $(PLATFORM_DIR)/$(SUBTARGET)/upgrade-bundle.tar.gz $(PLATFORM_DIR)/$(SUBTARGET)/iopboot.bin
rm -f $(PLATFORM_DIR)/$(SUBTARGET)/linux.7z $(PLATFORM_DIR)/$(SUBTARGET)/ecnt.dtb $(PLATFORM_DIR)/$(SUBTARGET)/root.ubifs ./root.ubifs $(PLATFORM_DIR)/$(SUBTARGET)/root.squashfs $(PLATFORM_DIR)/$(SUBTARGET)/ubilinux $(PLATFORM_DIR)/$(SUBTARGET)/upgrade-bundle.tar.gz $(PLATFORM_DIR)/$(SUBTARGET)/iopboot.bin
endef
#
......
#!/bin/sh
invocation=$1
image=$2
log_tag="$0 $1"
......@@ -14,6 +13,11 @@ do_pre_upgrade() {
log "- pre_upgrade -"
log "- dump u-boot env -"
nanddump -s 0x7c000 -f ./uboot_env.bin /dev/mtd0
if [[ "ubifs" != "$(fw_printenv -n rootfstype)" ]]; then
log "- Squshfs detected -"
do_squashfs_update $image
fi
}
do_post_upgrade() {
......@@ -32,9 +36,55 @@ do_post_upgrade() {
log "- Fixing uboot serdes_sel variable -"
fw_setenv serdes_sel 2
fi
}
do_exit_reboot() {
log "- exit and reboot -"
reboot && sleep 60 ; reboot -f ; sleep 60 ; exit 1
}
do_squashfs_update() {
local image=$1
local next_bank_boot_mtd="mtd2"
local next_bank_rootfs_mtd="mtd4"
local next_bank_id="2"
if [[ "1" != "$(fw_printenv -n active_image)" ]]; then
next_bank_boot_mtd="mtd1"
next_bank_rootfs_mtd="mtd3"
next_bank_id="1"
fi
if [ ! -f "$image" ]; then
log "- $image does not exist -"
exit 1
fi
log "- Start squashfs bank$next_bank_id sysupgrade -"
fdtextract -e bootloader $image -o /tmp/bootloader.bin
if [ -f "bootloader.bin" ]; then
log "- Upgrading bootloader -"
flash_erase /dev/mtd0 0 0
nandwrite -p /dev/mtd0 /tmp/bootloader.bin
rm /tmp/bootloader.bin
fi
log "- Upgrading kernel -"
fdtextract -e boot $image -o /tmp/boot.bin
flash_erase /dev/$next_bank_boot_mtd 0 0
nandwrite -p /dev/$next_bank_boot_mtd /tmp/boot.bin
rm /tmp/boot.bin
log "- Upgrading rootfs -"
fdtextract -e squashfs $image -o /tmp/squashfs.bin
flash_erase /dev/$next_bank_rootfs_mtd 0 0
nandwrite -p /dev/$next_bank_rootfs_mtd /tmp/squashfs.bin
rm /tmp/squashfs.bin
#For future use
#reboot && sleep 60 ; reboot -f ; sleep 60 ; exit 1
do_post_upgrade $image
log "- Set boot bank $next_bank_id and reboot-"
fw_setenv active_image $next_bank_id
do_exit_reboot
}
case $invocation in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment