diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2022-03-04 16:03:26 +0100 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2022-03-07 14:48:02 +0100 |
commit | 13c9f1f37df6d34ee5f1ba1d8f7542a1b24736fa (patch) | |
tree | fd8c3418ad2e8a45cf3d906145e7a113ceb54a62 /target/linux/bcm4908/base-files/lib/upgrade/platform.sh | |
parent | e12ffac02d40affd3706943a5789741a5e42d643 (diff) | |
download | upstream-13c9f1f37df6d34ee5f1ba1d8f7542a1b24736fa.tar.gz upstream-13c9f1f37df6d34ee5f1ba1d8f7542a1b24736fa.tar.bz2 upstream-13c9f1f37df6d34ee5f1ba1d8f7542a1b24736fa.zip |
bcm4908: support "rootfs_data" on U-Boot devices
1. Create "rootfs_data" dynamicaly
U-Boot firmware images can contain only 2 UBI volumes: bootfs (container
with U-Boot + kernel + DTBs) and rootfs (e.g. squashfs). There is no way
to include "rootfs_data" UBI volume or make firmware file tell U-Boot to
create one.
For that reason "rootfs_data" needs to be created dynamically. Use
preinit script to handle that. Fire it right before "mount_root" one.
2. Relate "rootfs_data" to flashed firmware
As already explained flashing new firmware with U-Boot will do nothing
to the "rootfs_data". It could result in new firmware reusing old
"rootfs_data" overlay UBI volume and its file. Users expect a clean
state after flashing firmware (even if flashing the same one).
Solve that by reading flash counter of running firmware and storing it
in "rootfs_data" UBI volume. Every mismatch will result in wiping old
data.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit 93259e8ca261c7965618fe11c2d385638da5cfa6)
Diffstat (limited to 'target/linux/bcm4908/base-files/lib/upgrade/platform.sh')
-rw-r--r-- | target/linux/bcm4908/base-files/lib/upgrade/platform.sh | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/target/linux/bcm4908/base-files/lib/upgrade/platform.sh b/target/linux/bcm4908/base-files/lib/upgrade/platform.sh index e7d4bfe4de..bee90e8366 100644 --- a/target/linux/bcm4908/base-files/lib/upgrade/platform.sh +++ b/target/linux/bcm4908/base-files/lib/upgrade/platform.sh @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause -RAMFS_COPY_BIN="bcm4908img expr egrep fdtget fw_printenv fw_setenv tr" +. /lib/functions/bcm4908.sh + +RAMFS_COPY_BIN="bcm4908img expr egrep ln fdtget fw_printenv fw_setenv readlink tr" PART_NAME=firmware @@ -134,17 +136,7 @@ platform_pkgtb_get_image() { } } -platform_pkgtb_setup_env_config() { - local size=$((0x$(get_hex_u32_le /dev/ubi0_1 4))) - - dd if=/dev/ubi0_1 of=/tmp/env.head count=8 iflag=count_bytes - dd if=/dev/ubi0_1 of=/tmp/env.body skip=8 iflag=skip_bytes - printf "%s\t0x%x\t0x%x\t0x%x" "/tmp/env.body" 0x0 $size $size > /tmp/env.config -} - platform_pkgtb_get_upgrade_index() { - platform_pkgtb_setup_env_config - case "$(fw_printenv -l /tmp -n -c /tmp/env.config COMMITTED)" in 1) echo 2;; 2) echo 1;; @@ -160,8 +152,6 @@ platform_pkgtb_commit() { local seq2 local tmp - platform_pkgtb_setup_env_config - # Read current values for valid in $(fw_printenv -l /tmp -n -c /tmp/env.config VALID | tr ',' ' '); do case "$valid" in @@ -272,11 +262,20 @@ platform_check_image() { # upgrade # +platform_pkgtb_clean_rootfs_data() { + local ubidev=$(nand_find_ubi $CI_UBIPART) + local ubivol="$(nand_find_volume $ubidev rootfs_data)" + + bcm4908_verify_rootfs_data "$ubivol" +} + platform_do_upgrade_pkgtb() { local cmd="${2:-cat}" local size local idx bootfs_id rootfs_id + bcm4908_pkgtb_setup_env_config + idx=$(platform_pkgtb_get_upgrade_index) case "$idx" in 1) bootfs_id=3; rootfs_id=4;; @@ -295,6 +294,8 @@ platform_do_upgrade_pkgtb() { platform_pkgtb_commit $idx + CI_UBIPART="image" + platform_pkgtb_clean_rootfs_data nand_do_upgrade_success } |