Setup, Build, and Flashing
  • 17 Aug 2023
  • 5 Minutes to read
  • Dark
    Light
  • PDF

Setup, Build, and Flashing

  • Dark
    Light
  • PDF

Article Summary

Build Environment Setup

Hardware Requirements
  • 64-bit environment
  • 400GB of free disk space (more is better)
  • 64 GB of RAM (more is better)

Please see Android document 'Hardware requirements' for the detail.

There are two different methods you can use to set up the build environment. One is to install the required packages onto your host filesystem.

Another is to use a docker container, where the installation of the required packages is automated for you.

> Host Build

Required Packages Installation

  • Tested with Ubuntu 20.04 and 22.04
  • Update Ubuntu
    sudo apt update
    sudo apt full-upgrade
    sudo apt autoclean
    sudo apt autoremove
    
  • Install required packages
    • Ubuntu 20.04
      sudo apt-get install tzdata git-core gnupg flex bison apt-utils build-essential zip curl \
      zlib1g-dev liblz-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses5-dev \
      x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \
      fontconfig uuid uuid-dev liblzo2-2 liblzo2-dev lzop u-boot-tools mtd-utils \
      android-sdk-libsparse-utils android-sdk-ext4-utils device-tree-compiler gdisk m4 make \
      libssl-dev libghc-gnutls-dev swig libdw-dev dwarves python bc cpio tar lz4 zstd rsync \
      ninja-build clang android-tools-adb gperf software-properties-common sshpass \
      ssh-askpass xz-utils kpartx vim screen sudo wget locales openjdk-8-jdk python3 kmod cgpt \
      bsdmainutils lzip hdparm cmake python3-protobuf
      
    • Ubuntu 22.04
      sudo apt-get install tzdata git gnupg flex bison apt-utils build-essential zip curl \
      zlib1g-dev liblz-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5 lib32ncurses-dev \
      x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \
      fontconfig uuid uuid-dev liblzo2-2 liblzo2-dev lzop u-boot-tools mtd-utils \
      android-sdk-libsparse-utils device-tree-compiler gdisk m4 make libssl-dev swig libdw-dev \
      dwarves python3 python-is-python3 bc cpio tar lz4 zstd rsync ninja-build clang adb gperf \
      software-properties-common sshpass ssh-askpass xz-utils kpartx vim screen sudo wget locales \
      kmod cgpt bsdmainutils lzip hdparm cmake python3-protobuf
      

> Docker Container Build (Optional)

Adapt docker dontainer based compile environment

  • Install docker
  • Create docker image (Just first time)
    cd cookers
    docker build -t build_droid13 .
    
  • Create and run a new docker container
    sudo docker run --privileged=true --name mx8_build  -v <your source folder>:/home/build -it build_droid13 bash
    
  • Run a existed docker container
    sudo docker container start mx8_build
    sudo docker container attach mx8_build
    
  • After entering the container, change directory to /home/build to build Android

> Install Repo Tool

Install repo

curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo
chmod a+x repo
sudo mv repo /usr/bin/repo

> Download The Source Code

Initialize repo using the latest LTS release (LTS branch):

repo init -u https://github.com/technexion-android/manifest -b tn-android-13.0.0_1.2.0_8m-next -m tn-android-13.0.0_1.2.0.xml

Download the source code:

repo sync -j<N>
  • <N> is up to cors numbers on your host PC


Start Compiling The Source Code

> Setup Android build environment

EDM-G-IMX8MP + WANDBOARD (HDMI)

For example using display HDMI

source cookers/env.bash.imx8.edm-g-imx8mp.wandboard.hdmi

EDM-G-IMX8MP + WIZARD (HDMI)

For example using display HDMI

source cookers/env.bash.imx8.edm-g-imx8mp.wizard.hdmi

EDM-G-IMX8MM + WANDBOARD (LVDS)

For example using display LVDS panel VL10112880

source cookers/env.bash.imx8.edm-g-imx8mm.wandboard.lvds_vl10112880

EDM-G-IMX8MM + WIZARD (LVDS)

For example using display LVDS panel VL10112880

