Mathew McBride af0546da34 layerscape: armv8_64b: add Traverse Ten64 NAND variant
The Ten64 board[1] is based around NXP's Layerscape LS1088A SoC.
It is capable of booting both standard Linux distributions
from disk devices, using EFI, and booting OpenWrt
from NAND.

See the online manual for more information, including the
flash layout[2].

This patchset adds support for generating Ten64 images
for NAND boot.
For disk boot, one can use the EFI support that was
recently added to the armvirt target.

We previously supported NAND users by building
inside our armvirt/EFI target[3], but this approach
is not suitable for OpenWrt upstream. Users who
used our supplied NAND images will be able to upgrade
to this via sysupgrade.

Signed-off-by: Mathew McBride <matt@traverse.com.au>

[1] - https://www.traverse.com.au/hardware/ten64
[2] - https://ten64doc.traverse.com.au/hardware/flash/
[3] - Example:
285e4360e1
2023-06-25 16:02:19 +02:00

190 lines
4.4 KiB
Bash

#
# Copyright 2015-2019 Traverse Technologies
# Copyright 2020 NXP
#
RAMFS_COPY_BIN="/usr/sbin/fw_printenv /usr/sbin/fw_setenv /usr/sbin/ubinfo /bin/echo"
RAMFS_COPY_DATA="/etc/fw_env.config /var/lock/fw_printenv.lock"
REQUIRE_IMAGE_METADATA=1
platform_do_upgrade_sdboot() {
local diskdev partdev parttype=ext4
local tar_file="$1"
local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
export_bootdevice && export_partdevice diskdev 0 || {
echo "Unable to determine upgrade device"
return 1
}
if export_partdevice partdev 1; then
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt 2>&1
echo "Writing kernel..."
tar xf $tar_file ${board_dir}/kernel -O > /mnt/fitImage
umount /mnt
fi
echo "Erasing rootfs..."
dd if=/dev/zero of=/dev/mmcblk0p2 bs=1M > /dev/null 2>&1
echo "Writing rootfs..."
tar xf $tar_file ${board_dir}/root -O | dd of=/dev/mmcblk0p2 bs=512k > /dev/null 2>&1
}
platform_do_upgrade_traverse_nandubi() {
bootsys=$(fw_printenv bootsys | awk -F= '{{print $2}}')
newbootsys=2
if [ "$bootsys" -eq "2" ]; then
newbootsys=1
fi
# If nand_do_upgrade succeeds, we don't have an opportunity to add any actions of
# our own, so do it here and set back on failure
echo "Setting bootsys to #${newbootsys}"
fw_setenv bootsys $newbootsys
CI_UBIPART="nandubi"
CI_KERNPART="kernel${newbootsys}"
CI_ROOTPART="rootfs${newbootsys}"
nand_do_upgrade "$1" || (echo "Upgrade failed, setting bootsys ${bootsys}" && fw_setenv bootsys $bootsys)
}
platform_do_upgrade_traverse_slotubi() {
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
echo "Active boot slot: ${part}"
new_active_sys="b"
if [ ! -z "${part}" ]; then
if [ "${part}" = "ubia" ]; then
CI_UBIPART="ubib"
else
CI_UBIPART="ubia"
new_active_sys="a"
fi
fi
echo "Updating UBI part ${CI_UBIPART}"
fw_setenv "openwrt_active_sys" "${new_active_sys}"
nand_do_upgrade "$1"
return $?
}
platform_copy_config_sdboot() {
local diskdev partdev parttype=ext4
export_bootdevice && export_partdevice diskdev 0 || {
echo "Unable to determine upgrade device"
return 1
}
if export_partdevice partdev 1; then
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt 2>&1
echo "Saving config backup..."
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt
fi
}
platform_copy_config() {
local board=$(board_name)
case "$board" in
fsl,ls1012a-frwy-sdboot | \
fsl,ls1021a-iot-sdboot | \
fsl,ls1021a-twr-sdboot | \
fsl,ls1028a-rdb-sdboot | \
fsl,ls1043a-rdb-sdboot | \
fsl,ls1046a-frwy-sdboot | \
fsl,ls1046a-rdb-sdboot | \
fsl,ls1088a-rdb-sdboot | \
fsl,lx2160a-rdb-sdboot)
platform_copy_config_sdboot
;;
esac
}
platform_check_image() {
local board=$(board_name)
case "$board" in
traverse,ls1043v | \
traverse,ls1043s)
nand_do_platform_check "traverse-ls1043" $1
return $?
;;
traverse,ten64)
nand_do_platform_check "ten64-mtd" $1
return $?
;;
fsl,ls1012a-frdm | \
fsl,ls1012a-frwy-sdboot | \
fsl,ls1012a-rdb | \
fsl,ls1021a-iot-sdboot | \
fsl,ls1021a-twr | \
fsl,ls1021a-twr-sdboot | \
fsl,ls1028a-rdb | \
fsl,ls1028a-rdb-sdboot | \
fsl,ls1043a-rdb | \
fsl,ls1043a-rdb-sdboot | \
fsl,ls1046a-frwy | \
fsl,ls1046a-frwy-sdboot | \
fsl,ls1046a-rdb | \
fsl,ls1046a-rdb-sdboot | \
fsl,ls1088a-rdb | \
fsl,ls1088a-rdb-sdboot | \
fsl,ls2088a-rdb | \
fsl,lx2160a-rdb | \
fsl,lx2160a-rdb-sdboot)
return 0
;;
*)
echo "Sysupgrade is not currently supported on $board"
;;
esac
return 1
}
platform_do_upgrade() {
local board=$(board_name)
# Force the creation of fw_printenv.lock
mkdir -p /var/lock
touch /var/lock/fw_printenv.lock
case "$board" in
traverse,ls1043v | \
traverse,ls1043s)
platform_do_upgrade_traverse_nandubi "$1"
;;
traverse,ten64)
platform_do_upgrade_traverse_slotubi "${1}"
;;
fsl,ls1012a-frdm | \
fsl,ls1012a-rdb | \
fsl,ls1021a-twr | \
fsl,ls1028a-rdb | \
fsl,ls1043a-rdb | \
fsl,ls1046a-frwy | \
fsl,ls1046a-rdb | \
fsl,ls1088a-rdb | \
fsl,ls2088a-rdb | \
fsl,lx2160a-rdb)
PART_NAME=firmware
default_do_upgrade "$1"
;;
fsl,ls1012a-frwy-sdboot | \
fsl,ls1021a-iot-sdboot | \
fsl,ls1021a-twr-sdboot | \
fsl,ls1028a-rdb-sdboot | \
fsl,ls1043a-rdb-sdboot | \
fsl,ls1046a-frwy-sdboot | \
fsl,ls1046a-rdb-sdboot | \
fsl,ls1088a-rdb-sdboot | \
fsl,lx2160a-rdb-sdboot)
platform_do_upgrade_sdboot "$1"
return 0
;;
*)
echo "Sysupgrade is not currently supported on $board"
;;
esac
}