Bitbake & OpenEmbedded Overview

Table of Contents

General

bitbake

http://developer.berlios.de/projects/bitbake/

obtained from git://git.openembedded.org/bitbake.git. Releases can be downloaded from http://downloads.yoctoproject.org/releases/bitbake/ and the developer mailing list, bitbake-devel can be found at http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/bitbake-devel.

Install and Tutorial

Using OpenEmbedded on Linux systems

Misc

Variable

openembedded/conf/bitbake.conf

# Path prefixes
export base_prefix = ""
export prefix = "/usr"
export exec_prefix = "/usr"

# Base paths
export base_bindir = "${base_prefix}/bin"
export base_sbindir = "${base_prefix}/sbin"
export base_libdir = "${base_prefix}/lib"

# Architecture independent paths
export datadir = "${prefix}/share"
export sysconfdir = "${base_prefix}/etc"
export servicedir = "${base_prefix}/srv"
export sharedstatedir = "${base_prefix}/com"
export localstatedir = "${base_prefix}/var"
export infodir = "${datadir}/info"
export mandir = "${datadir}/man"
export docdir = "${datadir}/doc"
.....
##################################################################
# Download locations and utilities.
##################################################################

OE_STRICT_CHECKSUMS ?= "1"

ADOBE_MIRROR = "http://fpdownload.macromedia.com/get/flashplayer/current/"
APACHE_MIRROR = "http://archive.apache.org/dist"
DEBIAN_MIRROR = "ftp://ftp.debian.org/debian/pool"
E_MIRROR = "http://download.enlightenment.org/releases"
E_SVN = "svn://svn.enlightenment.org/svn/e"
FREEBSD_MIRROR = "ftp://ftp.freebsd.org/pub/FreeBSD/"
FREEDESKTOP_CVS = "cvs://anoncvs:anoncvs@anoncvs.freedesktop.org/cvs"
FREESMARTPHONE_GIT = "git://git.freesmartphone.org"
GENTOO_MIRROR = "http://distfiles.gentoo.org/distfiles"
GNOME_GIT = "git://git.gnome.org"
...

Notes of OpenEmbedded User Manual

Notes

conf/documentation.conf

PN[doc] = "PN holds the name of the package (Package Name). It is gathered from the bitbake-file filename"
PV[doc] = "PV holds the version of the package (Package Version). The default value is 1.0, it is \
retrieved from the bitbake-file filename but can be changed."
PR[doc] = "PR is the revision of the package (Package Revision). By default it is set to r0."
PF[doc] = "Package name - Package version - Package revision (PN-PV-PR)"
P[doc] = "Package name - Package version (PN-PF)"
S[doc] = "Directory that holds the sources to build, WORKDIR/PN-PV by default. The 'make' or equivalent command is run from this directory."
SECTION[doc] = "Section of the packages e.g. console/networking"

# dependencies
GROUPdependencies[doc] = "The keys in this group influence the dependency handling of BitBake \
and the resulting packages."
DEPENDS[doc] = "Build time dependencies, things needed to build the package. @group dependencies"
RDEPENDS[doc] = "Run time dependencies, things needed for a given package to run. This is used to populate the ipkg:Depends field. @group dependencies"
PROVIDES[doc] = "Names for additional build time dependencies that this package will provide. @group dependencies"
RPROVIDES[doc] = "Names for additional run time dependencies that this
package will provide. This is used to populate the ipkg:Provides field. @group dependencies"

DLDIR[doc] = "The directory where tarballs will be stored. @group fetcher"

