Build Source Code in Ubuntu Virtual Machine
  • 01 Oct 2021
  • 4 Minutes to read
  • Dark
    Light
  • PDF

Build Source Code in Ubuntu Virtual Machine

  • Dark
    Light
  • PDF

Article summary

Introduction

The virtual machine is to reduce the complexity of setting up the development environment for building Android, Yocto, and Ubuntu images for TechNexion SOM/baseboards. The virtual machine is based on Ubuntu-20.04 LTS x64 architecture. This virtual machine can be executed under an OS that has VirtualBox 6.1.14 installed.
This build environment supports development of the following software for TechNexion target SOM/baseboards:

Supported Software BuildsSupported Version
FreeRTOS1.0.1 for iMX7, and SDK v2.3 for iMX8
U-boot2018.03
Linux kernel4.14.98
Yocto2.5(Sumo)/3.0(Zeus)
UbuntuUbuntu 20.04
AndroidAndroid 9.0 (Pie)

Note: For older versions of Linux/Android/Yocto, please use previous releases of virtual machine.

Warning

DO NOT use the uuu utility or dd utility within the VM if it is running on top of a Ubuntu host OS. There are timing issues with VirtualBox mounted USB device that can cause flashing to fail. This problem has not been seen on Windows or Mac OS hosts. If running on a Linux host, please use the native Linux host OS to run uuu or dd utility to flash images to the target device instead.

Build source code for target board

Toolchains and Cross-compile build environment

There are three toolchains, GCC-7.3.1-none-eabi for building FreeRTOS binaries, GCC-7.4.1-arm for building 32-bit ARM binaries, GCC-7.4.1-aarch64 for building 64-bit AArch64 binaries, in the virtual machine.

By default, these toolchains are located in "/home/technexion/Desktop/Tools" directory.

Recommended toolchain for u-boot/kernel/FreeRTOS for different SoC:

ToochainSoC
gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-guieabihfi.MX6/i.MX7
gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnui.MX8
gcc-arm-none-eabi-7-2018-q2-updateFreeRTOS

Before compiling source codes, make sure to setup the build environment by exporting cross-compile environment variables:
For iMX6/iMX7:

technexion@tn-vm:~$ source ~/buildenv.sh 32
arch 32 gnueabihf
technexion@tn-vm:~$

For iMX8:

technexion@tn-vm:~$ source ~/buildenv.sh 64
arch 64
technexion@tn-vm:~$

For FreeRTOS:\

technexion@tn-vm:~$ source ~/buildenv.sh rtos
arch 32 none-eabi
technexion@tn-vm:~$

All TechNexion source codes are located on the TechNexion github:
https://github.com/TechNexion (for main source code distributions)
https://github.com/TechNexion-customization (for customized source code distributions)
https://github.com/technexion-android (for android source code distributions)

Build u-boot

In a command line terminal:

  1. Download source code:
    technexion@tn-vm:~$ git clone https://github.com/TechNexion/u-boot-tn-imx.git
    technexion@tn-vm:~$ cd u-boot-tn-imx
    technexion@tn-vm:~/u-boot-tn-imx$
  1. Set the u-boot config:For edm-imx8mq-wizard:
    For pico-imx6:
    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 32
    technexion@tn-vm:~/u-boot-tn-imx$ make pico-imx6_spl_defconfig

For pico-imx6ul:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 32
    technexion@tn-vm:~/u-boot-tn-imx$ make pico-imx6ul_spl_defconfig

For pico-imx7:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 32
    technexion@tn-vm:~/u-boot-tn-imx$ make pico-imx7d_spl_defconfig

For pico-imx8mm:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/u-boot-tn-imx$ make pico-imx8mm_defconfig

For pico-imx8mq:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/u-boot-tn-imx$ make pico-imx8mq_spl_defconfig

For edm-imx6:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 32
    technexion@tn-vm:~/u-boot-tn-imx$ make edm-imx6_spl_defconfig

For edm-imx7:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 32
    technexion@tn-vm:~/u-boot-tn-imx$ make edm-imx7d_spl_defconfig

For edm-imx8mq:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/u-boot-tn-imx$ make edm-imx8mq_defconfig

For flex-imx8mm:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/u-boot-tn-imx$ make flex-imx8mm_defconfig

For xore-imx8mm:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/u-boot-tn-imx$ make xore-imx8mm_defconfig

For axon-imx8mm:

    technexion@tn-vm:~/u-boot-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/u-boot-tn-imx$ make axon-imx8mm_defconfig
  1. Compile u-boot:
    technexion@tn-vm:~/u-boot-tn-imx$ make
  1. Build flash.bin for imx8 boards:
    For pico-imx8mm-pi/wizard:
    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -c
    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -b imx8mm-pico-pi

