diff --git a/iopsys-econet/base-files/lib/upgrade/platform.sh b/iopsys-econet/base-files/lib/upgrade/platform.sh index 333504656bf633adc5ab6f11398386fac09dd8fe..3fe21e1f0e2eb7f0bb7e7aceb322509b90d848b0 100644 --- a/iopsys-econet/base-files/lib/upgrade/platform.sh +++ b/iopsys-econet/base-files/lib/upgrade/platform.sh @@ -1,5 +1,10 @@ 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() { diff --git a/iopsys-econet/en7562/boot.its b/iopsys-econet/en7562/boot.its index 004fcd2ab3ff1e0e005305609182181e21859410..c03717563b4b2c5a46a22f550e1fd56d888b31f8 100755 --- a/iopsys-econet/en7562/boot.its +++ b/iopsys-econet/en7562/boot.its @@ -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"); diff --git a/iopsys-econet/image/Makefile b/iopsys-econet/image/Makefile index 3c729f4d82b334a901d7e9a9082d7675221e0892..0a616b81125c3a99f9f63f993ccdd5b557e88715 100755 --- a/iopsys-econet/image/Makefile +++ b/iopsys-econet/image/Makefile @@ -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 # diff --git a/iopsys-econet/image/upgrade-bundle/upgrade b/iopsys-econet/image/upgrade-bundle/upgrade index dc9618d5b2ed75cd6ea0b0de13206789253c19b3..0c22cc761dc7667f6b0252f2bb68004dfa54b6b9 100755 --- a/iopsys-econet/image/upgrade-bundle/upgrade +++ b/iopsys-econet/image/upgrade-bundle/upgrade @@ -1,6 +1,5 @@ #!/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