Home
Slides - Free Electrons
Contents
1. 2 _SRCDIR ifndef 2 _CONFIGURE_CMDS ifeq 4 target define 2 _CONFIGURE_CMDS cd PKG _BUILDDIR amp amp PKG _CONF_ENV HOST_DIR usr bin cmake PKG _SRCDIR DCMAKE_TOOLCHAIN_FILE HOST_DIR usr share buildroot toolchainfile cmake PKG _CONF_OPT endef else define 2 _CONFIGURE_CMDS host case endef endif endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 288 326 CMake package infrastructure 2 2 2 _DEPENDENCIES host cmake ifndef 2 _BUILD_CMDS ifeq 4 target define 2 _BUILD_CMDS TARGET_MAKE_ENV PKG _MAKE_ENV PKG _MAKE PKG _MAKE_OPT C PKG _BUILDDIR endef else host case endif endif other commands ifndef 2 _INSTALL_TARGET_CMDS define 2 _INSTALL_TARGET_CMDS TARGET_MAKE_ENV PKG _MAKE_ENV PKG _MAKE PKG _MAKE_OPT PKG _INSTALL_TARGET_OPT C PKG _BUILDDIR endef endif call inner generic package 1 2 3 4 endef cmake package call inner cmake package pkgname target host cmake package call inner cmake package host pkgname host free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 289 326 Autoreconf in pkg autotools mk gt Package infra
2. gt Buildroot collects build duration data in the file 0 build build time log gt make graph build generates several graphs in 0 graphs gt gt gt gt gt build hist build pdf build time in build order build hist duration pdf build time by duration build hist name pdf build time by package name build pie packages pdf pie chart of the per package build time build pie steps pdf pie chart of the per step build time gt Note only works properly after a complete clean rebuild free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 226 326 Build time graphing example Build time of packages by build order Time seconds free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 227 326 Instrumentation scripts gt Additional analysis tools can be constructed using the instrumentation scripts mechanism gt BR2_INSTRUMENTATLON_SCRIPTS is an environment variable containing a space separated list of scripts that will be called before and after each step of the build of all packages gt Three arguments are passed to the scripts 1 start or stop to indicate whether it s the beginning or end of the step 2 the name of the step 3 the name of the package free electrons Embedded Linux kernel dri
3. Build BUILD_DIR stamp_built call step_start build call MESSAGE Building foreach hook PKG _PRE_BUILD_HOOKS call hook sep PKG _BUILD_CMDS foreach hook PKG _POST_BUILD_HOOKS call hook sep Q touch call step_end build gt Step handled by the package by defining a value for lt pkg gt _BUILD_CMDS gt Same principle of hooks gt step_start and step_end are part of instrumentation to measure the duration of each step and other actions free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 276 326 The generic package macro gt Packages built for the target generic package call inner generic package pkgname call UPPERCASE pkgname call UPPERCASE pkgname target gt Packages built for the host host generic package call inner generic package host pkgname call UPPERCASE host pkgname call UPPERCASE pkgname host gt In package zlib zlib mk ALS oe Bae eval generic package eval host generic package gt Leads to call inner generic package zlib ZLIB ZLIB target call inner generic package host zlib HOST_ZLIB ZLIB host free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 277 326 inner generic
4. TARGET_DIR usr lib systemd system named service mkdir p TARGET_DIR etc systemd system multi user target wants In sf usr lib systemd system named service TARGET_DIR etc systemd system named service endef free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 200 326 Advanced package aspects Config scripts free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 201 326 Config scripts introduction gt Libraries not using pkg config often install a small shell script that allows applications to query the compiler and linker flags to use the library gt Examples curl config freetype config etc gt Such scripts will gt generally return results that are not appropriate for cross compilation gt be used by other cross compiled Buildroot packages that use those libraries gt By listing such scripts in the lt pkg gt _CONFIG_SCRIPTS variable Buildroot will adapt the prefix header and library paths to make them suitable for cross compilation gt Paths in lt pkg gt _CONFIG_SCRIPTS are relative to STAGING_DIR usr bin free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 202 326 Config scripts examples libpng mk LIBPNG_CONFIG_SCRIPTS libpng LIBP
5. gt Defconfigs BeagleBone defconfig updated new defconfig for CubieBoard for Olimex mx233 Olinuxino for Calao Systems TNY A9G20 LPW gt Packages gt A number of packages have been fixed to use the lt pkg gt _CONFIG_SCRIPTS mechanism to get their lt pkg gt config shell script installed and modified properly gt Licensing information has been added to a number of packages gt Use XZ tarballs for a number of packages gt Noticeable package changes additions gt The glib2 libgtk2 webkit stack has been updated to recent versions Support for Gstreamer 1 x has been added OpenGL support for TI OMAP platforms has been added OpenGL support for Allwinner platforms has been added gt OpenMAX support for RaspberryPi has been added gt Top level menu names reordered and renamed for clarity yv v free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 311 326 In 2013 11 gt Architectures Nios Il support MIPS arch handling fixes gt Toolchains glibc support upstream uClibc fixes uClibc 0 9 31 for avr32 internal crosstool ng backend removed external musl toolchain support gcc 4 8 2 updated Linaro external toolchains Fortran and objective C support deprecated mudflap support vvvvvvyvvyvy iy Bootloaders U Boot u boot imx support version bumps Linux use kmod instead of module init tools System default to devtmpfs for dev Y
6. lt name gt lt type gt lt mode gt lt uid gt lt gid gt lt major gt lt minor gt lt start gt lt inc gt lt count gt dev mem c 640 o 1 1 dev kmem 640 o 1 2 o dev i2c c 666 o 89 o i 4 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com Users table gt One may need to add specific Unix users and groups in addition to the ones available in the default skeleton gt BR2_ROOTFS_USERS_TABLES is a space separated list of user tables gt Packages can also specify their own users See the Advanced package aspects section for details Users table example lt username gt lt uid gt lt group gt lt gid gt lt password gt lt home gt lt shell gt lt groups gt lt comment gt foo il bar i blabla home foo bin sh alpha bravo Foo user test 8000 wheel 1 bin sh Test user free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 91 326 I Post image scripts gt Once all the filesystem images have been created at the very end of the build post image scripts are called gt They allow to do any custom action at the end of the build For example gt Extract the root filesystem to do NFS booting gt Generate a final firmware image gt Start the flashing process gt BR2_ROOTFS_POST_IMAGE_SCRIPT is a space
7. Implemented by the generic package infrastructure Implemented by the package itself free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 134 326 Other package infrastructures gt The other package infrastructures are meant to be used when the software component uses a well known build system gt They inherit all the behavior of the generic package infrastructure downloading extracting patching etc gt And in addition to that they typically implement a default behavior for the configuration compilation and installation steps gt For example autotools package will implement the configuration step as a call to the configure script with the right arguments gt pkg kconfig is an exception it only provides some helpers for packages using Kconfig but does not implement the configure build and installation steps free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 135 326 Integrating new packages in Buildroot mk file for generic package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 136 326 The lt pkg gt mk fil Oo e lt pkg gt mk file gt The mk file of a package does not look like a normal Makefile gt It is a succession of variable definitions
8. dependencies gt All packages have three targets in their dependencies gt dirs creates the main directories BUILD_DIR TARGET_DIR HOST_DIR etc As part of creating TARGET_DIR the root filesystem skeleton is copied into it gt prepare generates a kconfig related auto conf file gt dependencies triggers the check of Buildroot system dependencies i e things that must be installed on the machine to use Buildroot free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 284 326 Rebuilding packages gt Once one step of a package build process has been done it is never done again due to the stamp file gt Even if the package configuration is changed or the package is disabled gt Buildroot doesn t try to be smart gt One can force rebuilding a package from its configure step or build step using make lt pkg gt reconfigure or make lt pkg gt rebuild 1 clean for rebuild rm f 2 _TARGET_BUILD rm f 2 _TARGET_INSTALL_STAGING rm f 2 _TARGET_INSTALL_TARGET rm f 2 _TARGET_INSTALL_IMAGES rm f 2 _TARGET_INSTALL_HOST 1 rebuild 1 clean for rebuild 1 1 clean for reconfigure 1 clean for rebuild rm f 2 _TARGET_CONFIGURE 1 reconfigure 1 clean for reconfigure 1 free electrons Embedded Linux kernel drivers and Android Development consulting training and suppor
9. depends on BR2_USE_WCHAR and depends on BR2_ TOOLCHAIN_HAS_THREADS because the package requires wide char and thread support from the toolchain There is an associated comment because such support can be added to the toolchain Multiple select BR2_PACKAGE_ because the package needs numerous libraries free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 125 326 Dependency propagation gt A limitation of kconfig is that it doesn t propagate depends on dependencies accross select dependencies gt Scenario if package A has a depends on FOO and package B has a select A then package B must replicate the depends on FOO libglib2 package neard package config BR2_PACKAGE_LIBGLIB2 bool libglib2 select BR2_PACKAGE_GETTEXT if select BR2_PACKAGE_LIBICONV if select BR2_PACKAGE_LIBFFI select BR2_PACKAGE_ZLIB Eed depends on BR2_USE_WCHAR gettext depends on BR2_TOOLCHAIN_HAS_THREADS depends on BR2_USE_MMU fork config BR2_PACKAGE_NEARD bool neard depends on BR2_USE_WCHAR libglib2 libnl dbus libglib2 depends on BR2_TOOLCHAIN_HAS_THREADS depends on BR2_USE_MMU dbus libglib2 select BR2_PACKAGE_DBUS select BR2_PACKAGE_LIBGLIB2 select BR2_PACKAGE_LIBNL free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 126 326 Config in host fo
10. value expanded at time of assignment gt FOOBAR value prepend to the variable with a separating space defaults to expanded at the time of use gt FOOBAR value defined only if not already defined gt Multi line variables are described using define NAME endef define FOOBAR line 1 line 2 endef gt Make variables are referenced using the FOOBAR syntax free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 113 326 Conditions gt With ifeq or ifneg ifeq BR2_CCACHE y CCACHE HOST_DIR usr bin ccache endif distclean clean ifeq DL_DIR TOPDIR d1 rm rf DL_DIR endif gt With the if make function HOSTAPD_LIBS if BR2_STATIC_LIBS lcrypto 1z free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 114 326 Defining and using functions gt Defining a function is exactly like defining a variable MESSAGE echo TERM_BOLD gt gt gt PKG _NAME PKG _VERSION call qstrip 1 TERM_RESET define legal license header pkg license file HOST TARGET printf LEGAL_INFO_SEPARATOR n t 1 2 n LEGAL_INFO_SEPARATOR n n n gt gt LEGAL_LICENSES_TXT_ 3 endef gt Arguments accessible as 1 2 etc gt Called using the call func arg1 arg2 construct BUILD_
11. 0 host gt output gt host usr lib usr bin usr sbin vv usr lt tuple gt sysroot bin usr lt tuple gt sysroot lib usr lt tuple gt sysroot usr lib usr lt tuple gt sysroot usr bin vvvv Vv gt Contains both the tools built for the host cross compiler etc and the sysroot of the toolchain Variable HOST_DIR Host tools are directly in host usr The sysroot is in host lt tuple gt sysroot usr lt tuple gt is an identifier of the architecture vendor operating system C library and ABI E g arm unknown linux gnueabihf gt Variable for the sysroot STAGING_DIR Yv v v free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 57 326 Build tree 0 staging gt output gt staging gt Just a symbolic link to the sysroot i e to host lt tuple gt sysroot gt Available for convenience free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 58 326 Build tree 0 target gt output gt target bin etc lib usr bin usr lib usr share usr sbin THIS_IS_NOT_YOUR_ROOT_FILESYSTEM VVVVVVVVY gt The target root filesystem Usual Linux hierarchy Not completely ready for the target permissions device files etc gt Buildroot does not run as root all files are owned by the user running Buildroot not setui
12. Copy rootfs overlays Execute lt Create rootfs lt Execute post image scripts images post build scripts free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 81 326 Root filesystem skeleton gt The base of a Linux root filesystem Unix directory hierarchy a few configuration files and scripts in etc No programs or libraries gt First thing to get copied to TARGET_DIR at the beginning of the build gt By default BR2_ROOTFS_SKELETON_DEFAULT y the one in system skeleton is used gt A custom skeleton can be used through the BR2_ROOTFS_SKELETON_CUSTOM and BR2_ROOTFS_SKELETON_CUSTOM_PATH options gt Not recommended though the skeleton is only copied once at the beginning of the build and the base is usually good for most projects gt Use rootfs overlays or post build scripts for customization free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 82 326 Installation of packages gt All the selected target packages will be built can be Busybox Qt OpenSSH lighttpd and many more gt Most of them will install files in TARGET_DIR programs libraries fonts data files configuration files etc gt This is really the step that will bring the vast majority of the files in the root filesystem gt Covered in more details in t
13. and their source code plus a licensing manifest Useful for license compliance make legal info Variable LEGAL_INFO_DIR 62 326 Toolchains in Buildroot Toolchains in Buildroot Embedded Linux Experts free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 63 326 What is a cross compilation toolchain gt A set of tools to build and debug code for a target architecture from a machine running a different architecture gt Example building code for ARM from a x86 64 PC Cross compilation toolchain free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 64 326 Two possibilities for the toolchain gt Buildroot offers two choices for the toolchain called toolchain backends gt The internal toolchain backend where Buildroot builds the toolchain entirely from source gt The external toolchain backend where Buildroot uses a existing pre built toolchain gt Selected from Toolchain gt Toolchain type free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 65 326 Internal toolchain backend gt Ma
14. configure and do the staging installation target packages only gt lt p g gt install target download extract patch configure and do the target installation target packages only gt lt p g gt install download extract patch configure and install free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 239 326 Package specific targets example 1 make strace gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt strace strace strace strace strace strace strace 4 10 Extracting 4 10 Patching 4 10 Updating config sub and config guess 4 10 Patching libtool 4 10 Configuring 4 10 Building 4 10 Installing to target make strace build nothing make 1ltrace patch gt gt gt ltrace 0896ce554f80afdcba81d9754f6104f863dea803 Extracting gt gt gt ltrace 0896ce554f80afdcba81d9754f6104f863dea803 Patching make ltrace gt gt gt argp standalone 1 3 Extracting argp standalone 1 3 Patching argp standalone 1 3 Updating config sub and config guess argp standalone 1 3 Patching libtool gt gt gt gt gt gt gt gt gt Ro gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt ol ltrace ltrace ltrace ltrace ltrace 896ce554f80afdcba81d9754f6104f863dea803 Configuring 896ce554f80afdcba81d9754f6104f863dea803 Autoreconfiguring 0896ce554
15. echo git describe date Y M d H m S gt TARGET_DIR etc build id Create applog mountpoint and adjust etc fstab mkdir p TARGET_DIR applog grep q dev mtdblock7 TARGET_DIR etc fstab echo dev mtdblock7 t t applog tjffs2 tdefaults t t to gt gt TARGET_DIR etc fstab Remove unneeded files rm rf TARGET_DIR usr share icons bar Buildroot configuration BR2_ROOTFS_POST_BUILD_SCRIPT board myproject post build sh free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 87 326 Generating the filesystem images gt In the Filesystem images menu you can select which filesystem image formats to generate gt To generate those images Buildroot will generate a shell script that gt Changes the owner of all files to 2 2 root user gt Takes into account the global permission and device tables as well as the per package ones gt Takes into account the global and per package users tables gt Runs the filesystem image generation utility which depends on each filesystem type genext2fs mkfs ubifs tar etc gt This script is executed using a tool called fakeroot gt Allows to fake being root so that permissions and ownership can be modified device files can be created etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free elec
16. free electrons com 2 326 Hyperlinks in the document There are many hyperlinks in the document gt Regular hyperlinks http kernel org gt Kernel documentation links Documentation kmemcheck txt gt Links to kernel source files and directories drivers input include linux fb h gt Links to the declarations definitions and instances of kernel symbols functions types data structures platform_get_irq GFP_KERNEL struct file_operations free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 3 326 Free Electrons at a glance gt Engineering company created in 2004 not a training company gt Locations Orange Toulouse Lyon France gt Serving customers all around the world See http free electrons com company customers gt Head count 9 Only Free Software enthusiasts gt Focus Embedded Linux Linux kernel Android Free Software Open Source for embedded and real time systems gt Activities development training consulting technical support gt Added value get the best of the user and development community and the resources it offers free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 4 326 Free Electrons on line resources gt All our training materials http free electrons com docs Technical blog h
17. free electrons com 256 326 Effect of lt pkg gt _OVERRIDE_SRCDIR gt For each package you can define a lt pkg gt _OVERRIDE_SRCDIR variable that points to a local directory containing the source code for this package gt Instead of downloading and extracting the original source Buildroot will rsync the source from the specified directory to the build directory gt Invoking make lt pkg gt reconfigure make lt pkg gt rebuild make lt pkg gt reinstall will retrigger a rsync free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 257 326 Passing lt pkg gt _OVERRIDE_SRCDIR gt lt pkg gt _OVERRIDE_SRCDIR can be specified gt In the package mk file itself Not ideal solution and identical to lt pkg gt _SITE_METHOD local gt In a package override file configured in BR2_PACKAGE_OVERRIDE_FILE by default CONFIG_DIR local mk Example local mk LIBPNG_OVERRIDE_SRCDIR HOME projects libpng LINUX_OVERRIDE_SRCDIR HOME projects linux free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 258 326 lt pkg gt _OVERRIDE_SRCDIR workflow make libpng rebuild all free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 259 326 Debugging debugging symbols and strippi
18. gt Buildroot will gt include BR2_EXTERNAL Config in in the configuration menu under a new menu called User provided options gt include BR2_EXTERNAL external mk in the make logic gt include BR2_EXTERNAL configs in the list of defconfigs free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 233 326 BR2_EXTERNAL recommended structure board lt company gt lt boardname gt linux config busybox config lt other configuration files gt post_build sh post_image sh rootfs_overlay etc lt some file gt patches foo lt some patch gt libbar lt some other patches gt configs lt boardname gt _defconfig package lt company gt packagel Config in packagel mk package2 Config in package2 mk Config in external mk free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 234 326 BR2_EXTERNAL Config in gt Custom configuration options gt Configuration options for the BR2_EXTERNAL packages gt The BR2_EXTERNAL variable is available Example BR2_EXTERNAL Config in source BR2_EXTERNAL package packagel Config in source BR2_EXTERNAL package package2 Config in free electrons Embedded
19. profiling related tools gt To list just a few strace Itrace LT Tng perf sysdig sysprof OProfile valgrind vvvvvvyvyvy gt Look in Target packages gt Debugging profiling and benchmark for more free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 264 326 Generating a SDK for application developers gt If you would like application developers to build applications for a Buildroot generated system without building Buildroot you can generate a SDK gt To achieve this gt Customize the BR2_HOST_DIR option to a path like opt project sdk gt Do a full build from scratch Due to the value of BR2_HOST_DIR the cross compiler and the sysroot with all its libraries will be installed in opt project sdk instead of the normal 0 host gt Tarball the opt project sdk and share it with the developers gt Warnings gt The SDK is not relocatable it must remain in opt project sdk gt The SDK must remain in sync with the root filesystem running on the target otherwise applications built with the SDK may not run properly free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 265 326 Eclipse plug in gt For application developers interested in using the Eclipse IDE a Buildroot specific plugin has been developed gt It integrates
20. the configuration gt being smart is very very complicated if you want to do it in a reliable way free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 244 326 Understanding rebuilds 2 gt When a package has been built by Buildroot Buildroot keeps a hidden file telling that the package has been built gt Buildroot will therefore never rebuild that package unless a full rebuild is done or this specific package is explicitly rebuilt gt Buildroot does not recurse into each package at each make invocation it would be too time consuming So if you change one source file in a package Buildroot does not know it gt When make is invoked Buildroot will always gt Build the packages that have not been built in a previous build and install them to the target Cleanup the target root filesystem from useless files Run post build scripts copy rootfs overlays Generate the root filesystem images Run post image scripts Yv v Y free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 245 326 Understanding rebuilds scenarios 1 gt If you enable a new package in the configuration and run make gt Buildroot will build it and install it gt However other packages that may benefit from this package will not be rebuilt automatically gt If you remove a packag
21. updates to the existing configurations gt Infrastructure gt Buildroot is now less noisy when built with the silent option make s gt A number of package infrastructure variables have been renamed from _OPT to _OPTS for consistency gt Option to choose what shell bin sh points to gt Documentation gt Various updates to the user manual gt The asciidoc documentation handling has now been extended so it can be used by BR2_EXTERNAL free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 318 326 In 2015 02 1 gt Static shared library handling reworked gt This is now a tristate shared only shared and static static only gt Default is now shared only to speed up the build BR2_PREFER_STATIC_LIB is now called BR2_STATIC_LIBS gt Toolchain gt The toolchain internal and external will now warn when an unsafe library or header path is used gt f BR2_COMPILER_PARANOID_UNSAFE_PATH is enabled under build options this instead becomes an error gt Architectures Freescale E5500 and E6500 PowerPC support added deprecated MIPS 1 2 3 4 support removed gt Defconfigs Freescale p2020ds MIPS creator C120 Raspberrypi with DT UDOO Quad free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 319 326 In 2015 02 2 gt make lt foo gt _
22. which must be prefixed by the uppercase package name gt FOOBAR_SITE http foobar com downloads gt define FOOBAR_BUILD_CMDS MAKE C D endef gt And ends with a call to the desired package infrastructure macro gt eval generic package gt eval autotools package gt eval C host autotools package gt The variables tell the package infrastructure what to do for this specific package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 137 326 Naming conventions gt The Buildroot package infrastructures make a number of assumption on variables and files naming gt The following must match to allow the package infrastructure to work for a given package gt The directory where the package description is located must be package lt pkg gt where lt pkg gt is the lowercase name of the package gt The Config in option enabling the package must be named BR2_PACKAGE_ lt PKG gt where lt PKG gt is the uppercase name of the package gt The variables in the mk file must be prefixed with lt PKG gt _ where lt PKG gt is the uppercase name of the package gt Note a in the lower case package name is translated to _ in the upper case package name free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 138 326 free Na
23. 326 Existing defconfigs gt Buildroot comes with a number of existing defconfigs for various publicly available hardware platforms gt RaspberryPi BeagleBone Black CubieBoard Atmel evaluation boards Minnowboard various i MX6 boards gt QEMU emulated platforms gt List them using make help changed to make list defconfigs since Buildroot 2015 05 gt Minimal defconfigs only build a toolchain bootloader kernel and minimal root filesystem make qemu_arm_vexpress_defconfig make gt Additional instructions often available in board lt boardname gt e g board qemu arm vexpess readme txt free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 43 326 Assembling a defconfig 1 2 gt defconfigs are trivial text files one can use simple concatenation to assemble them from fragments platform1 frag BR2_arm y BR2_TOOLCHAIN_BUILDROOT_WCHAR y BR2_GCC_VERSION_4_9_X y platform2 frag BR2_mipsel y BR2_TOOLCHAIN_EXTERNAL y BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201405 y packages frag BR2_PACKAGE_STRESS y BR2_PACKAGE_MTD y BR2_PACKAGE_LIBCONF IG y free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 44 326 Assembling a defconfig 2 2 debug frag BR2_ENABLE_DEBUG y BR2_PACKAGE_STRACE y Build a release system for platform1 suppor
24. Make sure to install the relevant libraries in your system ncurses for menuconfig nconfig Qt for xconfig Gtk for gconfig free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 30 326 Buildroot 2015 02 Configuration Arrow keys navigate the menu lt Enter gt selects submenus gt or empty submenus Highlighted letters are hotkeys Pressing lt Y gt selectes a feature while lt N gt will exclude a feature Press lt Esc gt lt Esc gt to exit lt gt for Help lt gt for Search Legend feature is selected feature is Build options gt Toolchain gt System configuration gt Kernel gt Target packages gt Filesystem images gt Bootloaders gt Host utilities gt Legacy config options gt lt aEXUE gt lt Help gt lt Save gt lt Load gt free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 31 326 Running the build gt As simple as make gt Often useful to keep a log of the build output for analysis or investigation make 2 gt amp 1 tee build log free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 32 326 Build results gt The build results are located in output images gt Depe
25. Small root filesystem starting at 2 MB gt 1600 packages for user space libraries apps available gt Many architectures supported gt Well known technologies make and kconfig gt Vendor neutral gt Active community regular releases gt The present slides cover Buildroot 2015 08 There may be some differences if you use older or newer Buildroot versions gt http buildroot org free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 25 326 Buildroot design goals gt Buildroot is designed with a few key goals Simple to use Simple to customize Reproducible builds Small root filesystem Relatively fast boot Easy to understand v vvveyvyy gt Some of these goals require to not necessarily support all possible features gt They are some more complicated and featureful build systems available Yocto Project OpenEmbedded free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 26 326 Who s using Buildroot gt System makers gt Google gt Barco gt Rockwell Collins gt Processor vendors gt Imagination Technologies gt Marvell gt Atmel gt Analog Devices gt Many companies when doing R amp D on products gt Many many hobbyists on development boards Raspberry Pi BeagleBone Black etc free electrons Embedd
26. VvV v y Infrastructure Infrastructure Make 3 82 fixes locales generation fixes CVS download support post rsync hooks free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 312 326 In 2014 02 gt Support for external packages defconfigs BR2_EXTERNAL gt Cleanup of environment variable names for consistency gt Toolchain new Linaro and Sourcery Codebench toolchains x86 Support for AMD Jaguar cores SSE4 x SH SH2 SH3 SH3EB variants removed Microblaze Internal toolchain support gt Legal infrastructure Info is now split between host and target packages large number of license annotations gt Lua selection between lua 5 1 5 2 luarocks support gt Python package infrastructure many new packages gt Defconfigs Armadeus APF51 and Zedboard added apf27 apf28 beaglebone microblaze pandaboard qemu raspberry pi updated free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 313 326 In 2014 05 1 gt Architectures gt Support for MIPS 032 ABI on MIPS 64 targets has been removed too exotic gt Support for the ARM A12 variant and Intel corei7 gt Defconfigs Minnowboard and Altera SoCkit added QEMU updates gt Bootloaders Grub2 and gummiboot support syslinux support extended gt Kconfig handling for minimum kernel headers ve
27. a temporary location gt Finally a tarball containing only the source code and not the version control history or metadata is created and stored in DL_DIR gt Example avrdude eabe 67c4527bc2eedc5db9288ef5cf1818ec720 tar gz This tarball will be re used for the next builds and attempts are made to download it from the primary and backup sites Due to this always use a tag name or a full commit id and never a branch name the code will never be re downloaded when the branch is updated electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 106 326 File integrity checking gt Buildroot packages can provide a hash file to provide hashes for the downloaded files gt The download infrastructure uses this hash file when available to check the integrity of the downloaded files gt Hashs are checked every time a downloaded file is used even if it is already cached in DL_DIR gt If the hash is incorrect the download infrastructure attempts to re download the file once If that still fails the build aborts with an error Hash checking message strace 4 10 tar xz OK md5 107a5be455493861189e9b57a3a51912 strace 4 10 tar xz OK shal 5c3ec4c5a9eeb440d7ec70514923c2e7e7f9ab6c gt gt gt strace 4 10 Extracting free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electron
28. and Android Development consulting training and support http free electrons com 230 326 BR2_EXTERNAL principle gt Storing your custom packages custom configuration files and custom defconfigs inside the Buildroot tree may not be the most practical solution gt Doesn t cleanly separate open source parts from proprietary parts gt Makes it harder to upgrade Buildroot gt The BR2_EXTERNAL mechanism allows to store your own package recipes defconfigs and other artefacts outside of the Buildroot source tree gt Note can only be used to add new packages not to override existing Buildroot packages free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 231 326 BR2_EXTERNAL example organization gt project gt buildroot gt The Buildroot source code cloned from Git or extracted from a release tarball gt external gt Your external tree with your own custom packages and defconfigs gt output build1 gt output build2 gt Several output directories to build various configurations gt custom app gt custom lib gt The source code of your custom applications and libraries free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 232 326 BR2_EXTERNAL mechanism gt Specify BR2_EXTERNAL on the command line when building
29. dir end log config defconfig 2015 05 06 17 09 27 OK 1655934 Thomas Peinat mips none dir end log config defconfig Autobuild daily reports From Thomas Petazzoni lt thomas petazzoni free electrons com gt To buildroot uclibc org Subject Buildroot autobuild buildroot net Build results for 2015 05 05 Date Wed 6 May 2015 08 30 17 0200 CEST Build statistics for 2015 05 05 success failures timeouts TOTAL 301 50 1 352 freerdp 770c67d340d5f0a7b48 postgresql 9 4 1 python pyqt 4 11 3 Detail of failures powerpc boost 1 57 0 NOK http autobuild buildroot net results b64fd94a8ccff7fa8 bfin cc tool 26 NOK http autobuild buildroot net results 5f84d5696a52c7541 xtensa cc tool 26 NOK http autobuild buildroot net results d971db839e84480a5 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 307 326 What s new in Buildroot What s new in Buildroot Embedded Linux Experts free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 308 326 What s new in Buildroot gt The major improvements in each release are summari
30. free electrons com 146 326 Mandatory vs optional dependencies gt free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electro Very often software components have some mandatory dependencies and some optional dependencies only needed for optional features Handling mandatory dependencies in Buildroot consists in gt Using a select or depends on on the main package option in Config in gt Adding the dependency in lt pkg gt _DEPENDENCIES For optional dependencies there are two possibilities gt Handle it automatically in the mk file if the optional dependency is available use it gt Handle it explicitly add a package sub option in the Config in file Automatic handling is usually preferred as it reduces the number of Config in options but it makes the possible dependency less visible to the user ns com 147 326 Dependencies ntp example gt Mandatory dependency libevent gt Optional dependency handled automatically openssl package ntp Config in config BR2_PACKAGE_NTP bool ntp select BR2_PACKAGE_LIBEVENT package ntp ntp mk Esci NTP_DEPENDENCIES host pkgconf libevent Esad ifeq BR2_PACKAGE_OPENSSL y NTP_CONF_OPTS with crypto NTP_DEPENDENCIES openssl else NTP_CONF_OPTS without crypto disable openssl random endif ee free electrons Embedded Linux kernel drivers and Android Devel
31. gedit lab history txt Lab commands Cross compiling kernel export ARCH arm export CROSS_COMPILE arm linux make sama5_defconfig Booting kernel through tftp setenv bootargs console ttySO root dev nfs setenv bootcmd tftp 0x21000000 zimage tftp 0x22000000 dtb bootz 0x21000000 0x2200 Making ubifs images mkfs ubifs d rootfs o root ubifs e 124KiB m 2048 c 1024 Encountered issues Restart NFS server after editing etc exports free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 11 326 Cooperate As in the Free Software and Open Source community cooperation during practical labs is valuable in this training session gt If you complete your labs before other people don t hesitate to help other people and investigate the issues they face The faster we progress as a group the more time we have to explore extra topics gt Explain what you understood to other participants when needed It also helps to consolidate your knowledge gt Don t hesitate to report potential bugs to your instructor gt Don t hesitate to look for solutions on the Internet as well free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 12 326 Command memento sheet gt This memento sheet gives command examples for the most typical needs looking for files extra
32. host buzz then the host foo package will have host bar host baz and host buzz in its dependencies ifeq 4 target ifeq 2 _ADD_TOOLCHAIN_DEPENDENCY YES 2 _DEPENDENCIES toolchain endif endif gt Adding the toolchain dependency to target packages Except for some specific packages e g C library free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 279 326 Q inner generic package stamp files 2 _TARGET_INSTALL_TARGET 2 _TARGET_INSTALL_STAGING 2 _TARGET_INSTALL_IMAGES 2 _TARGET_INSTALL_HOST 2 _TARGET_BUILD 2 _TARGET_CONFIGURE 2 _TARGET_RSYNC 2 _TARGET_RSYNC_SOURCE 2 _TARGET_PATCH 2 _TARGET_EXTRACT 2 _TARGET_SOURCE 2 _TARGET_DIRCLEAN 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR 2 _DIR stamp_target_installed stamp_staging_installed stamp_images_installed stamp_host_installed stamp_built stamp_configured stamp_rsynced stamp_rsync_sourced stamp_patched stamp_extracted stamp_downloaded stamp_dircleaned gt Defines shortcuts to reference the stamp files 2 _TARGET_INSTALL_TARGET PKG 2 2 _TARGET_INSTALL_STAGING PKG 2 2 _TARGET_INSTALL_IMAGES PKG 2 2 _TARGET_INSTALL_HOST PKG 2 E gt Pa
33. old way of doing dev not very practical gt Using mdev mdev is part of Busybox and can run custom actions when devices are added removed Requires devtmpfs kernel support gt Using eudev Forked from systemd allows to run custom actions Requires devtmpfs kernel support gt When systemd is used the only option is udev from systemd itself free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 94 326 Other customization options gt There are various other options to customize the root filesystem gt getty options to run a login prompt on a serial port or screen gt hostname and banner options gt DHCP network on one interface for more complex setups use an overlay gt root password gt timezone installation and selection free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 95 326 Deploying the images gt By default Buildroot simply stores the different images in 0 images gt It is up to the user to deploy those images to the target device gt Possible solutions gt For removable storage SD card USB keys gt manually create the partitions and extract the root filesystem as a tarball to the appropriate partition gt use a tool like genimage to create a complete image of the media including all partitions gt For NAN
34. package infrastructure gt Note as of Buildroot 2015 05 TARGETS has been renamed to PACKAGES free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 272 326 Diving into pkg generic mk gt The package pkg generic mk file is divided in two main parts gt Definition of the actions done in each step of a package build process Done through stamp file targets gt Definition of the inner generic package generic package and host generic package macros that define the sequence of actions as well as all the variables needed to handle the build of a package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 273 326 Definition of the actions code BUILD_DIR stamp_downloaded Do some stuff here Q touch BUILD_DIR stamp_host_installed Do some stuff here BUILD_DIR stamp_extracted Q touch Do some stuff here Q touch BUILD_DIR stamp_staging_installed Do some stuff here BUILD_DIR stamp_patched Q touch Do some stuff here Q touch BUILD_DIR stamp_images_installed Do some stuff here BUILD_DIR stamp_configured Q touch Do some stuff here Q touch BUILD_DIR stamp_target_installed Do some stuff here BUILD_DIR stamp_built Q touch Do some stuff here Q
35. pwd gt buildroot gt config arch package output fs vvvvy free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 36 326 Out of tree build introduction gt Out of tree build allows to use an output directory different than output Useful to build different Buildroot configurations with the same source tree Customization of the output directory done by passing 0 path to directory on the command line Configuration file stored inside the 0 directory as opposed to inside the Buildroot sources for the in tree build case project gt buildroot Buildroot sources gt foo output output of a first project gt config gt bar output output of a second project gt config free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 37 326 Out of tree build usin gt To start an out of tree build two solutions gt From the Buildroot source tree simplify specify a O variable make O foo output menuconfig gt From an empty output directory specify O and the path to the Buildroot source tree make C buildroot O pwd menuconfig gt Once one out of tree operation has been done menuconfig loading a defconfig etc Buildroot creates a small wrapper Makefile in the output directory gt This wrapper Makefile the
36. separated list of post image scripts to call gt Post image scripts are called gt from the Buildroot source directory gt with the BINARIES_DIR path as first argument gt with the contents of the BR2_ROOTFS_POST_SCRIPT_ARGS as other arguments gt with a number of available environment variables BR2_CONFIG HOST_DIR STAGING_DIR TARGET_DIR BUILD_DIR BINARIES_DIR and BASE_DIR free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 92 326 Init hani nit mechanism gt Buildroot supports multiple init implementations gt Busybox init the default Simplest solution gt sysvinit the old style featureful init implementation gt systemd the new generation init system gt Selecting the init implementation in the System configuration menu will gt Ensure the necessary packages are selected gt Make sure the appropriate init scripts or configuration files are installed by packages See Advanced package aspects for details free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 93 326 dev management method gt Buildroot supports four methods to handle the dev directory gt Using devtmpfs dev is managed by the kernel devtmpfs which creates device files automatically Requires kernel 2 6 32 Default option gt Using static dev This is the
37. software make manual make html v http www nostarch com gnumake free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 110 326 Basi f make rul asics of make rules gt At their core Makefiles are simply defining rules to create targets from prerequisites using recipe commands TARGET PREREQUISITES RECIPE gt target name of a file that is generated Can also be an arbitrary action like clean in which case it s a phony target gt prerequisites list of files or other targets that are needed as dependencies of building the current target gt recipe list of shell commands to create the target from the prerequisites free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 111 326 Rule example Makefile clean rm rf TARGET_DIR BINARIES_DIR HOST_DIR BUILD_DIR BASE_DIR staging LEGAL_INFO_DIR distclean clean Eagal rm rf BR2_CONFIG CONFIG_DIR config old CONFIG_DIR auto deps gt clean and distclean are phony targets free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 112 326 Defining and referencing variables gt Defining variables is done in different ways gt FOOBAR value expanded at time of use gt FOOBAR
38. the toolchain s generated by Buildroot into the Eclipse C C Development Environment gt Allows Eclipse projects to easily use the compiler linker and debugger provided by Buildroot gt In Buildroot enable the BR2_ECLIPSE_REGISTER option gt In Eclipse install the Buildroot plugin and follow the instructions available from the plugin website gt See https github com mbats eclipse buildroot bundle wiki for download installation and usage details free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 266 326 Practical lab Application development v Build and run your own application v Remote debug your application gt Use lt pkg gt _OVERRIDE_SRCDIR Set up Eclipse for Buildroot application development v free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 267 326 Understanding Buildroot internals Embedded Linux Experts Understanding Buildroot internals free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 268 326 Configuration system gt Uses almost unchanged the kconfi
39. with utility host tools and libraries needed for gcc host m4 host mpc host mpfr host gmp Installed in HOST_DIR usr bin include lib Build goes on with the cross binutils host binutils installed in HOST_DIR usr bin gt Then the first stage compiler host gcc initial gt We need the linux headers installed in STAGING_DIR usr include We build the C library uclibc in this example Installed in STAGING_DIR 1ib STAGING_DIR usr include and of course TARGET_DIR lib We build the final compiler host gcec final installed in HOST_DIR usr bin free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com uctibe host gcc initial linux headers a host binutils host mpe host mpfr host gmp host m4 292 326 External toolchain back end gt Implemented as one package toolchain external gt Knows about well known toolchains CodeSourcery Linaro etc or allows to use existing custom toolchains built with Buildroot Crosstool NG etc gt Core logic a 2 3 Extract the toolchain to HOST_DIR opt ext toolchain Run some checks on the toolchain Copy the toolchain sysroot C library and headers kernel headers to STAGING_DIR usr include lib Copy the toolchain libraries to TARGET_DIR usr lib Create symbolic links or wrappers for the compiler linker debugger etc from HOS
40. A_DOWNLOADS a list of additional files to download together with the package source code It is up to the package mk file to do something with them gt Two options gt Just a file name assumed to be relative to lt pkg gt _SITE gt A full URL downloaded over HTTP FTP gt Examples sysvinit mk SYSVINIT_PATCH sysvinit_ SYSVINIT_VERSION dsf 13 1 squeezel diff gz perl mk PERL_CROSS_SITE http raw github com arsv perl cross releases PERL_CROSS_SOURCE per1 PERL_CROSS_BASE_VERSION cross PERL_CROSS_VERSION tar gz PERL_EXTRA_DOWNLOADS PERL_CROSS_SITE PERL_CROSS_SOURCE free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 145 326 Describing dependencies gt Dependencies expressed in Config in do not enforce build order gt The lt pkg gt _DEPENDENCIES variable is used to describe the dependencies of the current package gt Packages listed in lt pkg gt _DEPENDENCIES are guaranteed to be built before the configure step of the current package starts gt It can contain both target and host packages gt It can be appended conditionally with additional dependencies python mk PYTHON_DEPENDENCIES host python libffi ifeq BR2_PACKAGE_PYTHON_READLINE y PYTHON_DEPENDENCIES readline endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http
41. Buildroot Buildroot Embedded Linux Experts free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Latest update December 18 2015 Document updates and sources http free electrons com doc training buildroot Corrections suggestions contributions and translations are welcome Send them to feedback free electrons com free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 1 326 Rights t ights to copy Copyright 2004 2015 Free Electrons License Creative Commons Attribution Share Alike 3 0 http creativecommons org licenses by sa 3 0 legalcode You are free gt to copy distribute display and perform the work gt to make derivative works gt to make commercial use of the work Under the following conditions gt Attribution You must give the original author credit gt Share Alike If you alter transform or build upon this work you may distribute the resulting work only under a license identical to this one gt For any reuse or distribution you must make clear to others the license terms of this work gt Any of these conditions can be waived if you get permission from the copyright holder Your fair use and other rights are in no way affected by the above free electrons Embedded Linux kernel drivers and Android Development consulting training and support http
42. D flash gt Transfer the image to the target and flash it gt NFS booting gt initramfs free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 96 326 Deploying the image NFS booting gt Many people try to use 0 target directly for NFS booting gt This cannot work due to permissions ownership being incorrect gt Clearly explained in the THIS_IS_NOT_YOUR_ROOT_FILESYSTEM file gt Generate a tarball of the root filesystem gt Use sudo tar C nfs xf output images rootfs tar to prepare your NFS share free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 97 326 Deploying the image initramfs gt Another common use case is to use an initramfs i e a root filesystem fully in RAM gt Convenient for small filesystems fast booting or kernel development gt Two solutions gt BR2_TARGET_ROOTFS_CPIO y to generate a cpio archive that you can load from your bootloader next to the kernel image gt BR2_TARGET_ROOTFS_INITRAMFS y to directly include the initramfs inside the kernel image Only available when the kernel is built by Buildroot free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 98 326 Practical lab Root filesystem construction gt Explore t
43. DFU_UTIL_VERSION 6 DFU_UTIL_SITE http dfu util gnumonks org releases DFU_UTIL_LICENSE GPLv2 DFU_UTIL_LICENSE_FILES COPYING HOST_DFU_UTIL_DEPENDENCIES host libusb eval host autotools package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 173 326 Example 3 target and host of the same package package e2tools e2tools mk E2TOOLS_VERSION 3158ef18a903ca4a98b8fa220c9fc5c133d8bdf6 E2TOOLS_SITE call github ndim e2tools E2TOOLS_VERSION Source coming from GitHub no configure included E2TOOLS_AUTORECONF YES E2TOOLS_LICENSE GPLv2 E2TOOLS_LICENSE_FILES COPYING E2TOOLS_DEPENDENCIES e2fsprogs E2TOOLS_CONF_ENV LIBS lpthread HOST_E2TOOLS_CONF_ENV LIBS Ipthread eval autotools package eval host autotools package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 174 326 Practical lab New packages in Buildroot gt Practical creation of several new packages in Buildroot using the different package infrastructures free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 175 326 Advanced package aspects Advanced package aspects Embedded Linux Experts free electrons Copyright 2004 2015 Fre
44. DIR stamp_extracted Fos eal call MESSAGE Extracting define legal license nofiles pkg HOST TARGET call legal license header 1 unknown license file s 2 endef free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 115 326 Useful make functions gt subst and patsubst to replace text ICU_SOURCE icu4c subst _ ICU_VERSION src tgz gt filter and filter out to filter entries gt foreach to implement loops foreach incdir TI_GFX_HDR_DIRS INSTALL d STAGING_DIR usr include notdir incdir INSTALL D m 0644 D include incdir h STAGING_DIR usr include notdir incdir gt dir notdir addsuffix addprefix to manipulate file names UBOOT_SOURCE notdir UBOOT_TARBALL IMAGEMAGICK_CONFIG_SCRIPTS addsuffix config Magick MagickCore MagickWand Wand gt And many more see the GNU Make manual for details free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 116 326 Writi riting recipes gt Recipes are just shell commands gt Each line must be indented with one Tab gt Each line of shell command in a given recipe is independent from the other variables are not shared between lines in the recipe gt Need to use a single line possibly split using to do complex shell c
45. ENV and HOST_MAKE_ENV to pass in the MAKE environment to ensure the PATH is correct TARGET_CONFIGURE_OPTS and HOST_CONFIGURE_OPTS to pass CC LD CFLAGS etc TARGET_DIR STAGING_DIR BINARIES_DIR and HOST_DIR free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 155 326 Describing actions example 1 eeprog mk EEPROG_VERSION 0 7 6 EEPROG_SITE http www codesink org download EEPROG_LICENSE GPLv2 EEPROG_LICENSE_FILES eeprog c define EEPROG_BUILD_CMDS MAKE TARGET_CONFIGURE_OPTS C D endef define EEPROG_INSTALL_TARGET_CMDS CINSTALL m 0755 D D eeprog TARGET_DIR usr bin eeprog endef eval generic package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 156 326 Describing actions example 2 zlib mk ZLIB_VERSION 1 2 8 ZLIB_SOURCE zlib ZLIB_VERSION tar xz ZLIB_SITE http downloads sourceforge net project libpng zlib ZLIB_VERSION ZLIB_INSTALL_STAGING YES define ZLIB_CONFIGURE_CMDS cd D rm rf config cache TARGET_CONFIGURE_ARGS TARGET_CONFIGURE_OPTS CFLAGS TARGET_CFLAGS ZLIB_PIC configure ZLIB_SHARED prefix usr endef define ZLIB_BUILD_CMDS MAKE1 C D endef define ZLIB_INSTALL_STAGING_CMDS MAKE1 C D DESTDIR
46. GET NO linux mk LINUX_INSTALL_IMAGES YES free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 153 326 Describing actions for generic package gt In a package using generic package only the download extract and patch steps are implemented by the package infrastructure gt The gt gt gt gt other steps should be described by the package mk file lt pkg gt _CONFIGURE_CMDS always called lt pkg gt _B lt pkg gt _I lt pkg gt _I lt pkg gt _I lt pkg gt _I lt pkg gt _I lt pkg gt _I lt pkg gt _I UILD_ NSTAL NSTAL NSTAL NSTAL NSTAL NSTAL NSTAL CMDS always called L_TARGET_CMDS called when L_TARGET YES for target packages L_STAGING_CMDS called when L_STAGING YES for target packages L_IMAGES_CMDS called when L_IMAGES YES for target packages L_CMDS always called for host packages gt Packages are free to not implement any of these variables they are all optional free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 154 326 Describing actions useful variables Inside an action block the following variables are often useful gt gt gt D is the source directory of the package MAKE to call make MAKE1 when the package doesn t build properly in parallel mode TARGET_MAKE_
47. ION 3 4 2 PYTHON_LXML_SITE http lxml de files PYTHON_LXML_SOURCE 1xml PYTHON_LXML_VERSION tgz Eege PYTHON_LXML_SETUP_TYPE setuptools PYTHON_LXML_DEPENDENCIES libxml2 libxslt zlib PYTHON_LXML_BUILD_OPTS with xslt config STAGING_DIR usr bin xslt config with xml2 config STAGING_DIR usr bin xml2 config eval python package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 167 326 Integrating new packages in Buildroot Target vs host packages free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 168 326 Host pack ost packages gt As explained earlier most packages in Buildroot are cross compiled for the target They are called target packages gt Some packages however may need to be built natively for the build machine they are called host packages They can be needed for a variety of reasons gt Needed as a tool to build other things for the target Buildroot wants to limit the number of host utilities required to be installed on the build machine and wants to ensure the proper version is used So it builds some host utilities by itself gt Needed as a tool to interact debug reflash generate images or other activities around the build itself gt Version dependencies building a Python interpreter for the targe
48. Linux kernel drivers and Android Development consulting training and support http free electrons com 235 326 BR2_EXTERNAL external mk gt Can include custom make logic gt Generally only used to include the package mk files Example BR2_EXTERNAL external mk include sort wildcard BR2_EXTERNAL package mk free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 236 326 Using BR2_EXTERNAL gt Not a configuration option only an environment variable to be passed on the command line make BR2_EXTERNAL path to external gt Automatically saved in the hidden br external file in the output directory gt no need to pass BR2_EXTERNAL at every make invocation gt can be changed at any time by passing a new value and removed by passing an empty value gt Can be either an absolute or a relative path but if relative important to remember that it s relative to the Buildroot source directory free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 237 326 Use BR2_EXTERNAL in your configuration gt In your Buildroot configuration don t use absolute paths for the rootfs overlay the post build scripts global patch directories etc gt If they are located in your BR2_EXTERNAL you can use BR2_EXTERNAL in your Buildroot configuration optio
49. NG_SERIES config libpng config imagemagick mk IMAGEMAGICK_CONFIG_SCRIPTS addsuffix config Magick MagickCore MagickWand Wand ifeq BR2_INSTALL_LIBSTDCPP BR2_USE_WCHAR yy IMAGEMAGICK_CONFIG_SCRIPTS Magick config endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 203 326 Confi ipts effect onfig scripts effec Without lt pkg gt _CONFIG_SCRIPTS output staging usr bin libpng config cflags ldflags I usr include libpng16 L usr lib lpng16 With lt pkg gt _CONFIG_SCRIPTS output staging usr bin libpng config cflags ldflags I buildroot output host usr arm buildroot linux uclibcgnueabi sysroot usr include libpng16 L buildroot output host usr arm buildroot linux uclibcgnueabi sysroot usr lib lpng16 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 204 326 Hooks Hooks principle 1 gt Buildroot package infrastructure often implement a default behavior for certain steps gt generic package implements for all packages the download extract and patch steps gt Other infrastructures such as autotools package or cmake package also implement the configure build and installations steps gt In some situations the package may want to do additional actions before or after one these steps gt The ho
50. STAGING_DIR LDCONFIG true install endef define ZLIB_INSTALL_TARGET_CMDS MAKE1 C D DESTDIR TARGET_DIR LDCONFIG true install endef eval generic package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 157 326 Integrating new packages in Buildroot autotools package infrastructure free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 158 326 The autotools package infrastructure basics gt The autotools package infrastructure inherits from generic package and is specialized to handle autotools based packages gt It provides a default implementation of gt lt pkg gt _CONFIGURE_CMDS Calls the configure script with appropriate environment variables and arguments gt lt pkg gt _BUILD_CMDS Calls make gt lt pkg gt _INSTALL_TARGET_CMDS lt pkg gt _INSTALL_STAGING_CMDS and lt pkg gt _INSTALL_CMDS Call make install with the appropriate DESTDIR gt A normal autotools based package therefore does not need to describe any action only metadata about the package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 159 326 The autotools package steps Implemented by the Implemented by the generic package al autotools package infrastructure i
51. T_DIR usr bin lt tuple gt lt tool gt to HOST_DIR opt ext toolchain bin lt tuple gt lt tool gt A wrapper program is used for certain tools gcc Id g etc in order to ensure a certain number of compiler flags are used especially sysroot STAGING_DIR and target specific flags free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 293 326 Root filesystem image generation gt Once all the targets in TARGETS have been built it s time to create the root filesystem images gt First the target finalize target does some cleanup of TARGET_DIR by removing documentation headers static libraries etc gt Then the root filesystem image targets listed in ROOTFS_TARGETS are processed gt These targets are added by the common filesystem image generation infrastructure in fs common mk gt The purpose of this infrastructure is to factorize the preparation logic and then call fakeroot to create the filesystem image free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 294 326 fs common mk define ROOTFS_TARGET_INTERNAL ROOTFS_ 2 _DEPENDENCIES host fakeroot host makedevs if PACKAGES_USERS host mkpasswd BINARIES_DIR rootfs 1 target finalize ROOTFS_ 2 _DEPENDENCIES call MESSAGE Generating root filesystem image r
52. able ARM EABI5 version 1 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 252 326 free Building code for Buildroot pkg config elec Using the system pkg config pkg config cflags libpng I usr include libpng12 pkg config libs libpng lpng12 Using the Buildroot pkg config export PATH pwd output host usr bin PATH pkg config cflags libpng I output host usr arm buildroot linux uclibcgnueabi sysroot usr include libpng16 pkg config libs libpng L output host usr arm buildroot linux uclibcgnueabi sysroot usr lib lpng16 Note too long lines have been splitted rons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 253 326 Building code for Buildroot autotools gt Building simple autotools components outside of Buildroot is easy export PATH buildroot output host usr bin PATH configure host arm linux gt Passing host arm linux tells the configure script to use the cross compilation tools prefixed by arm linux gt In more complex cases some additional CFLAGS or LDFLAGS might be needed in the environment free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 254 326 The lt pkg gt _OVERRIDE_SRCDIR mechanism gt Very o
53. and support http free electrons com 301 326 Release schedule gt The Buildroot community publishes stable releases every three months gt YYYY 02 YYYY 05 YYYY 08 and YYYY 11 every year gt The three months cycle is split in two periods gt Two first months of active development gt One month of stabilization before the release gt At the beginning of the stabilization phase rc1 is released gt Several rc versions are published during this stabilization phase until the final release gt Development not completely stopped during the stabilization a next branch is opened free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 302 326 Contribution process gt Contributions are made in the form of patches gt Created with git and sent by e mail to the mailing list gt Use git send email to avoid issues gt The patches are reviewed tested and discussed by the community gt You may be requested to modify your patches and submit updated versions gt Once ready they are applied by the project maintainer Peter Korsgaard or the interim maintainer Thomas Petazzoni gt Some contributions may be rejected if they do not fall within the Buildroot principles ideas as discussed by the community ree electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons co
54. ar host baz gt Can be overridden if the dependencies of the host variant are different than the ones of the target variant free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 171 326 Example 1 a pure build utility gt bison a general purpose parser generator gt Purely used as build dependency in packages gt FBSET_DEPENDENCIES host bison host flex gt No Config in host not visible in menuconfig package bison bison mk BISON_VERSION 3 0 4 BISON_SOURCE bison BISON_VERSION tar xz BISON_SITE BR2_GNU_MIRROR bison BISON_LICENSE GPLv3 BISON_LICENSE_FILES COPYING HOST_BISON_DEPENDENCIES host m4 eval host autotools package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 172 326 Example 2 a flashing utility gt dfu util to reflash devices support the USB DFU protocol Typically used on a development PC gt Not used as a build dependency of another package visible in menuconfig package dfu util Config in host config BR2_PACKAGE_HOST_DFU_UTIL bool host dfu util help Dfu util is the host side implementation of the DFU 1 0 specification of the USB forum DFU is intended to download and upload firmware to devices connected over USB http dfu util gnumonks org package dfu util dfu util mk
55. com 119 326 Basic elements of a Buildroot package v A directory package foo v A Config in file written in kconfig language describing the configuration options for the package gt A lt pkg gt mk file written in make describing where to fetch the source how to build and install it etc gt An optional lt pkg gt hash file providing hashes to check the integrity of the downloaded tarballs gt Optionally patch files that are applied on the package source code before building gt Optionally any additional file that might be useful for the package init script example configuration file etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 120 326 Integrating new packages in Buildroot Config in file free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 121 326 package lt pkg gt Config in basics gt Describes the configuration options for the package gt Written in the kconfig language gt One option is mandatory to enable disable the package it must be named BR2_PACKAGE_ lt PACKAGE gt config BR2_PACKAGE_STRACE bool strace help A useful diagnostic instructional and debugging tool Allows you to track what system calls a program makes while it is running http sourceforge net projects strace gt The ma
56. cting a tar archive gt It saves us 1 day of UNIX Linux command line training gt Our best tip in the command line shell always hit the Tab key to complete command names and file paths This avoids 95 of typing mistakes gt Get an electronic copy on http free electrons com doc training embedded linux command_memento pdf free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 13 326 vi basic commands gt The vi editor is very useful to make quick changes to files in an embedded target gt Though not very user friendly at first vi is very powerful and its main 15 commands are easy to learn and are sufficient for 99 of everyone s needs gt Get an electronic copy on http free electrons com doc training embedded linux vi_memento pdf gt You can also take the quick tutorial by running vimtutor This is a worthy investment free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 14 326 Practical lab Training Setup Prepare your lab environment gt Download the lab archive gt Enforce correct permissions free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 15 326 Introduction to Embedded Linux Embed
57. d etc Used to generate the final root filesystem images in images gt Variable TARGET_DIR free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 59 326 Build tree 0 images gt output gt images gt ziImage gt armada 370 mirabox dtb gt rootfs tar gt rootfs ubi gt Contains the final images kernel image bootloader image root filesystem image s gt Variable BINARIES_DIR free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 60 326 Build tree 0 graphs gt output gt gt Yv v v graphs Visualization of Buildroot operation dependencies between packages time to build the different packages make graph depends make graph build Variable GRAPHS_DIR See the section Analyzing the build later in this training free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 61 326 Build tree 0 legal info gt output gt legal info gt gt gt gt gt gt gt gt gt gt free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com manifest csv host manifest csv licenses txt licenses sources Legal information license of all packages
58. d Android Development consulting training and support http free electrons com 162 326 More complicated autotools package example POPPLER_VERSION 0 32 0 POPPLER_SOURCE poppler POPPLER_VERSION tar xz POPPLER_SITE http poppler freedesktop org POPPLER_DEPENDENCIES fontconfig POPPLER_LICENSE GPLv2 POPPLER_LICENSE_FILES COPYING POPPLER_INSTALL_STAGING YES POPPLER_CONF_OPTS with font configuration fontconfig ifeq BR2_PACKAGE_LCMS2 y POPPLER_CONF_OPTS enable cms lcms2 POPPLER_DEPENDENCIES lcms2 else POPPLER_CONF_OPTS enable cms none endif ifeq BR2_PACKAGE_TIFF y POPPLER_CONF_OPTS enable libtiff POPPLER_DEPENDENCIES tiff else POPPLER_CONF_OPTS disable libtiff endif Eg EE ifeq BR2_PACKAGE_POPPLER_QT y POPPLER_DEPENDENCIES qt POPPLER_CONF_OPTS enable poppler qt4 else POPPLER_CONF_OPTS disable poppler qt4 endif ifeq BR2_PACKAGE_OPENJPEG y POPPLER_DEPENDENCIES openjpeg POPPLER_CONF_OPTS enable libopenjpeg openjpeg1 else POPPLER_CONF_OPTS enable libopenjpeg none endif eval autotools package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 163 326 Integrating new packages in Buildroot python package infrastructure free electrons Embedded Linux kernel drivers and Android Development consulting tra
59. d Android Development consulting training and support http free electrons com 183 326 Patch application ordering gt Overall the patches are applied in this order 1 Patches mentioned in the lt pkg gt _PATCH variable of the package mk file They are automatically downloaded before being applied 2 Patches present in the package directory package lt pkg gt patch 3 Patches present in the global patch directories gt In each case they are applied gt In the order specified in a series file if available gt Otherwise in alphabetic ordering free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 184 326 Patch ti atch conventions gt There are a few conventions and best practices that the Buildroot project encourages to use when managing patches gt Their name should start with a sequence number that indicates the ordering in which they should be applied Is package nginx patch Q001 auto type sizeof rework autotest to be cross compila patch Q002 auto feature add mechanism allowing to force feature patch 0003 auto set ngx_feature_run_force_result for each featu patch 0004 auto lib libxslt conf allow to override ngx_feature_ patch Q005 auto unix make sys_nerr guessing cross friendly patch gt Each patch should contain a description of what the patch does and if possible its upstream status gt Each patch should contai
60. d Linux kernel drivers and Android Development consulting training and support http free electrons com 220 326 Analyzing the build as Embedded Linux Experts Analyzing the build free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 221 326 Analyzing the build available tools gt Buildroot provides several useful tools to analyze the build gt The licensing report covered in a previous section which allows to analyze the list of packages and their licenses gt The dependency graphing tools gt The build time graphing tools gt A tool to analyze the contribution of each package to the filesystem size is under development it should be merged in Buildroot 2015 08 Patches are already available gt Additional tools can be constructed using instrumentation scripts free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 222 326 Dependency graphing gt Exploring the dependencies between packages is useful to understand gt why a particular package is being brought into the build gt if the build size and duration can be reduced gt make graph depends to generate a full depende
61. ded Linux Experts Introduction to Embedded Linux free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 16 326 Simplified Linux system architecture Userspace Application Application Application Linux kernel free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 17 326 Overall Linux boot sequence Bootloader Loads the kernel to RAM and starts it 4 Kernel Initializes hardware devices and kernel subsystems Mounts the root filesystem indicated by root Starts the init application sbin init by default sbin init Starts other user space services and applications Zo o Other applications Root filesystem free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 18 326 Embedded Linux work gt BSP work porting the bootloader and Linux kernel developing Linux device drivers gt system integration work assembling all the user space components needed for the system configure them develop the upgrade and recovery mechanisms etc gt application development write the company specific appl
62. defconfig now saves the path to the defconfig in the config soa make savedefconfig automatically updates it Infrastructure for packages using the Erlang rebar tool has been added Hashes for a large number of packages have been added Hashes are now checked for both target and host packages The system menu now has an option to automatically configure a network interface through DHCP at bootup The default filesystem skeleton now uses a separate tmpfs for run instead of a symlink to tmp for security reasons to protect against conflicts with user generated temporary files BR2_EXTERNAL is now exported to post build and post image scripts free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 320 326 In 2015 05 1 gt Architectures gt gt Removed AVR32 support SuperH64 deprecated Added support for steamroller corei7 avx and core avx2 x86 variants gt Toolchains gt IPv6 and Largefile support now enforced for uClibc Corresponding Kconfig symbols removed gt External CodeSourcery AMD64 2014 05 added gt musl cross 1 1 6 added gt CodeSourcery SuperH 2 and Xilinx Microblaze v2 14 3 vvvyvyy removed Distro class external toolchains are now detected and blacklisted Internal toolchain support for Nios2 added Blackfin removed Aarch64 and sh musl support uClibc ng support added Libatomic is now handled for interna
63. droot uses them as follows gt depends on for architecture toolchain feature or big feature dependencies E g package only available on x86 or only if wide char support is enabled or depends on Python gt select for enabling the necessary other packages needed to build the current package libraries etc gt Such dependencies only ensure consistency at the configuration level They do not guarantee build ordering free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 124 326 package lt pkg gt Config in dependency example btrfs progs package config BR2_PACKAGE_BTRFS_PROGS bool btrfs progs depends on BR2_USE_WCHAR util linux depends on BR2_USE_MMU util linux depends on BR2_TOOLCHAIN_HAS_THREADS select select select select select select select select help BR2_PACKAGE_ACL BR2_PACKAGE_ATTR BR2_PACKAGE_E2FSPROGS BR2_PACKAGE_LZO BR2_PACKAGE_UTIL_LINUX BR2_PACKAGE_UTIL_LINUX_LIBBLKID BR2_PACKAGE_UTIL_LINUX_LIBUUID BR2_PACKAGE_ZLIB Btrfs filesystem utilities https btrfs wiki kernel org in comment btrfs progs needs a toolchain w wchar threads depends on BR2_USE_MMU depends on BR2_USE_WCHAR BR2_TOOLCHAIN_HAS_THREADS gt depends on BR2_USE_MMU because the package uses fork Note that there is no comment displayed about this dependency because it s a limitation of the architecture
64. e Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 176 326 Advanced package aspects Licensing report free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 177 326 Licensing report introduction gt gt A key aspect of embedded Linux systems is license compliance Embedded Linux systems integrate together a number of open source components each distributed under its own license The different open source licenses may have different requirements that must be met before the product using the embedded Linux system starts shipping Buildroot helps in this license compliance process by offering the possibility of generating a number of license related information from the list of selected packages Generated using make legal info free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 178 326 Licensing report contents of legal info gt sources all the source files that are redistributable tarballs patches etc gt buildroot config the Buildroot config file gt host manifest csv a CSV file with the list of host packages their version
65. e electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 208 326 Advanced package aspects Overriding commands free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 209 326 Overriding commands principle gt In other situations a package may want to completely override the default implementation of a step provided by a package infrastructure gt A package infrastructure will in fact only implement a given step if not already defined by a package gt So defining lt pkg gt _EXTRACT_CMDS or lt pkg gt _BUILDS_CMDS in your package mk file will override the package infrastructure implementation if any free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 210 326 Overriding commands examples jquery source code is only one file JQUERY_SITE http code jquery com JQUERY_SOURCE jquery JQUERY_VERSION min js define JQUERY_EXTRACT_CMDS cp DL_DIR JQUERY_SOURCE D endef tftpd install only what s needed define TFTPD_INSTALL_TARGET_CMDS CINSTALL D D tftp tftp TARGET_DIR usr bin tftp CINSTALL D D tftpd tftpd TARGET_DIR usr sbin tftpd endef eval autotools package free electrons Embedded Linux kernel drivers and Android Development c
66. e from the configuration and run make gt Nothing happens The files installed by this package are not removed from the target filesystem gt Buildroot does not track which files are installed by which package gt Need to do a full rebuild to get the new result Advice do it only when really needed gt f you change the sub options of a package that has already been built and run make gt Nothing happens gt You can force Buildroot to rebuild this package using make lt pkg gt reconfigure or make lt pkg gt rebuild free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 246 326 Understanding rebuilds scenarios 2 gt f you make a change to a post build script a rootfs overlay or a post image script and run make gt This is sufficient since these parts are re executed at every make invocation gt If you change a fundamental system configuration option architecture type of toolchain or toolchain configuration init system etc gt You must do a full rebuild gt If you change some source code in output build lt foo gt lt version gt and issue make gt The package will not be rebuilt automatically Buildroot has a hidden file saying that the package was already built gt Use make lt pkg gt reconfigure or make lt pkg gt rebuild gt And remember that doing changes in output build lt foo gt lt version gt can on
67. ecial ownership and permissions for files and directories define lt pkg gt _PERMISSIONS name type mode uid gid major minor start inc count endef gt The major minor start inc and count fields are not used free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 194 326 File permissions and ownership examples gt sudo needs to be installed setuid root define SUDO_PERMISSIONS usr bin sudo f 4755 endef gt var lib nginx needs to be owned by www data which has UID GID 33 defined in the skeleton define NGINX_PERMISSIONS var lib nginx d 755 33 33 endef free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 195 326 Devices gt Defining devices only applies when the chosen dev management strategy is Static using a device table In other cases device files are created dynamically gt A default set of device files is described in system device_table_dev txt and created by Buildroot in the root filesystem images gt When packages need some additional custom devices they can use the lt pkg gt _DEVICES variable define lt pkg gt _DEVICES name type mode uid gid major minor start inc count endef gt Becoming less useful since most people are using a dynamic dev nowadays free electrons Embedded Linux kernel drivers and A
68. ecture variant FPU and ABI selected in the Target options gt look for libraries and headers in the sysroot gt no need to pass weird gcc flags free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 67 326 External toolchain backend possibilities gt Allows to re use existing pre built toolchains gt Great to gt save the build time of the toolchain gt use vendor provided toolchain that are supposed to be reliable gt Several options gt Use an existing toolchain profile known by Buildroot gt Download and install a custom external toolchain gt Directly use a pre installed custom external toolchain free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 68 326 Existing external toolchain profile gt Buildroot already knows about a wide selection of publicly available toolchains gt Toolchains from Linaro ARM and AArch64 Mentor Graphics ARM MIPS NIOS II PowerPC SuperH x86 x86 64 Analog Devices Blackfin and the musl project gt In such cases Buildroot is able to download and automatically use the toolchain gt It already knows the toolchain configuration C library being used kernel headers version etc gt Additional profiles can easily be added free electrons Embedded Linux kernel drivers and Android Development con
69. ed Linux kernel drivers and Android Development consulting training and support http free electrons com 27 326 Getting Buildroot gt Stable Buildroot releases are published every three months gt Tarballs are available for each stable release gt http buildroot org downloads gt However it is generally more convenient to clone the Git repository gt Allows to clearly identify the changes you make to the Buildroot source code gt Simplifies the upstreaming of the Buildroot changes gt git clone git git busybox net buildroot gt Git tags available for every stable release free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 28 326 Using Buildroot gt Implemented in make gt With a few helper shell scripts gt All interaction happens by calling make in the main Buildroot sources directory cd buildroot make help gt No need to run as root Buildroot is designed to be executed with normal user privileges gt Running as root is even strongly discouraged free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 29 326 Configuring Buildroot gt Like the Linux kernel uses Kconfig gt A choice of configuration interfaces gt gt gt gt make make make make menuconfig nconfig xconfig gconfig gt
70. eful when there is no version control system provided by the upstream project gt http savannah nongnu org projects quilt free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 189 326 Generating patches with Git Needs to be done outside of Buildroot you cannot use the Buildroot package build directory i Clone the upstream Git repository git clone git Create a branch starting on the tag marking the stable release of the software as packaged in Buildroot git checkout b buildroot changes v3 2 Import existing Buildroot patches if any git am path to buildroot package lt foo gt x patch Make your changes and commit them git commit s m this is a change Generate the patches git format patch v3 2 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 190 326 Generating patches with Quilt l Extract the package source code tar xf path to dl lt foo gt lt version gt tar gz Inside the package source code reate a directory for patches mkdir patches Import existing Buildroot patches quilt import path to buildroot package lt foo gt x patch Apply existing Buildroot patches quilt push a Create a new patch quilt new 0001 fix header inclusion patch Edit a file quilt edit main c Re
71. ependencies thanks te the name af each package being a make target BUILD_DIR alib xy2 stamp_patched BUILD_DIR lib xyz stamp_extracted S BUILD_DIR z1ib xyz stamp_downloaded Unity shortcuts not used during a normal build Example of package build gt gt gt zlib 1 2 8 Downloading here it wgets the tarball gt gt gt zlib 1 2 8 Extracting xzcat home thomas d1 zlib 1 2 8 tar xz tar gt gt gt zlib 1 2 8 Patching gt gt gt zlib 1 2 8 Configuring cd home thomas projets buildroot output bui configure shared prefix usr gt gt gt zlib 1 2 8 Building usr bin make j1 C home thomas projets bui gt gt gt zlib 1 2 8 Installing to staging directory usr bin make j1 C home thomas projets bui d zlib 1 2 8 droot output build zlib 1 2 8 droot output build zlib 1 2 8 DESTDIR home thomas projets buildroot output host usr arm buildroot linux uclibcgnueabi sysroot LDCONFIG true instal gt gt gt zlib 1 2 8 Installing to target usr bin make j1 C home thomas projets bui droot output build zlib 1 2 8 DESTDIR home thomas projets buildroot output target LDCONFIG true instal free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 283 326 Preparation work dirs prepare dependencies pkg generic mk 2 _TARGET_SOURCE dirs prepare 2 _TARGET_SOURCE
72. er electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com sunxi mali Config in config BR2_PACKAGE_SUNXI_MALI bool sunxi mali select BR2_PACKAGE_HAS_LIBEGL select BR2_PACKAGE_HAS_LIBGLES config BR2_PACKAGE_PROVIDES_LIBGLES default sunxi mali sunxi mali sunxi mali mk EZR SUNXI_MALI_PROVIDES libegl libgles PERI gt The variable lt pkg gt _PROVIDES is only used to detect if two providers for the same virtual package are enabled 218 326 Virtual package user qt5 qt5base Config in config BR2_PACKAGE_QT5BASE_OPENGL_ES2 bool OpenGL ES 2 0 depends on BR2_PACKAGE_HAS_LIBGLES help Use OpenGL ES 2 0 and later versions qt5 qt5base qt5base mk ifeq BR2_PACKAGE_QT5BASE_OPENGL_DESKTOP y QT5BASE_CONFIGURE_OPTS opengl desktop QT5BASE_DEPENDENCIES libgl else ifeq BR2_PACKAGE_QT5BASE_OPENGL_ES2 y QT5BASE_CONFIGURE_OPTS opengl es2 QT5BASE_DEPENDENCIES libgles else QT5BASE_CONFIGURE_OPTS no opengl endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 219 326 Practical lab Advanced packages gt Package an application with a mandatory dependency and an optional dependency gt Package a library hosted on GitHub gt Use hooks to tweak packages gt Add a patch to a package free electrons Embedde
73. ering the OpenGL ES API gt Eight packages are providers of the OpenGL ES API gpu amd bin mx51 gpu viv bin mx6q mesa3d nvidia driver nvidia tegra23 binaries rpi userland sunxi mali ti gfx free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 215 326 Virtual package definition Config in libgles Config in config BR2_PACKAGE_HAS_LIBGLES bool config BR2_PACKAGE_PROVIDES_LIBGLES depends on BR2_PACKAGE_HAS_LIBGLES string gt BR2_PACKAGE_HAS_LIBGLES is a hidden boolean gt Packages needing OpenGL ES will depends on it gt Packages providing OpenGL ES will select it gt BR2_PACKAGE_PROVIDES_LIBGLES is a hidden string gt Packages providing OpenGL ES will define their name as the variable value gt The libgles package will have a build dependency on this provider package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 216 326 Virtual package definition mk libgles libgles mk eval virtual package gt Nothing to do the virtual package infrastructure takes care of everything using the BR2_PACKAGE_HAS_ lt name gt and BR2_PACKAGE_PROVIDES_ lt name gt options free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 217 326 free Virtual package provid
74. ernel drivers and Android Development consulting training and support http free electrons com 40 326 defcontig efconfig example gt For the default Buildroot configuration the defconfig is empty everything is the default gt If you change the architecture to be ARM the defconfig is just one line BR2_arm y gt If then you also enable the stress package the defconfig will be just two lines BR2_arm y BR2_PACKAGE_STRESS y 41 326 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com Using and creating a defconfig gt To use a defconfig copying it to config is not sufficient as all the missing default options need to be expanded gt Buildroot allows to load defconfig stored in the configs directory by doing make lt foo gt _defconfig gt It overwrites the current config if any gt To create a defconfig run make savedefconfig gt Saved in the file pointed by the BR2_DEFCONFIG configuration option gt By default points to defconfig in the current directory if the configuration was started from scratch or points to the original defconfig if the configuration was loaded from a defconfig gt Move it to configs to make it easily loadable with make lt foo gt _defconfig free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 42
75. ernel package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 50 326 Source tree 3 5 gt package gt all the user space packages 1600 busybox gcc qt5 etc pkg generic mk core package infrastructure pkg cmake mk pkg autotools mk pkg perl mk etc Specialized package infrastructures logic to generate filesystem images in various formats common mk common logic cpio ext2 squashfs tar ubifs etc gt boot gt gt bootloader packages at91bootstrap3 barebox grub syslinux uboot etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 51 326 Source tree 4 5 gt configs gt default configuration files for various platforms gt similar to kernel defconfigs gt atmel_xplained_defconfig beaglebone_defconfig raspberrypi_defconfig etc gt board gt board specific files kernel configuration files kernel patches image flashing scripts etc gt typically go together with a defconfig in configs gt support gt misc utilities kconfig code libtool patches download helpers and more free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 52 326 Source tree 5 5 gt docs gt Buildroot documentation g
76. f80afdcba81d9754f6104f863dea803 Patching libtool 896ce554f80afdcba81d9754f6104f863dea803 Building 896ce554f80afdcba81d9754f6104f863dea803 Installing to target free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 240 326 Package specific targets advanced gt Additional useful targets gt gt gt make lt pkg gt show depends show the package dependencies ake lt pkg gt graph depends generates a dependency graph ake lt pkg gt dirclean completely remove the package source code directory The next make invocation will fully rebuild this package ake lt pkg gt reinstall force to re execute the installation step of the package make lt pkg gt rebuild force to re execute the build and installation steps of the package make lt pkg gt reconfigure force to re execute the configure build and installation steps of the package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 241 326 Package specific targets example 2 make strace 4 4 10 4 10 4 4 4 gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt strace strace strace strace strace strace strace 10 10 10 10 a 10 Extracting Patching Updating config sub and config guess Patching libtool Configuring Bu
77. fresh the patch quilt refresh free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 191 326 Advanced package aspects User permission and device tables free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 192 326 Package specific users gt The default skeleton in system skeleton has a number of default users groups gt Packages can define their own custom users groups using the lt pkg gt _USERS variable define lt pkg gt _USERS username uid group gid password home shell groups comment endef gt Examples define AVAHI_USERS awalai i awela lt lt 2 endef define MYSQL_USERS mysql 1 nogroup 1 var mysql MySQL daemon endef free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 193 326 File permissions and ownership gt By default before creating the root filesystem images Buildroot changes the ownership of all files to 0 2 i e root root gt Permissions are preserved as is but since the build is executed as non root it is not possible to install setuid applications gt A default set of permissions for certain files or directories is defined in system device_table txt gt The lt pkg gt _PERMISSIONS variable allows packages to define sp
78. ften you don t build packages manually Buildroot builds them for you gt But Buildroot also downloads them for you and keeps the source code in the package build directory gt Not very practical during development gt The build directory is temporary gets removed when doing a make clean or make lt pkg gt dirclean gt The build directory isn t checked out from your version control system gt Buildroot should for certain packages pick up the source from a local directory gt This is exactly what lt pkg gt _OVERRIDE_SRCDIR allows to do free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 255 326 Without lt pkg gt _OVERRIDE_SRCDIR gt The normal package build process when lt pkg gt _OVERRIDE_SRCDIR is not used is 1 Package gets downloaded as a tarball or from a VCS repository in which case a tarball is generated 2 The tarball is extracted in 0 build lt pkg gt lt version gt 3 Then the configure build and installs steps are executed gt 0 build lt pkg gt lt version gt does not contain any VCS metadata and is a temporary directory gt Running make lt pkg gt reconfigure make lt pkg gt rebuild make lt pkg gt reinstall only restarts the build process from one of the corresponding steps free electrons Embedded Linux kernel drivers and Android Development consulting training and support http
79. g code from the kernel in support kconfig variable CONFIG gt kconfig tools are built in BUILD_DIR buildroot config gt The main Config in file passed to config is at the top level of the Buildroot source tree CONFIG_CONFIG_IN Config in CONFIG support kconfig BR2_CONFIG CONFIG_DIR config include BR2_CONFIG BUILD_DIR buildroot config onf mkdir p D lxdialog MAKE C CONFIG f Makefile br F menuconfig BUILD_DIR buildroot config mconf outputmakefile mkdir p BUILD_DIR buildroot config COMMON_CONFIG_ENV lt CONFIG_CONFIG_IN free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 269 326 Configuration hierarchy gt arch Config in arm gt arch Config in mips gt arch Config in nios2 gt arch Config in x86 i arget options arch Config in Build options gt gt Config in gt toolchain toolchain buildroot Config in i aos gt toolchain toolchain external Config in erp fi z ti toolchain Config in _L toolchain toolchain common in ystem configuration lt gt system config in Kernel SES linux Config in gt package python Config in gt package qt Config in Target packages gt package Canfiy an package busybox Config in Filesystem images fs Config in gt fs ext2 Config in gt fs ubifs Config in Bootloaders gt boot c
80. g components easy free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 22 326 Embedded Linux build system tools gt A wide range of solutions Yocto OpenEmbedded PT Xdist Buildroot LTIB OpenBricks OpenWRT and more gt Today two solutions are emerging as the most popular ones gt Yocto OpenEmbedded Builds a complete Linux distribution with binary packages Powerful but somewhat complex and quite steep learning curve gt Buildroot Builds a root filesystem image no binary packages Much simpler to use understand and modify free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 23 326 Introduction to Buildroot Introduction to Buildroot Embedded Linux Experts free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 24 326 Buildroot at a gl uildroot at a glance gt Can build a toolchain a rootfs a kernel a bootloader gt Easy to configure menuconfig xconfig etc gt Fast builds a simple root filesystem in a few minutes gt Easy to understand written in make extensive documentation gt
81. h you
82. he build output gt Customize the root filesystem using a rootfs overlay gt Use a post build script gt Customize the kernel with patches and additional configuration options gt Add more packages gt Use defconfig files and out of tree build free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 99 326 Download infrastructure in Buildroot Download infrastructure in Buildroot Embedded Linux Experts free electrons Copyright 2004 2015 Free Electro Creative Commons BY SA 3 0 lic Corrections suggestions contri jod tions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 100 326 free Introduction gt One important aspect of Buildroot is to fetch source code or binary files from third party projects gt Download supported from HTTP S FTP Git Subversion CVS Mercurial etc gt Being able to do reproducible builds over a long period of time requires understanding the download infrastructure electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 101 326 Download location gt Each Buildroot package indicates in its mk file which files it needs to be downloaded gt Can be a tarball one or several patches binar
83. he section about creating your own Buildroot packages free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 83 326 Cleanup step gt Once all packages have been installed a cleanup step is executed to reduce the size of the root filesystem gt It mainly involves gt Removing header files pkg config files CMake files static libraries man pages documentation gt Stripping all the programs and libraries using strip to remove unneeded information Depends on BR2_ENABLE_DEBUG and BR2_STRIP_ options gt Additional specific clean up steps clean up unneeded Python files when Python is used etc See TARGET_FINALIZE_HOOKS in the Buildroot code free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 84 326 Root filesystem overlay gt To customize the contents of your root filesystem to add configuration files scripts symbolic links directories or any other file one possible solution is to use a root filesystem overlay gt A root filesystem overlay is simply a directory whose contents will be copied over the root filesystem after all packages have been installed Overwriting files is allowed gt The option BR2_ROOTFS_OVERLAY contains a space separated list of overlay paths grep BR2_ROOTFS_OVERLAY config BR2_ROOTFS_OVERLAY board myproject roo
84. ications and libraries free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 19 326 System integration several possibilities Pros Cons Building everything manually Full flexibility Learning experience Dependency hell Need to understand a lot of details Version compatibility Lack of reproducibility Binary distribution Debian Ubuntu Fedora etc Easy to create and extend Hard to customize Hard to optimize boot time size Hard to rebuild the full system from source Large system Uses native compilation slow No well defined mechanism to gen erate an image Lots of mandatory dependencies Not available for all architectures Build systems Buildroot Yocto PTXdist etc Nearly full flexibility Built from source customization and optimization are easy Fully reproducible Uses cross compilation Have embedded specific packages not necessarily in desktop distros Make more features optional Not as easy as a binary distribution Build time free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com Embedded Linux build system principle gt Building from source lot of flexibility gt Cross compilation leveraging fast build machines gt Recipes for buildin
85. ilding Installing to target ls output build strace 4 10 make strace dirclean rm Rf home thomas projets buildroot output build strace 4 10 ls output build no strace 4 10 directory ESA free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 242 326 Package specific targets example 3 make strace gt gt gt strace 4 10 Extracting gt gt gt strace 4 10 Patching gt gt gt strace 4 10 Updating config sub and config guess gt gt gt strace 4 10 Patching libtool gt gt gt strace 4 10 Configuring gt gt gt strace 4 10 Building gt gt gt strace 4 10 Installing to target make strace rebuild gt gt gt strace 4 10 Building gt gt gt strace 4 10 Installing to target make strace reconfigure gt gt gt strace 4 10 Configuring gt gt gt strace 4 10 Building gt gt gt strace 4 10 Installing to target free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 243 326 Understanding rebuilds 1 gt Doing a full rebuild is achieved using make clean all gt It will completely remove all build artefacts and restart the build from scratch gt Buildroot does not try to be smart gt once the system has been built if a configuration change is made the next make will not apply all the changes made to
86. in package option is a bool with the package name as the prompt Will be visible in menuconfig gt The help text give a quick description and the homepage of the project free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 122 326 package lt pkg gt Config in inclusion gt The hierarchy of configuration options visible in menuconfig is built by reading the top level Config in file and the other Config in file it includes gt All package lt pkg gt Config in files are included from package Config in gt The location of a package in one of the package sub menu is decided in this file package Config in menu Target packages menu Audio and video applications source package alsa utils Config in endmenu menu Libraries menu Audio Sound source package alsa lib Config in endmenu free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 123 326 package lt pkg gt Config in dependencies gt kconfig allows to express dependencies using select or depends on statements gt select is an automatic dependency if option A select option B as soon as A is enabled B will be enabled and cannot be unselected gt depends on is a user assisted dependency if option A depends on option B A will only be visible when B is enabled gt Buil
87. ining and support http free electrons com 164 326 Python package infrastructure basics gt Modules for the Python language often use distutils or setuptools as their build installation system gt Buildroot provides a python package infrastructure for such packages gt Supports all the generic package metadata information source site license etc gt Adds a mandatory variable lt pkg gt _SETUP_TYPE which must be set to either distutils or setuptools gt And several optional variables to further adjust the build lt pkg gt _ENV lt pkg gt _BUILD_OPTS lt pkg gt _INSTALL_TARGET_OPTS lt pkg gt _INSTALL_STAGING_OPTS lt pkg gt _INSTALL_OPTS lt pkg gt _NEEDS_HOST_PYTHON free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 165 326 Python package simple example python serial mk PYTHON_SERIAL_VERSION 2 6 PYTHON_SERIAL_SOURCE pyserial PYTHON_SERIAL_VERSION tar gz PYTHON_SERIAL_SITE http pypi python org packages source p pyserial PYTHON_SERIAL_LICENSE Python Software Foundation License PYTHON_SERTAL_LICENSE_FILES LICENSE txt PYTHON_SERIAL_SETUP_TYPE distutils eval python package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 166 326 Python package more complicated example python serial mk PYTHON_LXML_VERS
88. inx zc706 ARC AXS101 and AXS103 gt Infrastructure gt Filesystems Complete rework of the ISO9660 support ree electrons Embedded Linux gt gt gt gt gt gt Predictable permissions in the generated rootfs Support for kconfig fragments New kernel module infrastructure Rework of the skeleton and init scripts packaging New linux tools infrastructure in the linux package GCC version dependency mechanism kernel drivers and Android Development consulting training and support http free elec trons com 323 326 Acknowled t cknowledgements gt Free Electrons would like to thank the following members of the Buildroot community for their useful comments and reviews during the development of these training materials gt Thomas De Schampheleire Peter Korsgaard Yann E Morin Arnout Vandecappelle Gustavo Zacarias v vyv y free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 324 326 Last slides Embedded Linux Experts Last slides free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 325 326 Last slide Thank you And may the Source be wit
89. kes Buildroot build the entire cross compilation toolchain from source gt Provides a lot of flexibility in the configuration of the toolchain gt Kernel headers version gt C library Buildroot supports uClibc e glibc and musl gt e glibc the standard C library Good choice if you don t have tight space constraints gt 10 MB gt uClibc and musl smaller C libraries uClibc supports non MMU architectures Good for very small systems lt 10 MB gt Different versions of binutils and gcc Keep the default versions unless you have specific needs gt Numerous toolchain options C LTO OpenMP libmudflap graphite and more depending on the selected C library gt Building a toolchain takes quite some time 15 20 minutes on moderately recent machines free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 66 326 Internal toolchain backend result gt host usr bin lt tuple gt lt tool gt the cross compilation tools compiler linker assembler and more gt host usr lt tuple gt gt sysroot usr include the kernel headers and C library headers gt sysroot lib and sysroot usr lib C library and gcc runtime gt include c C library headers gt lib host libraries needed by gcc binutils gt target gt lib and usr lib C and C libraries gt The compiler is configured to gt generate code for the archit
90. l drivers and Android Development consulting training and support http free electrons com 180 326 Licensing information examples linux mk LINUX_LICENSE GPLv2 LINUX_LICENSE_FILES COPYING acl mk ACL_LICENSE GPLv2 programs LGPLv2 1 libraries ACL_LICENSE_FILES doc COPYING doc COPYING LGPL owl linux mk OWL_LINUX_LICENSE PROPRIETARY OWL_LINUX_LICENSE_FILES LICENSE OWL_LINUX_REDISTRIBUTE NO free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 181 326 Advanced package aspects Patching packages free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 182 326 Patching packages why gt In some situations it might be needed to patch the source code of certain packages built by Buildroot gt Useful to gt Fix cross compilation issues gt Backport bug or security fixes from upstream gt Integrate new features or fixes not available upstream or that are too specific to the product being made gt Patches are automatically applied by Buildroot during the patch step i e after extracting the package but before configuring it gt Buildroot already comes with a number of patches for various packages but you may need to add more for your own packages or to existing packages free electrons Embedded Linux kernel drivers an
91. l world lt world target post image ae target post image TARGET_ROOTFS target finalize contains the list of root filesystem and calls the post image scripts image types to generate target finalize TARGETS and does the root filesystem finalization remove headers remove doc stripping copy rootfs overlays run post build scripts etc rootfs ubifs lt contains the list of packages to build Dependency exists for all packages Note arrows indicate a make dependency So in practice the build order is the reverse of the arrow direction Buildroot community support and contribution Buildroot community support and contribution Embedded Linux Experts free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 298 326 Documentation Buildroot comes with its own documentation v Pre built versions available at http buildroot org docs html PDF HTML text Source code of the manual located in docs manual in the Buildroot sources gt Written in Asciidoc format v v The manual can be built with gt make manual gt or just make manual html make manual pdf make manual epub make manual text make manual split html gt A number of t
92. l and external toolchains Link time optimization LTO support free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 321 326 In 2015 05 2 gt Defconfigs Freescale i MX28 EVK i MX31 PDK and SABRE Auto Raspberry Pi 2 RloTboard gt Infrastructure gt gt gt gt Hashes for a large number of packages have been added Missing hashes now stop the build unless explicitly disabled Spaces and colons are now supported in package versions Dependencies can now be listed for the patch step lt PKG gt _PATCH_DEPENDENCIES Kconfig and Linux kernel extensions infrastructure has been added gt Makedevs now has a recursive r option gt external deps legal info source source check have been reimplemented using the package infrastructure so their output behaviour may differ from earlier some packages were not included in the past free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 322 326 I In 2015 08 gt Architectures Minimal support for ARM Cortex M3 and AArch64 big endian gt Toolchains Use uClibc ng by default add gcc 5 x support update toolchain components gt Defconfigs VIA VAB 820 AMOS 820 OLimex OLinuxino A20 Lime many Atmel evaluation boards ACME Systems Aria G25 WarPboard Altera Cyclone 5 Development Board Xil
93. ld buildroot org toolchains tarballs br arm full 2015 02 tar bz2 Toolchain URL ARCH Linux Toolchain prefix NEW External toolchain kernel headers series 3 18 x gt External toolchain C library uClibc gt Toolchain has WCHAR support Toolchain has locale support Toolchain has threads support NEW Toolchain has threads debugging support Toolchain has NPTL threads support NEW Toolchain has SSP support NEW Toolchain has RPC support Toolchain has C support Extra toolchain libraries to be copied to target NEW Copy gdb server to the Target NEW Build cross gdb for the host NEW Purge unwanted locales NEW Enable MMU support NEW Target Optimizations NEW Target linker options NEW Register toolchain within Eclipse Buildroot plug in NEW free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 71 326 Oo External toolchain result gt host opt ext toolchain where the original toolchain tarball is extracted Except when a local pre installed toolchain is used gt host usr bin lt tuple gt lt tool gt symbolic links to the cross compilation tools in their original location Except the compiler which points to a wrapper program gt host usr lt tuple gt gt sysroot usr include the kernel headers and C library headers gt sysroot lib and sysroot us
94. license etc gt host licenses lt pkg gt the full license text of all host packages per package gt host licenses txt the full license text of all host packages in a single file gt licenses txt the full license text of all target packages in a single file gt README gt licenses the full license text of all target packages per package manifest csv a CSV file with the list of target packages their version license etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 179 326 Including licensing information in packages gt lt pkg gt _LICENSE gt Comma separated list of license s under which the package is distributed gt Free form string but should if possible use the license codes from https spdx org licenses gt Can indicate which part is under which license programs tests libraries etc gt lt pkg gt _LICENSE_FILES gt Space separated list of file paths from the package source code containing the license text and copyright information gt Paths relative to the package top level source directory gt lt pkg gt _REDISTRIBUTE gt Boolean indicating whether the package source code can be redistributed or not part of the legal info output gt Defaults to YES can be overridden to NO gt If NO source code is not copied when generating the licensing report free electrons Embedded Linux kerne
95. ll install something to one of these locations gt lt pkg gt _INSTALL_TARGET defaults to YES If YES then lt pkg gt _INSTALL_TARGET_CMDS will be called gt lt pkg gt _INSTALL_STAGING defaults to NO If YES then lt pkg gt _INSTALL_STAGING_CMDS will be called gt lt pkg gt _INSTALL_IMAGES defaults to NO If YES then lt pkg gt _INSTALL_IMAGES_CMDS will be called free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 151 326 Defining where to install 2 gt A package for an application gt installs to TARGET_DIR only gt lt pkg gt _INSTALL_TARGET defaults to YES so there is nothing to do gt A package for a shared library gt installs to both TARGET_DIR and STAGING_DIR gt must set lt pkg gt _INSTALL_STAGING YES gt A package for a pure header based library or a static only library gt installs only to STAGING_DIR gt must set lt pkg gt _INSTALL_TARGET NO and lt pkg gt _INSTALL_STAGING YES gt A package installing a bootloader or kernel image gt installs to BINARIES_DIR gt must set lt pkg gt _INSTALL_IMAGES YES free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 152 326 Defining where to install 3 libyaml mk LIBYAML_INSTALL_STAGING YES eigen mk EIGEN_INSTALL_STAGING YES EIGEN_INSTALL_TAR
96. llows to pass additional compiler flags when building target packages gt Do not pass flags to select a CPU or FPU these are already passed by Buildroot gt Be careful with the flags you pass they affect the entire build gt Target linker options gt Allows to pass additional linker flags when building target packages gt gdb and Eclipse related options gt Covered in our Application development section later free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 74 326 Managing the Linux kernel configuration Managing the Linux kernel configuration Embedded Linux Experts free electrons Copyri ar 2004 2015 Free Electron reative Commons BY SA 3 0 lic ian 5 free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 75 326 Introduction gt The Linux kernel itself uses kconfig to define its configuration gt Buildroot cannot replicate all Linux kernel configuration options in its menuconfig gt Defining the Linux kernel configuration therefore needs to be done in a special way gt Note while described with the example of the Linux kernel this discussion is also valid for other packages using kconfig barebox uclibc busybox and in the near future u boot free electrons Embedded Linux kernel drivers and Android Development cons
97. ly specific patches gt The global patch directories mechanism allows to specify additional locations where Buildroot will look for patches to apply on packages gt BR2_GLOBAL_PATCH_DIR specifies a space separated list of directories containing patches gt These directories must contain sub directories named after the packages themselves containing the patches to be applied free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 187 326 Global patch directory example Patching strace ls package strace patch 0001 linux aarch64 add missing header patch find patches patches patches strace patches strace 0001 Demo strace change patch grep BR2_GLOBAL_PATCH_DIR config BR2_GLOBAL_PATCH_DIR HOME patches make strace Eea gt gt gt strace 4 10 Patching Applying 0001 linux aarch64 add missing header patch using patch patching file linux aarch64 arch_regs h Applying 0001 Demo strace change patch using patch patching file README Er free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 188 326 G ti tch enerating patches gt To generate the patches against a given package source code there are typically two possibilities gt Use the upstream version control system often Git gt Use a tool called quilt gt Us
98. ly be temporary this directory is removed during a make clean free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 247 326 Tips for building faster gt Build time is often an issue so here are some tips to help gt gt gt gt gt Use fast hardware lots of RAM and SSD Do not use virtual machines You can enable the ccache compiler cache using BR2_CCACHE Use external toolchains instead of internal toolchains Learn about rebuilding only the few packages you actually care about gt Build everything locally do not use NFS for building Remember that you can do several independent builds in parallel in different output directories free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 248 326 Practical lab Advanced aspects gt Use legal info for legal information extraction gt Use graph depends for dependency graphing gt Use graph build for build time graphing gt Use BR2_EXTERNAL to isolate the project specific changes packages configs etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 249 326 Application development Embedded Linux Experts Application development free electrons Copyright 2004 2015 Free Electrons C
99. m 303 326 Patchwork gt Tool that records all patches sent on the mailing list gt Allows the community to see which patches need review testing and the maintainers which patches can be applied gt Everyone can create an account to manage his own patches gt http patchwork buildroot org Incoming patches Filters State Action Required Archived No Patch A R T Date Submitter Delegate State 1 1 python pyat fix opengl build failure 000 aha Gwenhael Goavec Merou New i 1 1 ot fix missing target 000 2015 05 Gwenhael Goavec Merou New v3 3 3 expect bump to version 5 45 3 101 a0 Fabio Porcedda New ae A eae 2015 05 3 2 3 manual cvs document that a branch or a date can be used 000 2 Fabio Porcedda New FETA 7 sain Peis 2015 05 i v3 1 3 support download cvs add support to use a date instead of a tag ia 2 Fabio Porcedda New package poppler autoconf options take two dashes 000 801505 Yann E MORIN New 7 2015 05 cc tool fix static build problem with boost regex ooo 2 Thomas Petazzoni New cryptsetup disable on broken NIOS 2 toolchains 000 puao Thomas Petazzoni New 2 2 packagellibtirpc Add patches to fix mus build 000 01505 J rg Krause New free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 304 326 Automated build testing gt The enormous number of configuration options in B
100. m configuration file is used free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 78 326 Typical fl ypical flow 1 make menuconfig gt Start with a defconfig from the kernel say mvebu_v7_defconfig 2 Run make linux menuconfig to customize the configuration 3 Do the build test tweak the configuration as needed 4 You cannot do make linux update config defconfig since the Buildroot configuration points to a kernel defconfig 5 make menuconfig gt Change to a custom configuration file There s no need for the file to exist it will be created by Buildroot 6 make linux update defconfig gt Will create your custom configuration file as a minimal defconfig free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 79 326 Root filesystem in Buildroot Root filesystem in Buildroot Embedded Linux Experts free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 80 326 Overall rootfs construction steps Copy the skeleton gt Build install gt Run a number of to TARGET_DIR all packages cleanup steps l
101. ming conventions global namespace gt The package infrastructure expects all variables it uses to be prefixed by the uppercase package name gt If your package needs to define additional private variables not used by the package infrastructure they should also be prefixed by the uppercase package name gt The namespace of variables is global in Buildroot gt If two packages created a variable named BUILD_TYPE it will silently conflict electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 139 326 Behind the scenes gt Behind the scenes eval generic package gt is a make macro that is expanded gt infers the name of the current package by looking at the directory name package lt pkg gt lt pkg gt mk lt pkg gt is the package name gt will use all the variables prefixed by lt PKG gt _ gt and expand to a set of make rules and variable definitions that describe what should be done for each step of the package build process free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 140 326 mk file accessing the configuration gt The Buildroot config file is a succession of lines name value gt This file is valid make syntax gt The main Buildroot Makefile simply includes it which turns every Buildroot configuration option into a make va
102. n a Signed off by that identifies the author of the patch free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 185 326 Patch example From 81289d1d1adaf5a767a4b4d1309c286468cfd37f Mon Sep 17 00 00 00 2001 From Samuel Martin lt s martin49 gmail com gt Date Thu 24 Apr 2014 23 27 32 0200 Subject PATCH 1 5 auto type sizeof rework autotest to be cross compilation friendly Rework the sizeof test to do the checks at compile time instead of at runtime This way it does not break when cross compiling for a different CPU architecture Signed off by Samuel Martin lt s martin49 gmail com gt auto types sizeof 42 tt tttttttttttttttttttt tt tenn 9 onan 1 file changed 28 insertions 14 deletions diff git a auto types sizeof b auto types sizeof index 9215a54 c2c3ede 100644 a auto types sizeof b auto types sizeof 14 7 14 7 END ngx_size cat lt lt END gt NGX_AUTOTEST c cat lt lt _EOF gt NGX_AUTOTEST c Bossa free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 186 326 Global patch directories gt You can include patches for the different packages in their package directory package lt pkg gt gt However doing this involves changing the Buildroot sources themselves which may not be appropriate for some high
103. n avoids the need to pass O and the path to the Buildroot source tree free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 38 326 Out of tree build example 1 You are in your Buildroot source tree 1s arch board boot Makefile package 2 Create a new output directory and move to it we mkdir foobar output cd foobar output ow 3 Start a new Buildroot configuration oe make C buildroot O pwd menuconfig 4 Start the build passing O and C no longer needed thanks to the wrapper a make 5 Adjust the configuration again restart the build clean the build a make menuconfig make make clean ae free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 39 326 Full config file vs defconfig gt The config file is a full config file it contains the value for all options except those having unmet dependencies gt The default config without any customization has 2655 lines as of Buildroot 2015 08 gt Not very practical for reading and modifying by humans gt A defconfig stores only the values for options for which the non default value is chosen gt Much easier to read gt Can be modified by humans gt Can be used for automated construction of configurations free electrons Embedded Linux k
104. n be built using BR2_PACKAGE_HOST_GDB y gt gdbserver gt With the internal toolchain backend can be built using BR2_PACKAGE_GDB y BR2_PACKAGE_GDB_SERVER y gt With the external toolchain backend if gdbserver is provided by the toolchain it can be copied to the target using BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY y or otherwise built from source like with the internal toolchain backend free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 262 326 Debugging remote debugging setup gt On the target start gdbserver gt Use a TCP socket network connectivity needed gt The multi mode is quite convenient gt gdbserver multi localhost 2345 gt On the host start lt tuple gt gdb gt output host usr bin lt tuple gt gdb lt program gt gt lt program gt is the path to the program to debug with debugging symbols gt Inside gdb you need to gt Connect to the target gdb target remote extended lt ip gt 2345 gt Set the path to the sysroot so that gdb can find debugging symbols for libraries gdb set sysroot output staging gt Start the program gdb run free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 263 326 Debugging tools available in Buildroot gt Buildroot also includes a huge amount of other debugging or
105. ncy graph which can be huge gt make lt pkg gt graph depends to generate the dependency graph of a given package gt The graph is done according to the current Buildroot configuration gt Resulting graphs in 0 graphs free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 223 326 Dependency graphing advanced gt Variable BR2_GRAPH_OUT to select the output format Defaults to pdf can be png or svg for example gt Internally the graph is generated by the Python script support scripts graph depends gt All options that this script supports can be passed using the BR2_GRAPH_DEPS_OPTS variable when calling make graph depends gt Example gt Generate a PNG graph of the openssh package dependencies gt Custom colors gt Stop graphing on the host automake package to remove a part of the graph we re not interested in BR2_GRAPH_OUT png BR2_GRAPH_DEPS_OPTS colours red blue green stop on host automake make openssh graph depends free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 225 326 Build ti hi uild time graphing gt When the generated embedded Linux system grows bigger and bigger the build time also increases gt It is sometimes useful to analyze this build time and see if certain packages are particularly problematic
106. nding on the configuration this directory will contain gt One or several root filesystem images in various formats gt One kernel image possibly one or several Device Tree blobs gt One or several bootloader images gt There is no standard way to install the images on any given device gt Those steps are very device specific gt Buildroot provides some tools for specific platforms e g SAM BA for Atmel imx usb loader for i MX6 etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 33 326 free Practical lab Basic Buildroot usage gt Get Buildroot gt Configure a minimal system with Buildroot for the BeagleBone Black gt Do the build gt Prepare the BeagleBone Black for usage gt Flash and test the generated system electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 34 326 Managing the build and the configuration Managing the build and the configuration Embedded Linux Experts free electrons 35 326 Default build organization gt By default gt All the build output goes into a directory called output within the top level Buildroot source directory gt O output gt The configuration file is stored as config in the top level Buildroot source directory gt CONFIG_DIR TOPDIR gt TOPDIR shell
107. ndroid Development consulting training and support http free electrons com 196 326 xenomai mk define XENOMAI_DEVICES dev rtheap c 666 10 254 dev rtscope c 666 10 253 dev rtp c 666 150 o i 82 endef Advanced package aspects Init scripts and systemd unit files free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 198 326 Init scripts systemd unit files gt Buildroot supports several main init systems sysvinit Busybox and systemd gt When packages want to install a program to be started at boot time they need to install either a startup script sysvinit Busybox or a systemd service file gt They can do so with the lt pkg gt _INSTALL_INIT_SYSV and lt pkg gt _INSTALL_INIT_SYSTEMD variables which contain a list of shell commands gt Buildroot will execute either the lt pkg gt _INSTALL_INIT_SYSV or the lt pkg gt _INSTALL_INIT_SYSTEMD commands of all enabled packages depending on the selected init system free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 199 326 Init scripts systemd unit files example bind mk define BIND_INSTALL_INIT_SYSV CINSTALL m 0755 D package bind S81named TARGET_DIR etc init d S81named endef define BIND_INSTALL_INIT_SYSTEMD CINSTALL D m 644 package bind named service
108. nfrastructure free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 160 326 The autotools package infrastructure variables gt It provides additional variables that can be defined by the package gt lt pkg gt _CONF_ENV to pass additional values in the environment of the configure script lt pkg gt _CONF_OPTS to pass additional options to the configure script lt pkg gt _INSTALL_OPTS lt pkg gt _INSTALL_STAGING_OPTS and lt pkg gt _INSTALL_TARGET_OPTS to adjust the make target and options used for the installation lt pkg gt _AUTORECONF Defaults to NO can be set to YES if regenerating Makefile in files and configure script is needed The infrastructure will automatically make sure autoconf automake libtool are built lt pkg gt _GETTEXTIZE Defaults to NO can be set to YES to gettextize the package Only makes sense if lt pkg gt _AUTORECONF YES free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 161 326 Canonical autotools package example libyaml mk LIBYAML_VERSION 0 1 6 LIBYAML_SOURCE yaml LIBYAML_VERSION tar gz LIBYAML_SITE http pyyaml org download libyaml LIBYAML_INSTALL_STAGING YES LIBYAML_LICENSE MIT LIBYAML_LICENSE_FILES LICENSE eval autotools package free electrons Embedded Linux kernel drivers an
109. ng gt To use debuggers you need the programs and libraries to be built with debugging symbols gt The BR2_ENABLE_DEBUG option controls whether programs and libraries are built with debugging symbols gt Disabled by default gt Sub options allow to control the amount of debugging symbols i e gcc options g1 g2 and g3 gt The BR2_STRIP_none and BR2_STRIP_strip options allow to disable or enable stripping of binaries on the target free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 260 326 Debugging debugging symbols and stripping gt With BR2_ENABLE_DEBUG y and BR2_STRIP_strip y gt get debugging symbols in STAGING_DIR for libraries and in the build directories for everything gt stripped binaries in TARGET_DIR gt Appropriate for remote debugging gt With BR2_ENABLE_DEBUG y and BR2_STRIP_none y gt debugging symbols in both STAGING_DIR and TARGET_DIR gt appropriate for on target debugging free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 261 326 Debugging remote debugging requirements gt To do remote debugging you need gt A cross debugger gt With the internal toolchain backend can be built using BR2_PACKAGE_HOST_GDB y gt With the external toolchain backend is either provided pre built by the toolchain or ca
110. ning and support http free electrons com 128 326 Config in sub options gt Additional sub options can be defined to further configure the package to enable or disable extra features gt The value of such options can then be fetched from the package mk file to adjust the build accordingly gt Run time configuration does not belong to Config in package pppd Config in config BR2_PACKAGE_PPPD bool pppd depends on BR2_STATIC_LIBS depends on BR2_USE_MMU if BR2_PACKAGE_PPPD config BR2_PACKAGE_PPPD_FILTER bool filtering select BR2_PACKAGE_LIBPCAP help Packet filtering abilities for pppd If enabled the pppd active filter and pass filter options are available config BR2_PACKAGE_PPPD_RADIUS bool radius help Install RADIUS support for pppd endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 129 326 Integrating new packages in Buildroot Package infrastructures free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 130 326 Package infrastructures what is it gt Each software component to be built by Buildroot comes with its own build system gt Buildroot does not re invent the build system of each component it simply uses it gt Numerous build systems available hand written Makefiles or shell scripts autoto
111. ns gt With the recommended structure shown before a Buildroot configuration would look like BR2_GLOBAL_PATCH_DIR BR2_EXTERNAL board lt company gt lt boardname gt patches BR2_ROOTFS_OVERLAY BR2_EXTERNAL board lt company gt lt boardname gt rootfs_overlay BR2_ROOTFS_POST_BUILD_SCRIPT BR2_EXTERNAL board lt company gt lt boardname gt post_build sh BR2_ROOTFS_POST_IMAGE_SCRIPT BR2_EXTERNAL board lt company gt lt boardname gt post_image sh BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG y BR2_LINUX_KERNEL_CUSTOM_CONF IG_FILE BR2_EXTERNAL board lt company gt lt boardname gt 1linux config free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 238 326 Package specific targets basics gt Internally each package is implemented through a number of package specific make targets gt They can sometimes be useful to call directly in certain situations gt The targets used in the normal build flow of a package are lt p lt p lt p lt p lt p lt p lt p vvvvrvyvy yv g gt fully build and install the package g gt source just download the source code g gt extract download and extract g gt patch download extract and patch g gt configure download extract patch and configure g gt build download extract patch configure and build g gt install staging download extract patch
112. ns suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 47 326 Buildroot source and build trees Source tree free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 48 326 Source tree 1 5 gt Makefile gt top level Makefile handles the configuration and general orchestration of the build gt Config in gt top level Config in main general options Includes many other Config in files gt arch gt Config in files defining the architecture variants processor type ABI floating point etc gt Config in Config in arm Config in x86 Config in microblaze etc free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 49 326 Source tree 2 5 gt toolchain gt packages for generating or using toolchains gt toolchain virtual package that depends on either toolchain buildroot or toolchain external gt toolchain buildroot virtual package to build the internal toolchain gt toolchain external package to handle external toolchains gt system gt skeleton the rootfs skeleton gt Config in options for system wide features like init system dev handling etc gt linux gt linux mk the Linux k
113. ok mechanism allows packages to add such custom actions free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 206 326 Hooks principle 2 gt There are pre and post hooks available for all steps of the package compilation process gt download extract rsync patch configure build install install staging install target install images legal info gt lt pkg gt _ PRE POST _ lt step gt _HOOKS gt Example CMAKE_POST_INSTALL_TARGET_HOOKS CVS_POST_PATCH_HOOKS BINUTILS_PRE_PATCH_HOOKS gt Hook variables contain a list of make macros to call at the appropriate time gt Use to register an additional hook to a hook point gt Those make macros contain a list of commands to execute free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 207 326 Hooks ooks examples libungif mk remove unneeded binaries define LIBUNGIF_BINS_CLEANUP rm f addprefix TARGET_DIR usr bin LIBUNGIF_BINS endef LIBUNGIF_POST_INSTALL_TARGET_HOOKS LIBUNGIF_BINS_CLEANUP vsftpd mk adjust configuration define VSFTPD_ENABLE_SSL SED s VSF_BUILD_SSL define VSF_BUILD_SSL D builddefs h endef ifeq BR2_PACKAGE_OPENSSL y VSFTPD_DEPENDENCIES openssl VSFTPD_LIBS lssl lcrypto VSFTPD_POST_CONFIGURE_HOOKS VSFTPD_ENABLE_SSL endif fre
114. ols CMake and also some specific to languages Python Perl Lua Erlang etc gt In order to avoid duplicating code Buildroot has package infrastructures for well known build systems gt And a generic package infrastructure for software components with non standard build systems free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 131 326 Package infrastructures ackage pkg cmake mk ackage pkg autotools mk package pkg luarocks mk p pl p package pkg generic mk generic package package pkg kconfig mk package pkg perl mk package pke python mk free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 132 326 generic package infrastructure gt To be used for software components having non standard build systems gt Implements a default behavior for the downloading extracting and patching steps of the package build process gt Implements init script installation legal information collection etc gt Leaves to the package developer the responsibility of describing what should be done for the configuration building and installation steps free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 133 326 generic package steps install lt _ build lt lt configure
115. onfis in a er ar Host utilities gt package Config in host gt package dfu util Config in host Legacy config options 2s Contae legacy L gt package openocd Config in host free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 270 326 lt all world lt world target post image target post image TARGET_ROOTFS target finalize and calls the post image scripts target finalize TARGETS and does the root filesystem finalization remove headers remove doc stripping copy rootfs overlays run post build scripts etc contains the list of root filesystem image types to generate Note arrows indicate a make dependency So in K A practice the build order is the reverse of the contains the list of packages to build S including kernel toolchain bootloaders and all user space libraries applications Where is TARGETS filled Part of package pkg generic mk argument 1 is the lowercase package name argument 2 is the uppercase package name including a HOST_ prefix for host packages define inner generic package 2 _KCONFIG_VAR BR2_PACKAGE_ 2 ifeq 2 _KCONFIG_VAR y TARGETS 1 endif 2 _KCONFIG_VAR endef inner generic package gt Adds the lowercase name of an enabled package as a make target to the TARGETS variable gt package pkg generic mk is really the core of the
116. onstructs gt Shell variables must be referenced using name package pppd pppd mk define PPPD_INSTALL_RADIUS for m in PPPD_RADIUS_CONF do INSTALL m 644 D PPPD_DIR pppd plugins radius etc m TARGET_DIR etc ppp radius m done endef free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 117 326 Integrating new packages in Buildroot free electrons Integrating new packages in Buildroot free electrons Copyright 2004 2015 Free Electro je Commons BY SA 3 0 lic pars suggestions cottnbutiogs and translations are welcome Embedded Linux kernel drivers and Android Development consul Iting g trai ining and support http free electrons com Embedded Linux Experts 118 326 Why adding new packages in Buildroot v A package in Buildroot speak is the set of meta information needed to automate the build process of a certain component of a system gt Can be used for open source third party proprietary components or in house components gt Can be used for user space components libraries and applications but also for firmware kernel drivers bootloaders etc gt Do not confuse with the notion of binary package in a regular Linux distribution free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons
117. onsulting training and support http free electrons com 211 326 Advanced package aspects Legacy handling Legacy handling Config in legacy gt When a Config in option is removed the corresponding value in the config is silently removed gt Due to this when users upgrade Buildroot they generally don t know that an option they were using has been removed gt Buildroot therefore adds the removed config option to Config in legacy with a description of what has happened gt If any of these legacy options is enabled then Buildroot refuses to build free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 213 326 free Advanced package aspects Virtual packages electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com I Virtual packages gt There are situations where different packages provide an implementation of the same interface gt The most useful example is OpenGL gt OpenGL is an API gt Each HW vendor typically provides its own OpenGL implementation each packaged as separate Buildroot packages gt Packages using the OpenGL interface do not want to know which implementation they are using they are simply using the OpenGL API gt The mechanism of virtual packages in Buildroot allows to solve this situation gt libgles is a virtual package off
118. ools need to be installed on your machine see the manual itself v free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 299 326 Getting support g supp gt Free support gt The mailing list for e mail discussion http lists busybox net mailman listinfo buildroot 1300 subscribers quite heavy traffic gt The IRC channel buildroot on the Freenode network for interactive discussion 100 people most available during European daylight hours gt Bug tracker https bugs busybox net buglist cgi product buildroot gt Commercial support gt A number of embedded Linux services companies including Free Electrons can provide commercial services around Buildroot free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 300 326 Tips to get free support gt If you have a build issue to report gt Make sure to reproduce after a make clean all cycle gt Include the Buildroot version Buildroot config that reproduces the issue and last 100 200 lines of the build output in your report gt Use pastebin sites like http code bulix org when reporting issues over IRC gt The community will be much more likely to help you if you use a recent Buildroot version free electrons Embedded Linux kernel drivers and Android Development consulting training
119. ootfs 1 foreach hook ROOTFS_ 2 _PRE_GEN_HOOKS call hook sep echo chown h R 0 0 TARGET_DIR gt gt FAKEROOT_SCRIPT echo HOST_DIR usr bin makedevs d FULL_DEVICE_TABLE TARGET_DIR gt gt FAKEROOT_SCRIPT echo ROOTFS_ 2 _CMD gt gt FAKEROOT_SCRIPT chmod atx FAKEROOT_SCRIPT PATH BR_PATH HOST_DIR usr bin fakeroot FAKEROOT_SCRIPT rootfs 1 BINARIES_DIR rootfs 1 ROOTFS_ 2 _POST_TARGETS ifeq BR2_TARGET_ROOTFS_ 2 y TARGETS_ROOTFS rootfs 1 endif endef define ROOTFS_TARGET call ROOTFS_TARGET_INTERNAL 1 call UPPERCASE 1 endef free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 295 326 fs ubifs ubifs mk UBIFS_OPTS e BR2_TARGET_ROOTFS_UBIFS_LEBSIZE c BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT m BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE ifeq BR2_TARGET_ROOTFS_UBIFS_RT_ZLIB y UBIFS_OPTS x zlib endif UBIFS_OPTS call qstrip BR2_TARGET_ROOTFS_UBIFS_OPTS ROOTFS_UBIFS_DEPENDENCIES host mtd define ROOTFS_UBIFS_CMD HOST_DIR usr sbin mkfs ubifs d TARGET_DIR UBIFS_OPTS o endef eval call ROOTFS_TARGET ubifs free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 296 326 lt al
120. opment consulting training and support http free electrons com 148 326 Dependencies mpd example 1 2 package mpd Config in menuconfig BR2_PACKAGE_MPD bool mpd depends on BR2_INSTALL_LIBSTDCPP select BR2_PACKAGE_BOOST select BR2_PACKAGE_LIBGLIB2 select BR2_PACKAGE_LIBICONV if BR2_ENABLE_LOCALE Eon odl config BR2_PACKAGE_MPD_FLAC bool flac select BR2_PACKAGE_FLAC help Enable flac input streaming support Select this if you want to play back FLAC files free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 149 326 Dependencies mpd example 2 2 package mpd mpd mk MPD_DEPENDENCIES host pkgconf boost libglib2 ESS ifeq BR2_PACKAGE_MPD_FLAC y MPD_DEPENDENCIES flac MPD_CONF_OPTS enable flac else MPD_CONF_OPTS disable flac endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 150 326 Defining where to install 1 gt Target packages can install files to different locations gt To the target directory TARGET_DIR which is what will be the target root filesystem gt To the staging directory STAGING_DIR which is the compiler sysroot gt To the images directory BINARIES_DIR which is where final images are located gt There are three corresponding variables to define whether or not the package wi
121. our participation can make our session more interactive and make the topics easier to learn free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 9 326 Practical lab guidelines 5 During practical labs gt We cannot support more than 8 workstations at once each with its board and equipment Having more would make the whole class progress slower compromising the coverage of the whole training agenda exception for public sessions up to 10 people gt So if you are more than 8 participants please form up to 8 working groups gt Open the electronic copy of your lecture materials and use it throughout the practical labs to find the slides you need again gt Don t hesitate to copy and paste commands from the PDF slides and labs free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 10 326 Advise write down your commands During practical labs write down all your commands in a text file gt You can save a lot of time re using commands in later labs This helps to replay your work if you make significant mistakes You build a reference to remember commands in the long run That s particular useful to keep kernel command line settings that you used earlier Also useful to get help from the instructor showing the commands that you run
122. package defining variables Macro code 2 _TYPE 2 _NAME 2 _RAWNAME 4 1 patsubst host 1 2 _BASE_NAME 1 2 _VERSION 2 _DIR BUILD_DIR 2 _BASE_NAME ifndef 2 _SOURCE ifdef 3 _SOURCE 2 _SOURCE 3 _SOURCE else 2 _SOURCE 2 RAWNAME 2 VERSION tar gz endif endif ifndef 2 _SITE ifdef 3 _SITE 2 _SITE 3 _SITE endif endif Expanded for host zlib HOST_ZLIB_TYPE host HOST_ZLIB_NAME host zlib HOST_ZLIB_RAWNAME zlib HOST_ZLIB_BASE_NAME host zlib HOST_ZLIB_VERSION HOST_ZLIB_DIR BUILD_DIR host zlib HOST_ZLIB_VERSION ifndef HOST_ZLIB_SOURCE ifdef ZLIB_SOURCE HOST_ZLIB_SOURCE ZLIB_SOURCE else HOST_ZLIB_SOURCE zlib HOST_ZLIB_VERSION tar gz endif endif ifndef HOST_ZLIB_SITE ifdef ZLIB_SITE HOST_ZLIB_SITE ZLIB_SITE endif endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 278 326 inner generic package dependencies ifeq 4 host 2 _DEPENDENCIES filter out host toolchain 1 patsubst host host host addprefix host 3 DEPENDENCIES endif gt Dependencies of host packages if not explicitly specified are derived from the dependencies of the target package by adding a host prefix to each dependency gt If a package foo defines FOO_DEPENDENCIES bar baz
123. r host packages gt Most of the packages in Buildroot are target packages i e they are cross compiled for the target architecture and meant to be run on the target platform gt Some packages have a host variant built to be executed on the build machine Such packages are needed for the build process of other packages gt The majority of host packages are not visible in menuconfig they are just dependencies of other packages the user doesn t really need to know about them gt A few of them are potentially directly useful to the user flashing tools etc and can be shown in the Host utilities section of menuconfig gt In this case the configuration option is in a Config in host file included from package Config in host and the option must be named BR2_PACKAGE_HOST_ lt PACKAGE gt free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 127 326 Config in host example package Config in host menu Host utilities source package genimage Config in host source package 1pc325 loader Config in host source package openocd Config in host source package qemu Config in host endmenu package openocd Config in host config BR2_PACKAGE_HOST_OPENOCD bool host openocd help OpenOCD Open On Chip Debugger http openocd org free electrons Embedded Linux kernel drivers and Android Development consulting trai
124. r lib C library and gcc runtime gt include c C library headers gt target gt lib and usr lib C and C libraries gt The wrapper takes care of passing the appropriate flags to the compiler gt Mimics the internal toolchain behavior free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 72 326 K head i ernel headers version gt One option in the toolchain menu is particularly important the kernel headers version gt When building user space programs libraries or the C library kernel headers are used to know how to interface with the kernel gt This kernel user space interface is backward compatible but can introduce new features gt It is therefore important to use kernel headers that have a version equal or older than the kernel version running on the target gt With the internal toolchain backend choose an appropriate kernel headers version gt With the external toolchain backend beware when choosing your toolchain free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 73 326 Other toolchain menu options gt The toolchain menu offers a few other options gt Purge unwanted locales gt This allows to get rid of translation files when not needed They consume quite a lot of disk space gt Target optimizations gt A
125. reative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 250 326 Building code for Buildroot gt The Buildroot cross compiler is installed in HOST_DIR usr bin gt It is already set up to gt generate code for the configured architecture gt look for libraries and headers in STAGING_DIR gt Other useful tools that may be built by Buildroot are installed in CHOST_DIR usr bin gt pkg config to find libraries Beware that it is configured to return results for target libraries it should only be used when cross compiling gt qmake when building Qt applications with this build system gt autoconf automake libtool to use versions independent from the host system gt Adding HOST_DIR usr bin to your PATH when cross compiling is the easiest solution free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 251 326 Building code for Buildroot C program Building a C program for the host gcc o foobar foobar c file foobar foobar ELF 64 bit LSB executable x86 64 version 1 Building a C program for the target export PATH pwd output host usr bin PATH arm linux gcc o foobar foobar c file foobar foobar ELF 32 bit LSB execut
126. rent methods gt wget for FTP HTTP downloads scp to fetch the tarball using SSH SCP svn for Subversion cvs for CVS git for Git hg for Mercurial bzr for Bazaar file for a local tarball local for a local directory YYYY vY v v y gt In most cases the fetching method is guessed by Buildroot using the lt pkg gt _SITE variable gt Exceptions gt Git Subversion or Mercurial repositories accessed over HTTP or SSH gt file and local methods gt In such cases use lt pkg gt _SITE_METHOD explicitly free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 143 326 Download methods examples gt Subversion repository accessed over HTTP CJSON_VERSION 58 CJSON_SITE_METHOD svn CJSON_SITE http svn code sf net p cjson code gt Source code available in a local directory MYAPP_SITE TOPDIR apps myapp MYAPP_SITE_METHOD local gt The download will consist in copying the source code from the designated directory to the Buildroot per package build directory free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 144 326 Downloading more elements gt lt pkg gt _PATCH a list of patches to download and apply before building the package They are automatically applied by the package infrastructure gt lt pkg gt _EXTR
127. riable gt From a package mk file one can directly use such variables ifeq BR2_PACKAGE_LIBCURL y endif FOO_DEPENDENCIES if BR2_PACKAGE_TIFF tiff gt Hint use the make qstrip function to remove double quotes on string options NODEJS_MODULES_LIST call qstrip BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 141 326 Download related variables gt lt pkg gt _SITE download location gt HTTP S or FTP URL where a tarball can be found or the address of a version control repository gt CAIRO_SITE http cairographics org releases gt FMC_SITE git git freescale com ppc sdk fmc git gt lt pkg gt _VERSION version of the package gt version of a tarball or a commit revision or tag for version control systems gt CAIRO_VERSION 1 14 2 gt FMC_VERSION fsl sdk v1 5 rc3 gt lt pkg gt _SOURCE file name of the tarball gt The full URL of the downloaded tarball is lt pkg gt _SITE lt pkg gt _SOURCE gt When not specified defaults to lt pkg gt lt pkg gt _VERSION tar gz gt CAIRO_SOURCE cairo CAIRO_VERSION tar xz free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 142 326 Available download methods gt Buildroot can fetch the source code using diffe
128. rsion required for packages Now packages needing specific kernel header features can specify these requirements in Kconfig free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 314 326 In 2014 05 2 gt Toolchains gt GCC 4 9 Glibc 2 19 gt Support for the musl C library for internal and external vvvrvrvyiy toolchains GCC 4 8 R3 support for ARC Internal toolchain support for Aarch64 and Microblaze Toolchain tuple vendor name can now be customized Updated external Linaro ARM Aarch64 toolchains Added external Linaro ARMEB toolchain A GDB gdbinit file is now generated for external toolchains to automatically set the correct sysroot gt Infrastructure gt gt gt gt Support for but disabled as it leads to unreproducible builds toplevel parallel builds Python package infrastructure extended to support Python 3 x Perl and virtual package infrastructure support added PRE_ _HOOKS support for all build steps free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 315 326 In 2014 08 1 gt Architectures gt Powerpc64 BE LE added AVR32 deprecated gt Improved altivec SPE atomic instructions handling Additional PowerPC CPU variants added gt Defconfigs Atmel SAMA5D3 Congatec QMX6 Lego ev3 TS 5x00 qemu system
129. s com 107 326 Download related make targets gt make source gt Triggers the download of all the files needed to build the current configuration gt All files are stored in DL_DIR gt Allows to prepare a fully offline build gt make external deps gt Lists the files from DL_DIR that are needed for the current configuration to build gt Does not guarantee that all files are in DL_DIR a make source is required gt make source check gt Checks whether the upstream site of all downloads needed for the current configuration are still available free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 108 326 GNU Make 101 Embedded Linux Experts GNU Make 101 free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 109 326 Introduction v Buildroot being implemented in GNU Make it is quite important to know the basics of this language gt Basics of make rules Defining and referencing variables Conditions Defining and using functions gt gt gt gt Useful make functions v This does not aim at replacing a full course on GNU Make v http www gnu org
130. sion boards called capes See http beagleboardtoys com free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 7 326 Do not damage your BeagleBone Black gt Do not remove power abruptly gt Boards components have been damaged by removing the power or USB cable in an abrupt way not leaving the PMIC the time to switch off the components in a clean way See http bit 1ly 1FWHNZi gt Reboot reboot or shutdown halt the board in software when Linux is running gt You can also press the RESET button to reset and reboot gt When there is no software way you can also switch off the board by pressing the POWER button for 8 seconds gt Do not leave your board powered on a metallic surface like a laptop with a metal finish free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 8 326 Participate During the lectures gt Don t hesitate to ask questions Other people in the audience may have similar questions too This helps the trainer to detect any explanation that wasn t clear or detailed enough Don t hesitate to share your experience for example to compare Linux Android with other operating systems used in your company Your point of view is most valuable because it can be similar to your colleagues and different from the trainer s Y
131. ss variables to the free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com stamp file targets especially PKG 280 326 inner generic package sequencing Step sequencing for target packages 1 1 install 1 install 1 install staging 1 install target 1 install images 1 install target 2 _TARGET_INSTALL_TARGET 2 _TARGET_INSTALL_TARGET 2 _TARGET_BUILD 1 build 2 _TARGET_BUILD 2 _TARGET_BUILD 2 _TARGET_CONFIGURE 1 configure 2 _TARGET_CONFIGURE 2 _TARGET_CONFIGURE 2 _FINAL_DEPENDENCIES 2 TARGET_CONFIGURE 2 _TARGET_PATCH 1 patch 2 _TARGET_PATCH 2 _TARGET_PATCH 2 _TARGET_EXTRACT 1 extract 2 _TARGET_EXTRACT 2 _TARGET_EXTRACT 2 TARGET_SOURCE 1 source 2 _TARGET_SOURCE 2 _TARGET_SOURCE dirs prepare 2 _TARGET_SOURCE dependencies free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 281 326 S BUILD_DIR alboye stamp_target_installed S BUILD_DIR zib xy2 stamp_staging_installed S BUILD_DIR 2lib xy2 stamp_images_installed S BUILD_DIR zlib xyz stamp_built S BUILD_DIR zlib xyz stamp_configured List of zlib dependencies by package name Triggers the build of each of these d
132. structures can also add additional capabilities controlled by variables in packages gt For example with the autotools package infra one can do FOOBAR_AUTORECONF YES in a package to trigger an autoreconf before the configure script is executed gt Implementation in pkg autotools mk define AUTORECONF_HOOK call MESSAGE Autoreconfiguring Q cd PKG _SRCDIR amp amp PKG _AUTORECONF_ENV AUTORECONF PKG _AUTORECONF_OPTS endef ifeq 2 _AUTORECONF YES 2 _PRE_CONFIGURE_HOOKS AUTORECONF_HOOK 2 _DEPENDENCIES host automake host autoconf host libtool endif free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 290 326 Toolchai t oolchain suppor gt One virtual package toolchain with two implementations in the form of two packages toolchain buildroot and toolchain external gt toolchain buildroot implements the internal toolchain back end where Buildroot builds the cross compilation toolchain from scratch This package simply depends on host gcc final to trigger the entire build process gt toolchain external implements the external toolchain back end where Buildroot uses an existing pre built toolchain free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 291 326 Internal toolchain back end Build starts
133. sulting training and support http free electrons com 69 326 Custom external toolchains gt If you have a custom external toolchain select Custom toolchain in Toolchain v Buildroot can download and extract it for you gt Convenient to share toolchains between several developers gt Option Toolchain to be downloaded and installed in Toolchain origin gt The URL of the toolchain tarball is needed v Or Buildroot can use an already installed toolchain gt Option Pre installed toolchain in Toolchain origin gt The local path to the toolchain is needed v In both cases you will have to tell Buildroot the configuration of the toolchain C library kernel headers version etc gt Buildroot needs this information to know which packages can be built with this toolchain gt Buildroot will check those values at the beginning of the build free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 70 326 External toolchain example configuration Toolchain Enter gt selects submenus gt or empty submenus Highlighted letters are hotkeys Pressir ll exclude a feature Press lt Esc gt lt Esc gt to exit lt gt for Help lt gt for Search Legend featt d E _Toolchain type External toolchain gt Toolchain Custom toolchain gt Toolchain origin Toolchain to be downloaded and installed gt http autobui
134. t Written in AsciiDoc can generate HTML PDF TXT versions make manual gt 90 pages PDF document gt Also available pre generated online gt http buildroot org downloads manual manual html free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 53 326 Buildroot source and build trees Build tree free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 54 326 Build tree 0 v output v Global output directory v Can be customized for out of tree build by passing O lt dir gt v Variable O as passed on the command line Variable BASE_DIR as an absolute path v free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 55 326 Build tree 0 build gt output gt build gt gt gt gt gt Y v v buildroot config busybox 1 22 1 host pkgconf 8 9 kmod 1 18 build time log Where all source tarballs are extracted Where the build of each package takes place In addition to the package sources and object files stamp files are created by Buildroot v Variable BUILD_DIR free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 56 326 Build tree
135. t http free electrons com 285 326 Specialized package infrastructures gt The generic package infrastructure is fine for packages having a custom build system gt For packages using a well known build system we want to factorize more logic gt Specialized package infrastructures were created to handle these packages and reduce the amount of duplication gt For autotools CMake Python Perl Lua and kconfig packages free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 286 326 CMake package example flann package flann flann mk FLANN_VERSION d c04f4d29 ebc3aa9411a3322992d298e51 f5aa FLANN_SITE call github mariusmuja flann FLANN_VERSION FLANN_INSTALL_STAGING YES FLANN_LICENSE BSD 3c FLANN_LICENSE_FILES COPYING FLANN_CONF_OPT DBUILD_C_BINDINGS ON DBUILD_PYTHON_BINDINGS OFF DBUILD_MATLAB_BINDINGS OFF DBUILD_EXAMPLES if BR2_PACKAGE_FLANN_EXAMPLES ON OFF DBUILD_TESTS OFF DBUILD_DOC OFF DUSE_OPENMP if BR2_GCC_ENABLE_OPENMP ON OFF DPYTHON_EXECUTABLE OFF eval cmake package free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 287 326 CMake package infrastructure 1 2 define inner cmake package 2 _CONF_ENV 2 _CONF_OPT 2 _SRCDIR 2 _DIR 2 _SUBDIR 2 _BUILDDIR
136. t kconfig merge_config sh platform1 frag packages frag gt config make olddefconfig make Build a debug system for platform2 support kconfig merge_config sh platform2 frag packages frag debug frag gt config make olddefconfig make gt olddefconfig expands a minimal defconfig to a full config gt Saving fragments is not possible it must be done manually from an existing defconfig free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 45 326 Other building tips a gt Cleaning targets gt Cleaning all the build output but keeping the configuration file make clean gt Cleaning everything including the configuration file and downloaded file if at the default location make distclean gt Verbose build gt By default Buildroot hides a number of commands it runs during the build only showing the most important ones gt To get a fully verbose build pass V 1 make V 1 gt Passing V 1 also applies to packages like the Linux kernel busybox free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 46 326 Buildroot source and build trees Embedded Linux Experts Buildroot source and build trees free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Correctio
137. t needs a Python interpreter of the same version on the host free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 169 326 Target vs host in the package infrastructure 1 gt Each package infrastructure provides a lt foo gt package macro and a host lt foo gt package macro gt For a given package in package baz baz mk lt foo gt package will create a package named baz and host lt foo gt package will create a package named host baz gt lt foo gt package will use the variables prefixed with BAZ_ gt host lt foo gt package will use the variables prefixed with HOST_BAZ_ free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 170 326 Target vs host in the package infrastructure 2 gt For many variables when HOST_BAZ_ lt var gt is not defined the package infrastructure uses BAZ_ lt var gt instead source site version license etc gt E g defining lt PKG gt _SITE once is sufficient gt But not for all variables especially commands gt E g HOST_ lt PKG gt _BUILD_CMDS is not inherited from lt PKG gt _BUILD_CMDS gt HOST_ lt PKG gt _DEPENDENCIES is handled specially gt Derived automatically from lt PKG gt _DEPENDENCIES after prepending host to all dependencies gt FOO_DEPENDENCIES bar host baz HOST_FOO_DEPENDENCIES host b
138. tfs overlay find type f board myproject rootfs overlay board myproject rootfs overlay etc ssh sshd_config board myproject rootfs overlay etc init d S99myapp free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 85 326 Oo Post build scripts gt Sometimes a root filesystem overlay is not sufficient you can use post build scripts gt Can be used to customize existing files remove unneeded files to save space add new files that are generated dynamically build date etc gt Executed before the root filesystem image is created Can be written in any language shell scripts are often used gt BR2 free electron list o gt TA ROOTFS_POST_BUILD_SCRIPT contains a space separated f post build script paths RGET_DIR path passed as first argument additional arguments can be passed in the BR2 gt Various environment variables are available s Embedded Linux gt gt ROOTFS_POST_SCRIPT_ARGS option BR2_CONFIG path to the Buildroot config file HOST_DIR STAGING_DIR TARGET_DIR BUILD_DIR BINARIES_DIR BASE_DIR kernel drivers and Android Development consulting training and support http free electrons com 86 326 Post build script example board myproject post build sh bin sh TARGET_DIR 1 BOARD_DIR board myproject Generate a file identifying the build git commit and build date
139. touch gt BUILD_DIR build directory of any package gt a make target depending on one stamp file will trigger the corresponding action gt the stamp file prevents the action from being re executed free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 274 326 Action example 1 download Retrieve the archive BUILD_DIR stamp_downloaded foreach hook PKG _PRE_DOWNLOAD_HOOKS call hook sep leer if PKG _SOURCE call DOWNLOAD PKG _SITE PKG _SOURCE foreach p PKG _EXTRA_DOWNLOADS call DOWNLOAD PKG _SITE p sep foreach p PKG _PATCH if findstring p call DOWNLOAD p call DOWNLOAD PKG _SITE p Ds sep foreach hook PKG _POST_DOWNLOAD_HOOKS call hook sep Q mkdir p D Q touch Step handled by the package infrastructure In all stamp file targets PKG is the upper case name of the package So when used for Busybox PKG _SOURCE is the value of BUSYBOX_SOURCE gt Hooks make macros called before and after each step Downloads the files mentioned in lt pkg gt _SOURCE lt pkg gt _EXTRA_DOWNLOADS and lt pkg gt _PATCH free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 275 326 Action example 2 build
140. trons com 88 326 I Permission table gt By default all files are owned by the root user and the permissions with which they are installed in TARGET_DIR are preserved gt To customize the ownership or the permission of installed files one can create one or several permission tables gt BR2_ROOTFS_DEVICE_TABLE contains a space separated list of permission table files The option name contains device for backward compatibility reasons only gt The system device_table txt file is used by default gt Packages can also specify their own permissions See the Advanced package aspects section for details Permission table example lt name gt lt type gt lt mode gt lt uid gt lt gid gt lt major gt lt minor gt lt start gt lt inc gt lt count gt dev d 755 o o s tmp d 1777 0 var www d 755 33 33 gt z z free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com Device table gt When the system is using a static dev one may need to create additional device nodes gt Done using one or several device tables gt BR2_ROOTFS_STATIC_DEVICE_TABLE contains a space separated list of device table files gt The system device_table_dev txt file is used by default gt Packages can also specify their own device files See the Advanced package aspects section for details Device table example
141. ttp free electrons com blog Quarterly newsletter http lists free electrons com mailman listinfo newsletter News and discussions Google https plus google com FreeElectronsDevelopers News and discussions LinkedIn http linkedin com groups Free Electrons 4501089 Quick news Twitter http twitter com free_electrons Linux Cross Reference browse Linux kernel sources on line http 1xr free electrons com free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 5 326 Generic course information Embedded Linux Experts Generic course information free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 6 326 Hardware used in this training session BeagleBone Black from CircuitCo gt Texas Instruments AM335x ARM Cortex A8 gt Powerful CPU with 3D acceleration additional processors PRUs and lots of peripherals gt 512 MB of RAM 2 GB of on board eMMC storage 4 GB in Rev C USB host and USB device ports microSD slot HDMI port 2 x 46 pins headers with access to many expansion buses 12C SPI UART and more v yy Y y gt A huge number of expan
142. uildroot make it very difficult to test all combinations gt Random configurations are therefore built 24 7 by multiple machines gt Random choice of architecture toolchain combination from a pre defined list gt Random selection of packages using make randpackageconfig gt Random enabling of features like static library only or BR2_ENABLE_DEBUG y gt Scripts and tools publicly available at http git buildroot net buildroot test gt Results visible at http autobuild buildroot org gt Daily e mails with the build results of the past day free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 305 326 Buildroot tests 2015 05 06 18 12 18 OK 1655934 dir end log config defconfig 2015 05 06 18 11 08 OK 1f55934c none dir end log config defconfig 2015 05 06 18 04 57 OK 1f55934 none dir end log config defconfig 2015 05 06 17 56 09 OK 1f55934 none dir end log config defconfig 2015 05 06 17 53 08 OK 1f55934e none dir end log config defconfig 2015 05 06 17 45 56 OK 1559340 none dir end log config defconfig 2015 05 06 17 32 35 OK 1f55934 none dir end log config defconfig 2015 05 06 17 25 19 OK 1f55934 none dir end log config defconfig 2015 05 06 17 18 30 OK 1f55934 none dir end log config defconfig 2015 05 06 17 16 22 OK 1f55934c none dir end log config defconfig 2015 05 06 17 10 07 OK 1655934 Pee Konpa nios2 none
143. ulting training and support http free electrons com 76 326 Defining the configuration gt In the Kernel menu in menuconfig after selecting the kernel version you have two options to define the kernel configuration gt Use a defconfig gt Will use a defconfig provided within the kernel sources gt Available in arch lt ARCH gt configs in the kernel sources gt Used unmodified by Buildroot gt Good starting point gt Use a custom config file gt Allows to give the path to either a full config or a minimal defconfig gt Usually what you will use so that you can have a custom configuration free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 77 326 Changing the configuration gt Running one of the Linux kernel configuration interfaces gt gt gt gt make make make make linux menuconfig linux nconfig linux xconfig linux gconfig gt Will load either the defined kernel defconfig or custom configuration file and start the corresponding Linux kernel configuration interface gt Changes made are only made in 0 build linux lt version gt i e they are not preserved across a clean rebuild gt To save them gt make linux update config to save a full config file gt make linux update defconfig to save a minimal defconfig Available since Buildroot 2015 05 gt Only works if a custo
144. vers and Android Development consulting training and support http free electrons com 228 326 Instrumentation scripts example instrumentation sh bin sh echo 3 now 1 s 2 Output make BR2_INSTRUMENTATION_SCRIPTS instrumentation sh strace now starts extract gt gt gt strace 4 10 Extracting xzcat home thomas dl strace 4 10 tar xz tar strip components 1 C home thomas projets buildroot output build strace 4 1 xf strace now ends extract strace now starts patch gt gt gt strace 4 10 Patching Applying 0001 linux aarch64 add missing header patch using patch patching file linux aarch64 arch_regs h gt gt gt strace 4 10 Updating config sub and config guess for file in config guess config sub do for i in find home thomas projets buildroot output build strace 4 10 name file do cp support gnuconfig file i done done gt gt gt strace 4 10 Patching libtool strace now ends patch strace now starts configure gt gt gt strace 4 10 Configuring free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 229 326 Advanced topics i Embedded Linux Experts Advanced topics free electrons Copyright 2004 2015 Free Electrons Creative Commons BY SA 3 0 license Corrections suggestions contributions and translations are welcome free electrons Embedded Linux kernel drivers
145. xtensa qemu aarch64 virt added A number of tweaks to existing ones Ipc32xx defconfigs removed gt Toolchain gt Microblaze support for internal musl toolchain gt Default to GCC 4 8 for internal toolchain remove deprecated 4 3 and 4 6 versions gt External CodeSourcery Linaro toolchain updates gt Option to copy gconv libraries for external toolchains free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 316 326 In 2014 08 2 gt Infrastructure gt graph depends improvements gt Download handling is now done using helper scripts gt Integrity of downloads can now be verified using hashes gt Legal info License info of local or overridden packages are saved as well Toolchain packages are also taken into account gt autotools Static linking with libtool v1 5 improvements gt Gettextize support similar to autoreconf gt kconfig package infrastructure added gt User manual restructured reworked free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 317 326 In 2014 11 gt Toolchains gt Use mcpu march instead of mtune gt Support additional ARC and sparc variants gt Updated Code sourcery and Linaro external toolchains gt Defconfigs Freescale iMX6DL SabreSD Minnowboard MAX QEMU powerpc64 pseries added and a number of
146. y gt updated before every Buildroot release to contain the downloaded files for all packages gt exception cannot store all possible versions for packages that have their version as a configuration option Generally only affects the kernel or bootloader which typically don t disappear upstream free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 104 326 DL_DIR gt Once a file has been downloaded by Buildroot it is cached in the directory pointed by DL_DIR gt By default TOPDIR dl gt Can be changed gt using the BR2_DL_DIR configuration option gt or by passing the BR2_DL_DIR environment variable which overrides the config option of the same name gt The download mechanism is written in a way that allows independent parallel builds to share the same DL_DIR using atomic renaming of files gt No cleanup mechanism files are only added never removed even when the package version is updated free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 105 326 free Special case of VCS download gt When a package uses the source code from Git Subversion or another VCS Buildroot cannot directly download a tarball It uses a VCS specific method to fetch the specified version of the source from the VCS repository gt The source code is stored in
147. y files etc gt When downloading a file Buildroot will successively try the following locations 1 The local DL_DIR directory where downloaded files are kept 2 The primary site as indicated by BR2_PRIMARY_SITE 3 The original site as indicated by the package mk file 4 The backup Buildroot mirror as indicated by BR2_BACKUP_SITE free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 102 326 Primary site gt The BR2_PRIMARY_SITE option allows to define the location of a HTTP or FTP server gt By default empty so this feature is disabled gt When defined used in priority over the original location gt Allows to do a local mirror in your company of all the files that Buildroot needs to download gt When option BR2_PRIMARY_SITE_ONLY is enabled only the primary site is used gt It does not fall back on the original site and the backup Buildroot mirror gt Guarantees that all downloads must be in the primary site free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 103 326 Backup Buildroot mirror gt Since sometimes the upstream locations disappear or are temporarily unavailable having a backup server is useful gt Address configured through BR2_BACKUP_SITE gt Defaults to http sources buildroot net gt maintained by the Buildroot communit
148. zed in the file named CHANGES in the Buildroot source tree gt Always mentions changes that could cause backward compatibility problems gt The following slides summarize the major new features added in each release between 2013 08 and 2015 08 gt All new Buildroot versions come with new packages and many updates to the existing packages gt Such package additions and updates are not listed in the following slides free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 309 326 In 2013 08 1 gt Architectures improved support for floating point on ARM and Thumb Thumb2 support for ARM OABI removed gt Toolchains gt Yv vY yv v support added for Sourcery CodeBench ARM and MIPS 2013 05 Linaro ARM and Aarch64 toolchains updated support added for the Arago ARMv5 and ARMv7 toolchains gcc 4 8 x version bumped support for installing both FDPIC and FLAT libraries on Blackfin support for uClibc 0 9 31 removed gt convert the internal toolchain backend to use the package infrastructure support added for eglibc in the internal toolchain backend toolchain components for the ARC architecture updated and gdb for ARC added support for Blackfin in the internal toolchain fixed free electrons Embedded Linux kernel drivers and Android Development consulting training and support http free electrons com 310 326 In 2013 08 2
Download Pdf Manuals
Related Search
Related Contents
Honeywell Q539 User's Manual Elettrobisturi Electrosurgical knife Bistouri électrique Elektroskalpell Manual - OKINA USA Modems CDM-625 Advanced Satellite Modem with DoubleTalk 第3版【MJ0259-3A】 PRESS RELEASE - リンクスインターナショナル GOMA ARABIGA HV DOLMAR - Dolmar Productos Enológicos ELECTRIC-HYDRAULIC LIFT s.p . pId tune Inp Al Out Conf CoMM accs Inp. Out l.i np AlM EHit inp Copyright © All rights reserved.
Failed to retrieve file