Debian is a free to use and redistribute Linux distribution that is widely used by the community for industrial and desktop applications.
This distribution started in 1993 as Debian Project with Ian Murdock inviting developers to contribute in one of the first Linux distributions.
Debian takes an important role in Linux world with a clear idea about be a full featured and free distribution with over than 59,000 packages provided as a free to use and distribute that supports a wide range of functionalities.
Currently, Debian 12 supports 9 architectures which makes it in a universal operating system that can be implemented in embedded systems, desktops or servers.
Finally, Debian has been an inspiration for well-known Linux distributions such as Kali and Ubuntu.
In this guide we will check the installation process of Debian 12 for NXP microprocessors i.MX family, specifically for i.MX8M Mini, i.MX8M Nano, i.MX8M Plus and i.MX93.
For this purpose, we divided the document in the following topics:
Hardware Requirements
Software Requirements
Host Preparation
SD Card Preparation
Copying Bootloader
Copying Kernel and DTB files
Debian Installation
Configure Base System
Boot your target
References
Hardware Requirements
Linux Host computer (Ubuntu 20.04 or later)
USB Card reader or Micro SD to SD adapter
SD Card
Evaluation Kit Board for the i.MX8M Nano, i.MX8M Mini, i.MX8M Plus or i.MX93
Software Requirements
Linux Ubuntu (20.04 and 24.04 tested) or Debian for host
BSP version 6.1.55 for your specific target (Embedded Linux for i.MX Applications Processors | NXP Semiconductors)
Host Preparation
For Debian installation we will require some specific packages for host.
You can download the packages using the following command:
$ sudo apt install debian-archive-keyring debootstrap qemu-user-static
We must validate the key to verify the archive using the command:
$ sudo apt-key add /usr/share/keyrings/debian-archive-keyring.gpg
If running an older release you need to get the unstable keyring package (because the version in your release is probably too old to have the current key)
$ wget http://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2023.4_all.deb
$ sudo dpkg -i debian-archive-keyring_2023.4_all.deb
SD Card Preparation
The Linux kernel running on the Linux host assigns a device node to the SD/MMC card reader. The kernel might decide the device node name or udev rules might be used. In the following instructions, it is assumed that udev is not used.
To identify the device node assigned to the SD/MMC card, carry out the following command:
$ cat /proc/partitions
Partitioning the SD card
On most Linux host operating systems, the SD card is mounted automatically upon insertion. Therefore, before running fdisk, make sure that the SD card is unmounted if it was previously mounted (through sudo umount /dev/sdx).
Start by running fdisk with root permissions. Use the instructions above to determine the card ID. We are using sdx as an example.
$ sudo fdisk /dev/sdx
Type the following parameters (each followed by <ENTER>):
$fdisk: p # lists the current partitions
$fdisk: d # to delete existing partitions. Repeat this until no unnecessary
partitions
$fdisk: n # create a new partition
$fdisk: p # create a primary partition - use for both partitions
$fdisk: 1 # the first partition
$fdisk: 20480 # starting at offset sector
$fdisk: 1024000 # ending position of the first partition to be used for the boot
Images
$fdisk: p # to check the partitions
$fdisk: n # create a new partition
$fdisk: p # create a primary partition
$fdisk: 2 # the second partition
$fdisk: 1228800 # starting at offset sector, which leaves enough space for the kernel, the bootloader and its configuration data
$fdisk: <enter> # using the default value will create a partition that extends to
the last sector of the media
$fdisk: p # to check the partitions
$fdisk: w # this writes the partition table to the media and fdisk exits
Copying Bootloader and Kernel
In this section we will copy the bootloader and kernel image to SD card.
First, we can create a new directory to unzip the BSP downloaded from the NXP site.
$ mkdir debian-imx
$ cd debian-imx
$ unzip ~/Downloads/LF_v6.1.55-2.2.0_images_<board>.zip
Where board is:
IMX8MPEVK
IMX8MNEVK
IMX8MMEVK
IMX93EVK
Then, copy the U-Boot image.
$ sudo dd if=<U-Boot_image> of=/dev/sdx bs=1k seek=<offset> conv=fsync
Where offset is:
33 - for i.MX 8M Mini
32 - for i.MX 8M Nano, i.MX 8M Plus, and i.MX 9
The sectors of SD/eMMC before the “offset” KB are reserved. It may include the partition table.
Copying Kernel image and DTB files
This section describes how to load the kernel image and DTB. The pre-built SD card image uses the VFAT partition for storing kernel image and DTB, which requires a VFAT partition that is mounted as a Linux drive, and the files are copied into it. This is the preferred method.
Default: VFAT partition
Format partition 1 on the card as VFAT with this command:
$ sudo mkfs.vfat /dev/sdx1
Mount the formatted partition with this command:
$ mkdir mountpoint
$ sudo mount /dev/sdx1 mountpoint
Copy the zImage and *.dtb files to the mountpoint by using cp. The device tree names should match
$ sudo cp *.dtb mountpoint/
$sudo cp Image-<board_name>.bin mountpoint/Image
Where board_name is:
imx8mpevk
imx8mnevk
imx8mmevk
imx93evk
the one used by the variable specified by U-Boot. Unmount the partition with this command:
$ sudo umount mountpoint
Debian Installation
For Debian installation we will use the official tool debootstrap. This tool allows us to install Debian without a disk and run the system using qemu in a different architecture.
Before using debootstrap tool we need to format and mount the second partition of the SD card with the commands below:
$ sudo mkfs.ext4 /dev/sdx2
$ sudo mount /dev/sdx2 mountpoint/
debootstrap can download the needed files directly from the archive when you run it. You can substitute any Debian archive mirror for http.us.debian.org/debian in the command below, preferably a mirror close to you network-wise. Mirrors are listed at http://www.debian.org/mirror/list
$ sudo debootstrap --arch arm64 --foreign bookworm mountpoint/ http://ftp.debian.org/debian
This step takes a while and depends on the resources of your host machine.
Configure Base System
Now you’ve got a real Debian system, though rather lean, on disk. chroot into it:
$ sudo cp /usr/bin/qemu-aarch64-static mountpoint/usr/bin
$ sudo LANG=C.UTF-8 chroot mountpoint/ qemu-aarch64-static /bin/bash
After chrooting you may need to set the terminal definition to be compatible with the Debian base system, for example:
$ export TERM=xterm-color
we need to finish the multi-stage boot strap
$ /debootstrap/debootstrap --second-stage
At this point /dev/ only contains very basic device files. For the next steps of the installation, additional device files may be needed. There are different ways to go about this and which method you should use depends on the host system you are using for the installation, whether you intend to use a modular kernel or not, and whether you want to use dynamic (e.g. using udev) or static device files for the new system.
A few of the available options are:
install the makedev package, and create a default set of static device files using (after chrooting)
$ apt install makedev
$ mount none /proc -t proc
$ cd /dev
$ MAKEDEV generic
With these next steps we will be setting up the Debian system:
Setting fstab
FSTAB is a configuration table designed to ease the burden of mounting and unmounting file systems to a machine.
$ nano /etc/fstab # stock fstab - you probably want to override this with a machine specific one
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0
# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0
Setting Timezone
The following command allows you to choose your timezone.
$ dpkg-reconfigure tzdata
Configure apt
Debootstrap will have created a very basic /etc/apt/sources.list that will allow installing additional packages. However, you may want to add some additional sources, for example for source packages and security updates:
$ nano /etc/apt/sources.list deb http://deb.debian.org/debian bookworm main non-free-firmware
deb-src http://deb.debian.org/debian bookworm main non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
deb-src http://deb.debian.org/debian-security/ bookworm-security main non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src http://deb.debian.org/debian bookworm-updates main non-free-firmware
Make sure to run the apt update after you have made changes to the sources list
Configure locales and keyboard
To configure your locale settings to use a language other than English, install the locales support package and
configure it. Currently, the use of UTF-8 locales is recommended.
$ apt install locales
$ dpkg-reconfigure locales
To configure your keyboard (if needed):
$ apt install console-setup
$ dpkg-reconfigure keyboard-configuration
Note that the keyboard cannot be set while in the chroot, but will be configured for the next reboot
Adding Users
$ apt install sudo
$ adduser imx
$ usermod -aG sudo imx
$ nano /etc/sudoers imx ALL=(ALL:ALL) ALL
Tasksel Installation
As mentioned earlier, the installed system will be very basic. If you would like to make the system a bit more mature, there is an easy method to install all packages with “standard” priority:
$ tasksel install standard
$ apt clean
$ exit
$ sudo umount mountpoint/
$sync
Boot your target
Now, you can boot your target from your SD Card. (Review your specific target documentation)
Configure Networking (after booting target)
Based on Debian official documentation for new systems the common names for network interfaces such as eth0 or wlan0 are not used. Therefore, we will need to list the interfaces using:
$ ls /sys/class/net
To have ethernet connection we will need to create a file in the path etc/network/.
$ sudo nano etc/network/interfaces
Type the following commands on the file:
auto lo
iface lo inet loopback
auto end0
iface end0 inet dhcp
Install Neofetch (Optional)
$ apt install neofetch
Outputs
Debian 12 running on i.MX8MP
Debian 12 running on i.MX93
References
Chapter 1. Definitions and overview. (2021, January). Retrieved May 30, 2024, from https://www.debian.org/doc/manuals/debian-faq/basic-defs.en.html
Debian GNU/Linux Installation Guide. (2024). https://www.debian.org/releases/stable/i386/install.en.pdf
Arm64Port. (n.d.). https://wiki.debian.org/Arm64Port
i.MX Linux User's Guide (nxp.com)
查看全文