summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYogesh Siraswar2018-01-17 15:29:58 -0600
committerYogesh Siraswar2018-01-17 15:29:58 -0600
commit6502befe40ac5922193dde753c8fcc62cd2ae9ad (patch)
tree21c14ab66e7a784fc1f6ef2e29c3af9c32d5e65f /fastboot.sh
downloaddevice-ti-am43xevm-d-marshmallow-mr3-release.tar.gz
device-ti-am43xevm-d-marshmallow-mr3-release.tar.xz
device-ti-am43xevm-d-marshmallow-mr3-release.zip
am43xevm device filed-marshmallow-mr3-release
These file were verified on AM438x EVM: 1) Android 6AM1.3 release 2) 4.4 kernel Signed-off-by: Yogesh Siraswar <yogeshs@ti.com>
Diffstat (limited to 'fastboot.sh')
-rwxr-xr-xfastboot.sh253
1 files changed, 253 insertions, 0 deletions
diff --git a/fastboot.sh b/fastboot.sh
new file mode 100755
index 0000000..240d410
--- /dev/null
+++ b/fastboot.sh
@@ -0,0 +1,253 @@
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## poll the board to find out its configuration
63#product=`${FASTBOOT} getvar product 2>&1 | grep product | awk '{print$2}'`
64cpu=`${FASTBOOT} getvar cpu 2>&1 | grep cpu | awk '{print$2}'`
65cputype=`${FASTBOOT} getvar secure 2>&1 | grep secure | awk '{print$2}'`
66boardrev=`${FASTBOOT} getvar board_rev 2>&1 | grep board_rev | awk '{print$2}'`
67
68
69# Make EMU = HS
70if [ ${cputype} = "EMU" ] || [ ${cputype} = "HS" ]; then
71 cputype="HS"
72 xloader="${PRODUCT_OUT}${cputype}_QSPI_MLO"
73 uboot="${PRODUCT_OUT}${cputype}_u-boot.img"
74# If fastboot does not support getvar default to GP
75elif [ ${cputype} = "" ] || [ ${cputype} = "GP" ]; then
76 cputype="GP"
77 xloader="${PRODUCT_OUT}${cputype}_MLO"
78 uboot="${PRODUCT_OUT}u-boot.img"
79fi
80
81# Based on cpu, decide the dtb to flash, default fall back to J6 and LCD 10
82if [ ${cpu} = "J6ECO" ]; then
83 if [ ${boardrev} = "C" ]; then
84 environment="${PRODUCT_OUT}dra72-evm-lcd-osd.dtb"
85 elif [ ${boardrev} = "1.3A" ]; then
86 environment="${PRODUCT_OUT}am571x-idk-lcd-osd101t2587.dtb"
87 else
88 environment="${PRODUCT_OUT}dra72-evm-lcd10.dtb"
89 fi
90else
91 if [ ${boardrev} = "H" ]; then
92 environment="${PRODUCT_OUT}dra7-evm-lcd-osd.dtb"
93 else
94 environment="${PRODUCT_OUT}am57xx-evm-reva3.dtb"
95 fi
96fi
97
98if [ ${cpu} = "J6" ]; then
99 if [ ${boardrev} = "A.30" ]; then
100 environment="${PRODUCT_OUT}am57xx-evm-reva3.dtb"
101 elif [ ${boardrev} = "1.3A" ]; then
102 environment="${PRODUCT_OUT}am572x-idk-lcd-osd.dtb"
103 elif [ ${boardrev} = "B.10" ]; then
104 environment="${PRODUCT_OUT}am57xx-beagle-x15-revb1.dtb"
105 fi
106fi
107
108# Create the filename
109bootimg="${PRODUCT_OUT}boot.img"
110systemimg="${PRODUCT_OUT}system.img"
111userdataimg="${PRODUCT_OUT}userdata.img"
112cacheimg="${PRODUCT_OUT}cache.img"
113recoveryimg="${PRODUCT_OUT}recovery.img"
114
115
116# Verify that all the files required for the fastboot flash
117# process are available
118
119if [ ! -e "${bootimg}" ] ; then
120 echo "Missing ${bootimg}"
121 exit -1;
122fi
123if [ ! -e "$xloader" ] ; then
124 echo "Missing ${xloader}"
125 exit -1;
126fi
127if [ ! -e "${uboot}" ] ; then
128 echo "Missing ${uboot}"
129 exit -1;
130fi
131if [ ! -e "${environment}" ] ; then
132 echo "Missing ${environment}"
133 exit -1;
134else
135 echo "DTB = ${environment}"
136fi
137if [ ! -e "${systemimg}" ] ; then
138 echo "Missing ${systemimg}"
139 exit -1;
140fi
141if [ ! -e "${userdataimg}" ] ; then
142 echo "Missing ${userdataimg}"
143 exit -1;
144fi
145if [ ! -e "${cacheimg}" ] ; then
146 echo "Missing ${cacheimg}"
147 exit -1;
148fi
149if [ ! -e "${recoveryimg}" ] ; then
150 echo "Missing ${recoveryimg}"
151 exit -1;
152fi
153
154echo "Create GPT partition table"
155${FASTBOOT} oem format
156
157echo "Setting target for bootloader to emmc"
158${FASTBOOT} oem mmc
159
160sleep 3
161
162echo "Flashing bootloader....."
163echo " xloader: ${xloader}"
164${FASTBOOT} flash xloader ${xloader}
165
166sleep 3
167echo " bootloader: ${uboot}"
168${FASTBOOT} flash bootloader ${uboot}
169
170#echo "Reboot: make sure new bootloader runs..."
171${FASTBOOT} reboot-bootloader
172
173sleep 5
174
175echo "Re-creating GPT partition table with new bootloader"
176${FASTBOOT} oem format
177
178echo "Flash android partitions"
179${FASTBOOT} flash boot ${bootimg}
180echo "Flashing environemnt....."
181echo " environment: ${environment}"
182${FASTBOOT} flash environment ${environment}
183${FASTBOOT} flash recovery ${recoveryimg}
184${FASTBOOT} flash system ${systemimg}
185
186userdataimg_orig="${userdataimg}.orig"
187if [ ! -f $userdataimg_orig ]; then
188 cp $userdataimg $userdataimg_orig
189else
190 cp $userdataimg_orig $userdataimg
191fi
192
193echo "Resizing userdata.img"
194resizefail=0
195userdatasize=`./fastboot getvar userdata_size 2>&1 | grep "userdata_size" | awk '{print$2}'`
196if [ -n "$userdatasize" ]; then
197 while [ 1 ];do
198 echo Current userdata partition size=${userdatasize} KB
199 if [ -d "./data" ]; then
200 echo "Removing data"
201 rm -rf ./data || resizefail=1
202 if [ $resizefail -eq 1 ]; then
203 echo "unable to remove data folder" && break
204 fi
205 fi
206 mkdir ./data
207 ./simg2img userdata.img userdata.img.raw
208 mount -o loop -o grpid -t ext4 ./userdata.img.raw ./data || resizefail=1
209 if [ $resizefail -eq 1 ]; then
210 echo "Mount failed" && break
211 fi
212 ./make_ext4fs -s -l ${userdatasize}K -a data userdata.img data/
213 sync
214 umount data
215 sync
216 rm -rf ./data
217 rm userdata.img.raw
218 break
219 done
220else
221 resizefail=1
222fi
223
224if [ $resizefail -eq 1 ]; then
225 echo "userdata resize failed."
226 echo "Eg: sudo ./fastboot.sh"
227 echo "For now, we are defaulting to original userdata.img"
228 cp $userdataimg_orig $userdataimg
229fi
230${FASTBOOT} flash userdata ${userdataimg}
231
232#flash cache.img
233${FASTBOOT} flash cache ${cacheimg}
234
235#reboot now
236#${FASTBOOT} reboot
237
238#if [ $resizefail -eq 1 ]; then
239# echo "--------------------------------------------------"
240# echo "Attempt was made to resize the userdata partition image"
241# echo "to the size available on your SOM. But it failed either"
242# echo "because it failed to remove existing ./data folder or because"
243# echo "you are not running this script with superuser privileges"
244# echo "Don't panic! The script just loaded the original userdata.img"
245# echo "so, things should just work as expected. Just that the size"
246# echo "of /data will be smaller on target."
247# echo ""
248# echo "If you really want to resize userdata.img, remove any existing"
249# echo "./data folder and run \"sudo ./fastboot.sh\""
250# echo "For now, we are defaulting to original userdata.img"
251# echo "--------------------------------------------------"
252#fi
253