b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | # |
| 3 | # Copyright (C) 2017 OpenWrt.org |
| 4 | |
| 5 | RAMFS_COPY_BIN='fw_printenv fw_setenv dmesg' |
| 6 | RAMFS_COPY_DATA="/etc/fw_env.config" |
| 7 | REQUIRE_IMAGE_METADATA=0 |
| 8 | |
| 9 | platform_check_image() |
| 10 | { |
| 11 | local board=$(board_name) |
| 12 | |
| 13 | nand_do_platform_check $board $1 |
| 14 | return $? |
| 15 | } |
| 16 | |
| 17 | platform_do_upgrade() { |
| 18 | # TODO no need to switch to ramfs with dual partitions in |
| 19 | # fact we don't even want to reboot as part of seamless |
| 20 | # upgrades. Instead just upgrade opposite partition and mark |
| 21 | # the next reboot to boot from that partition. Could just call |
| 22 | # stage2 directly but need to refactor nand_upgrade_success |
| 23 | # for this to work. |
| 24 | # Also the nand functions don't allow url to be used |
| 25 | |
| 26 | local board=$(board_name) |
| 27 | |
| 28 | case "$board" in |
| 29 | img,pistachio-marduk) |
| 30 | local boot_partition=$(dmesg | grep "ubi0: attached.*" | sed "s/^.*\(firmware[0-1]\).*/\1/g") |
| 31 | |
| 32 | echo "Current boot partiton $boot_partition (/dev/mtd$(find_mtd_index $boot_partition))" |
| 33 | mkdir -p /var/lock |
| 34 | if [ "$boot_partition" == "firmware0" ]; then |
| 35 | CI_UBIPART="firmware1" |
| 36 | fw_setenv boot_partition 1 || exit 1 |
| 37 | else |
| 38 | CI_UBIPART="firmware0" |
| 39 | fw_setenv boot_partition 0 || exit 1 |
| 40 | fi |
| 41 | echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))" |
| 42 | ;; |
| 43 | esac |
| 44 | |
| 45 | nand_do_upgrade $1 |
| 46 | } |