Debian Build Release Stage

From Variscite Wiki
Revision as of 10:14, 15 September 2023 by Francesco (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release RELEASE_BUSTER_V3.1_DART-MX8M.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
DART-MX8M - Debian Buster 10 with imx_4.19.35_1.1.0_var01 Linux release


Overview

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

Notes:
  • 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).
  • From time to time (but rarely), the servers from which the build script retrieves data may be unavailable or slow. Usually, this is only a temporary issue, please try again at a later time.

Setup Development Environment

Please refer to the page Debian Development Environment to learn how to set up a suitable development environment.

Installing required packages

Please make sure your host PC, running a suitable Ubuntu, is up to date:

$ sudo apt-get update && sudo apt-get dist-upgrade

Then, install the following packages:

$ sudo apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx \
lvm2 dosfstools gpart binutils bison git lib32ncurses5-dev libssl-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 cmake


While installing the packages, using Ubuntu 20.04, users may receive the warning

Package python-git is not available, ...

Since the package is only available in up to Ubuntu 18.04, just ignore it and run:

$ sudo apt-get install python3-git python3-m2crypto

Note: If you are using Ubuntu 20.04 the QEMU package must be updated to latest version (>= 1:4.2-3ubuntu6.19).
To check the currently installed version of the qemu-user-static package on Ubuntu 20.04 LTS, use the below command:

$ apt list qemu-user-static


Note: Variscite provides Docker containers that can be used for a development environment as an alternative to a virtual machine or a dedicated computer. To learn more, please see Variscite's Docker Build Environment guide.

Reference documentation

Documentation is available from https://www.debian.org/doc/

Download Debian build script

Important update:

As of March 31, 2023, all codeaurora.org repositories have been migrated to other platforms, and the project has been shut down.
For more information, please visit: https://bye.codeaurora.org/

In this context, errors may occur when deploying the Debian sources, such as:
fatal: unable to look up source.codeaurora.org (port 9418) (No address associated with hostname)

Variscite has updated all relevant software repositories. Please refer to the patch(es):

Download archive containing the build script and support files for building Debian Buster for this board.
You can choose between downloading a release tag or downloading the latest revision (recommended). Follow only one of the next two bullet sections, accordingly:

  • Download the latest revision:
$ cd ~
$ git clone https://github.com/varigit/debian-var.git -b debian_buster_var02 debian_imx8mq-var-dart

or

  • Download a release tag:

Each release in https://github.com/varigit/debian-var/releases corresponds to a tag.
One can find a list of all available tags in https://github.com/varigit/debian-var/tags.
To target a specific release/tag, run the following:

$ cd ~
$ git clone https://github.com/varigit/debian-var.git -b refs/tags/TAG_NAME debian_imx8mq-var-dart

For example:

$ cd ~
$ git clone https://github.com/varigit/debian-var.git -b refs/tags/mx8m-dart-debian-buster-sd.v31 debian_imx8mq-var-dart

Setup and build Debian

Deploy sources

Download all necessary sources, required for the Debian build, by running the following command:

$ cd ~/debian_imx8mq-var-dart
$ MACHINE=imx8mq-var-dart ./var_make_debian.sh -c deploy

This will download the toolchain, bootloader, kernel, firmware blobs, and so on, to the folder ~/debian_imx8mq-var-dart/src and in case of the toolchain to ~/debian_imx8mq-var-dart/toolchain.

Note: The deploy command is only mandatory for the very first build setup.

If you want to re-deploy the source(s), delete the entire folder ~/debian_imx8mq-var-dart/src or just delete the desired subfolder and reinvoke the deploy command.

Build all

Warning: Internet connection should be available!
$ cd ~/debian_imx8mq-var-dart
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c all |& tee build.log

Build by parts

Build bootloader

$ cd ~/debian_imx8mq-var-dart
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c bootloader

Build kernel, dtb files and kernel modules

$ cd ~/debian_imx8mq-var-dart
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c kernel
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c modules
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c kernelheaders
Note: The kernel build (script command -c kernel) also includes the built of the device tree blobs.


Build rootfs

Warning: Internet connection should be available!

Before you build the rootfs, please ensure all parts (bootloader, kernel, device tree blobs, and so on) are in place since they are dependencies of the rootfs build.

Run the following commands to build the rootfs:

$ cd ~/debian_imx8mq-var-dart
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c rootfs

You can find the rootfs at ~/debian_imx8mq-var-dart/rootfs and an archive (rootfs.tar.gz) at ~/debian_imx8mq-var-dart/output.

Pack rootfs

Assuming you've already built the rootfs, by following the Build rootfs or Build all step, you can (re-)create the archive as a single and separate step:

$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c rtar


Build Results

