summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPraneeth Bajjuri2018-10-15 17:35:11 -0500
committerPraneeth Bajjuri2018-10-15 17:40:20 -0500
commit00e023dbde76d24d05dd50849326e0f65dfa9e85 (patch)
tree68d116d76057cec9c175d600f9daaa7ceddc40d7
parent97b8ca534f223a24aa1e66c185dd54f0082925ba (diff)
downloaddevice-ti-am65xevm-00e023dbde76d24d05dd50849326e0f65dfa9e85.tar.gz
device-ti-am65xevm-00e023dbde76d24d05dd50849326e0f65dfa9e85.tar.xz
device-ti-am65xevm-00e023dbde76d24d05dd50849326e0f65dfa9e85.zip
am65xevm: Initial fastboot script
Initial Fastboot flashing script to flash all android images on am65xevm Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
-rwxr-xr-xfastboot.sh202
1 files changed, 202 insertions, 0 deletions
diff --git a/fastboot.sh b/fastboot.sh
new file mode 100755
index 0000000..f90eeba
--- /dev/null
+++ b/fastboot.sh
@@ -0,0 +1,202 @@
1#!/bin/bash
2
3usage ()
4{
5 echo "Usage: sudo fastboot.sh <options>";
6 echo "options:";
7 echo " --help Show this message and exit"
8 exit 1;
9}
10
11#no args case
12if [ "$1" = "--help" ] ; then
13 usage
14fi
15
16# Pre-packaged DB
17export FASTBOOT=${FASTBOOT-"./fastboot"}
18export PRODUCT_OUT=${PRODUCT_OUT-"./"}
19export LD_LIBRARY_PATH=./
20
21echo "Fastboot: $FASTBOOT"
22echo "Image location: $PRODUCT_OUT"
23
24
25# =============================================================================
26# pre-run
27# =============================================================================
28
29# Verify fastboot program is available
30# Verify user permission to run fastboot
31# Verify fastboot detects a device, otherwise exit
32if [ -f ${FASTBOOT} ]; then
33 fastboot_status=`${FASTBOOT} devices 2>&1`
34 if [ `echo $fastboot_status | grep -wc "no permissions"` -gt 0 ]; then
35 cat <<-EOF >&2
36 -------------------------------------------
37 Fastboot requires administrator permissions
38 Please run the script as root or create a
39 fastboot udev rule, e.g:
40
41 % cat /etc/udev/rules.d/99_android.rules
42 SUBSYSTEM=="usb",
43 SYSFS{idVendor}=="0451"
44 OWNER="<username>"
45 GROUP="adm"
46 -------------------------------------------
47 EOF
48 exit 1
49 elif [ "X$fastboot_status" = "X" ]; then
50 echo "No device detected. Please ensure that" \
51 "fastboot is running on the target device"
52 exit -1;
53 else
54 device=`echo $fastboot_status | awk '{print$1}'`
55 echo -e "\nFastboot - device detected: $device\n"
56 fi
57else
58 echo "Error: fastboot is not available at ${FASTBOOT}"
59 exit -1;
60fi
61
62# make bootloader image
63# bootloader.img is FAT Image consisting
64# sysfw.itb, u-boot.img and tispl.bin
65dd if=/dev/zero of=bootloader.img bs=1048576 count=8
66mkfs.vfat bootloader.img
67mcopy -i bootloader.img tispl.bin ::tispl.bin
68mcopy -i bootloader.img u-boot.img ::u-boot.img
69mcopy -i bootloader.img sysfw.itb ::sysfw.itb
70
71## poll the board to find out its configuration
72cpu=`${FASTBOOT} getvar cpu 2>&1 | grep cpu | awk '{print$2}'`
73cputype=`${FASTBOOT} getvar secure 2>&1 | grep secure | awk '{print$2}'`
74boardrev=`${FASTBOOT} getvar board_rev 2>&1 | grep board_rev | awk '{print$2}' | cut -b 1`
75
76# Create the filename
77tiboot3bin="${PRODUCT_OUT}tiboot3.bin"
78bootloaderimg="${PRODUCT_OUT}bootloader.img"
79systemimg="${PRODUCT_OUT}system.img"
80userdataimg="${PRODUCT_OUT}userdata.img"
81vendorimg="${PRODUCT_OUT}vendor.img"
82bootfitimg="${PRODUCT_OUT}boot_fit.img"
83
84# Verify that all the files required for the fastboot flash
85# process are available
86
87if [ ! -e "${tiboot3bin}" ] ; then
88 echo "Missing ${tiboot3bin}"
89 exit -1;
90fi
91if [ ! -e "${bootloaderimg}" ] ; then
92 echo "Missing ${bootloaderimg}"
93 exit -1;
94fi
95if [ ! -e "${systemimg}" ] ; then
96 echo "Missing ${systemimg}"
97 exit -1;
98fi
99if [ ! -e "${userdataimg}" ] ; then
100 echo "Missing ${userdataimg}"
101 exit -1;
102fi
103if [ ! -e "${vendorimg}" ] ; then
104 echo "Missing ${vendorimg}"
105 exit -1;
106fi
107if [ ! -e "${bootfitimg}" ] ; then
108 echo "Missing ${bootfitimg}"
109 exit -1;
110fi
111
112#echo "Create GPT partition table"
113#${FASTBOOT} oem format
114
115sleep 3
116
117echo "Flashing tiboot3....."
118echo " tiboot3bin: ${tiboot3bin}"
119${FASTBOOT} flash tiboot3 ${tiboot3bin}
120
121sleep 3
122echo " bootloader: ${bootloaderimg}"
123${FASTBOOT} flash bootloader ${bootloaderimg}
124
125# echo "Reboot: make sure new bootloader runs..."
126# ${FASTBOOT} reboot-bootloader
127# sleep 5
128
129#echo "Re-creating GPT partition table with new bootloader"
130#${FASTBOOT} oem format
131
132echo "Flash android partitions"
133${FASTBOOT} flash system ${systemimg}
134${FASTBOOT} flash vendor ${vendorimg}
135
136echo "Flashing FIT Boot Image"
137${FASTBOOT} flash boot ${bootfitimg}
138
139userdataimg_orig="${userdataimg}.orig"
140if [ ! -f $userdataimg_orig ]; then
141 cp $userdataimg $userdataimg_orig
142else
143 cp $userdataimg_orig $userdataimg
144fi
145
146echo "Resizing userdata.img"
147resizefail=0
148userdatasize=`${FASTBOOT} getvar userdata_size 2>&1 | grep "userdata_size" | awk '{print$2}'`
149if [ -n "$userdatasize" ]; then
150 while [ 1 ];do
151 echo Current userdata partition size=${userdatasize} KB
152 if [ -d "./data" ]; then
153 echo "Removing data"
154 rm -rf ./data || resizefail=1
155 if [ $resizefail -eq 1 ]; then
156 echo "unable to remove data folder" && break
157 fi
158 fi
159 mkdir ./data
160 ./simg2img ${userdataimg} ${userdataimg}.raw
161 mount -o loop -o grpid -t ext4 ${userdataimg}.raw ./data || resizefail=1
162 if [ $resizefail -eq 1 ]; then
163 echo "Mount failed" && break
164 fi
165 ./make_ext4fs -s -l ${userdatasize}K -a data ${userdataimg} data/
166 sync
167 umount data
168 sync
169 rm -rf ./data
170 rm ${userdataimg}.raw
171 break
172 done
173else
174 resizefail=1
175fi
176
177if [ $resizefail -eq 1 ]; then
178 echo "userdata resize failed."
179 echo "Eg: sudo ./fastboot.sh"
180 echo "For now, we are defaulting to original userdata.img"
181 cp $userdataimg_orig $userdataimg
182fi
183${FASTBOOT} flash userdata ${userdataimg}
184
185#reboot now
186#${FASTBOOT} reboot
187
188#if [ $resizefail -eq 1 ]; then
189# echo "--------------------------------------------------"
190# echo "Attempt was made to resize the userdata partition image"
191# echo "to the size available on your SOM. But it failed either"
192# echo "because it failed to remove existing ./data folder or because"
193# echo "you are not running this script with superuser privileges"
194# echo "Don't panic! The script just loaded the original userdata.img"
195# echo "so, things should just work as expected. Just that the size"
196# echo "of /data will be smaller on target."
197# echo ""
198# echo "If you really want to resize userdata.img, remove any existing"
199# echo "./data folder and run \"sudo ./fastboot.sh\""
200# echo "For now, we are defaulting to original userdata.img"
201# echo "--------------------------------------------------"
202#fi