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

来源:互联网 发布:产品效果图制作软件 编辑:程序博客网 时间:2024/06/11 05:36

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

Here is a quick summary at booting Linux on the i.MX 6 sabre sd platform.

 

This assumes you already have u-boot working on your platform as described here. This implies you already have a "working" Linux development environment with some ARM cross-compilers at hand (e.g. Debian +Emdebian).

 

Get Linux sources

 

We will use git to fetchLinux sources:


  $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


This should create a linux directory with all the latest sources (after a while).


Note that for more stability you might want to checkout a release instead of the latest version; to do so, list the available release tags with e.g. git tag -l 'v3.*', and git checkout <the-desired-tag>.

 

Compile

 

Assuming your cross compiler is called e.g. arm-linux-gnueabihf-gcc, you can compile by doing:

 

  $ cd linux

  $ export ARCH=arm

  $ export CROSS_COMPILE=arm-linux-gnueabihf-

  $ make imx_v6_v7_defconfig

  $ make

  $ make uImage


This should create a number of files, including arch/arm/boot/uImage and arch/arm/boot/dts/imx6q-sabresd.dtb.

 

Put on SD

We need a proper FAT partition on the SD card, from which u-boot will be able to load the kernel and dtb. Also, we need to make sure we leave some space foru-boot starting from offset 1024B. Here is an example SD card layout:

 

  +-----+------+--------+-----+----------------

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

  +-----+------+--------+-----+----------------

  0     512    1024           1M

 

(offsets in bytes)

 

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

 

  Device    Boot      Start         End      Blocks   Id  System

  /dev/sdc1            2048     8054783     4026368    c  W95 FAT32 (LBA)

 

(units: 512B sectors)

 

You can format the FAT partition, mount, copy and unmount with:


  $ mkfs.vfat /dev/<your-sd-card-first-partition>

  $ mount /dev/<your-sd-card-first-partition> /mnt

  $ cp arch/arm/boot/uImagearch/arm/boot/dts/imx6q-sabresd.dtb /mnt/

  $ umount /mnt


Your SD card first partition is typically something in/dev/sd<X>1 or/dev/mmcblk<X>p1. Note that you need write permissions on the SD card for the command to succeed, so you might need to su - as root, or use sudo,or do achmod a+w asroot on the SD card device node to grant permissions to users.


Also, be sure to haveu-boot on the SD card as explained inthis post.

 

Boot!

 

That's it; u-boot already knows how to deal with your kernel by default so you are good to go.Insert the SD card into 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. You should see u-boot messages:

 

  U-Boot 2013.07-rc1-00014-g74771f4 (Jun 21 2013 - 16:27:39)


u-boot should load theuImage and dtb from SD card and boot the kernel:


  (...)

  reading uImage

  4215344 bytes read in 449 ms (9 MiB/s)

  Booting from mmc ...

  reading imx6q-sabresd.dtb

  22818 bytes read in 22 ms (1012.7 KiB/s)

  ## Booting kernel from Legacy Image at 12000000 ...

     Image Name:   Linux-3.10.0-rc6

     Image Type:   ARM Linux Kernel Image (uncompressed)

     Data Size:    4215280 Bytes = 4 MiB

     Load Address: 10008000

     Entry Point:  10008000

     Verifying Checksum ... OK

  ## Flattened Device Tree blob at 11000000

     Booting using the fdt blob at 0x11000000

     Loading Kernel Image ... OK

  OK

     Using Device Tree in place at 11000000, end 11008921

 

 

  Starting kernel ...

 

The kernel should boot:

 

  Booting Linux on physical CPU 0x0

  Linux version 3.10.0-rc6 (vstehle@debian) (gcc version 4.7.2 (Debian 4.7.2-5) ) #1 SMP Fri Jun 21 18:09:26 CEST 2013


By default, the kernel will try to mount a root filesystem from the SD card second partition, as can be read in the default kernel command line:


  (...)

  Kernel command line: console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw

 

...but we did not prepare a root filesystem partition, so after a number of boot messages the kernel will wait indefinitely:

 

  (...)

  mmc1: new SDHC card at address b368

  (...)

   mmcblk0: p1

  (...)

  Waiting for root device /dev/mmcblk1p2...

 

We will see in another post how to prepare this root filesystem on the second SD card partition. Enjoy!

 

See also...

 

  • If you plan to compile Linux often, you might want to use a C compiler cache; seethis post.
  • Once you have Linux booting on your platform the next step is to give it a root filesystem. Seethis post for a Debian root filesystem, and this post for a minimal busybox filesystem.

原创粉丝点击