For pico-imx8mq-pi/wizard:

    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -c
    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -b imx8mq-pico-pi

For edm-imx8mq-wizard:

    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -c
    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -b imx8mq-edm-wizard

For flex-imx8mm-pi/wizard:

    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -c
    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -b imx8mm-flex-pi

For xore-imx8mm-pi/wizard:

    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -c
    technexion@tn-vm:~/u-boot-tn-imx$ ./install_uboot_imx8.sh -b imx8mm-xore-pi
  1. Locate u-boot binary images:
    For imx6/imx6ul/imx7:
technexion\@tn-vm:\~/u-boot-tn-imx\$ find . -name SPL
./SPL
technexion\@tn-vm:\~/u-boot-tn-imx\$ find . -name u-boot.bin
./u-boot.bin

For imx8:

technexion\@tn-vm:\~/u-boot-tn-imx\$ find . -name flash.bin
./imk-mkimage/iMX8M/flash.bin

Detailed instructions for building u-boot:
https://github.com/TechNexion/u-boot-tn-imx/wiki

Build kernel

In a command line terminal:

  1. Download source code:
    technexion@tn-vm:~$ git clone https://github.com/TechNexion/linux-tn-imx.git
    technexion@tn-vm:~$ cd linux-tn-imx
    technexion@tn-vm:~/linux-tn-imx$
  1. Set the kernel config:
    For imx6, imx6ul, imx7:
    technexion@tn-vm:~/linux-tn-imx$ source ~/buildenv.sh 32
    technexion@tn-vm:~/linux-tn-imx$ make tn_imx_defconfig

For imx8:

    technexion@tn-vm:~/linux-tn-imx$ source ~/buildenv.sh 64
    technexion@tn-vm:~/linux-tn-imx$ make tn_imx8_defconfig
  1. Compile the kernel:
    technexion@tn-vm:~/linux-tn-imx/$ make

Compile the kernel modules specifically:

    technexion@tn-vm:~/linux-tn-imx/$ make modules

Compile the kernel device trees specifically:

    technexion@tn-vm:~/linux-tn-imx/$ make dtbs
  1. Locate the kernel image, device tree blobs, and kernel modules:
    Kernel image:

For imx6, imx6ul, imx7:

    technexion@tn-vm:~/linux-tn-imx/$ find . -name zImage
    ./arch/arm/boot/zImage

For imx8:

    technexion@tn-vm:~/linux-tn-imx/$ find . -name Image
    ./arch/arm64/boot/Image

