Debian Build Release
Overview
This page describes how to build and install Debian distribution (Bookworm) on Variscite boards with VAR-SOM-MX93.
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).
For additional details about this release, refer to the Release Notes.
Create build environment
These instructions were tested on Ubuntu 20.04/22.04 x64 host PCs. When using other distributions, there may be issues.
To learn more, please see Variscite's Docker Build Environment guide.
Windows with WSL/WSL2 is not supported for developmentInstalling 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 libssl-dev gawk wget \ git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev \ autoconf libtool libglib2.0-dev libarchive-dev xterm sed cvs subversion \ kmod coreutils texi2html bc docbook-utils 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 zstd udisks2 libgnutls28-dev \ python-pysqlite2 python-git python-m2crypto python-pyelftools
While installing the packages, 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 python3-pyelftools
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
Deploy source
Download archive containing the build script and support files for building Debian Bookworm for this board:
$ cd ~ $ git clone https://github.com/varigit/debian-var -b debian_bookworm_var01 debian_imx93_var_som
Create environment (Internet connection should be available):
$ cd ~/debian_imx93_var_som $ MACHINE=imx93-var-som ./var_make_debian.sh -c deploy
This environment prepared to build.
Make Debian
Build all
Internet connection should be available
$ cd ~/debian_imx93_var_som $ sudo MACHINE=imx93-var-som ./var_make_debian.sh -c all |& tee build.log
Build by parts
Build bootloader
$ cd ~/debian_imx93_var_som $ sudo MACHINE=imx93-var-som ./var_make_debian.sh -c bootloader
Build Linux kernel packages
$ cd ~/debian_imx93_var_som $ sudo MACHINE=imx93-var-som ./var_make_debian.sh -c kernelpackage
Build rootfs
Internet connection should be available
$ cd ~/debian_imx93_var_som $ sudo MACHINE=imx93-var-som ./var_make_debian.sh -c rootfs
Pack rootfs
To create the root file system archive (rootfs.tar.gz), run the following commands:
$ cd ~/debian_imx93_var_som $ sudo MACHINE=imx93-var-som ./var_make_debian.sh -c rtar
Create boot SD card
- Follow the above steps for make rootfs, kernel, bootloader;
- Insert the SD card to card reader connected to a host system;
- Run the following commands (Caution! All data on the card will be destroyed):
$ cd ~/debian_imx93_var_som $ sudo MACHINE=imx93-var-som ./var_make_debian.sh -c sdcard -d /dev/sdX
where '/dev/sdX' path to the block SD device in your system.
Create a boot SD card image using a loop device
It is also possible to use the "MACHINE=imx93-var-som ./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=imx93-var-som-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 imx93-var-som-debian-sd.img
To find the actual loop device being used, run:
$ losetup -a | grep imx93-var-som-debian-sd.img
Write the content to the loop device to generate the SD card image:
$ sudo MACHINE=imx93-var-som ./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 imx93-var-som-debian-sd.img
To write the SD card image to a real SD card device use the following command:
$ zcat imx93-var-som-debian-sd.img.gz | sudo dd of=/dev/sdX bs=1M && sync
(Replace /dev/sdX with your actual SD device, e.g. /dev/sdb)
Boot the board with a bootable SD card
Setting the Boot Mode
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 "Image.gz-" 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
Build Results
The resulted images are located in ~/debian_imx93_var_som/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 |
imx93-var-som-symphony.dtb | Device tree for VAR-SOM-MX93 on Symphony-Board |
Linux console access
User name | User password | User descriptor |
---|---|---|
root | root | system administrator |
user | user | local user |
x_user | used for X session access |
Flash images to eMMC
To install Debian to the on-SOM eMMC, run the following command as root:
# install_debian.sh
The above script is located in /usr/sbin in the rootfs of the SD card used to boot Debian.
How-to: Test and use an interface
Please see this section in the Yocto developer guide page. It is the same for Debian.
How-to: Modify the kernel configuration
To modify the kernel configuration (add/remove features and drivers) please follow the steps below:
1. $ cd ~/debian_imx93_var_som/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
How-to: Build and install a custom device tree
To build and install a custom device tree, add the filename to G_LINUX_DTB in https://github.com/varigit/debian-var/blob/debian_bookworm_var01/variscite/imx93-var-som/imx93-var-som.sh
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=~/debian_imx93_var_som/toolchain/arm-gnu-toolchain-12.2.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-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).