Build and Install Debian Buster for SMARC-iMX8MM (Solo, Solo Lite, Dual, Dual Lite, Quad and Quad Lite Core)


This document provides instructions for advanced users how Embedian offers patches and builds Debian Buster for Embedian's SMARC-iMX8MM product platform and how to install the images to bring the evaluation board up and running. 

Our aim is to fully support our hardware through device drivers. We also provide unit tests so that testing a board is easy and custom development can start precisely. The recommended host environment is Ubuntu 16.04.

Availability


SMARC-iMX8MM from Embedian

Carrier Board


EVK-STD-CARRIER-S20 (universal carrier board for all SMARC 2.0 modules) from Embedian

Basic Resources


 

Generating SSH Keys


We recommend you use SSH keys to establish a secure connection between your computer and Embedian Gitlab server. To download u-boot and kernel source codes from Embedian server. You need to register from Embedian's Gitlab server and put your ssh public key there. The steps below will walk you through generating an SSH key and then adding the public key to our Gitlab account.

Step 1. Check for SSH keys


First, we need to check for existing ssh keys on your computer. Open up Git Bash and run:

$ cd ~/.ssh
$ ls
# Lists the files in your .ssh directory

Check the directory listing to see if you have a file named either id_rsa.pub or id_dsa.pub. If you don't have either of those files go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.

Step 2. Generate a new SSH key


To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.

$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
$ ssh-add id_rsa

Now you need to enter a passphrase.

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

Which should give you something like this:

Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

Step 3. Add your SSH key to Embedian Gitlab Server


Copy the key to your clipboard.

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAABDAQABAAABAQDQUEnh8uGpfxaZVU6+uE4bsDrs/tEE5/BPW7jMAxak
6qgOh6nUrQGBWS+VxMM2un3KzwvLRJSj8G4TnTK2CSmlBvR+X8ZeXNTyAdaDxULs/StVhH+QRtFEGy4o
iMIzvIlTyORY89jzhIsgZzwr01nqoSeWWASd+59JWtFjVy0nwVNVtbek7NfuIGGAPaijO5Wnshr2uChB
Pk8ScGjQ3z4VqNXP6CWhCXTqIk7EQl7yX2GKd6FgEFrzae+5Jf63Xm8g6abbE3ytCrMT/jYy5OOj2XSg
6jlxSFnKcONAcfMTWkTXeG/OgeGeG5kZdtqryRtOlGmOeuQe1dd3I+Zz3JyT your_email@example.c
om

Go to Embedian Git Server. At Profile Setting --> SSH Keys --> Add SSH Key 

Paste your public key and press "Add Key" and your are done.

Create build environment


Install required packages


On Ubuntu machine:

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

Deploy Sources


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

$ cd ~/

$ git clone git@git.embedian.com:developer/smarc_mx8_debian.git -b debian_buster_mx8mm

$ cd ~/smarc_mx8_debian

$ MACHINE=smarcimx8m4g ./smarc_make_debian.sh -c deploy

This environment prepared to build.

If the LPDDR4 is 2GB on your SMARC module, the MACHINE name will be smarcims8mm2g

Make Debian


Build all


 The internet connection in your host PC has to be available.

$ cd ~/smarc_mx8_debian

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c all |& tee build.log

If the LPDDR4 is 2GB on your SMARC module, the MACHINE name will be smarcims8mm2g


Build by parts


Build bootloader


 

$ cd ~/smarc_mx8_debian

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c bootloader

Build kernel, dtb files and kernel modules


 

$ cd ~/smarc_mx8_debian

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c kernel

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c modules

Build rootfs


 

$ cd ~/smarc_mx8_debian

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c rootfs

Pack rootfs


 

$ cd ~/smarc_mx8_debian

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c rtar

If the LPDDR4 is 2GB on your SMARC module, the MACHINE name will be smarcims8mm2g

Setup SD card Automatically


 

$ cd ~/smarc_mx8_debian

$ sudo MACHINE=smarcimx8mm4g ./smarc_make_debian.sh -c sdcard -d /dev/sdX


where "/dev/sdX" is the SD block device in your host system. Shunt the "TEST#" pin of your device to Ground. Insert the SD card and you will see SMARC-iMX8MM booting with Debian Buster. Console port is defined on SER3

The device tree file of SMARC-iMX8MM is fsl-smarcimx8mm.dtb

Setup SD Card Manually


For these instruction, we are assuming: DISK=/dev/mmcblk0, "lsblk" is very useful for determining the device id.

