Build from Source

It’s recommended to use Ubuntu 18.04 (64-bit) for building the Android. All further instructions are given for exactly that distribution. Please make sure that your hardware meets the requirements specified in Android build requirements document: - At least 300 GiB of drive space - At least 16 GiB of RAM; if you have less – please make sure your swap partition is 32 GiB or more.

  1. Installing build dependencies
    • $ sudo apt update
      $ sudo apt install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig gcc make perl libncurses5-dev libssl-dev bc bison flex minicom vim git python
  2. Install the repo tool
    • $ mkdir ~/bin
      $ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
      $ chmod a+rx ~/bin/repo
      $ export PATH=$HOME/bin:$PATH
  3. Download and unpack the baremetal AArch64 GCC toolchain
    • $ wget "https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz"
      $ sudo tar xJvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz -C /opt
      $ rm gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz
  4. Configure basic Git settings (needed for repo tool to work properly):
    • $ git config --global user.email "you@example.com"
      $ git config --global user.name "Your Name"
  5. Obtaining the software
    • Obtain Android-Q source code:
      • $ mkdir -p ~/repos/android-q
        $ cd ~/repos/android-q
        $ repo init -u https://gitlab.com/Linaro/96boards/e850-96/platform/manifest.git -b android10-e850-96
        $ repo sync -j32
    • Obtain Linux kernel 4.14 source code:
      • $ cd ~/repos
        $ git clone https://gitlab.com/Linaro/96boards/e850-96/kernel.git
        $ cd kernel
        $ git checkout android-exynos-4.14-linaro
    • Obtain LittleKernel bootloader source code:
      • $ cd ~/repos
        $ git clone https://gitlab.com/Linaro/96boards/e850-96/lk.git
        $ cd lk
        $ git checkout 3830-ww-dev-linaro-e850-96
  6. Building the software
    • Building the Android-Q: Android-Q source code contains prebuilt files for Linux kernel, bootloader, etc. So it’s possible to build just Android-Q (and skip building the kernel and bootloader), which will generate all needed images. Output images will be located in out/target/product/erd850/ directory.
      • $ cd ~/repos/android-q
        $ source build/envsetup.sh
        $ lunch full_erd850-eng
        $ make
    • Building the kernel
      • $ cd ~/repos/kernel
      • $ prebuilts_path=~/repos/android-q/prebuilts
        $ clang_path=$prebuilts_path/clang/host/linux-x86/clang-r328903
        $ gcc_path=$prebuilts_path/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
        $ export LLVM_AR=$clang_path/bin/llvm-ar
        $ export LLVM_DIS=$clang_path/bin/llvm-dis
        $ export LTO_LLVM_LIB_BASE=$clang_path/lib64
        $ export PATH=$gcc_path/bin:$PATH
        $ export CROSS_COMPILE=aarch64-linux-android-
        $ export PATH=$clang_path/bin:$PATH
        $ export CLANG_TRIPLE=aarch64-linux-gnu-
        $ export ARCH=arm64
      • $ fragments/make-config.sh e850-96 android-full
      • $ make -j32 CC=clang
      • $ scripts/dtc/rebuild-dtbx.sh
    • Building the bootloader
      • $ cd ~/repos/lk
        $ export PATH=/opt/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin:$PATH
        $ export ARCH_arm64_TOOLCHAIN_PREFIX=aarch64-none-elf-
      • $ make -j16 erd3830
    • Rebuild Android with custom kernel
      • $ cd ~/repos/android-q
        $ source build/envsetup.sh
        $ lunch full_erd850-eng
      • $ cp ~/repos/kernel/arch/arm64/boot/dts/exynos/exynos3830.dtb device/samsung/erd850-prebuilts/dtb.img
        $ cp ~/repos/kernel/arch/arm64/boot/dts/exynos/exynos3830-e850-96-*.dtbo device/samsung/erd850-prebuilts/
        $ cp ~/repos/kernel/arch/arm64/boot/Image device/samsung/erd850-prebuilts/kernel
        $ cp ~/repos/kernel/vmlinux device/samsung/erd850-prebuilts/
        $ cp ~/repos/lk/build-erd3830/lk.bin device/samsung/erd850-prebuilts/bootloader.img
      • $ cd device/samsung/erd850-prebuilts/
        $ ./create-dtboimg.sh
        $ rm *.dtbo
        $ cd -
      • $ make
  7. Flashing the Software
    • To flash the images, enter the fastboot mode:
      • Connect the power cable to your E850-96 board
      • Press “POWER” button (SW2) for 1 sec to start booting the bootloader
      • Press and hold the “VOL_UP” button (SW4) for 7 seconds
    • $ cd ~/repos/android-q
      $ source build/envsetup.sh
      $ lunch full_erd850-eng
      $ cd out/target/product/erd850/
      $ ./ff_erd3830_all.sh