{{indexmenu_n>15}}
====== VIM4 Build Android ======
===== Preparations =====
* [[http://source.android.com/source/initializing.html|Set up a Build Environment]]
* [[products:sbc:vim4:development:android:download-android-source-code|Downloading the Android Source]]
* [[products:sbc:vim4:development:android:install-toolchains|Install Toolchains for the Amlogic Platform]]
===== Building =====
Make sure you have done all the ''Preparations'' listed above before getting started.
==== Build U-Boot ====
```shell
$ 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 ====
```shell
$ ./mk kvim4 -v common14-5.15 -jN
```
Replace ''N'' with the actual number of threads on your own computer.
==== Build Android ====
```shell
$ cd PATH_YOUR_PROJECT
$ . build/envsetup.sh
$ lunch kvim4_arm64-userdebug
$ make aml_upgrade -jN
$ make -jN otapackage
```
Gernerate images in this step: ''out/target/product/kvim4/update.img''.
Replace ''N'' with the actual number of threads on your own computer.
==== Build Script Demo ====
```sh demo.sh
$ cat demo.sh
#!/bin/bash
#build uboot
if [ "$1" == 'u' ] || [ "$1" == 'n' ]; then
echo "build uboot"
cd bootloader/uboot
if [ "$2" == 'n' ] || [ "$1" == 'n' ]; then
make clean
echo "build uboot n"
fi
./mk kvim4 --avb2 --vab
cd -
fi
#build kernel
if [ "$1" == 'k' ] || [ "$1" == 'n' ]; then
echo "build kernel"
if [ "$2" == 'n' ] || [ "$1" == 'n' ]; then
rm -rf common/common14-5.15/out
fi
./mk kvim4 -v common14-5.15 -j88
fi
#build android
if [ "$1" == 'a' ] || [ "$1" == 'n' ]; then
echo "build android"
if [ "$2" == 'n' ] || [ "$1" == 'n' ]; then
rm -rf out/
fi
. build/envsetup.sh
lunch kvim4_arm64-userdebug
# make installclean
rm android.log
make aml_upgrade -j88 >> android.log
fi
if [ "$1" == 'o' ] || [ "$1" == 'n' ]; then
echo "build otapackage"
. build/envsetup.sh
lunch kvim4_arm64-userdebug
make -j88 otapackage
fi
```
==== Build U-Boot ====
```shell
$ 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 ====
```shell
$ ./mk kvim4 -v 5.4 -jN
```
Replace ''N'' with the actual number of threads on your own computer.
==== Build Android ====
```shell
$ cd PATH_YOUR_PROJECT
$ . build/envsetup.sh
$ lunch kvim4-userdebug
$ make -jN otapackage
```
Gernerate images in this step: ''out/target/product/kvim4/update.img''.
Replace ''N'' with the actual number of threads on your own computer.
==== Build Script Demo ====
```sh demo.sh
$ cat demo.sh
#!/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
. build/envsetup.sh
lunch kvim4-userdebug
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
. build/envsetup.sh
lunch kvim4-userdebug
make clean
fi
. build/envsetup.sh
lunch kvim4-userdebug
make installclean
#make -j80 otapackage
make -j80
fi
```
**Build U-Boot:**
```shell
$ ./demo.sh u
```
**Build Kernel:**
```shell
$ ./demo.sh k
```
**Build Android:**
```shell
$ ./demo.sh a
```
**Build all:**
```shell
$ ./demo.sh n
```