How to build Buildroot for AT91


Host build system should be a Linux system with necessary software installed.

Note You can install missing packages using yum install with Fedora or apt-get install with Ubuntu or Debian. These commands may require root privileges or being in a correct sudoers group.

Get sources

You can easily download Buildroot sources on the official Buildroot git repository.

To get the source code, you have to clone the repository:

$ git clone git://
Cloning into 'buildroot'...
remote: Counting objects: 201576, done.
remote: Compressing objects: 100% (63717/63717), done.
remote: Total 201576 (delta 140322), reused 196000 (delta 136937)
Receiving objects: 100% (201576/201576), 42.93 MiB | 404.00 KiB/s, done.
Resolving deltas: 100% (140322/140322), done.
Checking connectivity... done.
$ cd buildroot
$ ls
CHANGES  COPYING  Makefile  Makefile.legacy  README  arch  board  boot  configs  docs  fs  linux  package  support  system  toolchain

The source code has been taken from the master branch which is pointing on the latest version of Buildroot. If you want to use a specific release, you can list them and use one of them by doing this:

$ git tag

$ git checkout  2016.02-rc3 -b buildroot-2016.02-rc3

To benefit the latest enhancements for Atmel products, you are advised to use the master branch.

Build the rootfs image

Assuming you are at the Buildroot root directory, you'll find a configs folder containing several default configurations. If you are familiar with kernel configuration, you'll see that it works in the same way.

For the same board, several defconfig files are provided:

  • atmel__xplained_defconfig provides at91bootstrap, u-boot, the kernel image and dtb files, a very basic rootfs for NAND flash memory.
  • atmel__xplained_mmc_defconfig provides the same stuff but for SD card. Moreover a SD card image is done to ease the creation of the bootable SD card.
  • atmel__xplained_dev_defconfig and atmel__xplained_mmc_dev_defconfig provide a rootfs with additional tools to use SoC devices (I2C, CAN, audio, etc.).

If you want to build the rootfs image we provide for sama5d2, you'll have to do:

$ make atmel_sama5d2_xplained_mmc_defconfig

Then you can build the rootfs:

$ make

Once compilation is done, have a look to output/images to see what has been generated:

$ ls output/images/
at91-sama5d2_xplained.dtb       at91-sama5d2_xplained_pda7.dtb   at91bootstrap.bin  boot.vfat    rootfs.ext4  sama5d2_xplained-sdcardboot-uboot-3.8.4.bin  u-boot.bin
at91-sama5d2_xplained_pda4.dtb  at91-sama5d2_xplained_pda7b.dtb  boot.bin           rootfs.ext2  rootfs.tar   sdcard.img                                   zImage

The board/atmel/readme.txt file documents how to flash the NAND using SAM-BA and how to create a bootable SD card.

This document explains how to set up a basic Buildroot system on various
Atmel boards. Additional details can also be found on the Linux4SAM website:

