From 3605eff88190af9cc2905ba750252c1643a1bc7d Mon Sep 17 00:00:00 2001 From: Pawel Dembicki Date: Wed, 19 Aug 2020 12:13:26 +0200 Subject: [PATCH] layerscape: add dtb to sysupgrade At this moment sysupgrade replaces only kernel and rootfs. This patch add dtb part to sysupgrade images to avoid situation when old dtb make system broken. Is possible to sysupgrade older images for NOR devices: 1. Firmware partition in bootargs need to be updated to: "49m@0xf00000(firmware)". Env should be saved after changes. 2. After step one, "sysupgrade -F" will work. Run tested: LS1046A-RDB Reviewed-by: Yangbo Lu Signed-off-by: Pawel Dembicki [bump PKG_RELEASE for uboot-layerscape] Signed-off-by: Adrian Schmutzler --- package/boot/uboot-layerscape/Makefile | 2 +- .../files/fsl_ls1012a-rdb-uEnv.txt | 2 +- .../files/fsl_ls1021a-twr-uEnv.txt | 2 +- .../files/fsl_ls1043a-rdb-uEnv.txt | 2 +- .../files/fsl_ls1046a-rdb-uEnv.txt | 2 +- .../files/fsl_ls1088a-rdb-uEnv.txt | 2 +- .../files/fsl_ls2088a-rdb-uEnv.txt | 2 +- .../etc/uci-defaults/05_fix-compat-version | 19 ++++++++++++++++++ .../base-files/lib/upgrade/platform.sh | 5 ++++- target/linux/layerscape/image/Makefile | 11 ++++++++-- target/linux/layerscape/image/armv7.mk | 15 +++++++++++--- target/linux/layerscape/image/armv8_64b.mk | 20 ++++++++++++++----- 12 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 target/linux/layerscape/base-files/etc/uci-defaults/05_fix-compat-version diff --git a/package/boot/uboot-layerscape/Makefile b/package/boot/uboot-layerscape/Makefile index 39dcf82be7..66946f48ce 100644 --- a/package/boot/uboot-layerscape/Makefile +++ b/package/boot/uboot-layerscape/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=uboot-layerscape PKG_VERSION:=LSDK-20.04 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://source.codeaurora.org/external/qoriq/qoriq-components/u-boot diff --git a/package/boot/uboot-layerscape/files/fsl_ls1012a-rdb-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1012a-rdb-uEnv.txt index f109a98b85..906feec9ee 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls1012a-rdb-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls1012a-rdb-uEnv.txt @@ -3,6 +3,6 @@ loadaddr=0x81000000 fdt_high=0xffffffffffffffff initrd_high=0xffffffffffffffff qspi_boot=sf probe 0:0;sf read $fdtaddr f00000 100000;sf read $loadaddr 1000000 1000000;bootm $loadaddr - $fdtaddr -bootargs=root=/dev/mtdblock8 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=1550000.spi:1m(bl2),4m(fip),1m(u-boot-env),4m(reserved-1),3m(pfe),2m(reserved-2),1m(dtb),16m(kernel),32m(rootfs),48m@0x1000000(firmware) +bootargs=root=/dev/mtdblock8 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=1550000.spi:1m(bl2),4m(fip),1m(u-boot-env),4m(reserved-1),3m(pfe),2m(reserved-2),1m(dtb),16m(kernel),32m(rootfs),49m@0xf00000(firmware) bootcmd=echo starting openwrt ...;pfe stop;run qspi_boot bootdelay=3 diff --git a/package/boot/uboot-layerscape/files/fsl_ls1021a-twr-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1021a-twr-uEnv.txt index d6c5f56fd9..c0792c51e3 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls1021a-twr-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls1021a-twr-uEnv.txt @@ -3,6 +3,6 @@ loadaddr=0x81000000 fdt_high=0xffffffff initrd_high=0xffffffff nor_boot=cp.b 60f00000 $fdtaddr 100000;cp.b 61000000 $loadaddr 1000000;bootm $loadaddr - $fdtaddr -bootargs=root=/dev/mtdblock6 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=60000000.nor:1m(rcw),2m(u-boot),1m(u-boot-env),11m(reserved-1),1m(dtb),16m(kernel),32m(rootfs),48m@0x1000000(firmware) cma=64M@0x0-0xb0000000 +bootargs=root=/dev/mtdblock6 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=60000000.nor:1m(rcw),2m(u-boot),1m(u-boot-env),11m(reserved-1),1m(dtb),16m(kernel),32m(rootfs),49m@0xf00000(firmware) cma=64M@0x0-0xb0000000 bootcmd=echo starting openwrt ...;run nor_boot bootdelay=3 diff --git a/package/boot/uboot-layerscape/files/fsl_ls1043a-rdb-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1043a-rdb-uEnv.txt index 1214bf40c2..3a958ce90c 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls1043a-rdb-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls1043a-rdb-uEnv.txt @@ -4,6 +4,6 @@ fdt_high=0xffffffffffffffff initrd_high=0xffffffffffffffff hwconfig=fsl_ddr:bank_intlv=auto nor_boot=cp.b 60f00000 $fdtaddr 100000;cp.b 61000000 $loadaddr 1000000;bootm $loadaddr - $fdtaddr -bootargs=root=/dev/mtdblock8 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=60000000.nor:1m(bl2),4m(fip),1m(u-boot-env),3m(reserved-1),256k(fman),5888k(reserved-2),1m(dtb),16m(kernel),32m(rootfs),48m@0x1000000(firmware) +bootargs=root=/dev/mtdblock8 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=60000000.nor:1m(bl2),4m(fip),1m(u-boot-env),3m(reserved-1),256k(fman),5888k(reserved-2),1m(dtb),16m(kernel),32m(rootfs),49m@0xf00000(firmware) bootcmd=echo starting openwrt ...;run nor_boot bootdelay=3 diff --git a/package/boot/uboot-layerscape/files/fsl_ls1046a-rdb-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1046a-rdb-uEnv.txt index 975b1c1e7f..a9b91e5ac7 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls1046a-rdb-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls1046a-rdb-uEnv.txt @@ -4,6 +4,6 @@ fdt_high=0xffffffffffffffff initrd_high=0xffffffffffffffff hwconfig=fsl_ddr:bank_intlv=auto qspi_boot=sf probe 0:0;sf read $fdtaddr f00000 100000;sf read $loadaddr 1000000 1000000;bootm $loadaddr - $fdtaddr -bootargs=root=/dev/mtdblock9 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=1550000.spi-0:1m(bl2),4m(fip),1m(u-boot-env),3m(reserved-1),256k(fman),5888k(reserved-2),1m(dtb),16m(kernel),32m(rootfs),48m@0x1000000(firmware) +bootargs=root=/dev/mtdblock9 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=1550000.spi-0:1m(bl2),4m(fip),1m(u-boot-env),3m(reserved-1),256k(fman),5888k(reserved-2),1m(dtb),16m(kernel),32m(rootfs),49m@0xf00000(firmware) bootcmd=echo starting openwrt ...;run qspi_boot bootdelay=3 diff --git a/package/boot/uboot-layerscape/files/fsl_ls1088a-rdb-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1088a-rdb-uEnv.txt index 7ab5550405..6ac6216d64 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls1088a-rdb-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls1088a-rdb-uEnv.txt @@ -5,6 +5,6 @@ initrd_high=0xffffffffffffffff hwconfig=fsl_ddr:bank_intlv=auto mc_init=sf probe 0:0;sf read 80000000 a00000 300000;sf read 80300000 e00000 100000;fsl_mc start mc 80000000 80300000;sf read 80400000 d00000 100000;fsl_mc apply dpl 80400000 qspi_boot=sf probe 0:0;sf read $fdtaddr f00000 100000;sf read $loadaddr 1000000 1000000;bootm $loadaddr - $fdtaddr -bootargs=root=/dev/mtdblock10 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=20c0000.spi-0:1m(bl2),4m(fip),1m(u-boot-env),4m(reserved-1),3m(mc),1m(dpl),1m(dpc),1m(dtb),16m(kernel),32m(rootfs),48m@0x1000000(firmware) +bootargs=root=/dev/mtdblock10 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=20c0000.spi-0:1m(bl2),4m(fip),1m(u-boot-env),4m(reserved-1),3m(mc),1m(dpl),1m(dpc),1m(dtb),16m(kernel),32m(rootfs),49m@0xf00000(firmware) bootcmd=echo starting openwrt ...;run mc_init;run qspi_boot bootdelay=3 diff --git a/package/boot/uboot-layerscape/files/fsl_ls2088a-rdb-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls2088a-rdb-uEnv.txt index fe2febd2ce..eb10a88d77 100644 --- a/package/boot/uboot-layerscape/files/fsl_ls2088a-rdb-uEnv.txt +++ b/package/boot/uboot-layerscape/files/fsl_ls2088a-rdb-uEnv.txt @@ -5,6 +5,6 @@ initrd_high=0xffffffffffffffff hwconfig=fsl_ddr:bank_intlv=auto mc_init=fsl_mc start mc 580a00000 580e00000;fsl_mc apply dpl 580d00000 nor_boot=cp.b 580f00000 $fdtaddr 100000;cp.b 581000000 $loadaddr 1000000;bootm $loadaddr - $fdtaddr -bootargs=root=/dev/mtdblock9 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS1,115200 mtdparts=580000000.nor:1m(bl2),4m(fip),1m(u-boot-env),4m(reserved-1),3m(mc),1m(dpl),1m(dpc),1m(dtb),16m(kernel),32m(rootfs),48m@0x1000000(firmware) +bootargs=root=/dev/mtdblock9 rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS1,115200 mtdparts=580000000.nor:1m(bl2),4m(fip),1m(u-boot-env),4m(reserved-1),3m(mc),1m(dpl),1m(dpc),1m(dtb),16m(kernel),32m(rootfs),49m@0xf00000(firmware) bootcmd=echo starting openwrt ...;run mc_init;run nor_boot bootdelay=3 diff --git a/target/linux/layerscape/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/layerscape/base-files/etc/uci-defaults/05_fix-compat-version new file mode 100644 index 0000000000..923f4ac273 --- /dev/null +++ b/target/linux/layerscape/base-files/etc/uci-defaults/05_fix-compat-version @@ -0,0 +1,19 @@ +# +# Copyright (C) 2020 OpenWrt.org +# + +. /lib/functions.sh + +case "$(board_name)" in + fsl,ls1012a-rdb | \ + fsl,ls1021a-twr | \ + fsl,ls1043a-rdb | \ + fsl,ls1046a-rdb | \ + fsl,ls1088a-rdb | \ + fsl,ls2088a-rdb) + uci set system.@system[0].compat_version="2.0" + uci commit system + ;; +esac + +exit 0 diff --git a/target/linux/layerscape/base-files/lib/upgrade/platform.sh b/target/linux/layerscape/base-files/lib/upgrade/platform.sh index fa0f21a6c5..633cbaf953 100644 --- a/target/linux/layerscape/base-files/lib/upgrade/platform.sh +++ b/target/linux/layerscape/base-files/lib/upgrade/platform.sh @@ -61,7 +61,7 @@ platform_do_upgrade_sdboot() { if [ -n "$diff" ]; then dd if="$1" of="/dev/$diskdev" bs=1024 count=4 > /dev/null 2>&1 echo "Writing image to /dev/$diskdev..." - dd if="$1" of="/dev/$diskdev" bs=1024 skip=16384 seek=16384 > /dev/null 2>&1 + dd if="$1" of="/dev/$diskdev" bs=1024 skip=15360 seek=15360 > /dev/null 2>&1 sync # Separate removal and addtion is necessary; otherwise, partition 1 @@ -72,6 +72,9 @@ platform_do_upgrade_sdboot() { return 0 fi + # write dtb + echo "Writing dtb to /dev/$diskdev..." + dd if="$1" of="/dev/$diskdev" bs=1024 skip=15360 seek=15360 count=1024 > /dev/null 2>&1 # write kernel image echo "Writing kernel to /dev/$diskdev..." dd if="$1" of="/dev/$diskdev" bs=1024 skip=16384 seek=16384 count=16384 > /dev/null 2>&1 diff --git a/target/linux/layerscape/image/Makefile b/target/linux/layerscape/image/Makefile index 8a38a25041..08864b1316 100644 --- a/target/linux/layerscape/image/Makefile +++ b/target/linux/layerscape/image/Makefile @@ -11,8 +11,8 @@ LS_SD_ROOTFSPART_OFFSET = 64 LS_SD_IMAGE_SIZE = $(shell echo $$((($(LS_SD_ROOTFSPART_OFFSET) + \ $(CONFIG_TARGET_ROOTFS_PARTSIZE)) * 1024 * 1024))) -# The limitation of flash sysupgrade.bin is 16MB kernel + 32MB rootfs -LS_SYSUPGRADE_IMAGE_SIZE = 48m +# The limitation of flash sysupgrade.bin is 1MB dtb + 16MB kernel + 32MB rootfs +LS_SYSUPGRADE_IMAGE_SIZE = 49m define Build/ls-clean rm -f $@ @@ -46,6 +46,13 @@ define Build/traverse-fit @mv -f $@.new $@ endef +define Device/fix-sysupgrade + DEVICE_COMPAT_VERSION := 2.0 + DEVICE_COMPAT_MESSAGE := DTB was added to sysupgrade. Image format is different. \ + To use sysupgrade You need to change firmware partition in bootargs to "49m@0xf00000(firmware)" and saveenv. \ + After that, You can use "sysupgrade -F". +endef + include $(SUBTARGET).mk $(eval $(call BuildImage)) diff --git a/target/linux/layerscape/image/armv7.mk b/target/linux/layerscape/image/armv7.mk index 8a86997399..23bd3e8d82 100644 --- a/target/linux/layerscape/image/armv7.mk +++ b/target/linux/layerscape/image/armv7.mk @@ -16,12 +16,14 @@ define Device/Default DEVICE_DTS = $(lastword $(subst _, ,$(1))) SUPPORTED_DEVICES = $(subst _,$(comma),$(1)) IMAGE_SIZE := 64m - IMAGE/sysupgrade.bin := append-kernel | pad-to 16M | \ + IMAGE/sysupgrade.bin = ls-append-dtb $$(DEVICE_DTS) | pad-to 1M | \ + append-kernel | pad-to 17M | \ append-rootfs | pad-rootfs | \ check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata endef define Device/fsl_ls1021a-twr + $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP DEVICE_MODEL := TWR-LS1021A DEVICE_VARIANT := Default @@ -54,7 +56,8 @@ define Device/fsl_ls1021a-twr-sdboot append-rootfs | check-size $(LS_SD_IMAGE_SIZE) IMAGE/sysupgrade.bin := \ ls-clean | \ - ls-append-sdhead $(1) | pad-to 16M | \ + ls-append-sdhead $(1) | pad-to 15M | \ + ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ append-rootfs | check-size $(LS_SD_IMAGE_SIZE) | append-metadata endef @@ -67,7 +70,7 @@ define Device/fsl_ls1021a-iot-sdboot DEVICE_DTS := ls1021a-iot FILESYSTEMS := ext4 SUPPORTED_DEVICES := - IMAGES := sdcard.img + IMAGES := sdcard.img sysupgrade.bin IMAGE/sdcard.img := \ ls-clean | \ ls-append-sdhead $(1) | pad-to 4K | \ @@ -76,5 +79,11 @@ define Device/fsl_ls1021a-iot-sdboot ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ append-rootfs | check-size $(LS_SD_IMAGE_SIZE) + IMAGE/sysupgrade.bin := \ + ls-clean | \ + ls-append-sdhead $(1) | pad-to 15M | \ + ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ + append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ + append-rootfs | check-size $(LS_SD_IMAGE_SIZE) | append-metadata endef TARGET_DEVICES += fsl_ls1021a-iot-sdboot diff --git a/target/linux/layerscape/image/armv8_64b.mk b/target/linux/layerscape/image/armv8_64b.mk index 6ed3e7c155..35bab47124 100644 --- a/target/linux/layerscape/image/armv8_64b.mk +++ b/target/linux/layerscape/image/armv8_64b.mk @@ -15,7 +15,8 @@ define Device/Default DEVICE_DTS = freescale/$(subst _,-,$(1)) SUPPORTED_DEVICES = $(subst _,$(comma),$(1)) IMAGE_SIZE := 64m - IMAGE/sysupgrade.bin := append-kernel | pad-to 16M | \ + IMAGE/sysupgrade.bin = ls-append-dtb $$(DEVICE_DTS) | pad-to 1M | \ + append-kernel | pad-to 17M | \ append-rootfs | pad-rootfs | \ check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata endef @@ -46,6 +47,7 @@ endef TARGET_DEVICES += fsl_ls1012a-frdm define Device/fsl_ls1012a-rdb + $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP DEVICE_MODEL := LS1012A-RDB DEVICE_PACKAGES += \ @@ -89,13 +91,15 @@ define Device/fsl_ls1012a-frwy-sdboot append-rootfs | check-size $(LS_SD_IMAGE_SIZE) IMAGE/sysupgrade.bin := \ ls-clean | \ - ls-append-sdhead $(1) | pad-to 16M | \ + ls-append-sdhead $(1) | pad-to 15M | \ + ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ append-rootfs | check-size $(LS_SD_IMAGE_SIZE) | append-metadata endef TARGET_DEVICES += fsl_ls1012a-frwy-sdboot define Device/fsl_ls1043a-rdb + $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP DEVICE_MODEL := LS1043A-RDB DEVICE_VARIANT := Default @@ -145,13 +149,15 @@ define Device/fsl_ls1043a-rdb-sdboot append-rootfs | check-size $(LS_SD_IMAGE_SIZE) IMAGE/sysupgrade.bin := \ ls-clean | \ - ls-append-sdhead $(1) | pad-to 16M | \ + ls-append-sdhead $(1) | pad-to 15M | \ + ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ append-rootfs | check-size $(LS_SD_IMAGE_SIZE) | append-metadata endef TARGET_DEVICES += fsl_ls1043a-rdb-sdboot define Device/fsl_ls1046a-rdb + $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP DEVICE_MODEL := LS1046A-RDB DEVICE_VARIANT := Default @@ -201,13 +207,15 @@ define Device/fsl_ls1046a-rdb-sdboot append-rootfs | check-size $(LS_SD_IMAGE_SIZE) IMAGE/sysupgrade.bin := \ ls-clean | \ - ls-append-sdhead $(1) | pad-to 16M | \ + ls-append-sdhead $(1) | pad-to 15M | \ + ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ append-rootfs | check-size $(LS_SD_IMAGE_SIZE) | append-metadata endef TARGET_DEVICES += fsl_ls1046a-rdb-sdboot define Device/fsl_ls1088a-rdb + $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP DEVICE_MODEL := LS1088A-RDB DEVICE_VARIANT := Default @@ -262,13 +270,15 @@ define Device/fsl_ls1088a-rdb-sdboot append-rootfs | check-size $(LS_SD_IMAGE_SIZE) IMAGE/sysupgrade.bin := \ ls-clean | \ - ls-append-sdhead $(1) | pad-to 16M | \ + ls-append-sdhead $(1) | pad-to 15M | \ + ls-append-dtb $$(DEVICE_DTS) | pad-to 16M | \ append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ append-rootfs | check-size $(LS_SD_IMAGE_SIZE) | append-metadata endef TARGET_DEVICES += fsl_ls1088a-rdb-sdboot define Device/fsl_ls2088a-rdb + $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP DEVICE_MODEL := LS2088ARDB DEVICE_PACKAGES += \ -- 2.30.2