$ export DISK=/dev/mmcblk0

Erase SD card:

$ sudo dd if=/dev/zero of=${DISK} bs=1M count=16

Create Partition Layout: Leave 2MB offset for flash.bin.

With util-linux v2.26, sfdisk was rewritten and is now based on libfdisk.

$ sudo sfdisk --version
sfdisk from util-linux 2.27.1

Create Partitions:

$ sudo sfdisk ${DISK} <<-__EOF__
2M,48M,0x83,*
50M,,,
__EOF__
$ sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
2,48,0x83,*
,,,-
__EOF__

Format Partitions:

for: DISK=/dev/mmcblk0
$ sudo mkfs.vfat -F 16 ${DISK}p1 -n boot
$ sudo mkfs.ext4 ${DISK}p2 -L rootfs
 
for: DISK=/dev/sdX
$ sudo mkfs.vfat -F 16 ${DISK}1 -n boot
$ sudo mkfs.ext4 ${DISK}2 -L rootfs

Mount Partitions:

On some systems, these partitions may be auto-mounted...

$ sudo mkdir -p /media/boot/
$ sudo mkdir -p /media/rootfs/
 
for: DISK=/dev/mmcblk0
$ sudo mount ${DISK}p1 /media/boot/
$ sudo mount ${DISK}p2 /media/rootfs/
 
for: DISK=/dev/sdX
$ sudo mount ${DISK}1 /media/boot/
$ sudo mount ${DISK}2 /media/rootfs/

Install Boot File

Users need to shunt cross the TEST# pin to ground. In this way, SMARC-iMX8MM will always boot up from SD card. 

Fuse flash.bin to the SD card. 


$ cd ~/smarc_mx8_debian
$ sudo dd if=output/imx-boot-sd.bin of=${DISK} bs=1024 seek=33

uEnv.txt based bootscript

Copy uEnv.txt to the boot partition:


$ sudo cp -v embedian/uEnv.txt /media/boot/

Install Kernel Image

Copy Image to the boot partition:


$ sudo cp -v output/Image /media/boot

Install Kernel Device Tree Binary

$ sudo mkdir -p /media/boot/dtbs

$ sudo cp -v output/fsl-smarcimx8mm.dtb /media/boot/dtbs/fsl-smarcimx8mm.dtb

The device tree name in your SD card has be to fsl-smarcimx8mm.dtb

Install Root File System and Kernel Modules


Extract Root File System:


$ sudo tar xvfz output/rootfs.tar.gx -C /media/rootfs

  1. MAC address is factory pre-installed at on board I2C EEPROM at offset 60 bytes). It starts with Embedian's vendor code 10:0D:32. u-boot will read it and pass this parameter to kernel.
  2. Kernel module is pre-built in debian rootfs
  3. The default console port is SER3.


Remove SD card:

$ sync
$ sudo umount /media/boot
$ sudo umount /media/rootfs

Build Results


The resulted images are locared in ~/smarc_mx8_debian/output directory:

Image NameDescription
rootfs.tar.gzRoot filesystem tarball for installation on SD card and eMMC
ImageLinux Kernel Image
imx-boot-sd.binBoot file for SD card and eMMC

Linux Console Access


User NameUser PasswordUser Descriptor
rootrootsystem administrator
useruserlocal user
x_user used for X session access

Setup eMMC


Shunt TEST# pin to Ground and boot up from your SD card. Run the following command as root user.

$ install_debian.sh

Modify the kernel configuration


To modify the kernel configuration (add/remove features and drivers). Please follow the step below.

$ cd ~/smarc_mx8_debian/src/kernel

$ sudo make arch=arm64 mrproper

$ sudo make arch=arm64 smarcimx8mm_defconfig

$ sudo make arch=arm64 menuconfig

 

Navigate the menu and select the desired kernel functionality Exit the menu and answer "Yes" when asked "Do you wish to save your new configuration?"

$ sudo make ARCH=arm64 savedefconfig

$ sudo cp arch/arm64/configs/smarcimx8mm_defconfig arch/arm64/configs/smarcimx8mm_defconfig.orig

$ sudo cp .config arch/arm64/configs/smarcimx8mm_defconfig

Follow the instructions above to rebuild kernel and modules, repack rootfs images and recreate SD card


Video Decoding


For playing video, we can use three solutions to support it. 

a) # gplay-1.0 <video file>

b) gst-launch-1.0 playbin uri=file://<video absolute path>


version 1.0a, 7/17/2020

Last updated 2020-07-17