[FE training-materials-updates] buildroot-rootfs: finalize lab

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Thu Apr 23 14:28:11 CEST 2015


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

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

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

commit 18fc909a8958a1d1483d4788e99497b840387ad8
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Thu Apr 23 14:27:47 2015 +0200

    buildroot-rootfs: finalize lab
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


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

18fc909a8958a1d1483d4788e99497b840387ad8
 .../bbb-connect-nunchuk.svg                        |   0
 labs/buildroot-rootfs/buildroot-rootfs.tex         | 197 +++++++++++++++++++++
 .../nunchuk-pinout.svg                             |   0
 3 files changed, 197 insertions(+)

diff --git a/labs/kernel-i2c-device-model/bbb-connect-nunchuk.svg b/labs/buildroot-rootfs/bbb-connect-nunchuk.svg
similarity index 100%
copy from labs/kernel-i2c-device-model/bbb-connect-nunchuk.svg
copy to labs/buildroot-rootfs/bbb-connect-nunchuk.svg
diff --git a/labs/buildroot-rootfs/buildroot-rootfs.tex b/labs/buildroot-rootfs/buildroot-rootfs.tex
index 4495d82..bfe9233 100644
--- a/labs/buildroot-rootfs/buildroot-rootfs.tex
+++ b/labs/buildroot-rootfs/buildroot-rootfs.tex
@@ -208,8 +208,205 @@ This will:
 \item Start the kernel \code{menuconfig} tool
 \end{itemize}
 
+Once in the kernel \code{menuconfig}, search for the option
+\code{CONFIG_JOYSTICK_WIICHUCK} by using the search engine tool
+accessible by typing \code{/}. Make sure to enable the {\em Nintendo
+  Wiimote Extension connector on i2c bus} option using a \code{*} so
+that the driver is part of the kernel image itself (enabling with
+\code{M} would lead the driver to be compiled as a module). Also, make
+sure the \code{CONFIG_INPUT_EVDEV} option is enabled with \code{*} (by
+default it is enabled as a module).
+
+You can now exit the kernel \code{menuconfig}, and restart the build
+of kernel:
+
+\begin{verbatim}
+make
+\end{verbatim}
+
+It should hopefully end successfully, and if you look closely at the
+build log, you should see the file \code{wiichuck.c} being compiled.
+
+However, the change of the configuration has only been made in the
+build directory of the Linux kernel, which gets removed when you do a
+\code{make clean}. Since we want to make this configuration
+persistent, we have to do a few more steps:
+
+\begin{enumerate}
+
+\item Run Buildroot \code{menuconfig}
+
+\item In the \code{Kernel} menu, instead of \code{Using a defconfig},
+  chose \code{Using a custom config file}. This will allow us to use
+  our own custom kernel configuration file, instead of a pre-defined
+  {\em defconfig} that comes with the kernel sources.
+
+\item In the \code{Configuration file path}, enter
+  \code{board/felabs/beagleboneblack/linux.config}.
+
+\item Exit \code{menuconfig}
+
+\item Run \code{make linux-update-config}. This will update the
+  configuration file in
+  \code{board/felabs/beagleboneblack/linux.config}. In this file,
+  verify that the option \code{CONFIG_JOYSTICK_WIICHUCK} is properly
+  set to \code{y}.
+
+\end{enumerate}
+
+Congratulations, your kernel configuration is now customized, and will
+be re-used for the next builds!
+
+\section{Connect the Wii Nunchuk}
+
+Take the nunchuk device provided by your instructor.
+
+We will connect it to the second I2C port of the CPU (\code{i2c1}),
+with pins available on the \code{P9} connector.
+
+Identify the 4 pins of the nunchuk connector:
+
+\begin{center}
+\includegraphics[width=4cm]{labs/buildroot-rootfs/nunchuk-pinout.pdf}
+\end{center}
+
+Connect the nunchuk pins:
+\begin{itemize}
+\item The \code{GND} pin to P9 pins 1 or 2 (\code{GND})
+\item The \code{PWR} pin to P9 pins 3 or 4 (\code{DC_3.3V})
+\item The \code{CLK} pin to P9 pin 17 (\code{I2C1_SCL})
+\item The \code{DATA} pin to P9 pin 18 (\code{I2C1_SDA})
+\end{itemize}
+
+\begin{center}
+\includegraphics[width=12cm]{labs/buildroot-rootfs/bbb-connect-nunchuk.pdf}
+\end{center}
+
+\section{Test the {\em nunchuk}}
+
+Reflash your system, both the {\em Device Tree}, Linux kernel image
+and root filesystem, and boot it.
+
+In the kernel boot log, you should see a message like:
+
+\begin{verbatim}
+input: Wiichuck expansion connector as /devices/platform/ocp/4802a000.i2c/i2c-1/1-0052/input/input0
+\end{verbatim}
+
+You can also explore {\em sysfs}, and see that your Nunchuk device is
+handled by the system:
+
+\begin{verbatim}
+cat /sys/bus/i2c/devices/1-0052/name
+\end{verbatim}
+
+Now, to get the raw events coming from the Nunchuk, you can do:
+
+\begin{verbatim}
+cat /dev/input/event0
+\end{verbatim}
+
+or, if you prefer to see hexadecimal values instead of raw binary:
+
+\begin{verbatim}
+cat /dev/input/event0 | hexdump -C
+\end{verbatim}
+
+You should see events when moving the Nunchuk (it has an
+accelerometer), when moving the joystick and pushing the buttons.
+
 \section{Add and use {\em input-tools}}
 
