[FE training-materials-updates] buildroot-advanced: new chapter

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Thu May 7 11:54:46 CEST 2015


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=1d21a7938cb478b40ba2b851c07725cb0c8dbfb0

>---------------------------------------------------------------

commit 1d21a7938cb478b40ba2b851c07725cb0c8dbfb0
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Thu May 7 11:54:43 2015 +0200

    buildroot-advanced: new chapter
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


>---------------------------------------------------------------

1d21a7938cb478b40ba2b851c07725cb0c8dbfb0
 Makefile                                           |   2 +-
 slides/buildroot-advanced/buildroot-advanced.tex   | 203 +++++++++++++++++++++
 .../buildroot-board-project.tex                    |  15 --
 3 files changed, 204 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 10ed029..b949ba5 100644
--- a/Makefile
+++ b/Makefile
@@ -294,7 +294,7 @@ BUILDROOT_SLIDES = \
 		buildroot-new-packages \
 		buildroot-advanced-packages \
 		buildroot-analysis \
-		buildroot-board-project \
+		buildroot-advanced \
 		buildroot-appdev \
 		buildroot-internals \
 		buildroot-support-contribution \
diff --git a/slides/buildroot-advanced/buildroot-advanced.tex b/slides/buildroot-advanced/buildroot-advanced.tex
new file mode 100644
index 0000000..77dfb94
--- /dev/null
+++ b/slides/buildroot-advanced/buildroot-advanced.tex
@@ -0,0 +1,203 @@
+\section{Advanced topics}
+
+\begin{frame}{Global patch directories}
+  \begin{itemize}
+  \item You can include patches for the different packages in their
+    package directory, \code{package/<pkg>/}.
+  \item However, doing this involves changing the Buildroot sources
+    themselves, which may not be appropriate for some highly specific
+    patches.
+  \item The {\em global patch directories} mechanism allows to specify
+    additional locations where Buildroot will look for patches to
+    apply on packages.
+  \item \code{BR2_GLOBAL_PATCH_DIR} specifies a space-separated list
+    of directories containing patches.
+  \item These directories must contain sub-directories named after the
+    packages, themselves containing the patches to be applied.
+  \end{itemize}
+\end{frame}
+
+\begin{frame}{Patch application ordering}
+  \begin{itemize}
+  \item Overall the patches are applied in this order:
+    \begin{enumerate}
+    \item Patches mentionned in the package \code{<pkg>_PATCH} variable
+    \item Patches present in the package directory
+      \code{package/<pkg>/*.patch}
+    \item Patches present in the global patch directories
+    \end{enumerate}
+  \item In each case, they are applied:
+    \begin{itemize}
+    \item In the order specified in a \code{series} file, if available
+    \item Otherwise, in alphabetic ordering
+    \end{itemize}
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]{Global patch directory example}
+
+\begin{block}{Patching {\em strace}}
+{\tiny
+\begin{verbatim}
+$ 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
+[...]
+>>> 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
+[...]
+\end{verbatim}}
+\end{block}
+
+\end{frame}
+
+\begin{frame}{{\tt BR2\_EXTERNAL}}
+  \begin{itemize}
+  \item Storing your custom packages, custom configuration files and
+    custom {\em defconfigs} inside the Buildroot tree may not be the
+    most practical solution
+    \begin{itemize}
+    \item Doesn't cleanly separate open-source parts from proprietary parts
+    \item Makes it harder to upgrade Buildroot
+    \end{itemize}
+  \item The \code{BR2_EXTERNAL} mechanism allows to store your own
+    package recipes, {\em defconfigs} and other artefacts outside of
+    the Buildroot tree.
+  \item Specify \code{BR2_EXTERNAL} on the command line when building.
+  \item Buildroot will:
+    \begin{itemize}
+    \item include \code{$(BR2_EXTERNAL)/Config.in} in the configuration menu
+    \item include \code{$(BR2_EXTERNAL)/external.mk} in the make logic
+    \item include \code{$(BR2_EXTERNAL)/configs/} in the list of {\em defconfigs}
+    \end{itemize}
+  \item Note: can only be used to add new packages, not to override
+    existing Buildroot packages
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]{{\tt BR2\_EXTERNAL}: recommended structure}
+
+  \begin{block}{}
+    {\tiny
+\begin{verbatim}
++-- board/
+|   +-- <company>/
+|       +-- <boardname>/
+|           +-- linux.config
+|           +-- busybox.config
+|           +-- <other configuration files>
+|           +-- post_build.sh
+|           +-- post_image.sh
+|           +-- rootfs_overlay/
+|           |   +-- etc/
+|           |   +-- <some file>
+|           +-- patches/
+|               +-- foo/
+|               |   +-- <some patch>
+|               +-- libbar/
+|                   +-- <some other patches>
+|
++-- configs/
+|   +-- <boardname>_defconfig
+|
++-- package/
+|   +-- <company>/
+|       +-- package1/
+|       |    +-- Config.in
+|       |    +-- package1.mk
+|       +-- package2/
+|           +-- Config.in
+|           +-- package2.mk
+|
++-- Config.in
++-- external.mk
+\end{verbatim}
+    }
+  \end{block}
+
+\end{frame}
+
+\begin{frame}[fragile]{{\tt BR2\_EXTERNAL/Config.in}}
+
+  \begin{itemize}
+  \item Custom configuration options
+  \item Configuration options for the \code{BR2_EXTERNAL} packages
+  \item The \code{$BR2_EXTERNAL} variable is available
+  \end{itemize}
+
+  \begin{block}{Example \code{$(BR2_EXTERNAL)/Config.in}}
+\begin{verbatim}
+source "$BR2_EXTERNAL/package/package1/Config.in"
+source "$BR2_EXTERNAL/package/package2/Config.in"
+\end{verbatim}
+  \end{block}
+
+\end{frame}
+
+\begin{frame}[fragile]{{\tt BR2\_EXTERNAL/external.mk}}
+
+  \begin{itemize}
+  \item Can include custom {\em make} logic
+  \item Generally only used to include the package \code{.mk} files
+  \end{itemize}
+
+  \begin{block}{Example \code{$(BR2_EXTERNAL)/external.mk}}
+\begin{minted}[fontsize=\scriptsize]{make}
+include $(sort $(wildcard $(BR2_EXTERNAL)/package/*/*.mk))
+\end{minted}
+  \end{block}
+\end{frame}
+
+\begin{frame}[fragile]{Using {\tt BR2\_EXTERNAL}}
+  \begin{itemize}
+  \item Not a configuration option, only an {\bf environment variable}
+    to be passed on the command line
+    \begin{block}{}
+\begin{verbatim}
+make BR2_EXTERNAL=/path/to/external
+\end{verbatim}
+    \end{block}
+  \item {\bf Automatically saved} in the hidden \code{.br-external}
+    file in the output directory
+    \begin{itemize}
+    \item no need to pass \code{BR2_EXTERNAL} at every make invocation
+    \item can be changed at any time by passing a new value, and
+      removed by passing an empty value
+    \end{itemize}
+  \item Can be either an {\bf absolute} or a {\bf relative} path, but
+    if relative, important to remember that it's relative to the
+    Buildroot source directory
+  \end{itemize}
+\end{frame}
+
+\begin{frame}{Tips for building faster}
+  \begin{itemize}
+  \item Build time is often an issue, so here are some tips to help
+    \begin{itemize}
+    \item Use fast hardware: lots of RAM, and SSD
+    \item Do not use virtual machines
+    \item You can enable the \code{ccache} {\em compiler cache} using
+      \code{BR2_CCACHE}
+    \item Use external toolchains instead of internal toolchains
+    \item Learn about rebuilding only the few packages you actually
+      care about
+    \item Build everything locally, do not use NFS for building
+    \item Remember that you can do several independent builds in
+      parallel in different output directories
+    \end{itemize}
+  \end{itemize}
+\end{frame}
diff --git a/slides/buildroot-board-project/buildroot-board-project.tex b/slides/buildroot-board-project/buildroot-board-project.tex
deleted file mode 100644
index 0850d42..0000000
--- a/slides/buildroot-board-project/buildroot-board-project.tex
+++ /dev/null
@@ -1,15 +0,0 @@
-\section{Board and project support}
-
-\setuplabframe
-{Board and project support}
-{
-  \begin{itemize}
-  \item Create a Buildroot configuration for a
-    specific project, with:
-    \begin{itemize}
-    \item a custom kernel configuration
-    \item custom packages
-    \item special root filesystem modifications
-    \end{itemize}
-  \end{itemize}
-}



More information about the training-materials-updates mailing list