2 # Copyright 2015-2019 Traverse Technologies
6 RAMFS_COPY_BIN
="/usr/sbin/fw_printenv /usr/sbin/fw_setenv /usr/sbin/ubinfo /bin/echo"
7 RAMFS_COPY_DATA
="/etc/fw_env.config /var/lock/fw_printenv.lock"
9 REQUIRE_IMAGE_METADATA
=1
11 platform_check_image_sdboot
() {
12 local diskdev partdev
diff
14 export_bootdevice
&& export_partdevice diskdev
0 ||
{
15 echo "Unable to determine upgrade device"
19 # get partitions table from boot device
20 get_partitions
"/dev/$diskdev" bootdisk
22 # get partitions table from sysupgrade.bin
23 dd if="$1" of
=/tmp
/image.bs bs
=512b count
=1 > /dev
/null
2>&1
25 get_partitions
/tmp
/image.bs image
28 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
30 rm -f /tmp
/image.bs
/tmp
/partmap.bootdisk
/tmp
/partmap.image
32 if [ -n "$diff" ]; then
33 echo "Partition layout has changed. Full image will be written."
34 ask_bool
0 "Abort" && exit 1
38 platform_do_upgrade_sdboot
() {
39 local diskdev partdev
diff
41 export_bootdevice
&& export_partdevice diskdev
0 ||
{
42 echo "Unable to determine upgrade device"
46 if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
47 # get partitions table from boot device
48 get_partitions
"/dev/$diskdev" bootdisk
50 # get partitions table from sysupgrade.bin
51 dd if="$1" of
=/tmp
/image.bs bs
=512b count
=1 > /dev
/null
2>&1
53 get_partitions
/tmp
/image.bs image
56 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
61 if [ -n "$diff" ]; then
62 dd if="$1" of
="/dev/$diskdev" bs
=1024 count
=4 > /dev
/null
2>&1
63 echo "Writing image to /dev/$diskdev..."
64 dd if="$1" of
="/dev/$diskdev" bs
=1024 skip
=16384 seek
=16384 > /dev
/null
2>&1
67 # Separate removal and addtion is necessary; otherwise, partition 1
68 # will be missing if it overlaps with the old partition 2
69 partx
-d - "/dev/$diskdev"
70 partx
-a - "/dev/$diskdev"
76 echo "Writing kernel to /dev/$diskdev..."
77 dd if="$1" of
="/dev/$diskdev" bs
=1024 skip
=16384 seek
=16384 count
=16384 > /dev
/null
2>&1
80 # iterate over each partition from the image and write it to the boot disk
81 while read part start size
; do
82 if export_partdevice partdev
$part; then
83 echo "Writing image to /dev/$partdev..."
84 dd if="$1" of
="/dev/$partdev" bs
=512 skip
="$start" count
="$size" > /dev
/null
2>&1
87 echo "Unable to find partition $part device, skipped."
89 done < /tmp
/partmap.image
92 platform_do_upgrade_traverse_nandubi
() {
93 bootsys
=$
(fw_printenv bootsys |
awk -F= '{{print $2}}')
95 if [ "$bootsys" -eq "2" ]; then
99 # If nand_do_upgrade succeeds, we don't have an opportunity to add any actions of
100 # our own, so do it here and set back on failure
101 echo "Setting bootsys to #${newbootsys}"
102 fw_setenv bootsys
$newbootsys
104 CI_KERNPART
="kernel${newbootsys}"
105 CI_ROOTPART
="rootfs${newbootsys}"
106 nand_do_upgrade
"$1" ||
(echo "Upgrade failed, setting bootsys ${bootsys}" && fw_setenv bootsys
$bootsys)
109 platform_copy_config
() {
110 local partdev parttype
=ext4
112 if export_partdevice partdev
1; then
113 mount
-t $parttype -o rw
,noatime
"/dev/$partdev" /mnt
114 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
118 platform_check_image
() {
119 local board
=$
(board_name
)
124 nand_do_platform_check
"traverse-ls1043" $1
136 fsl
,ls1012a-frwy-sdboot | \
137 fsl
,ls1021a-twr-sdboot | \
138 fsl
,ls1043a-rdb-sdboot | \
139 fsl
,ls1046a-rdb-sdboot | \
140 fsl
,ls1088a-rdb-sdboot
)
141 platform_check_image_sdboot
"$1"
145 echo "Sysupgrade is not currently supported on $board"
151 platform_do_upgrade
() {
152 local board
=$
(board_name
)
154 # Force the creation of fw_printenv.lock
156 touch /var
/lock
/fw_printenv.lock
161 platform_do_upgrade_traverse_nandubi
"$1"
171 default_do_upgrade
"$1"
173 fsl
,ls1012a-frwy-sdboot | \
174 fsl
,ls1021a-twr-sdboot | \
175 fsl
,ls1043a-rdb-sdboot | \
176 fsl
,ls1046a-rdb-sdboot | \
177 fsl
,ls1088a-rdb-sdboot
)
178 platform_do_upgrade_sdboot
"$1"
182 echo "Sysupgrade is not currently supported on $board"