Debian Build Release

From Variscite Wiki
DART-MX8M - Debian Buster 10 with imx_4.14.78_1.0.0_ga_var01 Linux release


1 Overview

This page describes how to build and install Debian distribution (Buster) on Variscite boards with DART-MX8M.

These instructions were tested on an Ubuntu 16.04 x64 host PC. When using other distributions, there may be problems.

Please note that the build script is based on debootstrap. As described in the following instructions, it's kindly suggested to create the build folder on the main Ubuntu volume on your host PC rather than an external media.
Using an external media, although automatically mounted, will cause debootstrap to complain about access rights (even when running the script with sudo).

2 Create build environment

2.1 Installing required packages

On Ubuntu building machine:

$ sudo apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx \
lvm2 dosfstools gpart binutils bison git lib32ncurses5-dev python-m2crypto gawk wget \
git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev \
autoconf libtool libglib2.0-dev libarchive-dev python-git xterm sed cvs subversion \
kmod coreutils texi2html bc docbook-utils python-pysqlite2 help2man make gcc g++ \
desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial automake groff curl \
lzop asciidoc u-boot-tools mtd-utils device-tree-compiler flex

2.2 Deploy source

Download archive containing the build script and support files for building Debian Buster for this board:

$ cd ~
$ git clone https://github.com/varigit/debian-var.git -b debian_buster_var01 var_mx8m_dart_debian

Create environment (Internet connection should be available):

$ cd ~/var_mx8m_dart_debian
$ MACHINE=imx8m-var-dart ./var_make_debian.sh -c deploy

This environment prepared to build.

3 Make Debian

3.1 Build all

Internet connection should be available

$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c all |& tee build.log


3.2 Build by parts

3.2.1 Build bootloader

$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c bootloader


3.2.2 Build kernel, dtb files and kernel modules

$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c kernel
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c modules


3.2.3 Build rootfs

Internet connection should be available

$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c rootfs


3.2.4 Pack rootfs

To create the root file system archive (rootfs.tar.gz), run the following commands:

$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c rtar


4 Create boot SD card

  1. Follow the above steps for make rootfs, kernel, bootloader;
  2. Insert the SD card to card reader connected to a host system;
  3. Run the following commands (Caution! All data on the card will be destroyed):
$ cd ~/var_mx8m_dart_debian
$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh -c sdcard -d /dev/sdX


where '/dev/sdX' path to the block SD device in your system.

4.1 Create a boot SD card image using a loop device

It is also possible to use the "MACHINE=imx8m-var-dart ./var_make_debian.sh" script to create a boot SD card image, while using a loop device instead of attaching a real SD card.

Create an empty file using the following command:

$ dd if=/dev/zero of=imx8m-var-dart-debian-sd.img bs=1M count=3720

The above command creates a 3700MiB file representing the SD card.

Attach the first available loop device to this file:

$ sudo losetup -Pf imx8m-var-dart-debian-sd.img

To find the actual loop device being used, run: $ losetup -a | grep imx8m-var-dart-debian-sd.img

Write the content to the loop device to generate the SD card image:

$ sudo MACHINE=imx8m-var-dart ./var_make_debian.sh <options> /dev/loopX

(Replace /dev/loopX with your actual loop device, e.g. /dev/loop0)

Detach the loop device from the file:

$ sudo losetup -d /dev/loopX

To compress the SD card image file use the following command:

$ gzip -9 imx8m-var-dart-debian-sd.img

To write the SD card image to a real SD card device use the following command:

$ zcat imx8m-var-dart-debian-sd.img.gz | sudo dd of=/dev/sdX bs=1M && sync

(Replace /dev/sdX with your actual SD device, e.g. /dev/sdb)

5 Boot the board with a bootable SD card

Note: The WiFi is not operational when booting from SD card, as the WiFi and SD card are using the same SDIO interface.
A typical use-case is to boot from an SD card, flash the eMMC, and re-boot from the eMMC to have the WiFi operational.