source cookers/env.bash.imx8.edm-g-imx8mp.wizard.lvds_vl10112880

> Get the NXP restricted extra packages

merge_restricted_extras
NOTES
  • sometimes could be stocking on the waiting github response, please try again.
  • Note that it will showing up a EULA message before merge packages, please type 'yes' to continue the process as follows:

    Could you agree this EULA and keep install packages?(yes/no) yes

  • You only need to install it once, it will take a lot of time to install these packages

> Get the Technexion firmware for WiFi/Bluetooth functions (recommended)

get_tn_firmware
NOTES
  • sometimes could be stocking on the waiting git server response, please try again.
  • It will install to directory vendor/technexion automatically.

> Full build OS image

cook -j<N>
  • <N> is up to cors numbers on your host PC

> Clean the all compiled files

throw

> Partial build

After modifying the source code, you can directly build U-Boot, kernel or Android.


Before building

  • Goto the top directory of your Android project
  • Remember to setup the build environment (see 'Setup build environment')

U-Boot

./imx-make.sh bootloader -j<N>
  • <N> is up to cors numbers on your host PC

Kernel

./imx-make.sh kernel -j<N>
  • <N> is up to cors numbers on your host PC

Android

Usually build U-Boot and kernel at the same time

./imx-make.sh -j<N>

or

cook -j<N>
  • <N> is up to cors numbers on your host PC

  • If you want build single Android package, see the Android document 'Building the code' for details


Flashing The Output Images

Output relative image files of path:

ls <source>/out/target/product/<target board>/
  • <source>: top directory of your project
  • <target board>: edm_g_imx8mp or others

> uuu way (recommended)

uuu version

Android 13 need version 1.4.182 or above

  1. TechNexion Android sources already include uuu in vendor/technexion/utils/mfgtools

  2. You can download uuu tool from NxP github too

    • Linux
      • Confirm where the previous uuu was installed
        which uuu
        
        The result may be /usr/bin, /usr/local/bin or other
      • For example, the previous uuu is located in /usr/bin, move the uuu to /usr/bin/ and grant available permissions
        sudo cp uuu /usr/bin/
        sudo chmod a+x /usr/bin/uuu
        
        If located in /usr/local/bin, move the uuu to /usr/local/bin/ and grant available permissions
        sudo cp uuu /usr/local/bin/
        sudo chmod a+x /usr/local/bin/uuu
        
    • Windows
    • For usage, please refer to NxP mfgtools Wiki
  3. Quick way for flashing to board (adapt uuu based flash script):
    For Ubuntu host:

    cd <source>/out/target/product/<target board>/
    sudo ./uuu_imx_android_flash.sh -f <soc_name> -a -e -c <card_size> -D .
    

    Options:

    • <soc_name> is up to your SoC platform of device, such as imx8mp, imx8mm, imx8mq, imx8mn
    • <card_size> is up to your eMMC size
      • eMMC 32GB: card_size=28

    Example for imx8mp with eMMC 32GB:

    • Linux
      sudo ./uuu_imx_android_flash.sh -f imx8mp -a -e -c 28 -D .
      
    • Windows
      uuu_imx_android_flash.bat -f imx8mp -a -e -c 28
      
Steps for boot mode change when flash the image
  1. Firstly, the user must be change the boot mode to serial download mode and connect a OTG cable from board to host PC.
  2. Then, running the uuu commands as above post. In the end,
    change back the boot mode to eMMC boot mode, that's it.

Notes
users need change to serial download mode if adapt uuu tool, and ums just keep eMMC boot mode is enough.

> Generate mass production image folder

Another situation is when you need move your image flash tool to factory side for MP, you can do these steps:

  1. issue command to generate a protable MP image folder
    gen_mp_images
    
    the output folder name is 'auto_test'
  2. compress auto_test folder to zip file, then you can take it to factory.
    zip -r auto_test.zip auto_test/*
    
  3. prepare computers for MP, install Ubuntu host PC with required packages as Host Build chapter.
  4. extract auto_test.zip
    unzip auto_test.zip
    
    then issue flash command as uuu way commands to flash image to target boards.

Was this article helpful?