Debian on the i.MX6 sabre sd platform in a few commands

Document created by Vincent Stehle Employee on Jun 24, 2013Last modified by Vincent Stehle Employee on Aug 19, 2014
Version 27Show Document
  • View in full screen mode


Here we show how to bootstrap the Debian Linux distribution from a PC to the i.MX6 sabre sd platform.


While bootstrapping Debian on any architecture "natively" is pretty straightforward, "cross-bootstrapping" requires some techniques that we will explain.


This document assumes you are able to boot a Linux kernel on your platform already. See this post for details on how to do it. Also, this document assumes you are using a Debian PC for preparing your SD card. You will require the following packages to be installed:


  • binfmt-support
  • qemu-user-static
  • debootstrap


Note: all the commands found in the following steps need to be run as root.


Formatting the SD card


We need to format the SD card with two partitions; one small FAT partition to contain the Linux kernel and its dtb, and one large ext4 partition, which will contain the root filesystem with the Debian userspace. Also, we need to make sure we leave some space for u-boot starting from offset 1024B. Here is an example SD card layout:



  | MBR |  ... | u-boot | ... | FAT partition | Linux partition ...


  0     512    1024           1M              ~257M


(offsets in bytes)



Here is an example SD card layout, as displayed by fdisk:


  Device    Boot      Start         End      Blocks   Id  System

  /dev/sdc1            2048      526335      262144    c  W95 FAT32 (LBA)

  /dev/sdc2          526336     8054783     3764224   83  Linux


(units: 512B sectors)


You can format and mount the Linux partition with:


  # mkfs.ext4 /dev/<your-sd-card-second-partition>

  # mount /dev/<your-sd-card-second-partition> /mnt

Your SD card second partition is typically something in /dev/sd<X>2 or /dev/mmcblk<X>p2. Do not forget to install u-boot and a Linux kernel as explained in those posts.


Bootstrapping Debian

First stage

The first stage of Debian bootstrapping is done with:

  # debootstrap --foreign --arch=armhf testing /mnt

This will retrieve the base Debian packages from the internet, and perform a first stage of installation:


  I: Retrieving Release

  I: Retrieving Release.gpg

  I: Checking Release signature

  I: Valid Release signature (key id A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553)

  I: Validating Packages

  I: Resolving dependencies of required packages...

  I: Resolving dependencies of base packages...

  I: Found additional required dependencies: insserv libbz2-1.0 libcap2 libdb5.1 libsemanage-common libsemanage1 libslang2 libustr-1.0-1

  I: Found additional base dependencies: libee0 libept1.4.12 libestr0 libgcrypt11 libgnutls-openssl27 libgnutls26 libgpg-error0 libidn11 libjson-c2 liblognorm0 libmnl0 libnetfilter-acct1 libnfnetlink0 libp11-kit0 libsqlite3-0 libtasn1-3 libxapian22

  I: Checking component main on


  I: Extracting util-linux...

  I: Extracting liblzma5...

  I: Extracting zlib1g...


At this point, the necessary tools for second stage of installation are under /mnt/debootstrap/.


Second stage


The second stage needs to run natively; on an arm platform, that is. But we can use the combination of two techniques to perform this stage on the PC anyway:

  # cp /usr/bin/qemu-arm-static /mnt/usr/bin/

  # chroot /mnt /debootstrap/debootstrap --second-stage

Those commands copy an arm emulator on the target filesystem, and use the chroot command to execute the second stage of the installation into the SD card, on the PC, with transparent emulation:


  I: Installing core packages...

  I: Unpacking required packages...

  I: Unpacking libacl1:armhf...

  I: Unpacking libattr1:armhf...

  I: Unpacking base-files...


  I: Configuring tasksel...

  I: Configuring tasksel-data...

  I: Configuring libc-bin...

  I: Base system installed successfully.

You can now remove /mnt/usr/bin/qemu-arm-static, or keep it for later, subsequent chroot under emulation.

Finetuning the root filesystem

For development it is handy to remove the root password on the target by removing the '*' from /mnt/etc/shadow on the SD card:


Also, we can add the following line in /mnt/etc/inittab to obtain a login prompt on the UART:

  T0:23:respawn:/sbin/getty -L ttymxc0 115200 vt100

You can now unmount the filesystem with:

  # umount /mnt


Your SD card is ready for booting. Insert it in the SD card slot of your i.MX6 sabre sd platform, connect to the USB to UART port with a serial terminal set to 115200 baud, no parity, 8bit data and power up the platform.

At the time of writing u-boot tells the kernel to boot from the wrong partition by default, so we need to interrupt by pressing enter at u-boot prompt for the first boot and setup u-boot environment to fix this:

  U-Boot > setenv mmcroot /dev/mmcblk0p2 rootwait rw

  U-Boot > saveenv

  Saving Environment to MMC...

  Writing to MMC(1)... done


As this is saved in the SD card it need only to be done once at first boot. You can reboot your board or type boot; your Debian system should boot to a prompt:



  [ ok ] Starting periodic command scheduler: cron.

  [ ok ] Running local boot scripts (/etc/rc.local).



  Debian GNU/Linux jessie/sid debian ttymxc0



  debian login:


From there you may login as root.


It is recommended to setup the network connection and install an ssh server inside the target for further development.




See also...


  • With the amounts of memory we have today in the systems, it is even possible to boot Debian in a ramdisk. See this post about busybox for the ramdisk generation.
  • Another way of generating a root filesystem is by building it with buildroot. See and this post for details.
3 people found this helpful