Building Android Source Code

Preparations

Building

Note

Before you start to build, make sure you have done all the Preparations listed above.

Build U-Boot:

1
2
3
$ cd PATH_YOUR_PROJECT
$ cd bootloader/uboot
$ ./mk kvim4 --avb2 --vab

Gernerate images in this step:

  • build/u-boot.bin: for onboard EMMC storage booting
  • build/u-boot.bin.sd.bin: for external TF card booting

Build Linux Kernel:

1
$ ./mk kvim4 -v 5.4 -jN
Note
  • Replace N with the actual number of threads on your own computer

Build Android:

1
2
3
4
$ cd PATH_YOUR_PROJECT
$ . build/envsetup.sh
$ lunch TARGET_LUNCH
$ make -jN otapackage

Gernerate images in this step:

  • out/target/product/TARGET/update.img
Note
  • VIM4 compiling Android will not compile the Linux Kernel at the same time as VIM3.
  • Replace N with the actual number of threads on your own computer
  • Replace TARGET_LUNCH to your lunch select.
    • For VIM4, it’s kvim4-userdebug.

Made your own compiled script demo:

1
$ vim demo.sh
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
#!/bin/bash

#build U-Boot
if [ "$1" == 'u' ] || [ "$1" == 'n' ]; then
echo "build U-Boot"
cd bootloader/uboot
./mk kvim4 --avb2 --vab
cd -
fi

#build Kernel
if [ "$1" == 'k' ] || [ "$1" == 'n' ]; then
echo "build Kernel"
if [ "$2" == 'n' ] || [ "$1" == 'n' ]; then
make distclean
fi
./mk kvim4 -v 5.4 -j100
fi

#build Android
if [ "$1" == 'a' ] || [ "$1" == 'n' ]; then
echo "build Android"
if [ "$2" == 'n' ] || [ "$1" == 'n' ]; then
make clean
fi
. build/envsetup.sh
lunch kvim4-userdebug
make installclean
#make -j80 otapackage
make -j80
fi
1
2
3
4
5
6
7
8
9
10
11
#build U-Boot
$ ./demo.sh u

#build Kernel
$ ./demo.sh k

#build Android
$ ./demo.sh a

#build all
$ ./demo.sh n

See Also