2018-04-30 12:42:39 +00:00
|
|
|
#
|
2019-03-04 05:05:27 +00:00
|
|
|
# Copyright 2015-2019 Traverse Technologies
|
2020-05-28 04:48:29 +00:00
|
|
|
# Copyright 2020 NXP
|
2018-04-30 12:42:39 +00:00
|
|
|
#
|
2019-07-17 06:02:05 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2020-02-25 19:07:41 +00:00
|
|
|
REQUIRE_IMAGE_METADATA=1
|
|
|
|
|
2020-05-28 08:02:28 +00:00
|
|
|
platform_check_image_sdboot() {
|
|
|
|
local diskdev partdev diff
|
|
|
|
|
|
|
|
export_bootdevice && export_partdevice diskdev 0 || {
|
|
|
|
echo "Unable to determine upgrade device"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# get partitions table from boot device
|
|
|
|
get_partitions "/dev/$diskdev" bootdisk
|
|
|
|
|
|
|
|
# get partitions table from sysupgrade.bin
|
|
|
|
dd if="$1" of=/tmp/image.bs bs=512b count=1 > /dev/null 2>&1
|
|
|
|
sync
|
|
|
|
get_partitions /tmp/image.bs image
|
|
|
|
|
|
|
|
# compare tables
|
|
|
|
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
|
|
|
|
|
|
|
rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
|
|
|
|
|
|
|
|
if [ -n "$diff" ]; then
|
|
|
|
echo "Partition layout has changed. Full image will be written."
|
|
|
|
ask_bool 0 "Abort" && exit 1
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
platform_do_upgrade_sdboot() {
|
|
|
|
local diskdev partdev diff
|
|
|
|
|
|
|
|
export_bootdevice && export_partdevice diskdev 0 || {
|
|
|
|
echo "Unable to determine upgrade device"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
|
|
|
|
# get partitions table from boot device
|
|
|
|
get_partitions "/dev/$diskdev" bootdisk
|
|
|
|
|
|
|
|
# get partitions table from sysupgrade.bin
|
|
|
|
dd if="$1" of=/tmp/image.bs bs=512b count=1 > /dev/null 2>&1
|
|
|
|
sync
|
|
|
|
get_partitions /tmp/image.bs image
|
|
|
|
|
|
|
|
# compare tables
|
|
|
|
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
|
|
|
else
|
|
|
|
diff=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$diff" ]; then
|
|
|
|
dd if="$1" of="/dev/$diskdev" bs=1024 count=4 > /dev/null 2>&1
|
2020-08-20 07:28:01 +00:00
|
|
|
echo "Writing image to /dev/$diskdev..."
|
2020-08-19 10:13:26 +00:00
|
|
|
dd if="$1" of="/dev/$diskdev" bs=1024 skip=15360 seek=15360 > /dev/null 2>&1
|
2020-05-28 08:02:28 +00:00
|
|
|
sync
|
|
|
|
|
|
|
|
# Separate removal and addtion is necessary; otherwise, partition 1
|
|
|
|
# will be missing if it overlaps with the old partition 2
|
|
|
|
partx -d - "/dev/$diskdev"
|
|
|
|
partx -a - "/dev/$diskdev"
|
|
|
|
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2020-08-19 10:13:26 +00:00
|
|
|
# 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
|
2020-05-28 08:02:28 +00:00
|
|
|
# write kernel image
|
2020-08-20 07:28:01 +00:00
|
|
|
echo "Writing kernel to /dev/$diskdev..."
|
|
|
|
dd if="$1" of="/dev/$diskdev" bs=1024 skip=16384 seek=16384 count=16384 > /dev/null 2>&1
|
2020-05-28 08:02:28 +00:00
|
|
|
sync
|
|
|
|
|
|
|
|
# iterate over each partition from the image and write it to the boot disk
|
|
|
|
while read part start size; do
|
|
|
|
if export_partdevice partdev $part; then
|
|
|
|
echo "Writing image to /dev/$partdev..."
|
|
|
|
dd if="$1" of="/dev/$partdev" bs=512 skip="$start" count="$size" > /dev/null 2>&1
|
|
|
|
sync
|
|
|
|
else
|
|
|
|
echo "Unable to find partition $part device, skipped."
|
|
|
|
fi
|
|
|
|
done < /tmp/partmap.image
|
|
|
|
|
|
|
|
}
|
2018-04-30 12:42:39 +00:00
|
|
|
platform_do_upgrade_traverse_nandubi() {
|
|
|
|
bootsys=$(fw_printenv bootsys | awk -F= '{{print $2}}')
|
|
|
|
newbootsys=2
|
|
|
|
if [ "$bootsys" -eq "2" ]; then
|
|
|
|
newbootsys=1
|
|
|
|
fi
|
|
|
|
|
2019-03-04 05:05:27 +00:00
|
|
|
# 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}"
|
2018-04-30 12:42:39 +00:00
|
|
|
fw_setenv bootsys $newbootsys
|
2019-03-04 05:05:27 +00:00
|
|
|
CI_UBIPART="nandubi"
|
|
|
|
CI_KERNPART="kernel${newbootsys}"
|
|
|
|
CI_ROOTPART="rootfs${newbootsys}"
|
2019-07-14 17:03:19 +00:00
|
|
|
nand_do_upgrade "$1" || (echo "Upgrade failed, setting bootsys ${bootsys}" && fw_setenv bootsys $bootsys)
|
2019-03-04 05:05:27 +00:00
|
|
|
|
2018-04-30 12:42:39 +00:00
|
|
|
}
|
2020-08-24 10:21:19 +00:00
|
|
|
platform_copy_config_sdboot() {
|
|
|
|
local diskdev partdev parttype=ext4
|
|
|
|
|
|
|
|
export_bootdevice && export_partdevice diskdev 0 || {
|
|
|
|
echo "Unable to determine upgrade device"
|
|
|
|
return 1
|
|
|
|
}
|
2020-05-28 08:02:28 +00:00
|
|
|
|
|
|
|
if export_partdevice partdev 1; then
|
2020-08-24 10:21:19 +00:00
|
|
|
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt 2>&1
|
2020-05-28 08:02:28 +00:00
|
|
|
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
|
|
|
|
umount /mnt
|
|
|
|
fi
|
|
|
|
}
|
2020-08-24 10:21:19 +00:00
|
|
|
platform_copy_config() {
|
|
|
|
local board=$(board_name)
|
|
|
|
|
|
|
|
case "$board" in
|
|
|
|
fsl,ls1012a-frwy-sdboot | \
|
|
|
|
fsl,ls1021a-twr-sdboot | \
|
|
|
|
fsl,ls1043a-rdb-sdboot | \
|
|
|
|
fsl,ls1046a-rdb-sdboot | \
|
|
|
|
fsl,ls1088a-rdb-sdboot)
|
|
|
|
platform_copy_config_sdboot
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2018-04-30 12:42:39 +00:00
|
|
|
platform_check_image() {
|
|
|
|
local board=$(board_name)
|
|
|
|
|
|
|
|
case "$board" in
|
|
|
|
traverse,ls1043v | \
|
2019-03-04 05:05:27 +00:00
|
|
|
traverse,ls1043s)
|
|
|
|
nand_do_platform_check "traverse-ls1043" $1
|
|
|
|
return $?
|
2018-04-30 12:42:39 +00:00
|
|
|
;;
|
2020-05-28 04:48:29 +00:00
|
|
|
fsl,ls1012a-frdm | \
|
|
|
|
fsl,ls1012a-rdb | \
|
|
|
|
fsl,ls1021a-twr | \
|
|
|
|
fsl,ls1043a-rdb | \
|
|
|
|
fsl,ls1046a-rdb | \
|
|
|
|
fsl,ls1088a-rdb | \
|
|
|
|
fsl,ls2088a-rdb)
|
2020-02-25 19:07:40 +00:00
|
|
|
return 0
|
|
|
|
;;
|
2020-05-28 08:02:28 +00:00
|
|
|
fsl,ls1012a-frwy-sdboot | \
|
|
|
|
fsl,ls1021a-twr-sdboot | \
|
|
|
|
fsl,ls1043a-rdb-sdboot | \
|
|
|
|
fsl,ls1046a-rdb-sdboot | \
|
|
|
|
fsl,ls1088a-rdb-sdboot)
|
|
|
|
platform_check_image_sdboot "$1"
|
|
|
|
return 0
|
|
|
|
;;
|
2018-04-30 12:42:39 +00:00
|
|
|
*)
|
|
|
|
echo "Sysupgrade is not currently supported on $board"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
platform_do_upgrade() {
|
|
|
|
local board=$(board_name)
|
|
|
|
|
2019-07-17 06:02:05 +00:00
|
|
|
# Force the creation of fw_printenv.lock
|
|
|
|
mkdir -p /var/lock
|
|
|
|
touch /var/lock/fw_printenv.lock
|
|
|
|
|
2018-04-30 12:42:39 +00:00
|
|
|
case "$board" in
|
|
|
|
traverse,ls1043v | \
|
2019-03-04 05:05:27 +00:00
|
|
|
traverse,ls1043s)
|
2019-07-14 17:03:19 +00:00
|
|
|
platform_do_upgrade_traverse_nandubi "$1"
|
2018-04-30 12:42:39 +00:00
|
|
|
;;
|
2020-05-28 04:48:29 +00:00
|
|
|
fsl,ls1012a-frdm | \
|
|
|
|
fsl,ls1012a-rdb | \
|
|
|
|
fsl,ls1021a-twr | \
|
|
|
|
fsl,ls1043a-rdb | \
|
|
|
|
fsl,ls1046a-rdb | \
|
|
|
|
fsl,ls1088a-rdb | \
|
|
|
|
fsl,ls2088a-rdb)
|
2020-02-25 19:07:40 +00:00
|
|
|
PART_NAME=firmware
|
|
|
|
default_do_upgrade "$1"
|
|
|
|
;;
|
2020-05-28 08:02:28 +00:00
|
|
|
fsl,ls1012a-frwy-sdboot | \
|
|
|
|
fsl,ls1021a-twr-sdboot | \
|
|
|
|
fsl,ls1043a-rdb-sdboot | \
|
|
|
|
fsl,ls1046a-rdb-sdboot | \
|
|
|
|
fsl,ls1088a-rdb-sdboot)
|
|
|
|
platform_do_upgrade_sdboot "$1"
|
|
|
|
return 0
|
|
|
|
;;
|
2018-04-30 12:42:39 +00:00
|
|
|
*)
|
|
|
|
echo "Sysupgrade is not currently supported on $board"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|