This guide covers the following configurations:
 - at91sam9g45m10ek_defconfig
 - at91sam9rlek_defconfig
 - at91sam9x5ek_defconfig (at91sam9g15, at91sam9g25, at91sam9x25,
   at91sam9g35 and at91sam9x35)
 - atmel_sama5d3xek_defconfig (sama5d31, sama5d33, sama5d34, sama5d35,
 - atmel_sama5d3_xplained_defconfig
 - atmel_sama5d3_xplained_dev_defconfig
 - atmel_sama5d3_xplained_mmc_defconfig
 - atmel_sama5d3_xplained_mmc_dev_defconfig
 - atmel_sama5d4ek_defconfig
 - atmel_sama5d4_xplained_defconfig
 - atmel_sama5d4_xplained_dev_defconfig
 - atmel_sama5d4_xplained_mmc_defconfig
 - atmel_sama5d4_xplained_mmc_dev_defconfig
 - atmel_sama5d2_xplained_mmc_defconfig
 - atmel_sama5d2_xplained_mmc_dev_defconfig

These configurations will use AT91Bootstrap, U-Boot and a Linux kernel from
the git trees maintained by Atmel.

Configuring and building Buildroot

For most configurations listed above, the Buildroot configuration
assumes the system will be flashed on NAND. In this case, after
building Buildroot, follow the instructions in the "Flashing the NAND
using SAM-BA" section below.

For the Xplained boards, an alternative Buildroot configuration is
provided to boot from an SD card. Those configurations are labeled as
'mmc'. In this case, after building Buildroot, follow the instructions
in the "Preparting the SD card" sction.

To configure and build Buildroot, run:

  make <board>_defconfig

Flashing the NAND using SAM-BA

Flashing the board

Connect the board:
 o at91sam9g45m10ek: DBGU: J10, USB sam-ba: J14
 o at91sam9rlek: DBGU: J19, USB sam-ba: J21
 o at91sam9x5ek: DBGU: J11, USB sam-ba: J20
 o sama5d3xek: DBGU: J14, USB sam-ba: J20
 o sama5d3 Xplained: DBGU: J23, USB sam-ba: J6
 o sama5d4ek: DBGU: J22 or J24, USB sam-ba: J1
 o sama5d4 Xplained: DBGU: J1, USB sam-ba: J11

Start the board in RomBOOT:
 o at91sam9g45m10ek:
    1. open JP8, JP10 and JP12
    2. start the board
    3. close JP8, JP10 and JP12

 o at91sam9rlek:
   1. J11 on 1-2 (BMS=1), open J12 and J13
   2. start the board
   3. close J12 and J13

 o at91sam9x5ek:
   1. open JP9 and:
      - Cogent: open *NCS jumper
      - Embest: open SW1
      - Ronetix: open J1 and J2
   2. start the board
   3. close JP9 and:
      - Cogent: close *NCS jumper
      - Embest: close SW1 (ON position)
      - Ronetix: close J1 and J2

 o sama5d3xek:
   1. start the board
   2. push BP4 and BP1
   3. release BP1
   4. release BP4

 o sama5d3 Xplained:
   1. open JP5 (NANDCS) and JP6 (SPICS)
   2. start the board
   3. close JP5 ans JP6

 o sama5d4ek:
   1. start the board
   2. push BP3 and BP4
   3. release BP4
   4. release BP3

 o sama5d4 Xplained:
   1. close JP7 (BOOT_DIS)
   2. start the board
   3. open JP7

"RomBOOT" should appear on your console (this should be ttyUSBx or ttyACMx)

Now locate the USB sam-ba interface it should be ttyACMx, usually ttyACM0
dmesg on your machine should give:
usb 1-2.1.4: New USB device found, idVendor=03eb, idProduct=6124
usb 1-2.1.4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
cdc_acm 1-2.1.4:1.0: ttyACM0: USB ACM device

Look for idVendor=03eb, idProduct=6124, this is the interface you want to use.

You can then flash the board using the provided script in board/atmel:

board/atmel/ <builddir_path> <interface> <board>

For example, for an out of tree build made in
/tmp/atmel_sama5d3_xplained/ for the sama5d3 Xplained, you would use:
board/atmel/ /tmp/atmel_sama5d3_xplained/ /dev/ttyACM0 sama5d3_xplained

Reboot, the system should boot up to the buildroot login invite.

Preparing the SD card

An image named sdcard.img is automatically generated. With this image,
you no longer have to care about the creation of the partition and
copying files to the SD card.

You need at least a 1GB SD card. All the data on the SD card will be
lost. To copy the image on the SD card:

/!\ Caution be sure to do it on the right mmcblk device /!\

dd if=output/images/sdcard.img of=/dev/mmcblk0

Insert your SD card in your Xplained board, and enjoy. The default
U-Boot environment will load properly the kernel and Device Tree blob
from the first partition of the SD card, so everything works

By default a 16MB FAT partition is created. It contains at91bootstrap,
u-boot, the kernel image and all dtb variants for your board. The dtb
used is the basic one:

U-Boot> print
bootcmd=fatload mmc 1:1 0x21000000 at91-sama5d2_xplained.dtb; fatload mmc 1:1 0x22000000 zImage; bootz 0x22000000 - 0x21000000

If you want to use a variant such as the _pda7 one, you will have to
update your u-boot environment:

U-Boot> setenv bootcmd 'fatload mmc 1:1 0x21000000 at91-sama5d2_xplained_pda7.dtb; fatload mmc 1:1 0x22000000 zImage; bootz 0x22000000 - 0x21000000'
U-Boot> save
Saving Environment to FAT...
writing uboot.env

A 512MB ext4 partition is also created to store the rootfs generated.

If you want to customize the size of the partitions and their content,
take a look at the the genimage.cfg file in the board directory.

Cross toolchain

While creating the rootfs, Buildroot will build a cross toolchain (or will download or use one present on your machine). You can find it under output/host/usr:

$ ls output/host/usr/bin
aclocal                                                arm-buildroot-linux-uclibcgnueabihf-ldd      arm-linux-gcc.br_real  cmake                   ifnames      mke2img     mtype
aclocal-1.15                                           arm-buildroot-linux-uclibcgnueabihf-nm       arm-linux-gcov         compile_et              infocmp      mkmanifest  mxtar                                           arm-buildroot-linux-uclibcgnueabihf-objcopy  arm-linux-gprof        cpack                   infotocap    mkpasswd    mzip
arm-buildroot-linux-uclibcgnueabihf-addr2line          arm-buildroot-linux-uclibcgnueabihf-objdump  arm-linux-ld           ctest                   kmod         mlabel      ncurses5-config
arm-buildroot-linux-uclibcgnueabihf-ar                 arm-buildroot-linux-uclibcgnueabihf-ranlib   arm-linux-ld.bfd       faked                   ldconfig     mmd         pcre-config
arm-buildroot-linux-uclibcgnueabihf-as                 arm-buildroot-linux-uclibcgnueabihf-readelf  arm-linux-ldconfig     fakeroot                ldd          mmount      pcregrep
arm-buildroot-linux-uclibcgnueabihf-c++                arm-buildroot-linux-uclibcgnueabihf-size     arm-linux-ldd          flex                    libtool      mmove       pcretest
arm-buildroot-linux-uclibcgnueabihf-c++.br_real        arm-buildroot-linux-uclibcgnueabihf-strings  arm-linux-nm           flex++                  libtoolize   mpartition  pkg-config
arm-buildroot-linux-uclibcgnueabihf-c++filt            arm-buildroot-linux-uclibcgnueabihf-strip    arm-linux-objcopy      floppyd                 linux-dtc    mrd         pkgconf
arm-buildroot-linux-uclibcgnueabihf-cc                 arm-linux-addr2line                          arm-linux-objdump      floppyd_installtest     lsattr       mren        recode-sr-latin
arm-buildroot-linux-uclibcgnueabihf-cc.br_real         arm-linux-ar                                 arm-linux-ranlib       gapplication            lz           msgattrib   reset
arm-buildroot-linux-uclibcgnueabihf-cpp                arm-linux-as                                 arm-linux-readelf      gdbus                   m4           msgcat      tabs
arm-buildroot-linux-uclibcgnueabihf-cpp.br_real        arm-linux-c++                                arm-linux-size         gdbus-codegen           makedevs     msgcmp      tgz
arm-buildroot-linux-uclibcgnueabihf-elfedit            arm-linux-c++.br_real                        arm-linux-strings      genext2fs               mattrib      msgcomm     tic
arm-buildroot-linux-uclibcgnueabihf-g++                arm-linux-c++filt                            arm-linux-strip        genimage                mbadblocks   msgconv     toe
arm-buildroot-linux-uclibcgnueabihf-g++.br_real        arm-linux-cc                                 autoconf               gettextize              mcat         msgen       toolchain-wrapper
arm-buildroot-linux-uclibcgnueabihf-gcc                arm-linux-cc.br_real                         autoheader             gio-querymodules        mcd          msgexec     tput
arm-buildroot-linux-uclibcgnueabihf-gcc-4.9.3          arm-linux-cpp                                autom4te               glib-compile-resources  mcheck       msgfilter   tset
arm-buildroot-linux-uclibcgnueabihf-gcc-4.9.3.br_real  arm-linux-cpp.br_real                        automake               glib-compile-schemas    mclasserase  msgfmt      uuidgen
arm-buildroot-linux-uclibcgnueabihf-gcc-ar             arm-linux-elfedit                            automake-1.15          glib-genmarshal         mcomp        msggrep     uz
arm-buildroot-linux-uclibcgnueabihf-gcc-nm             arm-linux-g++                                autopoint              glib-gettextize         mcopy        msginit     xgettext
arm-buildroot-linux-uclibcgnueabihf-gcc-ranlib         arm-linux-g++.br_real                        autoreconf             glib-mkenums            mdel         msgmerge    xml2-config
arm-buildroot-linux-uclibcgnueabihf-gcc.br_real        arm-linux-gcc                                autoscan               gobject-query           mdeltree     msgunfmt    xmlcatalog
arm-buildroot-linux-uclibcgnueabihf-gcov               arm-linux-gcc-4.9.3                          autoupdate             gperf                   mdir         msguniq     xmllint
arm-buildroot-linux-uclibcgnueabihf-gprof              arm-linux-gcc-4.9.3.br_real                  bison                  gresource               mdu          mshortname  yacc
arm-buildroot-linux-uclibcgnueabihf-ld                 arm-linux-gcc-ar                             captoinfo              gsettings               mformat      mshowfat
arm-buildroot-linux-uclibcgnueabihf-ld.bfd             arm-linux-gcc-nm                             chattr                 gtester                 minfo        mtools
arm-buildroot-linux-uclibcgnueabihf-ldconfig           arm-linux-gcc-ranlib                         clear                  gtester-report          mk_cmds      mtoolstest

Note If you do a make clean, you will delete the rootfs but also the cross toolchain. You can save the cross toolchain in another place. Moreover you can tell Buildroot to use it to save time for next compilations. To do it run make menuconfig then go to the Toolchain menu. Then select External toolchain as Toolchain type, Custom toolchain as Toolchain, Pre-installed toolchain as Toolchain origin. Finally set Toolchain path and Toolchain prefix.

Customizing Buildroot

Before building the rootfs image, you may want to customize it: adding/removing packages, modifying component configurations such as busybox and uclibc, generate the kernel, etc.

Customizing Busybox / Linux / U-boot / uClibc configuration

All the explanations are available in the Buildroot manual Configuration of other components section.

Adding/removing packages from the rootfs

You can easily add or remove packages from the rootfs. You simply have to do:

make menuconfig

and to go to the Package Selection for the target menu. Packages are sorted by categories:


You simply have to go in the desired category and to select or deselect the packages you want. Once done, you can build your rootfs.

Note If you have already done a build and you want to remove packages, you may have to do make clean and to rebuild the whole rootfs to be sure that the packages will be removed.

Updating the rootfs for another nand flash device

The rootfs are configured to run on the nand flash device present on atmel boards. If you use another one you may have to update some parameters. To do it, run make menuconfig and go to Filesystem images:


For a jffs2 root filesystem, you may have to update the page and erase size from Flash Type.

For a ubifs root filesystem, you may have to update the UBI logical erase block size, the UBI minimum I/O size, the Maximum LEB count, the UBI physical erase block size and the UBI sub-page size. You can find more information about these parameters in the ubi documentation.

Add your own software to Buildroot

Builroot is basically a big set of makefiles so you will have to follow some steps to insert your own application to the cross-building system. You should have a look at the official documentation since the procedure depends on the build system used.

Topic attachments
I Attachment Action Size Date Who Comment
PNGpng buildroot_kernel_linux-at91.png manage 62.0 K 2013-02-01 - 10:23 LudovicDesroches buildroot kernel build screenshot
PNGpng buildroot_nand_conf.png manage 92.6 K 2013-02-01 - 10:06 LudovicDesroches buildroot nand configuration screenshot
PNGpng buildroot_package_selection.png manage 79.1 K 2013-02-01 - 09:59 LudovicDesroches buildroot package selection screenshot
r24 - 26 Jul 2016 - 12:48:00 - LudovicDesroches
Linux & Open Source related information for AT91 Smart ARM Microcontrollers

Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

Atmel® and others, are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. This site is powered by the TWiki collaboration platform

ARM® and others are registered trademarks or trademarks of ARM Ltd. Other terms and product names may be trademarks of others.

Ideas, requests, contributions ? Connect to LinksToCommunities page.

Syndicate this siteRSS ATOM