Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling the AOSP and Creating an Image

Compile the AOSP source code to generate a Kbox Android image.

  1. Compile the AOSP source code.
    1. Generate your own unique set of release keys to sign the deployed Android image.
      1
      2
      3
      4
      cd ~/aosp/
      rm -rf ./build/target/product/security/release*
      chmod +x ./development/tools/make_key
      ./development/tools/make_key build/target/product/security/releasekey '/C=xx/ST=xxx/L=xxx/O=xxx/OU=xx/CN=xxx/emailAddress=xxxxx@xxx.com'
      

      When you run the make_key command, the system prompts you to enter the password. You can press Enter to skip this step.

      The parameters in the make_key command are described as follows:

      • build/target/product/security/releasekey indicates the name of the key to be generated.
      • The following parameters indicate company information. Set the parameters as required. For details, see Table 1.
      Table 1 make_key parameters

      Parameter

      Description

      C

      Country name (2-letter code)

      ST

      State or province name (full name)

      L

      Locality name (for example, city name)

      O

      Organization name (for example, company name)

      OU

      Organizational unit name (for example, section name)

      CN

      Common name (for example, user name or the host name of the server)

      emailAddress

      Contact email address

    2. Load all the commands in envsetup.sh to environment variables.
      1
      source build/envsetup.sh
      
    3. Select a compilation mode.
      1
      lunch kbox_arm64-trunk_staging-user
      
      • To compile the image in userdebug mode, change user to userdebug in the lunch command. The following uses kbox_arm64 as an example.
        lunch kbox_arm64-trunk_staging-userdebug
      • Kbox also provides a streamlined image in which some pre-installed applications are removed to achieve better memory utilization and performance.
        Use the following option to compile a streamlined image:
        lunch kbox_arm64_optimized-trunk_staging-user
    4. Perform compilation.
      1
      2
      make clean
      make -j
      

      In above commands, 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. After downloading source packages according to Software Environment, decompress the Kbox-AOSP15.zip package (see Applying the Kbox Android Patch), and upload the make_img_sample directory in the Kbox-AOSP15 folder to the ~/dependency directory.

    Assign appropriate permissions on the uploaded files and directories. You are not advised to assign the write permission for other user 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/kbox15_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/kbox_arm64/system.img
    

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