...your main source of everything AVR32 Linux

Navigation

BuildRoot

Buildroot home Official AVR32 buildroot Unofficial AVR32

Buildroot is a set of makefiles and scripts used to build a target root file system for an embedded device. It builds the toolchain programs for the target CPU architecture, the Linux kernel, the u-boot bootloader, and hundreds of different Linux applications and utilities. It uses menuconfig to configure all of it's options. Menuconfig is an ncurses based menu builder application. Menuconfig can also be used to configure the kernel, uClibc, and busybox.

Configuring

Buildroot can be run by the make command. The initial configuration is done by running make using a default configuration file. The default configuration files for the AVR32 development boards can be found in target/device/Atmel. To configure buildroot for the ATNGW100, you would type: make atngw100_defconfig

You can further customize your configuration by running: make menuconfig

The first steps buildroot takes is building the target toolchain, if you have selected to use the buildroot toolchain rather than an external toolchain. Using the buildroot toolchain is the default, and preferred method for building packages. After the toolchain is built, the kernel headers are unpackaged, and then uClibc is built. uClibc is the micro C library, which is a lighter weight alternative to the large GNU libc that is used on desktops and servers. After uClibc is built and installed, buildroot begins building the packages that were selected for the target. Finally the kernel and u-boot bootloader is built and the filesystems are generated and saved into the binaries directory. Depending on what types of filesystems you selected, there will be JFFS2 flash images and a tar file containing the entire root filesystem.

Build failures

If for some reason buildroot fails, it will resume at the point where it failed, thanks to stamp files that are created during the build process. Inside the build directories, buildroot creates hidden files such as .configured .unpacked .patched .stamp_downloaded .stamp_extracted .stamp_patched .stamp_target_installed .stamp_built. Each one signifies completion of whatever step it is named with. Deleting one of these files will result in that step being re-executed on the next run.

Directories

Buildroot uses several different output directories in the build process. The first directory is build_avr32. This directory contains all of the package builds and a special directory called staging_dir. The staging_dir is the directory that all of the builds install to, get their external headers from, and it is where the libraries are kept for linking. There is another directory called project_build_avr32 where the target root filesystem, busybox, and kernel build is kept. When then building is finished, the kernel and root filesystem are imaged and saved to the directory named binaries. The directory name toolchain_build is exactly that. It is also where uClibc's build is kept.

Adding new packages

You can add new packages to buildroot by creating a directory inside the package directory with the name of the package you want to build. Inside this new directory, you need to create two files. Config.in has the menuconfig options for the package inside it. It has the description of the package, and includes any dependency packages to be automatically selected, and if the package is to be excluded by some other option. The next file you will need to create is the .mk file. It should be named with the name of the package to be built. Finally you will need to add a reference to the package inside package/Config.in. Below is a sample Config.in and .mk file for the blackbox window manager:

Config.in

config BR2_PACKAGE_BLACKBOX
   bool "blackbox"
   default n
   depends on BR2_PACKAGE_XORG||BR2_PACKAGE_XORG7
   help
     Blackbox is a fast, lightweight window manager for the X Window System.

     http://blackboxwm.sourceforge.net/

comment "blackbox      - disabled (requires Xorg(7))"
   depends !(BR2_PACKAGE_XORG || BR2_PACKAGE_XORG7)

blackbox.mk

#############################################################
#
# blackbox
#
#############################################################

BLACKBOX_VERSION=0.70.1
BLACKBOX_SOURCE=blackbox-$(BLACKBOX_VERSION).tar.bz2
BLACKBOX_SITE=http://superb-west.dl.sourceforge.net/sourceforge/blackboxwm/
BLACKBOX_DIR=$(BUILD_DIR)/blackbox-$(BLACKBOX_VERSION)
BLACKBOX_CAT:=$(BZCAT)

$(DL_DIR)/$(BLACKBOX_SOURCE):
   $(WGET) -P $(DL_DIR) $(BLACKBOX_SITE)/$(BLACKBOX_SOURCE)

$(BLACKBOX_DIR)/.unpacked: $(DL_DIR)/$(BLACKBOX_SOURCE)
   $(BLACKBOX_CAT) $(DL_DIR)/$(BLACKBOX_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
   toolchain/patch-kernel.sh $(BLACKBOX_DIR) package/blackbox/ \*.patch
   $(CONFIG_UPDATE) $(BLACKBOX_DIR)
   touch $(BLACKBOX_DIR)/.unpacked

$(BLACKBOX_DIR)/.configured: $(BLACKBOX_DIR)/.unpacked
   (cd $(BLACKBOX_DIR); rm -rf config.cache; \
      $(TARGET_CONFIGURE_OPTS) \
      $(TARGET_CONFIGURE_ARGS) \
      ./configure \
      --target=$(GNU_TARGET_NAME) \
      --host=$(GNU_TARGET_NAME) \
      --build=$(GNU_HOST_NAME) \
      --prefix=/usr \
      --sysconfdir=/etc \
      --x-includes=$(STAGING_DIR)/usr/include/X11 \
      --x-libraries=$(STAGING_DIR)/usr/lib \
   )
   touch $(BLACKBOX_DIR)/.configured

$(BLACKBOX_DIR)/src/blackbox: $(BLACKBOX_DIR)/.configured
   $(MAKE) CC=$(TARGET_CC) -C $(BLACKBOX_DIR)

$(BLACKBOX_DIR)/.installed: $(BLACKBOX_DIR)/src/blackbox
   $(MAKE) -C $(BLACKBOX_DIR) DESTDIR=$(TARGET_DIR) install
   touch $(BLACKBOX_DIR)/.installed

blackbox: uclibc $(XSERVER) $(BLACKBOX_DIR)/.installed

blackbox-source: $(DL_DIR)/$(BLACKBOX_SOURCE)

blackbox-clean:
   @if [ -d $(BLACKBOX_DIR)/Makefile ]; then \
      $(MAKE) -C $(BLACKBOX_DIR) clean; \
   fi

blackbox-dirclean:
   rm -rf $(BLACKBOX_DIR)
#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(BR2_PACKAGE_BLACKBOX)),y)
TARGETS+=blackbox
endif

Simpler makefiles

There is also a new way to create a makefile in the latest buildroot. If the package you want to add is based on the autotools build system, you can create a more basic makefile. You can tell if a package uses autotools if it contains a configure script, and config.sub and config.guess files. This simpler makefile works by setting the variables for the package, then calling AUTOTARGETS, which is located in package/Makefile.autotools.in. You can see what options and variables are available by looking inside this file. Below is an example of a simpler autotools based makefile:

xapp_bitmap.mk

################################################################################
#
# xapp_bitmap -- X.Org bitmap application
#
################################################################################

XAPP_BITMAP_VERSION = 1.0.2
XAPP_BITMAP_SOURCE = bitmap-$(XAPP_BITMAP_VERSION).tar.bz2
XAPP_BITMAP_SITE = http://xorg.freedesktop.org/releases/individual/app
XAPP_BITMAP_AUTORECONF = NO
XAPP_BITMAP_DEPENDENCIES = xlib_libX11 xlib_libXaw xlib_libXmu xdata_xbitmaps

$(eval $(call AUTOTARGETS,package/x11r7,xapp_bitmap))

r3 - 28 Feb 2008 - 13:24 - JohnVoltz
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®, AVR® and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries.
All other trademarks are the property of their respective owners.
Powered by Wed, 08 Feb 2006 build 8740
Syndicate this site