How to build Buildroot for AT91

Prerequisites

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

To get the source code, you have to clone the buildroot-at91 and buildroot-external-microchip repositories. buildroot-at91 is a fork of Buildroot with a minimal amount of patches, only the ones which have not hit the mainline yet. The external tree provides stuff which won't hit the mainline: additional defconfigs and packages dedicated to our demos.

$ git clone https://github.com/linux4sam/buildroot-at91.git
Cloning into 'buildroot-at91'...
remote: Counting objects: 271126, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 271126 (delta 0), reused 2 (delta 0), pack-reused 271124
Receiving objects: 100% (271126/271126), 61.00 MiB | 2.36 MiB/s, done.
Resolving deltas: 100% (186357/186357), done.

$ ls buildroot-at91/
arch  board  boot  CHANGES  Config.in  Config.in.legacy  configs  COPYING  DEVELOPERS  docs  fs  linux  Makefile  Makefile.legacy  package  README  support  system  toolchain  utils


$ git clone https://github.com/linux4sam/buildroot-external-microchip.git
Cloning into 'buildroot-external-microchip'...
remote: Counting objects: 571, done.
remote: Compressing objects: 100% (159/159), done.
remote: Total 571 (delta 217), reused 288 (delta 170), pack-reused 225
Receiving objects: 100% (571/571), 94.41 KiB | 76.00 KiB/s, done.
Resolving deltas: 100% (332/332), done.

$ ls buildroot-external-microchip/
board  Config.in  configs  COPYING  docs  external.desc  external.mk  package  patches  README.md  system

The source code has been taken from the master branch which is pointing to the latest version of buildroot-at91 and buildroot-external-microchip. We advise you to use linux4sam tags to be sure that there is no mismatch between the versions of these two repositories.

You can list them and use one of them by doing this:

$ cd buildroot-external-microchip/
$ git tag | grep linux4sam
linux4sam_5.8
linux4sam_5.8-rc1
linux4sam_5.8-rc2
$ git checkout linux4sam_5.8 -b buildroot-external-microchip-linux4sam_5.8


$ cd ../buildroot-at91/
$ git tag | grep linux4sam
linux4sam_5.8
linux4sam_5.8-rc1
$ git checkout linux4sam_5.8 -b buildroot-at91-linux4sam_5.8

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_[soc]_xplained_defconfig provides at91bootstrap, u-boot, the kernel image and dtb files, a very basic rootfs for NAND flash memory.
  • atmel_[soc]_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_[soc]_xplained_dev_defconfig and atmel_[soc]_xplained_mmc_dev_defconfig provide a rootfs with additional tools to use SoC devices (I2C, CAN, audio, etc.).

The external provides extra defconfigs in its own configs folder:

  • [soc]_[board]_headless_defconfig provides barely the same stuff as atmel_[soc]_xplained_mmc_dev_defconfig plus mpio and libplanes packages.
  • [soc]_[board]_demo_defconfig provides the same stuff plus a Qt demo.
All these defconfigs target the SD card as boot media.

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

$ make atmel_sama5d2_xplained_mmc_defconfig
Note BR2_EXTERNAL is not mandatory if you don't plan to use the content of the external tree

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

$ BR2_EXTERNAL=../buildroot-external-microchip/ make sama5d2_xplained_demo_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

You can have a look at the Create a SD card with the demo page to create an SD card from the sdcard.img file. If you want to flash NAND or whatever memory you want with Sam-Ba, please go to the Using SAM-BA to flash components to board section of your board.

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
amuFormat.sh                                           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:

BR2_EXTERNAL=../buildroot-external-microchip/ make menuconfig

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

buildroot_package_selection.png

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:

buildroot_nand_conf.png

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
r26 - 05 Apr 2018 - 13:05:28 - 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