User Manual Orange Pi Zero 3

  Features   |  Use   |  Linux   |  Linux SDK   |  Android   |    Android SRC     |

RU          EN  

Chapt 6. How to compile Android 12 source code

Contents

6.1. Download the source code of Android


6.2. Compile the source code of Android



6.1. Download the source code of Android

  • 1) First download the Android 12 source code sub-volume compressed package from Baidu or Google Disk

    a. Baidu Netdisk



    Img 6.1

    b. Google Disk



    Img 6.2

  • 2) After downloading the sub-volume compression package of the Android 12 source code, please check whether the MD5 checksum is correct. If not, please download the source code again. The way to check the MD5 checksum is as follows:

    test@test:~$ md5sum -c H618-Android12-Src.tar.gz.md5sum
    H618-Android12-Src.tar.gzaa: OK
    H618-Android12-Src.tar.gzab: OK
    ......

  • 3) Then you need to combine multiple compressed files into one, and then extract the Android source code. The command looks like this:

    test@test:~$ cat H618-Android12-Src.tar.gza* > H618-Android12-Src.tar.gz
    test@test:~$ tar -xvf H618-Android12-Src.tar.gz

    6.2. Compile the source code of Android

    The compilation of Android12 is carried out on an x86_64 computer with Ubuntu 22.04 installed. Other versions of Ubuntu may have some differences in system package dependencies. The mirror download address of Ubuntu 22.04 amd64 version is as follows:

    ubuntu-22.04.2-desktop-amd64.iso

    The x86_64 computer hardware configuration for compiling the Android12 source code is recommended to have 16GB or more memory, and 200GB or more hard disk space is recommended. The more CPU cores, the better.

  • 1) First install the software packages required to compile the Android12 source code
    test@test:~$ sudo apt-get update
    test@test:~$ sudo apt-get install -y git gnupg flex bison gperf build-essential \
    zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
    lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache \
    libgl1-mesa-dev libxml2-utils xsltproc unzip u-boot-tools python-is-python3 \
    libssl-dev libncurses5 clang gawk

  • 2) Then compile the code in the longan folder, which mainly contains u-boot and linux kernel

    a. First run ./build.sh config to set compilation options

    test@test:~$ cd H618-Android12-Src/longan
    test@test:~/H618-Android12-Src/longan$ ./build.sh config
    Welcome to mkscript setup progress

    All available platform:
     0. android
     1. linux
    Choice [android]: 0
    

    All available ic:
     0. h618
    Choice [h618]: 0

    All available board:
     0. ft
     1. p1
     2. p2
     3. p7
     4. p7l
     5. perf1
     6. perf2
     7. perf3
     8. qa
    Choice [p2]: 2

    All available flash:
     0. default
     1. nor
    Choice [default]: 0

    All available kern_ver:
     0. linux-5.4
    Choice [linux-5.4]: 0

    All available arch:
     0. arm
     1. arm64
    Choice [arm64]: 1

    
    ......
    *** Default configuration is based on
     'sun50iw9p1smp_h618_android_defconfig'
     #
     # configuration written to .config
     #
    make[1]: Leaving directory \
     '/home/test/H618-Android12-Src/longan/out/kernel/build'
    make: Leaving directory \
     '/home/test/H618-Android12-Src/longan/kernel/linux-5.4'
    INFO: clean buildserver
    INFO: prepare_buildserver
    

    b. Then run the ./build.sh script to start compiling

    test@test:~/H618-Android12-Src/longan$ ./build.sh

    c. After the compilation is complete, you will see the following output

    sun50iw9p1 compile Kernel successful
    INFO: Prepare toolchain ...
    ......
    INFO: build kernel OK.
    INFO: build rootfs ...
    INFO: skip make rootfs for android
    INFO: ----------------------------------------
    INFO: build lichee OK.
    INFO: ----------------------------------------
    

  • 3) Then use the following command to compile the Android source code and generate the final Android image

    test@test:~$ cd H618-Android12-Src
    test@test:~/H618-Android12-Src$ source build/envsetup.sh
    test@test:~/H618-Android12-Src$ lunch apollo_p2-userdebug
    test@test:~/H618-Android12-Src$ make -j8
    test@test:~/H618-Android12-Src$ pack

  • 4) The storage path of the compiled and generated Android image is:
    longan/out/h618_android12_p2_uart0.img

     <         >