Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Zero/Android9

< Zero
Revision as of 10:00, 4 January 2022 by Cx (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
    Radxa Zero >  Android9

Recommend build host is Ubuntu 16.04 64bit, for other hosts, refer official Android documents Establishing a Build Environment.

Repo

   radxa$ wget 'https://storage.googleapis.com/git-repo-downloads/repo' -P /tmp/
   radxa$ sudo cp /tmp/repo /usr/local/bin/repo
   radxa$ sudo chmod +x /usr/local/bin/repo

In China Download Repo:

   radxa$ echo "export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'" >> ~/.bashrc
   radxa$ source ~/.bashrc
   radxa$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o /tmp/repo
   radxa$ sudo cp /tmp/repo /usr/local/bin/repo
   radxa$ sudo chmod +x /usr/local/bin/repo

Init Environment

Android's source code primarily consists of Java, C++, and XML files.
To compile the source code, you'll need to install OpenJDK 8, GNU C and C++ compilers, XML parsing libraries, ImageMagick, and several other related packages.

   radxa$ apt-get update -y && apt-get install -y openjdk-8-jdk python python-pip git-core gnupg flex bison gperf build-essential \
          zip curl liblz4-tool zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
          lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
          libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \
          htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \
          dosfstools vim-common parted udev lzop rsync
   radxa$ pip install pycrypto

Configure the JAVA environment

   radxa$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
   radxa$ export PATH=$JAVA_HOME/bin:$PATH
   radxa$ export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

DockerFile

   FROM ubuntu:xenial
   RUN apt-get update -y && apt-get install -y openjdk-8-jdk python python-pip git-core gnupg flex bison gperf build-essential \
       zip curl liblz4-tool zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
       lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
       libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \
       htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \
       dosfstools vim-common parted udev lzop rsync
   RUN pip install pycrypto
   RUN curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > /usr/local/bin/repo && \
       chmod +x /usr/local/bin/repo
   RUN which repo
   ENV REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/' USER=android9-docker
   ARG USER_ID=0
   ARG GROUP_ID=0
   RUN groupadd -g ${GROUP_ID} jenkins-docker && useradd -m -g jenkins-docker -u ${USER_ID} android9-docker
   # git config
   RUN echo "[user]" > /home/android9-docker/.gitconfig"
   RUN echo "   name = android9-docker" >> /home/android9-docker/.gitconfig
   RUN echo "   email = android9-docker@radxa.com" >> /home/android9-docker/.gitconfig
   USER android9-docker


Build DockerFile

   radxa$ docker build -t android-builder:9.x --build-arg USER_ID=`id -u` --build-arg GROUP_ID=`id -g` $(which-dir-dockerfile-in)

Download source code

   radxa$ mkdir zero-android9
   radxa$ cd zero-android9

Then run:

   radxa:zero-android9$ repo init -u https://gitlab.com/amlogic-android/manifests.git -b p-amlogic -m radxa-w2-p-release.xml
   radxa:zero-android9$ repo sync -d --no-tags -j4

It might take quite a bit of time to fetch the entire AOSP source code(more than 50GB)!

One Step Build

   ./device/amlogic/common/quick_compile.sh 14 1

Build u-boot

   radxa:zero-android9       $ cd bootloader/uboot-repo
   radxa:zero-android9/bootloader/uboot-repo$ ./mk radxa_zero --systemroot
   cp build/u-boot.bin ../../device/amlogic/$project_path/bootloader.img;
   cp build/u-boot.bin.usb.bl2 ../../device/amlogic/faraday/upgrade/u-boot.bin.usb.bl2;
   cp build/u-boot.bin.usb.tpl ../../device/amlogic/faraday/upgrade/u-boot.bin.usb.tpl;
   cp build/u-boot.bin.sd.bin ../../device/device/amlogic/faraday/upgrade/u-boot.bin.sd.bin;
   radxa:zero-android9/bootloader/uboot-repo$ cd -

Building AOSP

   radxa:zero-android9$ source build/envsetup.sh
   radxa:zero-android9$ lunch faraday-userdebug
   radxa:zero-android9$ make otapackage -j$(nproc)

It takes a long time, take a break and wait...
Image will be saved as a zip archive in directory out/target/product/faraday.
The format of file name will be like this faraday-fastboot-flashall-20211104.zip

Installation

See https://wiki.radxa.com/Zero/install/eMMC_Android