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:
Note: all the commands found in the following steps need to be run as root.
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.
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 http://ftp.us.debian.org/debian...
(...)
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/.
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.
For development it is handy to remove the root password on the target by removing the '*' from /mnt/etc/shadow on the SD card:
root::15880:0:99999:7:::
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.
Enjoy!
如果想更换不同的版本,可以试试下面的命令
debootstrap --arch=armel --foreign wheezy debian_armel_wheezy_rootfs/ http://ftp.us.debian.org/debian
chroot ./debian_armel_wheezy_rootfs /debootstrap/debootstrap --second-stage
用root用户建立以目录rootfs_debian的根文件系统
在文件夹中rootfs_debian中构造debian文件系统
# apt-get install binfmt-support qemu-user-static debootstrap
#debootstrap --arch=armel --foreign wheezy rootfs_debian/ http://ftp.us.debian.org/debian
#cp /usr/bin/qemu-arm-static ./rootfs_debian/usr/bin/
#chroot ./rootfs_debian /debootstrap/debootstrap --second-stage
#rm rootfs_debian/usr/bin/qemu-arm-static
#vim rootfs_debian/etc/shadow
去掉root登录密码, 去掉'*'
root::15880:0:99999:7:::
添加串口支持
在文件rootfs_debian/etc/inittab 中添加
T0:23:respawn:/sbin/getty -L ttymxc0 115200 vt100
添加更新包的源/etc/apt/sources.list
deb http://ftp.us.debian.org/debian wheezy main
Hello Vincent, link https://community.freescale.com/docs/DOC-99218 to generating a root filesystem by building it with buildroot is restricted. Can you please check and "unrestrict" it?
Hi DraganOstojic, thanks for pointing this out. This should be fixed now; sorry for the inconvenience.
Hi Vincent Stehle
This is Saida i recently purchased I.MX6DLSabreSD board.
i want to port u-boot to this board (sdcard booting)
most posts i hvae seen are related to Quad board only
i tried u-boot-2013-rc1.tar but its not booting may be this for quad
can you tell me which u-boot version supports for dual lite board
and also kernel posting steps
till now i have done with arm-none-eabi cross compiler tools
1 make mx6dsabredsd_config and cross compilation with above tool
2 dd if=u-boot.imx of=/dev/sdc1 bs=1k seek=1
3 sync
guide me if i did any mistakes
thank you in advance
This set of howtos is really awful and got me very fast a running system. Thank you very much.
But it only gives me command line.
I already tried to install xorg and kde-standard, but this gives me only a login-screen which crashes, when I try to login.
Obviously I have no graphics-driver or I'm missing some other configurations/files.
Is there a (simple) howto or tutorial to also set up a X-System with graphical desktop?
Hi steffendoster,
You might be interested in Buildroot then, as it allows to build x11 fairly easily.
If you want some hints for buildroot on i.MX6, we have this post on the matter: Buildroot for the i.MX6 sabre sd platform in a few commands. From there, adding x11 might be as simple as selecting the necessary packages with make menuconfig.
Best regards,
V.
Dear Vincent and other friends here,
Thanks so much for the help with installing debian on this i.MX6 sabre sd board. Following the instructions here, I was able to have a debian system running on it. But there is one kernel module missing, which is the cpurfreq kernel module.
This module is very important for me,since I would like to measure the computational speed of our algorithm at certain clock frequencies.
Can you confirm whether or not you are having this module in your built system ?
[ ok ] Loading cpufreq kernel modules...done (none).
[ ok ] CPUFreq Utilities: Setting ondemand CPUFreq governor...disabled, governor not available...done.
Thanks. I found the solution in this link:
[PATCH 3/3]: Support cpu frequency scaling and power management for iMX6SL
Hi @Vincent Stehle ,
Thanks for your helpful doc!
I am using the Debian 8 jessi(16.04) which has no /etc/inittab now.
So how can I obtain a login prompt on the UART??
All the Best
Kane