OpenEmbedded HowTo

  • Bitbake
    • Examples

      A bitbake nano will parse all *.bb files defined in local.conf, build a hash and build everything, which nano depends on and last but not least nano itself.

      A bitbake -c clean nano will clean the nano package.

      A bitbake -b whereYourOEPackageDirIsbitbake/nano/nano1.3.5.bb / will just build nano. All depends have already to be fullfilled for that. This does not execute the bb file parsing and spares time (e.g. during debugging).

      A bitbake -b whereYourOEPackageDirIsbitbake/nano/nano1.3.5.bb -f -c clean / will force a clean on the already builded nano package.

      A bitbake -b whereYourOEPackageDirIsbitbake/nano/nano1.3.5.bb -f -c fetch / will force a fetch on the already builded nano package. The package source is downloaded again independent of the cache status.

      A bitbake -b whereYourOEPackageDirIsbitbake/nano/nano1.3.5.bb -f -c build / will force a build on the nano package. This will execute all stages "before" compile like fetch, patch, configure … and compile itself.

      A bitbake -D -D -D nano will build the nano package and show you all files parsed.

      A bitbake virtual/kernel -c clean; bitbake virtual/kernel builds a new kernel for the opie-image and afterwards the related image.

  • How the configuration works

    An example is described in the following list.

    • openembedded/conf/bitbake.conf This is where all parsing starts.
    • YourBuildDir/conf/local.conf Here you can do you local configuration. Most interesting options are MACHINE and DISTRO. A TARGETOS or TARGETARCH are normally defined somewhere deeper in the conf tree.
    • openembedded/conf/machine/YourDefinedMachine.conf And all included machinexxx.conf files. Here the HW-dependend options (kernel, etc …) are defined.
    • openembedded/conf/distro/YourDefinedDistro.conf And all included YourDefinedDistroxxx.conf files (mostly none). Here the Distro dependend options are defined.
    • All BBFILES defined .bb files This is the final run.
  • Cleaning

    For example a qte rebuild needs

    cd tmp/work
    rm -rf *opie*
    rm -rf libopie*
    rm -rf libq*
    rm -rf *qte*
    cd tmp/cache
    rm -rf *opie*
    rm -rf *libopie*
    rm -rf *libq*
    rm -rf *qte*
    cd tmp/stamps
    rm -rf *opie*
    rm -rf libopie*
    rm -rf libq*
    rm -rf *qte*
    

    before rebuilding.

  • Debugging
    • Debugging output (-D) One option to get more information on the build process is to use additionally the -D option. This option may occur multiple times and thus increases the DebugLevel.
    bitbake -D -D -D nano
    
    • Show environment -e The option -e shows the environment variables set during a bitbake run.
    bitbake -e nano
    
    • Show package versions -s
    • Dry run -n The dry run can be used to check, whether all dependencies are fullfilled. Also versioning, etc. can be checked.
  • Using the tmp/deploy/ipk dir as your local repository
    #!/bin/sh
    
    TFILE="doit.rc"
    rm -f ${TFILE}
    rm -f Packages.new
    
    echo -n "finding packages ... "
    find *.ipk | \
            awk --traditional '{ printf( "echo -n .;ar -p %s control.tar.gz", $1 );
                                 printf( " | tar -xzO ./control >> Packages.new;" );
                                 printf( "echo Filename: %s >> Packages.new;", $1 );
                                 printf( "echo Size: %s >> Packages.new;", $1 );
                                 printf( "echo >> Packages.new\n" ); }' >> ${TFILE}
    echo `cat doit.rc | wc -l` found.
    /bin/sh ${TFILE}
    
  • Clean Package Dependends

    do\clean.rc

    #!/bin/sh
    # V0.1.0
    # Used to clean up OE package dependencies.
    # Note, that all recursive dependencies are cleaned.
    
    PAC=${1}
    DEPLIST=""
    DEPCNT="0"
    
    usage()
    {
            echo "usage : ${0} path/to/xx.bb"
            echo "        cleans all xx.bb dependend packages"
    }
    
    get_args()
    {
            if [ "${PAC}" == "" ]; then
                    usage
                    exit 1;
            fi
    
    }
    
    get_deps()
    {
            DEPLIST=`bbread ${PAC} | grep -E -i -e "^DEPENDS=" | sed -e 's/.*=\"//'`
            DEPLIST=`echo ${DEPLIST} | sed -e 's/\"//'`
            SELF=`echo ${PAC} | sed -e 's/\.bb$//'`
            SELF=`echo ${SELF} | sed -e 's/.*\///'`
            SELF=`echo ${SELF} | sed -e 's/_.*$//'`
            DEPLIST="${DEPLIST} ${SELF}"
            DEPCNT=`echo ${DEPLIST} | wc -w`
            echo found ${DEPCNT} dependend packages.
    }
    
    askme()
    {
            TMP=""
            TR="1"
    
            for r in ${DEPLIST}; do
                    if [ "${TR}" != "" ]; then
                            echo -n "Clean '${r}' Yes/(N)o/Rest ? : "
                            read aa
                    fi
                    case "${aa}" in
                            Y )
                            TMP="${TMP} ${r}"
                            ;;
                            R )
                            TR=""
                            TMP="${TMP} ${r}"
                            ;;
                    esac
            done
    
            DEPLIST=${TMP}
            DEPCNT=`echo ${DEPLIST} | wc -w`
    }
    
    grepit()
    {
            echo -n "Enter a : pattern to grep  "
            read REGI
    
            TMP=""
            for r in ${DEPLIST}; do
                    s=`echo ${r} | grep -v ${REGI}`
                    TMP="${TMP} ${s}"
            done
    
            DEPLIST=${TMP}
            DEPCNT=`echo ${DEPLIST} | wc -w`
    }
    
    ask_user()
    {
            if [ "${DEPCNT}" == "0" ]; then
                    echo "Nothing to clean ;-)"
                    exit 0
            fi
    
            echo Really clean the following packages ?
            echo "======================================================="
            echo ${DEPLIST}
            echo "======================================================="
            echo -n "Yes/(N)o/Askme/Grep : "
            read aa
    
            case "${aa}" in
                    Y )
                            ;;
                    G )
                            grepit
                            ask_user
                            ;;
                    A )
                            askme
                            ask_user
                            ;;
                    * )
                            echo "aborted :-("
                            exit 1
                            ;;
            esac
    }
    
    doit()
    {
            echo
            echo -n cleaning, please wait 
            bitbake -c clean ${DEPLIST}
    }
    
    get_args
    get_deps
    ask_user
    doit
    
    • use
    $ do_clean.rc ../openembedded/packages/meta/opie-image.bb
    
  • Customize to you needs
    • Adding another package repository

      The new BBFILES line(s) are e.g.

      BBFILES := "${HOME}/dev/oe/org.openembedded.dev/packages/*/*.bb"
      BBFILES += "${HOME}/myoe/packages/*/*.bb"
      
    • Adding a new machine
    • Adding a new distro
    • Adding a new bootstrap-image
    • Build the above mentioned bootstrap-image
    • Example : Adding a new package (from existing sources)

      Info: Preparing the Makefile

      This subsection describes the changes I had to do on the Makefile and the way to create and provide an appropriate patch.

      Unpack the sources tgz or the cvs dir into your patch dir and create a copy of the resulting dir named xxxorig.
      Edit the non _orig's Makefile.
      Remove (or comment) the CC entry to force CROSS usage
      Remove (or comment) the CFLAGS entry to force bitbake CFLAGS usage.
      Note, that this may be wrong, when non standard entries need to be provided. Change the CFLAGS to e.g. CYFLAGS entry in the complete Makefile in this case.
      Added $(DESTDIR) to the PRFIX variable to cause make to install binaries to the ${D} dir instead to /
      Potentially you do not want to install something like includ or man pages.
      remove that targets from Makefile then.
      Create a patch calling diff -Naur xxx xxxorig > xxxmake.patch where xxx is your packages dir name.
      Copy that patch to myoe/packages/schedutils/schedutils dir (matching the SRCURI's patch entry described above ).

      Done that changes, you have the chance to build your new package.

  • FAQ
    • During build process, a package complains not to find shared libs for installation

      This occured e.g. with the readline package for opie image. I did not find out, why this happens. The possible solution (at least it works on my system) is a manual (non bitbake) make clean;./configure and afterwards a bitbake -b ../.../readline_x.y.bb -c build. It seems to have something to do with the configuration phase of bitbake for this package.

    • How can I add a customized /etc/fstab ?

      /oe/sources/openembedded/recipes/base-files/base-files/fstab

Author: Shi Shougang

Created: 2015-03-05 Thu 23:20

Emacs 24.3.1 (Org mode 8.2.10)

Validate