summaryrefslogtreecommitdiff
path: root/recipes-bsp/dfu-metadata/files/recovery-linux.sh
blob: c613b5a045f3526d1551f6cfea3d97e5b5288ac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
if which dfu-util 2>&1 > /dev/null
then
	DFU_UTIL=$(which dfu-util) 2>&1 > /dev/null
else
	echo "Install dfu-util from your distro should the provided one not work with your distro"
	DFU_UTIL=recovery/dfu-util
fi

# boot to U-Boot from USB
sudo $DFU_UTIL -w -R -a bootloader --device 0451:6165 -D tiboot3-am62x-gp-evm.bin-dfu
sudo $DFU_UTIL -w -R -a tispl.bin --device 0451:6165 -D tispl.bin
sudo $DFU_UTIL -w -R -a u-boot.img --device 0451:6165  -D u-boot.img

# U-Boot starts DFU, flash U-Boot to eMMC
sudo $DFU_UTIL -w -a tiboot3.bin.raw --device 0451:6165 -D tiboot3.bin
sudo $DFU_UTIL -w -a tispl.bin.raw --device 0451:6165 -D tispl.bin
sudo $DFU_UTIL -w -R -a u-boot.img.raw --device 0451:6165  -D u-boot.img

# U-Boot starts UMS, wait for the device to appear
UMS_DEV=$(lsblk -I 8 -dp --output "MODEL,NAME" | grep UMS | sed 's#.*\(/dev/sd[a-z]\).*#\1#')
while [ -z $UMS_DEV ]; do
	sleep 1;
	echo 'Waiting for UMS...';
	UMS_DEV=$(lsblk -I 8 -dp --output "MODEL,NAME" | grep UMS | sed 's#.*\(/dev/sd[a-z]\).*#\1#')
done
# give it some time to settle in.
sleep 2
sudo umount ${UMS_DEV}?*

WIC=$(ls *.wic.??)
# use bmap-tool to flash eMMC user area
BMAPTOOL=$(realpath recovery/bmaptool) recovery/bmaptool.sh $WIC $UMS_DEV