+Since the raw events from the Nunchuk are not very convenient to read,
+let's install an application that will decrypt the raw input events
+and display them in a more human readable format: \code{evtest}.
+
+Enable this package in Buildroot, restart the build, reflash the root
+filesystem and reboot the system. Now you can use \code{evtest}:
+
+\begin{verbatim}
+evtest /dev/input/event0
+\end{verbatim}
+
 \section{Generate a {\em defconfig}}
 
+Now that our system is already in a good shape, let's make sure its
+configuration is properly saved and cannot be lost. Go in
+\code{menuconfig}, and in the \code{Build options} menu. There is an
+option called \code{Location to save buildroot config} which indicates
+where Buildroot will save the {\em defconfig} file generated by
+\code{make savedefconfig}. Adjust this value to
+\code{$(TOPDIR)/configs/felabs_defconfig}.
+
+Then, exit \code{menuconfig}, and run:
+
+\begin{verbatim}
+make savedefconfig
+\end{verbatim}
+
+Read the file \code{configs/felabs_defconfig} generated in the
+Buildroot sources. You will see the values for all the options for
+which we selected a value different from the default. So it's a very
+good summary of what our system is.
+
+Identify the options related to the following aspects of the system:
+
+\begin{itemize}
+\item The architecture specification
+\item The toolchain definition
+\item The system configuration
+\item The Linux kernel related configuration
+\item The selection of packages
+\item The U-Boot related configuration
+\end{itemize}
+
 \section{Testing a full rebuild}
+
+To make sure that we are able to rebuild our system completely, we'll
+start a build from scratch. And to learn something new, we'll use {\em
+  out of tree} build.
+
+To do so, create a build directory anywhere you want, and move inside
+this directory:
+
+\begin{verbatim}
+mkdir ~/felabs/buildroot-build/
+cd ~/felabs/buildroot-build/
+\end{verbatim}
+
+Now, we will load the \code{felabs_defconfig}:
+
+\begin{verbatim}
+make -C ~/felabs/buildroot/ O=$(pwd) felabs_defconfig
+\end{verbatim}
+
+Let's explain a little bit what happens here. By using
+\code{-C ~/felabs/buildroot/}, we in fact tell \code{make} that the
+\code{Makefile} to analyze is not in the current directory, but in the
+directory passed as the \code{-C} argument. By passing \code{O=}, we
+tell Buildroot where all the output should go: by default it goes in
+\code{output/} inside the Buildroot sources, but here we override that
+with the current directory (\code{$(pwd)}).
+
+This command will have two main effects:
+
+\begin{enumerate}
+
+\item It will load the \code{felabs_defconfig} as the current
+  configuration. After running the command, read the file named
+  \code{.config}. It's much longer than the {\em defconfig}, because
+  it contains the values for all options.
+
+\item It will create a minimal \code{Makefile} in this output
+  directory, which will allow us to avoid doing the \code{make -C
+    ... O=...} dance each time.
+
+\end{enumerate}
+
+Now that this is done, start the build. You can again save the build
+log:
+
+\begin{verbatim}
+make 2>&1 | tee build.log
+\end{verbatim}
+
diff --git a/labs/kernel-i2c-device-model/nunchuk-pinout.svg b/labs/buildroot-rootfs/nunchuk-pinout.svg
similarity index 100%
copy from labs/kernel-i2c-device-model/nunchuk-pinout.svg
copy to labs/buildroot-rootfs/nunchuk-pinout.svg



More information about the training-materials-updates mailing list