Booting Linux from SATA on i.MX6Q SABRE AI.

Document created by CarlosCasillas Employee on Sep 23, 2015Last modified by CarlosCasillas Employee on Oct 21, 2015
Version 2Show Document
  • View in full screen mode

This document explains how to prepare a SATA disk for the SABRE Automotive Platform of the i.MX6Q to boot Linux. So, for this, the following material will be needed:

  • SABRE AI board.
  • SATA Hard Disk.
  • SATA cable.
  • SATA power supply.
  • Linux Host computer.
  • i.MX6 Linux Demo Images BSP (L3.14.28_1.0.0).



1.- The BSP could be download from section "Run-time Software" --> “Operating System Software-Board Support Packages” --> "L3.14.28_1.0.0_iMX6QDLS_BUNDLE" of this webpage.


2.- Then, it is required to identify the configurations of the DIP switches (S2 and S1) to boot from SATA. They are indicated on table 3 of the SABRE AI Quick Start Guide:

sata switches.png


3.- Next, it will be required to connect the hard disk to the Linux Host computer, in order to prepare the partitions. The i.MX Linux User's Guide, on section 4.3  provides the steps to prepare a SD/MMC card to boot. Similar procedures will be applied on the hard disk:

  • Storing the U-Boot as raw data on the 3rd block of the disk.
  • Creating a FAT partition where the Kernel and the Device Tree will be stored.
  • Creating a EXT3/EXT4 partition to contain the Root File System.

image layout.png


CAUTION: It is necessary to know the proper assigned unit of the disk that will be partitioned, otherwise, the system may be destroyed/corrupted causing loss of data. In order to verify which unit is your target hard disk you could launch the following Linux commands:

$ cat /proc/partitions
$ df -h


To start creating the partitions, run the "fdisk" command with root permissions (make sure that the hard disk is unmounted if it was previously mounted). As an example, "sdx" will be used as the assigned unit (target hard disk):

$ sudo fdisk /dev/sdx


Type the following parameters (each followed by <ENTER>):

p               [lists the current partitions]

d               [to delete existing partitions. Repeat this until no unnecessary partitions are reported by the 'p' command to start fresh.]

u               [switch the unit to sectors instead of cylinders]

n               [create a new partition]

p               [create a primary partition - use for both partitions]

1               [the first partition]

20480       [starting at offset sector]

1024000   [size for the first partition to be used for the boot images]

p               [to check the partitions]




1228800   [starting at offset sector, which leaves enough space for the kernel, the boot loader and its configuration data]

<enter>    [using the default value will create a partition that extends to the last sector of the media]

p               [to check the partitions]

w              [this writes the partition table to the media and fdisk exits]



4.- Assuming that the BSP was already downloaded and uncompressed, the U-Boot file that will be used is the one with SATA support (u-boot-imx6qsabreauto_sata.imx). The kernel file to be used will be "zImage-imx6qdlsolo.bin", and the Device Tree file will be "zImage-imx6q-sabreauto.dtb". Finally, the Root File System will be contained on a "*.ext3" file. As an example, the QT5-Wayland will be used (fsl-image-qt5-wayland-imxqdlsolo.ext3).

bsp files linux.png

     a) Copying the U-Boot image:

sudo dd if=u-boot-imx6qsabreauto_sata.imx of=/dev/sdx bs=512 seek=2 conv=fsync


     b) Copying the kernel image and DTB file to FAT partition:

     First, it will be required to create the FAT partition, as steps from section 3 of this document just created the partitions, but didn't specified the file system of each one:

$ sudo mkfs.vfat /dev/sdx1

     Then, it is requiered to mount the formatted partition with this command:

$ mkdir /mountpoint
$ sudo mount /dev/sdx1 /mountpoint

      Copy the zImage and *.dtb file to the mountpoint by using cp command:

$ sudo cp zImage-imx6qdlsolo.bin /mountpoint 
$ sudo cp zImage-imx6q-sabreauto.dtb /mountpoint

     Finally, ensure to unmount the partition with this command:

$ sudo umount /mountpoint


    c) Copying the Root File System:

$ sudo dd if=fsl-image-qt5-wayland-imxqdlsolo.ext3 of=/dev/sdx2 && sync



5.- After finishing the copy, we can disconnect the hard disk from the Host computer and connecting it to the SABRE AI board. Ensure that the SATA disk is already powered and then turn on the board verifying that boot jumpers are properly configured to boot from SATA, and the i.MX should start to boot (check the Serial terminal) indicating that a SATA device is used. It is required to stop the boot process in order to perform some changes on U-Boot environment.

terminal sata linux.png


6.- The U-Boot environment changes that should be applied consist in creating a new "bootcmd_sata" (my_bootcmd_sata) including fatload commands for loading the kernel and DTB files from the FAT partition, instead of looking for them on fixed addresses:

=> setenv my_bootcmd_sata 'run my_bootargs_sata; sata init; fatload sata 0:1 ${loadaddr} zImage-imx6qdlsolo.bin; fatload sata 0:1 ${fdt_addr} zImage-imx6q-sabreauto.dtb; bootz ${loadaddr} - ${fdt_addr}'

The new definition of "my_bootargs_sata" must be declared as below, because the default declaration considers the Root File System on "sda1" partition:

=> setenv my_bootargs_sata 'setenv bootargs ${bootargs} root=/dev/sda2 rootwait rw'


Finally, the "bootcmd" should be modified to use the new declarations, and all the environment changes will be saved with the "saveenv" command:

=> setenv bootcmd 'run my_bootcmd_sata'
=> saveenv



7.- Now, a reset could be applied to the board to allow a normal boot, until getting the login screen on the serial terminal:


If a screen is connected to the SABRE AI board, the Wayland terminal could also be opened:

linux running on imx.jpg


Hope this will be useful for you.

Best regards!


2 people found this helpful