Buildroot for the i.MX6 sabre sd platform in a few commands

cancel
Showing results for 
Search instead for 
Did you mean: 

Buildroot for the i.MX6 sabre sd platform in a few commands

No ratings

Buildroot for the i.MX6 sabre sd platform in a few commands

br-sabresd.png

Here is a quick summary at building a bootloader, a kernel and a root filesystem for the i.MX 6 sabre sd platform, using buildroot.

This assumes you have a "working" Linux development environment at hand (e.g. Debian).

Buildroot is a fine build system, which makes deploying Linux on embedded platforms really easy. It is comparable to Yocto in spirit, but much simpler. Thanks to my colleague gillestalis, buildroot now has builtin support for the i.MX6 sabre sd platform.

Get buildroot sources

We will use git to fetch buildroot sources:


$ git clone git://git.busybox.net/buildroot


This should create a buildroot 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 '201*', and git checkout <the-desired-tag>.

Compile

The beauty of buildroot is that it will take care of everything for you, including preparing a cross compiler. You can download and build everything by doing:

$ cd buildroot

$ make freescale_imx6sabresd_defconfig

$ make

This should download and build everything, so it will take a while.

buildroot detects the number of CPUs you have in your machine and builds with parallel jobs automatically; no need to specify any -j argument to make here.

All build results fall under the output/images folder:

output/images/

+- rootfs.ext2

+- rootfs.tar

+- u-boot.bin

`- uImage

Format the SD card

As for Debian, we need to format the SD card with two partitions; one small FAT partition to contain the Linux kernel, and one large ext4 partition, which will contain the root filesystem with the buildroot generated 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 the FAT boot partition with:

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


Your SD card first partition is typically something in /dev/sd<X>1 or/dev/mmcblk<X>p1.


You can format the Linux partition with:

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


Your SD card second partition is typically something in /dev/sd<X>2 or/dev/mmcblk<X>p2.


Put on SD


As explained here, u-boot should reside at offset 1024B of your SD card. Also, as buildroot generates an u-boot.bin (and not an u-boot.imx) we should skip its first KB, too. In summary, to put u-boot on your SD, do:

  # dd if=output/images/u-boot.bin of=/dev/<your-sd-card> bs=1k seek=1 skip=1

  # sync

Your SD card device is typically something in /dev/sd<X> or /dev/mmcblk<X>. 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 a chmod a+w as root on the SD card device node to grant permissions to users.

Similarly to what this post describes, you can copy the kernel to the FAT boot partition with:

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

# cp output/images/uImage /mnt/

# umount /mnt


Your SD card first partition is typically something in /dev/sd<X>1 or/dev/mmcblk<X>p1.


And not unlike what is done in this post, You can install your generated root filesystem to the Linux partition with:

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

# tar -C /mnt -xvf output/images/rootfs.tar

# umount /mnt


Your SD card second partition is typically something in /dev/sd<X>2 or/dev/mmcblk<X>p2.

Boot!


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.


Like with Debian, u-boot default settings will not allow it to boot from the SD card, so we need to interrupt it by pressing enter at u-boot prompt for the first boot and setup u-boot environment to fix this:


MX6Q SABRESD U-Boot > setenv bootargs_mmc 'setenv bootargs ${bootargs} root=/dev/mmcblk1p2 rootwait'

MX6Q SABRESD U-Boot > setenv bootcmd_mmc 'run bootargs_base bootargs_mmc; mmc dev 2; fatload mmc 2:1 ${loadaddr} ${kernel}; bootm'

MX6Q SABRESD U-Boot > setenv bootcmd 'run bootcmd_mmc'

MX6Q SABRESD U-Boot > saveenv

Saving Environment to MMC...

Writing to MMC(2)... 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 buildroot system should boot to a prompt:

(...)

Welcome to Buildroot

buildroot login:

From there you may login as root.

Enjoy!


Tweak


buildroot uses Linux kernel kconfig to handle its configuration. So, as for the Linux kernel, changes to the configuration can be done with e.g.:


$ make menuconfig


Most of the options can be tuned from there, including (most importantly) which packages get installed into the generated root filesystem. This is configuration section 'Filesystem images'.


Further details are documented in buildroot manual.


Tips


  • ccache is natively supported by buildroot and can be easily enabled with configuration option BR2_CCACHE.
  • If you only use the generated rootfs.tar as described in this post and do not care about the rootfs.ext2, you might as well save a few seconds of build by disabling its generation. This is done with configuration option BR2_TARGET_ROOTFS_EXT2.
  • It is recommended to install an ssh server inside the target for further development. This is conveniently done with configuration option BR2_PACKAGE_OPENSSH.

See also...

Labels (5)
Comments

Thanks Vincent.

This is ironic. Your post hit at the same time as an e-mail regarding some patches that have been floating around.

           The buildroot February 2014 Archive by thread

N.B. The Buildroot GPU references and GStreamer plugins are quite old (which is what the patch set addresses). The current patch set only bumps them to coincide with the 3.5.7 release though.

Additional patches will be needed to bump to the latest.

I think gillestalis is preparing something based on 3.10.x. Stay tuned!

Thanks Vincent and gillestalis,

Once my patch set goes through, updating the package versions should be simple (almost s/3.5.7/3.10.9).

The difficult part will be chasing down which i.MX kernels need updating. I see at least SABRE SD and Wand in the code base.

Do you know if there are others? Can you help chase down versions supported?

The 3.10.9 binaries should be usable by all platforms by now, so that's probably the easy target.

We've added a branch to support 3.10.17 by incorporating OtavioSalvador's kernel patches (also used for Ubuntu/Debian distros):

        https://github.com/boundarydevices/linux-imx6/tree/boundary-imx_3.0.35_4.1.0-gpu4.6.9p13

I also noticed that the G2D components haven't been added to Buildroot?

Has anyone given though to their inclusion?

EricNelson, I wish it was just updating like that.

Currently the new releases as coming with fixes and layout changes so usually the integration is not that trivial; at same time, the work done in the Yocto Project BSP serves as a base how to package those components as we have overcome the issues when integrating them.

All current kernels in meta-fsl-arm and meta-fsl-arm-extra supports 3.10.9 GPU and 3.10.17 GPU in next branches (except Wandboard at this moment) so you may want to compare the ones we used.

Hi OtavioSalvador,

You're right. Things are never simple, but at the same time, leaving old versions in Buildroot is asking for support trouble.

We're trying not to support the 1.1.1 kernels for new customers, and Buildroot should have the latest stable versions.

As your efforts in Yocto show, there's a lot more to the picture for both GPU and VPU/gstreamer integration. The current Buildroot has the lowest-common denominator: FB-only versions of each.

I was running into some issues which didn't made it possible to me to start at least the Linux-Kernel:

1. The _defconfig-File is "freescale_imx6qsabresd_defconfig" not "freescale_imx6sabresd_defconfig".
2. The paths to the Freescale git repositories configured in "freescale_imx6qsabresd_defconfig" are wrong. They have to be:

BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git"

BR2_TARGET_UBOOT_CUSTOM_REPO_URL="git://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git"

(I also had to change git:// to http:// because my Firewall doesn't allow git)

3. In the generated Images there is no "u-boot.bin". But a "u-boot.imx", so I had to use "# dd if=output/images/u-boot.imx of=/dev/<your-sd-card> bs=1k seek=1"

4. The Environment for the generated u-boot seem incomplete:
4.1 There is no $kernel -variable instead there is $image which has first to be set to:
setenv image uImage

4.2 Also there is no $bootargs_base. The information about console and baud-rate normally set there is already stored in $bootargs

4.3 You want to boot the Kernel from mmcblk2 but the rootfs from mmcblk1. But in this howto, the kernel AND the rootfs is stored on mmcblk1.

You don't describe, how you put the kernel in mmc 2.

4.4 At least I got u-boot to load the kernel with this environment:

U-Boot > setenv image uImage

U-Boot > setenv bootargs console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw

U-Boot > setenv bootargs_mmc console=ttymxc0,115200 root=/dev/mmcblk1p2 rootwait rw

U-Boot > setenv bootcmd_mmc 'run bootargs_mmc; mmc dev 1; fatload mmc 1:1 ${loadaddr} ${image}; bootm'

U-Boot > setenv bootcmd 'run bootcmd_mmc'

Can somebody please share the u-boot environment variables to boot from SD card for the latest buildroot version?Or share the buildroot version tag which is already tested .

I have a more basic problem. After the third command above, I got the following:

$ make freescale_imx6sabresd_defconfig

make[1]: *** No rule to make target `freescale_imx6sabresd_defconfig'.  Stop.

