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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
|
[ -z "$ENV_MODEL_PATH" ] && echo "Need to set ENV_MODEL_PATH to the model's path, exiting" && return 1;
[ -z "$REMOTEUSER" ] && REMOTEUSER=$USER
[ ! -f "$ENV_MODEL_PATH/models/Linux64_GCC-4.1/RTSM_VE_AEMv8A.so" ] && echo "Can't find RTSM_VE_AEMv8A.so at \$ENV_MODEL_PATH/models/Linux64_GCC-4.1/
You set ENV_MODEL_PATH to $ENV_MODEL_PATH
Is this right?" && return 1;
export GLIT_DOC="Get linaro-image tools"
function glit() {
if [ -e /etc/mandriva-release -o -e /etc/rosa-release ]; then
bzr --version &>/dev/null || sudo urpmi bzr
else
sudo add-apt-repository ppa:linaro-maintainers/tools
sudo apt-get update
sudo apt-get install linaro-image-tools
sudo apt-get install bzr
fi
bzr branch lp:linaro-image-tools
if [ -e /etc/mandriva-release -o -e /etc/rosa-release ]; then
# Workaround for linaro-image-tools pulling in dpkg dependencies even
# when they aren't needed for the android part
# This breaks linaro-media-create obviously -- but we don't need that
sed -i -e 's,^from debian,#from debian,g' linaro-image-tools/linaro_image_tools/hwpack/builder.py linaro-image-tools/hwpack/packages.py
sed -i -e 's,^from apt,#from apt,g' linaro-image-tools/linaro_image_tools/hwpack/packages.py
sed -i -e 's,^import apt,#import apt,g' linaro-image-tools/linaro_image_tools/hwpack/packages.py linaro-image-tools/hwpack/tests/test_packages.py
fi
}
export MAKEMMC_DOC="make mmc.bin from a source build"
function makemmc() {
if [ ! -f ./linaro-image-tools/linaro-android-media-create ]; then
echo "Run glit() first"
return
fi
./linaro-image-tools/linaro-android-media-create \
--image_file mmc.bin \
--image_size 2000M \
--dev vexpress \
--system out/target/product/vexpress/system.tar.bz2 \
--userdata out/target/product/vexpress/userdata.tar.bz2 \
--boot out/target/product/vexpress/boot.tar.bz2
}
export PREBUILT_MAKEMMC_DOC="make mmc.bin from a source build"
function prebuilt_makemmc() {
if [ ! -f ./linaro-image-tools/linaro-android-media-create ]; then
echo "Run glit() first"
return
fi
./linaro-image-tools/linaro-android-media-create \
--image_file mmc.bin \
--image_size 2000M \
--dev vexpress \
--system system.tar.bz2 \
--userdata userdata.tar.bz2 \
--boot boot.tar.bz2
}
function untarboot() {
tar -jxvf out/target/product/vexpress/boot.tar.bz2
}
function placeramdisk() {
if [ ! -e boot/ramdisk.img ]; then
echo "Run untarbuiltboot"
fi
mkdir -p out/target/product/vexpress/
cp -af boot/ramdisk.img out/target/product/vexpress/
}
function untarbuiltboot() {
tar -jxvf boot.tar.bz2
}
function updateboot() {
if [ ! -e out/target/product/vexpress/boot/linux-system.axf ]; then
echo "no out/target/product/vexpress/boot/linux-system.axf"
echo "Run build, buildboot or bk followed by bi"
fi
mkdir -p boot
cp -af out/target/product/vexpress/boot/linux-system.axf boot/linux-system.axf
}
export RESTARTSSH_DOC="kill the ssh connection to the license server"
function killssh() {
local sshpid=$(ps aux | grep "[s]sh -L 8224" | awk '{print $2}')
echo $sshpid
if [ ! -z "$sshpid" ]; then
kill -9 $sshpid
else
echo "Nothing to kill"
fi
}
export RUN_DOC="run a build from a source build"
function run() {
if [ "$1" == "debugger" ]; then
export USE_MODEL=modeldebugger
else
export USE_MODEL=model_shell64
fi
export MODEL_PATH=$ENV_MODEL_PATH
export PATH=$PATH:$MODEL_PATH/bin/
export ARMLMD_LICENSE_FILE="8224@flexlm.linaro.org"
local grepssh=$(ps aux | grep "[s]sh -L 8224")
echo $grepssh
if [ -z "$grepssh" ]; then
ssh -L 8224:localhost:8224 \
-L 18224:localhost:18224 \
-N portfwd@23.21.178.170 &
sleep 2
fi
if [ ! -e boot/linux-system.axf ]; then
echo "run untarboot or updateboot"
return
fi
$USE_MODEL -a $(pwd)/boot/linux-system.axf $MODEL_PATH/models/Linux64_GCC-4.1/RTSM_VE_AEMv8A.so -C motherboard.mmc.p_mmc_file=$(pwd)/mmc.bin -C cluster.NUM_CORES=1 -C cluster.cpu0.unpredictable_WPMASKANDBAS=0 \
-C cluster.cpu0.unpredictable_non-contigous_BAS=0 \
-C cluster.cpu1.unpredictable_WPMASKANDBAS=0 \
-C cluster.cpu1.unpredictable_non-contigous_BAS=0 \
-C cluster.cpu2.unpredictable_WPMASKANDBAS=0 \
-C cluster.cpu2.unpredictable_non-contigous_BAS=0 \
-C cluster.cpu3.unpredictable_WPMASKANDBAS=0 \
-C cluster.cpu3.unpredictable_non-contigous_BAS=0 \
-C cluster.take_ccfail_undef=0 \
-C motherboard.hostbridge.userNetworking=true -C motherboard.hostbridge.userNetPorts="5556=6565" -C motherboard.smsc_91c111.enabled=1
}
function testbuild() {
prebuilt_makemmc
untarbuiltboot
run
}
export TESTBUILDALL_DOC="Run testbuildall after downloading:
boot.tar.bz2
system.tar.bz2
userdata.tar.bz2
"
function testbuildall() {
glit
testbuild
}
function runit() {
untarboot
run
}
function kitchensink() {
build
makemmc
untarboot
run
}
function bathsink() {
makemmc
untarboot
run
}
export BUILD_DOC="make a build"
function build() {
export CPUS=`grep -c processor /proc/cpuinfo`
export TARGET_PRODUCT=vexpress
export TARGET_SIMULATOR=false
export TARGET_BUILD_VARIANT=eng
export DEBUG_NO_STRICT_ALIASING=yes
export DEBUG_NO_STDCXX11=yes
export TOOLCHAIN_TRIPLET=arm-linux-androideabi
export BUILD_FS_IMAGE=1
export LINARO_BUILD_SPEC=juice-aosp
export ANDROID_64=true
. build/envsetup.sh
export PATH=$PATH:`pwd`/gcc-linaro-aarch64-linux-gnu-4.7/bin
if [ -z "$1" ]; then
time make -j${CPUS} boottarball systemtarball userdatatarball showcommands 2>&1 | tee build_log.txt
else
make -j${CPUS} $1 showcommands 2>&1 | tee build_log.txt
fi
}
export BUILD_DOC="just make boot stuff (rebuilds ramdisk.img)"
function buildboot() {
export CPUS=`grep -c processor /proc/cpuinfo`
export TARGET_PRODUCT=vexpress
export TARGET_SIMULATOR=false
export TARGET_BUILD_VARIANT=eng
export DEBUG_NO_STRICT_ALIASING=yes
export DEBUG_NO_STDCXX11=yes
export TOOLCHAIN_TRIPLET=arm-linux-androideabi
export BUILD_FS_IMAGE=1
export LINARO_BUILD_SPEC=juice-aosp
export ANDROID_64=true
. build/envsetup.sh
make -j${CPUS} boottarball
}
export BI_DOC="Build an image file, assumes kernel and ramdisk are up-to-date
Pass a ramdisk to use it, instead of the one that's part of the build"
function bi() {
MSG="
You can get one by downloading a boot.tar.bz2 from:
https://android-build.linaro.org/builds/~linaro-android-restricted/lindt-white/
Downloads > target > vexpress
tar -jxvf boot.tar.bz2
"
local ramdisk=1
if [ ! -e out/target/product/vexpress/obj/kernel/arch/arm64/boot/Image ]; then
echo "Build your kernel first with bk"
return
fi
if [ ! -e out/target/product/vexpress/ramdisk.img ]; then
echo "The ramdisk doesn't exist at: out/target/product/vexpress/ramdisk.img"
echo "Building without ramdisk"
ramdisk=0
fi
ln -sf $(pwd)/out/target/product/vexpress/obj/kernel/arch/arm64/boot/Image out/target/product/vexpress/kernel
ln -sf $(pwd)/out/target/product/vexpress/obj/kernel/scripts/dtc/dtc ./boot-wrapper/dtc
ln -sf $(pwd)/kernel/arch/arm64/boot/dts/vexpress-v2p-aarch64.dts ./boot-wrapper/vexpress-v2p-aarch64.dts
ln -sf $(pwd)/kernel/arch/arm64/boot/dts/vexpress-v2m-rs1.dtsi ./boot-wrapper/vexpress-v2m-rs1.dtsi
ln -sf $(pwd)/kernel/arch/arm64/boot/dts/skeleton.dtsi ./boot-wrapper/skeleton.dtsi
ln -sf $(pwd)/out/target/product/vexpress/kernel ./boot-wrapper/Image
if [ $ramdisk == 1 ]; then
ln -sf $(pwd)/out/target/product/vexpress/ramdisk.img ./boot-wrapper/filesystem.cpio.gz
PATH=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.7/bin:$PATH && \
make -C ./boot-wrapper clean && \
make -C ./boot-wrapper CROSS_COMPILE=aarch64-linux-android-
else
PATH=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.7/bin:$PATH && \
make -C ./boot-wrapper clean && \
sed 's/^INITRD_FLAGS/#INITRD_FLAGS/' <./boot-wrapper/Makefile | \
make -C ./boot-wrapper CROSS_COMPILE=aarch64-linux-android- -f-
fi
mkdir -p out/target/product/vexpress/boot
cp -fa ./boot-wrapper/linux-system.axf out/target/product/vexpress/boot/linux-system.axf
rm ./boot-wrapper/dtc
rm ./boot-wrapper/vexpress-v2p-aarch64.dts
rm ./boot-wrapper/vexpress-v2m-rs1.dtsi
rm ./boot-wrapper/skeleton.dtsi
rm ./boot-wrapper/Image
if [ $ramdisk == 1 ]; then
rm ./boot-wrapper/filesystem.cpio.gz
fi
}
function targetterm() {
telnet localhost 5000
}
function runadbhost() {
export ANDROID_PRODUCT_OUT=$(realpath out/target/product/vexpress/)
adb kill-server
sleep 1
adb connect 127.0.0.1:5556
adb wait-for-device
adb shell
}
function runadbtarget() {
stop adbd
setprop service.adb.tcp.port 6565
start adbd
}
# http://www.linuxjournal.com/content/using-named-pipes-fifos-bash
#
function reader() {
local pipe=/tmp/testpipe
trap "rm -f $pipe" EXIT
if [[ ! -p $pipe ]]; then
mkfifo $pipe
fi
while true
do
if read line <$pipe; then
if [[ "$line" == 'quit' ]]; then
break
fi
eval $line
fi
done
echo "Reader exiting"
}
function writer() {
pipe=/tmp/testpipe
if [[ ! -p $pipe ]]; then
echo "Reader not running"
exit 1
fi
if [[ "$1" ]]; then
echo "$1" >$pipe
else
echo "Hello from $$" >$pipe
fi
}
export PKG_DOC="Create an mmc.bin from compiled *.bz2s"
function pkg() {
if [ ! -f ./linaro-image-tools/linaro-android-media-create ]; then
bzr branch lp:linaro-image-tools
fi
export BINOUT=out/target/product/vexpress
./linaro-image-tools/linaro-android-media-create --image_file mmc.bin --image_size 2000M --dev vexpress --system $BINOUT/system.tar.bz2 --userdata $BINOUT/userdata.tar.bz2 --boot $BINOUT/boot.tar.bz2
}
export MOUNTMMC_DOC="Mount the the partitions of the mmc.bin
Will extract all partiions to mmc
If you call this like ./mountmmc.sh you will extract all partitions
if you call this like ./mountmmc.sh 1 2 5 you will extract partitions 1, 2 and 5
"
function mountmmc() {
if [ -d mmc ]; then
echo mmc dir exists, exiting
return
fi
mkdir mmc
pushd mmc
if [ "$#" == "0" ]; then
parted -s ../mmc.bin unit s print | \
awk '$1 ~ /[1-6]/ { gsub(/s/, "", $0); print $2,$4;\
system("dd if=../mmc.bin of="$1" bs=512 skip="$2" count="$4);\
system("mkdir d"$1);\
system("sudo mount -o loop "$1" d"$1); }'
else
for p in "$@"
do
parted -s ../mmc.bin unit s print | \
awk '$1 ~ /['$p']/ { gsub(/s/, "", $0); print $2,$4;\
system("dd if=../mmc.bin of="$1" bs=512 skip="$2" count="$4);\
system("mkdir d"$1);\
system("sudo mount -o loop "$1" d"$1); }'
done
fi
popd
}
export CLEANMMC_DOC="Deletes an mmc/ directory, created with mountmmc"
function cleanmmc() {
if [ ! -d mmc ]; then
echo No mmc directory, nothing to do, exiting!
return
fi
pushd mmc
sudo umount d*
rm -rf *
popd
rm -rf mmc
}
export GETTOMBS_DOC="Get tombs from a booted image,
will put tombstones in tombstones/"
function gettombs() {
#just call with ./gettombs.sh
mountmmc 5
cp -r mmc/d5/tombstones .
cleanmmc
}
export ORD_DOC="Open up a ramdisk for hacking"
function ord() {
if [ -z "$1" ]; then
local RAMDISK="../out/target/product/vexpress/ramdisk.img"
else
if [ ! -e "$1" ]; then
echo "$1 doesn't exist"
return
fi
local RAMDISK="../$1"
fi
if [ -d rd ]; then
echo rd exists, refusing to overwrite
return
fi
mkdir rd
pushd rd
pwd
cp $RAMDISK ../filesystem.cpio.gz
gzip -d ../filesystem.cpio.gz
cpio -i < ../filesystem.cpio
popd
}
export CRD_DOC="Close up a ramdisk, ord should have been run,
run bi after this to rebuild the axf file"
function crd() {
if [ -z "$1" ]; then
local RAMDISK="out/target/product/vexpress/ramdisk.img"
else
if [ ! -e "$1" ]; then
echo "$1 doesn't exist"
return
fi
local RAMDISK="$1"
fi
if [ ! -d rd ]; then
echo No rd directory, nothing to do, exiting!
return
fi
pushd rd
find ./ | cpio -H newc -o > ../ramdisk
gzip ../ramdisk -c > ../ramdisk.img
cp ../ramdisk.img ../$RAMDISK
popd
}
#just get stuff to build the kernel and boot loader
export GET_DOC="Just get stuff to rebuild the kernel and boot-wrapper"
function get() {
git clone git://android.git.linaro.org/people/pfefferz/gcc-linaro-aarch64-linux-gnu-4.7
pushd gcc-linaro-aarch64-linux-gnu-4.7
git checkout 4.7-13.02
popd
git clone git://android.git.linaro.org/people/pfefferz/boot-wrapper-aarch64 boot-wrapper
git clone git://git.linaro.org/kernel/linux-linaro-tracking kernel
pushd kernel
git checkout linux-linaro
popd
}
export BK_DOC="Configure and build a kernel"
function bk() {
export KERNEL_OUT=$(pwd)/out/target/product/vexpress/obj/kernel
export CPUS=`grep -c processor /proc/cpuinfo`
mkdir -p $KERNEL_OUT
if [ ! -z "$1" ]; then
PATH=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.7/bin:$PATH && \
make -j${CPUS} -C kernel O=$KERNEL_OUT ARCH=arm64 defconfig vexpress-android_defconfig
fi
PATH=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.7/bin:$PATH && \
make -j${CPUS} -C kernel O=$KERNEL_OUT ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- Image
}
export CK_DOC="Build a kernel"
function ck() {
export KERNEL_OUT=$(pwd)/out/target/product/vexpress/obj/kernel
export CPUS=`grep -c processor /proc/cpuinfo`
mkdir -p $KERNEL_OUT
PATH=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.7/bin:$PATH && \
make -j${CPUS} -C kernel O=$KERNEL_OUT ARCH=arm64 menuconfig
}
export UPDATEBOOT_DOC="update boot/ from boot-wrapper/"
function updatebootfrombootwrapper() {
export ANDROID_DIR=$(pwd)
export KERNEL_OUT=$ANDROID_DIR/out/target/product/vexpress/obj/kernel
cp -fa ./boot-wrapper/linux-system.axf ./boot/linux-system.axf
cp -fa $KERNEL_OUT/arch/arm64/boot/Image ./boot/kernel
}
export BUILDRUN_DOC="Build everything and run (on previously checked-out source)"
function buildrun() {
build
glit
bathsink
}
function getorupdatemanifest() {
./repo init -u ssh://$REMOTEUSER@linaro-private.git.linaro.org/srv/linaro-private.git.linaro.org/android/manifest.git -b linaro_android_4.2.2 -m vexpress-juice-aosp.xml
sed -i "s/linaro-big-little-switcher-bot/$REMOTEUSER/" .repo/manifest.xml
}
function tohttp {
wget http://bazaar.launchpad.net/~linaro-automation/linaro-android-build-tools/trunk/download/head:/sanitizemanifest.py-20121026100311-5cyxt3zk9wgvwohf-1/rewrite-manifest.py
python rewrite-manifest.py .repo/manifest.xml > new-manifest.xml
mv new-manifest.xml .repo/manifest.xml
time ./repo sync
}
function getsource() {
curl "http://android.git.linaro.org/gitweb?p=tools/repo.git;a=blob_plain;f=repo;hb=refs/heads/stable" > repo
chmod +x repo
getorupdatemanifest
tohttp
}
export GETANDBUILD_DOC="Get all source, build everything and run"
function getbuildrun() {
getsource
buildrun
}
function tagall {
./repo forall -c 'gtags'
}
export REMOVEGTAGS_DOC="travers the entire directory and remove GTAGS"
function removegtags {
local names=( GTAGS GSYMS GPATH GRTAGS )
for var in ${names[@]}; do
find . -name "$var" -exec rm {} \;
done
}
function genfilelist {
local names=( "*.c" "*.cc" "*.cpp" "*.h" "*.java*" "*.s" )
rm -rf filenames.txt
touch filenames.txt
for var in ${names[@]}; do
find . -name "$var" -exec echo {} >> filenames.txt \;
done
grep "[^ ]+" filenames.txt > tmp
mv tmp filenames.txt
}
function tagfilelist {
gtags -f filenames.txt
}
function bkbi {
bk
bi
updateboot
}
function crdbi {
crd
bi
updateboot
}
function pushchanges {
git push ssh://$REMOTEUSER@android.git.linaro.org:29418/people/pfefferz/at.git 'refs/heads/*' 'refs/tags/*'
}
|