我要评分
获取效率
正确性
完整性
易理解

Compiling the AOSP and Creating an Image

  1. Compile the AOSP source code.
    1
    2
    3
    # cd ~/aosp/
    # source build/envsetup.sh
    # lunch kbox_arm64-user
    

    By default, the user mode is used to compile the image. To compile the image in userdebug mode, change kbox_arm64-user to kbox_arm64-userdebug in the lunch command, as shown in the following:

    1
    # lunch kbox_arm64-userdebug
    
    # make clean

    When running the make clean command, wait until the command is successfully executed, and then run the subsequent compile commands. If the command output in the following figure is displayed, the command is executed successfully.

    1
    # make -j64
    

    When running this command, set the number following -j to the number of CPU cores of the server. To query the number of CPU cores, run the following command:

    1
    # cat /proc/cpuinfo |grep "processor" | wc -l
    

    If you run the make command without specifying the number of cores, one core is used for compilation by default. You can also use the -j parameter to specify the number of cores for compilation. The maximum allowed number of cores is the total number of CPU cores of the server. This document uses 64 cores as an example.

    In normal cases, the compilation can be completed. Sometimes a compilation error may occur due to the concurrent compilation sequence. In this case, run the make command again.

  2. Decompress Kbox-AOSP11.zip and upload make_img_sample in the Kbox-AOSP11 folder to the ~/dependency directory.

    Configure appropriate permissions on the uploaded files and directories. You are advised to not configure the write permission for other users in the owner group and other owner groups.

  3. Copy the generated image script to the ~/aosp directory and grant the execute permission on the script.
    1
    2
    3
    4
    # cd ~/dependency/make_img_sample/kbox11_android_build
    # cp create-package.sh ~/aosp/
    # cd ~/aosp
    # chmod +x create-package.sh
    
  4. Run the script to create a Kbox Android image.

    The root permission is required for creating an image. Execute the script as the root user. The directory must be an absolute path.

    1
    # ./create-package.sh ~/aosp/out/target/product/arm64/system.img
    

    The Kbox Android image is created. A Kbox image named android.tar is generated in the current directory.