5.1 Setting the Boot Mode

Make sure the BOOT SELECT DIP switch on the carrier board is set correctly before you power on the board.

SW7
 0 : Boot from SD card
 1 : Boot from eMMC


5.2 Device tree selection in U-Boot

As shown in the Build Results table above, we have different kernel device trees, corresponding to our different H/W configurations (sometimes they are renamed without the "zImage-" prefix).

In U-Boot, set the device tree file manually:

$ setenv fdt_file YOUR_DTB_FILE
$ saveenv


6 Build Results

The resulted images are located in ~/var_mx8m_dart_debian/output/.

Image name
How to use
rootfs.tar.gz Root filesystem tarball used for installation on SD card and eMMC
Image.gz Linux kernel image
imx-boot-sd.bin U-Boot built for SD card and eMMC
Device Tree name
Details
fsl-imx8mq-var-dart-emmc-wifi-hdmi.dtb DART-MX8M with eMMC, WIFI and HDMI display configuration on carrier board revisions 1.3 and higher.(SD card disabled)
fsl-imx8mq-var-dart-emmc-wifi-lvds.dtb DART-MX8M with eMMC, WIFI and LVDS display configuration on carrier board revisions 1.3 and higher. (SD card disabled)
fsl-imx8mq-var-dart-emmc-wifi-dual-display.dtb DART-MX8M with eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher. (SD card disabled)
fsl-imx8mq-var-dart-emmc-wifi-hdmi-cb12.dtb DART-MX8M with eMMC, WIFI and HDMI display configuration on carrier board revisions 1.1 and 1.2. (SD card disabled)
fsl-imx8mq-var-dart-emmc-wifi-lvds-cb12.dtb DART-MX8M with eMMC, WIFI and LVDS display configuration on carrier board revisions 1.1 and 1.2. (SD card disabled)
fsl-imx8mq-var-dart-emmc-wifi-dual-display-cb12.dtb DART-MX8M with eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2. (SD card disabled)
fsl-imx8mq-var-dart-sd-emmc-hdmi.dtb DART-MX8M with SD, eMMC and HDMI display configuration on carrier board revisions 1.3 and higher. (WIFI disabled)
fsl-imx8mq-var-dart-sd-emmc-lvds.dtb DART-MX8M with SD, eMMC and LCDIF LVDS display configuration on carrier board revisions 1.3 and higher. (WIFI disabled)
fsl-imx8mq-var-dart-sd-emmc-dual-display.dtb DART-MX8M with SD, eMMC and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher. (WIFI disabled)
fsl-imx8mq-var-dart-sd-emmc-hdmi-cb12.dtb DART-MX8M with SD, eMMC and HDMI display configuration on carrier board revisions 1.1 and 1.2. (WIFI disabled)
fsl-imx8mq-var-dart-sd-emmc-lvds-cb12.dtb DART-MX8M with SD, eMMC and LCDIF LVDS display configuration on carrier board revisions 1.1 and 1.2. (WIFI disabled)
fsl-imx8mq-var-dart-sd-emmc-dual-display-cb12.dtb DART-MX8M with SD, eMMC and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2. (WIFI disabled)
fsl-imx8mq-var-dart-m4-emmc-wifi-hdmi.dtb DART-MX8M with M4 eMMC, WIFI and HDMI display configuration on carrier board revisions 1.3 and higher.(SD card disabled)
fsl-imx8mq-var-dart-m4-emmc-wifi-lvds.dtb DART-MX8M with M4 eMMC, WIFI and LVDS display configuration on carrier board revisions 1.3 and higher. (SD card disabled)
fsl-imx8mq-var-dart-m4-emmc-wifi-dual-display.dtb DART-MX8M with M4 eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher. (SD card disabled)
fsl-imx8mq-var-dart-m4-emmc-wifi-hdmi-cb12.dtb DART-MX8M with M4 eMMC, WIFI and HDMI display configuration on carrier board revisions 1.1 and 1.2. (SD card disabled)
fsl-imx8mq-var-dart-m4-emmc-wifi-lvds-cb12.dtb DART-MX8M with M4 eMMC, WIFI and LVDS display configuration on carrier board revisions 1.1 and 1.2. (SD card disabled)
fsl-imx8mq-var-dart-m4-emmc-wifi-dual-display-cb12.dtb DART-MX8M with M4 eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2. (SD card disabled)
fsl-imx8mq-var-dart-m4-sd-emmc-hdmi.dtb DART-MX8M with M4 SD, eMMC and HDMI display configuration on carrier board revisions 1.3 and higher. (WIFI disabled)
fsl-imx8mq-var-dart-m4-sd-emmc-lvds.dtb DART-MX8M with M4 SD, eMMC and LCDIF LVDS display configuration on carrier board revisions 1.3 and higher. (WIFI disabled)
fsl-imx8mq-var-dart-m4-sd-emmc-dual-display.dtb DART-MX8M with M4 SD, eMMC and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher. (WIFI disabled)
fsl-imx8mq-var-dart-m4-sd-emmc-hdmi-cb12.dtb DART-MX8M with M4 SD, eMMC and HDMI display configuration on carrier board revisions 1.1 and 1.2. (WIFI disabled)
fsl-imx8mq-var-dart-m4-sd-emmc-lvds-cb12.dtb DART-MX8M with M4 SD, eMMC and LCDIF LVDS display configuration on carrier board revisions 1.1 and 1.2. (WIFI disabled)
fsl-imx8mq-var-dart-m4-sd-emmc-dual-display-cb12.dtb DART-MX8M with M4 SD, eMMC and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2. (WIFI disabled)