make: *** [_all] Error 2

So there must be something missing in the above procedure. What is is ?

Hi

I have used buildroot with QT for sabreauto, i have all the images in my output folder. I have tried making the card and separately copying images and also i tried flashing the full sdcard.img. After flashing sdcard.img i separately flashed bootloader with command:

sudo dd if=u-boot.bin of=/dev/sdb bs=512 seek=2 conv=fsync

Still the board is not booting.

My defconfig file is freescale_imx6qsabreauto_defconfig

Waiting for reply.

Thanks

Deepika

Hi

I am new to embedded Linux. I want to enable dual Display in imx6. I want to ask that which target application i should have to enable for that purpose in build root? or would i have to apply patch for that purpose. 

Regrds

Muhammad Asad Iqbal

At which file should your modifications be done?

BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git"

BR2_TARGET_UBOOT_CUSTOM_REPO_URL="git://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git"

After performing the above procedures, no files were generated to output/images directory.

Also, the following was the last lines on the terminal after compilation process:

Makefile:1382: recipe for target 'checkdtc' failed
make[1]: *** [checkdtc] Error 1
make[1]: Leaving directory '/XXXXX/buildroot/output/build/uboot-rel_imx_4.9.x_1.0.0_ga'
package/pkg-generic.mk:247: recipe for target '/XXXXX/buildroot/output/build/uboot-rel_imx_4.9.x_1.0.0_ga/.stamp_built' failed
make: *** [/XXXXX/buildroot/output/build/uboot-rel_imx_4.9.x_1.0.0_ga/.stamp_built] Error 2

Can the buildroot support VAR-SOM-MX6?

Version history
Revision #:
1 of 1
Last update:
‎12-26-2013 01:33 AM
Updated by: