1
0
Fork 0
forked from mirror/openwrt
openwrt/target/linux/ramips/mt7621/base-files/lib/upgrade/dualboot_datachk.sh
Sven Eckelmann (Plasma Cloud) c7c54f3134 ramips: add support for Plasma Cloud PAX1800-Lite
Plasma Cloud PAX1800-Lite is a dual-band Wi-Fi 6 router, based on MediaTek
MT7621A + MT79x5D platform.

Specifications:

- SOC:      MT7621AT (880 MHz)
- DRAM:     DDR3 448 MiB (Nanya NT5CC256M16DP-DI)
- Flash:    2 MiB SPI NOR (S25FL016K) + 128 MB SPI NAND (W25N02KVZEIR)
- Ethernet: 1x 10/100/1000 Mbps (SOC's built-in switch, with PoE+)
- Wi-Fi:    2x2:2 2.4/5 GHz (MT7905DAN + MT7975DN)
            (MT7905DAN doesn't support background DFS scan/BT)
- LED:      tri-color LED for status (red, blue, green)
- Buttons:  1x (reset)
- Antenna:  4x internal, non-detachable omnidirectional
- UART:     1x 4-pin (2.54 mm pitch, marked as "3V3 G/RX GND W/TX")
- Power:    12 V DC/2 A (DC jack)

MAC addresses:

WAN:     54:9C:27:xx:xx:00 (factory 0x3fff4, device label)
2.4 GHz: 54:9C:27:xx:xx:02 (factory 0x4, device label +2)
5 GHz:   54:9C:27:xx:xx:08 (factory 0xa, device label +8)

Flashing instructions:
======================

Various methods can be used to install the actual image on the flash.
Two easy ones are:

ap51-flash
----------

The tool ap51-flash (https://github.com/ap51-flash/ap51-flash) should be
used to transfer the image to the u-boot when the device boots up.

initramfs from TFTP
-------------------

The serial console (115200 8N1) must be used to access the u-boot shell
during bootup. It can then be used to first boot up the initramfs image
from a TFTP server (here with the IP 192.168.1.21):

    setenv serverip 192.168.1.21
    setenv ipaddr 192.168.1.1
    tftpboot 0x83001000 <filename-of-initramfs-kernel>.bin && bootm $fileaddr

The actual sysupgrade image can then be transferred (on the LAN port) to the
device via

    scp <filename-of-squashfs-sysupgrade>.bin root@192.168.1.1:/tmp/

On the device, the sysupgrade must then be started using

    sysupgrade -n /tmp/<filename-of-squashfs-sysupgrade>.bin

Signed-off-by: Sven Eckelmann (Plasma Cloud) <se@simonwunderlich.de>
Link: https://github.com/openwrt/openwrt/pull/20152
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-10-04 20:30:36 +02:00

67 lines
2.3 KiB
Bash

# The U-Boot loader with the datachk patchset for dualbooting requires image
# sizes and checksums to be provided in the U-Boot environment.
# The devices come with 2 main partitions - while one is active
# sysupgrade will flash the other. The boot order is changed to boot the
# newly flashed partition. If the new partition can't be booted due to
# upgrade failures the previously used partition is loaded.
platform_do_upgrade_dualboot_datachk() {
local next_boot_part=1
local tar_file="$1"
local bootseq
local setenv_script="/tmp/fw_env_upgrade"
if [ "$(grep 'ubi.mtd=firmware1' /proc/cmdline)" ]; then
next_boot_part=2
bootseq="2,1"
else
next_boot_part=1
bootseq="1,2"
fi
local board_dir="$(tar tf "${tar_file}" | grep -m 1 '^sysupgrade-.*/$')"
board_dir="${board_dir%/}"
local kernel_length="$(tar xf "${tar_file}" "${board_dir}/kernel" -O | wc -c)"
local rootfs_length="$(tar xf "${tar_file}" "${board_dir}/root" -O | wc -c)"
local kernel_md5="$(tar xf "${tar_file}" "${board_dir}/kernel" -O | md5sum)"
kernel_md5="${kernel_md5%% *}"
local rootfs_md5="$(tar xf "${tar_file}" "${board_dir}/root" -O | md5sum)"
rootfs_md5="${rootfs_md5%% *}"
CI_UBIPART="firmware${next_boot_part}"
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
nand_upgrade_prepare_ubi "${rootfs_length}" "squashfs" "$kernel_length" "0"
local ubidev="$(nand_find_ubi "${CI_UBIPART}")"
local kern_ubivol="$(nand_find_volume "${ubidev}" "${CI_KERNPART}")"
tar xf "${tar_file}" "${board_dir}/kernel" -O | \
ubiupdatevol "/dev/${kern_ubivol}" -s "${kernel_length}" -
local root_ubivol="$(nand_find_volume "${ubidev}" "${CI_ROOTPART}")"
tar xf "${tar_file}" "${board_dir}/root" -O | \
ubiupdatevol "/dev/${root_ubivol}" -s "${rootfs_length}" -
[ -f "${UPGRADE_BACKUP}" ] && nand_restore_config "${UPGRADE_BACKUP}"
# write new new uboot-env
printf "bootseq ${bootseq}\n" > "${setenv_script}"
printf "kernel_%i_size 0x%08x\n" "${next_boot_part}" "${kernel_length}" >> "${setenv_script}"
printf "kernel_%i_checksum %s\n" "${next_boot_part}" "${kernel_md5}" >> "${setenv_script}"
printf "rootfs_%i_size 0x%08x\n" "${next_boot_part}" "${rootfs_length}" >> "${setenv_script}"
printf "rootfs_%i_checksum %s\n" "${next_boot_part}" "${rootfs_md5}" >> "${setenv_script}"
mkdir -p /var/lock
fw_setenv -s "${setenv_script}" || {
echo "failed to update U-Boot environment"
return 1
}
}