One-click Image Compilation Script
Huawei provides an automation script for compiling the Kbox Android image. This script contains the entire compilation process. If you use the automation script to compile an image based on this section, you can skip the following sections in the "Software Compilation" chapter and start software deployment.
The automation script implements the operations described in Installing Dependency Packages and Compiling the AOSP Source Code and Creating an Image. To use the automation script, you need to prepare the AOSP source code, Kbox binary package provided by Huawei, ExaGear transcoding package, Android code patch package, and compilation script package. Obtain them based on Table 1. To use the automation script, perform the following steps:
- Create an auto_compile directory under the /home directory to store the AOSP source code and the automation script.
Ensure that the free space of the /home directory is greater than 250 GB. You can run the df -h command to check the remaining space.
1 2
mkdir -p /home/auto_compile cd /home/auto_compile
- Download the AOSP source code (version: android-11.0.0_r48) to the /home/auto_compile directory. Rename the AOSP source code directory aosp.
- Download Kbox-AOSP11.zip to the local host based on Software Environment, upload it to the /home/auto_compile directory on the server, and decompress it.
cd /home/auto_compile unzip Kbox-AOSP11.zip
- Modify the container network configuration.
- Open the kbox11_android_build.sh script.
1 2
cd /home/auto_compile/Kbox-AOSP11/make_img_sample/kbox11_android_build vim kbox11_android_build.sh
- Press i to enter the insert mode and set the DNS address of the container. Ensure that the configured address is valid and correct in format. Otherwise, the compiled image may be unavailable. The format is as follows:
1DNS=xx.xx.xx.xx
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the kbox11_android_build.sh script.
- Download the Android Kbox binary package, ExaGear transcoding package, source packages of Meson/Mesa/LLVM/libdrm/libva, and cloud phone application installation package to the local host based on Software Environment. Create a package folder in the following specified directory:
1 2
cd /home/auto_compile/Kbox-AOSP11/make_img_sample/kbox11_android_build mkdir -p package
Upload the packages to the /home/auto_compile/Kbox-AOSP11/make_img_sample/kbox11_android_build/package directory on the server.

The names of the downloaded third-party library source packages (Mesa, LLVM, libdrm, and libva) and the extracted folders should be the same as the values of the <package>_version or <package>_src variable configured in the /home/auto_compile/Kbox-AOSP11/make_img_sample/00_kbox_prepare.sh file. If not, rename the source code folders and package them again.
- Run the kbox11_android_build.sh automation script to complete Kbox compilation.
1 2
cd /home/auto_compile/Kbox-AOSP11/make_img_sample/kbox11_android_build && chmod +x kbox11_android_build.sh ./kbox11_android_build.sh
The script execution takes more than one hour. If the script is executed successfully, the following information is displayed. If an error is reported during the execution, check the script and contact Huawei technical support.
1 2 3
---------------Success-------------- /home/auto_compile/aosp/android.tar ---------------End--------------
The Kbox Android image is created. A Kbox image named android.tar is generated in the AOSP source code directory.
Troubleshooting
Symptom 1
When the kbox11_android_build.sh script is executed, the message "'format_info.h' file not found" may be displayed. The cause is that Mesa's multi-threaded compilation occasionally delays the generation of this header file, resulting in a compilation failure.
1 2 3 | ../src/mesa/main/formats.c:81:10: fatal error: 'format_info.h' file not found #include "format_info.h" 1 error generated. |
Solution
- Make the environment variables take effect.
1source ~/.bashrc
- Perform the compilation again.
1 2 3 4
cd /home/auto_compile/aosp source build/envsetup.sh lunch kbox_arm64-user make -j
If the same error occurs, run make -j to perform the compilation again until the error does not occur. If the execution is successful, the following information is displayed:1#### build completed successfully (xx:xx (mm:ss)) ####
- Run the following commands to generate a Kbox image android.tar:
1 2 3
cp -r /home/auto_compile/Kbox-AOSP11/make_img_sample/kbox11_android_build/create-package.sh /home/auto_compile/aosp chmod +x create-package.sh ./create-package.sh /home/auto_compile/aosp/out/target/product/arm64/system.img
Symptom 2
When the kbox11_android_build.sh script is executed, an error message "No such file or directory" may be reported. The reason for the issue is a variation in the folder name created upon unzipping the dependency package, such as the appending of a new suffix. The script cannot identify the folder name, resulting in a compilation failure.

Solution
The following steps are for reference only.
- Find the software package related to the error and unzip the package.
unzip drm-libdrm-2.4.111.zip
- Change the name of the extracted folder to the name displayed in the error message (predefined name in the script).
mv libdrm-libdrm-2.4.111-f801b07a60740425604d6563e5dc399375108bc4 drm-libdrm-2.4.111
- Compress the folder into a new software package and use the new software package for script-based automatic compilation.
mv drm-libdrm-2.4.111.zip drm-libdrm-2.4.111.zip.bak zip -r drm-libdrm-2.4.111.zip drm-libdrm-2.4.111
When the kbox11_android_build.sh script is executed, a dependency missing error may also occur. This error may be caused by new dependencies generated due to software package content update. If this error occurs, install the missing package in the environment.