The resulted images are located in ~/debian_imx8mq-var-dart/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
imx-boot-sd-dp.bin U-Boot built for SD card and eMMC with DP firmware
Device Tree name
Details
fsl-imx8mq-var-dart-sd-dp.dtb DTB for eMMC, SD and DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-sd-hdmi.dtb DTB for eMMC, SD and HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-sd-lvds.dtb DTB for eMMC, SD and LVDS display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-sd-lvds-dp.dtb DTB for eMMC, SD and dual LVDS+DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-sd-lvds-hdmi.dtb DTB for eMMC, SD and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-sd-hdmi-cb12.dtb DTB for eMMC, SD and HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-sd-lvds-cb12.dtb DTB for eMMC, SD and LVDS display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-sd-lvds-hdmi-cb12.dtb DTB for eMMC, SD and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-wifi-dp.dtb DTB for eMMC, WIFI and DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-wifi-hdmi.dtb DTB for eMMC, WIFI and HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-wifi-lvds.dtb DTB for eMMC, WIFI and LVDS display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-wifi-lvds-dp.dtb DTB for eMMC, WIFI and dual LVDS+DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-wifi-lvds-hdmi.dtb DTB for eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-wifi-hdmi-cb12.dtb DTB for eMMC, WIFI and HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-wifi-lvds-cb12.dtb DTB for eMMC, WIFI and LVDS display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-wifi-lvds-hdmi-cb12.dtb DTB for eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-m4-sd-dp.dtb DTB for M4, eMMC, SD and DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-sd-hdmi.dtb DTB for M4, eMMC, SD and HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-sd-lvds.dtb DTB for M4, eMMC, SD and LVDS display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-sd-lvds-dp.dtb DTB for M4, eMMC, SD and dual LVDS+DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-sd-lvds-hdmi.dtb DTB for M4, eMMC, SD and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-sd-hdmi-cb12.dtb DTB for M4, eMMC, SD and HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-m4-sd-lvds-cb12.dtb DTB for M4, eMMC, SD and LVDS display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-m4-sd-lvds-hdmi-cb12.dtb DTB for M4, eMMC, SD and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-m4-wifi-dp.dtb DTB for M4, eMMC, WIFI and DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-wifi-hdmi.dtb DTB for M4, eMMC, WIFI and HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-wifi-lvds.dtb DTB for M4, eMMC, WIFI and LVDS display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-wifi-lvds-dp.dtb DTB for M4, eMMC, WIFI and dual LVDS+DP display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-wifi-lvds-hdmi.dtb DTB for M4, eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.3 and higher.
fsl-imx8mq-var-dart-m4-wifi-hdmi-cb12.dtb DTB for M4, eMMC, WIFI and HDMI display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-m4-wifi-lvds-cb12.dtb DTB for M4, eMMC, WIFI and LVDS display configuration on carrier board revisions 1.1 and 1.2.
fsl-imx8mq-var-dart-m4-wifi-lvds-hdmi-cb12.dtb DTB for M4, eMMC, WIFI and dual LVDS+HDMI display configuration on carrier board revisions 1.1 and 1.2.


Create a bootable SD card

SD card structure

This is the structure of our Recovery/Extended SD card:
SD card part mx8m.png

The SD card is divided into 2 sections, as shown in the picture above:

  • The first unallocated 8MiB section is reserved for U-Boot. It can be replaced using the dd command as described in the Debian Build U-Boot section.
  • The first partition is an ext4 partition that contains the complete root filesystem (including kernel image and device tree files under /boot).

Note:
The last unallocated area is not used. It is there so that the rootfs will fit on any 4GB SD card, as not all 4GB SD cards are really the same size. If you want, you can use a program such as GParted to resize the roofs partition and make it end at the end of your specific SD card (of course, you can also use SD cards with much bigger capacity than 4GB, and then it makes more sense to resize the partition).

Create a Debian bootable SD card

Caution: Running the build script command 'sdcard' will destroy all data on the 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:
$ cd ~/debian_imx8mq-var-dart
$ sudo MACHINE=imx8mq-var-dart ./var_make_debian.sh -c sdcard -d /dev/sdX


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

Create a Debian bootable SD card image using a loop device

It is also possible to use the "MACHINE=imx8mq-var-dart ./var_make_debian.sh" script to create a boot SD card image while using a loop device instead of attaching a real physical 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 3720MiB 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=imx8mq-var-dart ./var_make_debian.sh -c sdcard -d /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

This will create a gz archive imx8m-var-dart-debian-sd.img.gz of the SD card image.

Clone a Debian bootable SD card image

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

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

Please refer also to Debian Recovery SD Card - Write the image to an SD Card.

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.

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


Automatic 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).

We implemented a script in U-Boot's environment, which sets the fdt_file environment variable based on the detected hardware.

Enable/Disable Automatic Device Tree selection

To enable the automatic device tree selection in U-Boot (already enabled by default):

$ setenv fdt_file undefined
$ saveenv

To disable the automatic device tree selection in U-Boot, set the device tree file manually:

$ setenv fdt_file YOUR_DTB_FILE
$ saveenv


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

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.

Installing packages which depend on libc

NXP Provides the Vivante GPU driver in binary form and it requires a specific minimum version of libc.
Due to this requirement from the GPU user space libraries, this Debian release uses an updated version of libc from the newer Debian Bullseye repository.
Therefore, if you need to install packages which depend on libc (like build-essentials, gcc, libc6-dev, etc.) please use their "testing" version (from Debian Bullseye).
For example:

apt-get update
apt-get install build-essential/testing gcc/testing g++/testing libc6-dev/testing