Device tree blobs:
For imx6, imx6ul, imx7:

    technexion@tn-vm:~/linux-tn-imx/$ ls arch/arm/boot/dts/*{edm,pico,tep,tek}*.dtb
    arch/arm/boot/dts/imx6dl-edm1-fairy.dtb
    …
    arch/arm/boot/dts/imx7d-tep1.dtb

For imx8:

    technexion@tn-vm:~/linux-tn-imx/$ ls arch/arm64/boot/dts/freescale/*{edm,pico,flex,xore,axon}*.dtb
    arch/arm64/boot/dts/freescale/imx8mm-axon-loopbacktest.dtb.dtb
    …
    arch/arm64/boot/dts/freescale/imx8mq-pico-wizard.dtb

Kernel modules:
For all architectures:

    technexion@tn-vm:~/linux-tn-imx/$ make modules_install INSTALL_MOD_PATH=~/modules
     INSTALL crypto/crypto_engine.ko
     …
     INSTALL sound/usb/snd-usbmidi-lib.ko
     DEPMOD 4.14.98_2.0.1-g0cac981fa

    technexion@tn-vm:~/linux-tn-imx/$ ls ~/modules/lib/modules/4.14.98_2.0.1-g0cac981fa/
    build  modules.alias  modules.builtin  modules.builtin.bin  modules.order  modules.symbols
    source  kernel  modules.alias.bin modules.builtin.alias.bin  modules.dep  modules.devname
    modules.softdep  modules.symbols.bin

Build FreeRTOS

In a command line terminal:

  1. Download source codes:
    technexion@tn-vm:~$ git clone https://github.com/TechNexion/freertos-tn.git
  1. Setup build environment:
    technexion@tn-vm:~$ source ~/buildenv.sh rtos
    technexion@tn-vm:~$ cd freetos-tn/boards/${board_name}/demo_apps/hello_world/armgcc/
  1. Build release
    technexion@tn-vm:~/freetos-tn/boards/${board_name}/demo_apps/hello_world/armgcc$ ./build_release.sh
  1. Locate the binary image
    technexion@tn-vm:~/freetos-tn/boards/${board_name}/demo_apps/hello_world/armgcc$ find . -name hello_world.bin
    ./release/hello_world.bin
    technexion@tn-vm:~/freetos-tn/boards/${board_name}/demo_apps/hello_world/armgcc$ cp ./release/hello_world.bin ${mounted FAT partition of target board eMMC}

Detailed instructions for building FreeRTOS:
https://github.com/TechNexion/freertos-tn

Build Yocto

In a command line terminal:

  1. Download source code
    technexion@tn-vm:~$ mkdir -p sumo; cd sumo
    technexion@tn-vm:~/sumo$ repo init -u https://github.com/TechNexion/tn-imx-yocto-manifest.git -b sumo_4.14.y_GA-stable -m imx-4.14.98-2.0.1_patch.xml –depth=1
    technexion@tn-vm:~/sumo$ repo sync
  1. Configure pico-imx8mm with qca wifi and 5 inch mipi display
    technexion@tn-vm:~/sumo$ MACHINE=pico-imx8mm DISTRO=fsl-imx-xwayland WIFI_FIRMWARE=y WIFI_MODULE=qca DISPLAY=mipi5 source edm-setup-release.sh -b build-pico-imx8mm
  1. Build yocto image
    technexion@tn-vm:~/sumo/build-pico-imx8mm$ bitbake fsl-image-qt5-validation-imx

Detailed instructions for building Yocto:
https://github.com/TechNexion/tn-imx-yocto-manifest

To build Yocto 2.5, please follow the instruction on the webpage of the github, and skip the part about using docker.

Build Ubuntu

In a command line terminal:

  1. Download source code
    technexion@tn-vm:~$ git clone https://github.com/TechNexion-customization/ubuntu-tn-imx8.git
    technexion@tn-vm:~$ cd ubuntu-tn-imx8
  1. Build ubuntu:
    technexion@tn-vm:~/ubuntu-tn-imx8$ make all
  1. Location ubuntu image
    technexion@tn-vm:~/ubuntu-tn-imx8$ find . -name ubuntu.img
    ./output/ubuntu.img

For detailed instructions:
https://github.com/TechNexion-customization/ubuntu-tn-imx8

Build Android 9.0 for iMX8

In a command line terminal:

  1. Download source code:
    technexion@tn-vm:~$ mkdir -p android; cd android
    technexion@tn-vm:~/android$ repo init -u https://github.com/technexion-android/manifest -b tn-p9.0.0_2.0.1_8m-ga -depth=1
    technexion@tn-vm:~/android$ repo sync
  1. Setup build environment:
    technexion@tn-vm:~/android$ source cookers/env.bash.imx8.pico-imx8m-mini.pi.mipi-dsi_ili9881c
    technexion@tn-vm:~/android$ merge_restricted_extras
  1. Build android:
    technexion@tn-vm:~/android$ cook -j4
  1. Package android for distribution:
    technexion@tn-vm:~/android$ gen_mp_images
  1. Locate distribution package:
    technexion@tn-vm:~/android$ ls ./auto_test
    boot.img  dtbo-imx8mq-img  flash.bin  fsl-sdcard-partition.sh  fsl-sdcard-partition-virtual-image.sh  partition-table.img  partition-table-7GB.img  partition-table-13GB.img  partition-table-28GB.img  partition-table-default.img  system.img  u-boot-imx8mq.imx  u-boot-imx8mq-evk-uuu.imx  uuu_imx_android_flash.bat  uuu_imx_android_flash.sh  vbmeta-imx8mq.img  vendor.img

For detailed instruction:
https://github.com/technexion-android/cookers

and follow instructions on the webpage to fetch the source code, compile, and load the image to the hardware. Skip the part about using docker.

Build UUU for programming target device

In a command line terminal:

  1. Download source code
    technexion@tn-vm:~$ git clone https://github.com/TechNexion/imx-mfgtools-tn.git
    technexion@tn-vm:~$ cd imx-mfgtools-tn
    technexion@tn-vm:~/imx-mfgtools-tn$ git checkout tn-uuu_1.3.154
  1. Compile uuu for Linux x86_64
    technexion@tn-vm:~/imx-mfgtools-tn$ cmake .
    technexion@tn-vm:~/imx-mfgtools-tn$ make
  1. Location uuu executable binary
    technexion@tn-vm:~/imx-mfgtools-tn$ find . -name uuu
    ./uuu
    ./uuu/uuu

Detailed instructions:
https://github.com/TechNexion/imx-mfgtools-tn/tree/tn-uuu_1.3.154


Was this article helpful?