7 Linux console access

User name User password User descriptor
root root system administrator
user user local user
x_user used for X session access

Please note: Vivante libraies for this release do not support X11, only weston backend is provided

8 Flash images to eMMC

To install Debian to the on-SOM eMMC, run the following command as root:

# install_debian.sh -d <lvds|hdmi|dp|dual-display>

where the "-d" option set display type, default is lvds. The above script is located in /usr/sbin in the rootfs of the SD card used to boot Debian.

9 How-to: Test and use an interface

Please see this section in the Yocto developer guide page. It is the same for Debian.

10 How-to: Modify the kernel configuration

To modify the kernel configuration (add/remove features and drivers) please follow the steps below:

1. $ cd ~/var_mx8m_dart_debian/src/kernel
2. $ sudo make ARCH=arm64 mrproper
3. $ sudo make ARCH=arm64 imx8_var_defconfig
4. $ sudo make ARCH=arm64 menuconfig
5. Navigate the menu and select the desired kernel functionality
6. Exit the menu and answer "Yes" when asked "Do you wish to save your new configuration?"
7. $ sudo make ARCH=arm64 savedefconfig
8. $ sudo cp arch/arm64/configs/imx8_var_defconfig arch/arm64/configs/imx8_var_defconfig.orig
9. $ sudo cp defconfig arch/arm64/configs/imx8_var_defconfig
10. Follow the instructions above to rebuild kernel and modules, repack rootfs images and recreate SD card

11 Build a sample C "Hello, world!" program

Create a file called myhello.c with the following content:

#include <stdio.h>

int main() {
	printf("Hello, World!\n");
	return 0;
}

Export the C (cross-)compiler path:

$ export CC=~/var_mx8m_dart_debian/toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc

Compile:

$ $CC myhello.c -o myhello

Now you should have an app called myhello, that can be run on your target board.
You can add it to your rootfs image or copy it directly to the rootfs on the board (using scp, for example).

12 Running X11 Applications via Xwayland

Since Vivante libraries for this release do not support X11 backend, only weston backend is provided, so if you want to run x11 based application
refer to XWayland Example