[bootlin/training-materials updates] master: labs/buildroot-rootfs: update to BBBW and 2019.02 (2eff3b4f)
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Wed Mar 20 15:01:13 CET 2019
Repository : https://github.com/bootlin/training-materials
On branch : master
Link : https://github.com/bootlin/training-materials/commit/2eff3b4f0aa4e45352b57dc0e37f0b2c2a457d13
>---------------------------------------------------------------
commit 2eff3b4f0aa4e45352b57dc0e37f0b2c2a457d13
Author: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
Date: Wed Mar 20 11:14:32 2019 +0100
labs/buildroot-rootfs: update to BBBW and 2019.02
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
>---------------------------------------------------------------
2eff3b4f0aa4e45352b57dc0e37f0b2c2a457d13
lab-data/buildroot/buildroot-rootfs/S30usbgadget | 36 ++++
.../linux/0001-Add-nunchuk-driver.patch | 18 +-
.../0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch | 28 +--
labs/buildroot-rootfs/buildroot-rootfs.tex | 232 +++++++++------------
4 files changed, 162 insertions(+), 152 deletions(-)
diff --git a/lab-data/buildroot/buildroot-rootfs/S30usbgadget b/lab-data/buildroot/buildroot-rootfs/S30usbgadget
new file mode 100755
index 00000000..48b67237
--- /dev/null
+++ b/lab-data/buildroot/buildroot-rootfs/S30usbgadget
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# set -e
+
+GADGET_DIR=/config/usb_gadget/g1
+OLDPWD=$(pwd)
+
+printf "Starting USB gadget: "
+
+modprobe cppi41
+modprobe musb-am335x
+modprobe musb-dsps
+modprobe phy-am335x
+modprobe libcomposite
+
+mkdir /config
+mount -t configfs none /config
+mkdir ${GADGET_DIR}
+cd ${GADGET_DIR}
+echo "0x05e8" > idVendor
+echo "0xa4a1" > idProduct
+mkdir strings/0x409
+echo "serialnumber" > strings/0x409/serialnumber
+echo "manufacturer" > strings/0x409/manufacturer
+echo "ECM Gadget" > strings/0x409/product
+mkdir functions/ecm.usb0
+mkdir configs/c.1
+mkdir configs/c.1/strings/0x409
+echo Conf 1 > configs/c.1/strings/0x409/configuration
+echo 120 > configs/c.1/MaxPower
+echo "06:32:9b:a9:9d:a5" > functions/ecm.usb0/host_addr
+ln -s functions/ecm.usb0 configs/c.1
+echo musb-hdrc.0 > UDC
+cd ${OLDPWD}
+
+echo "OK"
diff --git a/lab-data/buildroot/buildroot-rootfs/linux/0001-Add-nunchuk-driver.patch b/lab-data/buildroot/buildroot-rootfs/linux/0001-Add-nunchuk-driver.patch
index 07d9e36f..e7b21775 100644
--- a/lab-data/buildroot/buildroot-rootfs/linux/0001-Add-nunchuk-driver.patch
+++ b/lab-data/buildroot/buildroot-rootfs/linux/0001-Add-nunchuk-driver.patch
@@ -1,4 +1,4 @@
-From 3b54b33e76ba503852df8bd77398432b0b2147f8 Mon Sep 17 00:00:00 2001
+From 3ccd02991ef89b40b2b445ba6c91c753619644c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20T=C3=A9nart?= <antoine.tenart at bootlin.com>
Date: Mon, 7 Apr 2014 11:55:31 +0200
Subject: [PATCH 1/2] Add nunchuk driver
@@ -9,14 +9,14 @@ Content-Transfer-Encoding: 8bit
Signed-off-by: Antoine Ténart <antoine.tenart at bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
- drivers/input/joystick/Kconfig | 13 ++
+ drivers/input/joystick/Kconfig | 13 +
drivers/input/joystick/Makefile | 1 +
- drivers/input/joystick/wiichuck.c | 423 ++++++++++++++++++++++++++++++++++++++
+ drivers/input/joystick/wiichuck.c | 423 ++++++++++++++++++++++++++++++
3 files changed, 437 insertions(+)
create mode 100644 drivers/input/joystick/wiichuck.c
diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
-index 56eb471..5b7fba7 100644
+index d8f9c6e1fc08..ca5fd65e3561 100644
--- a/drivers/input/joystick/Kconfig
+++ b/drivers/input/joystick/Kconfig
@@ -193,6 +193,19 @@ config JOYSTICK_TWIDJOY
@@ -40,10 +40,10 @@ index 56eb471..5b7fba7 100644
tristate "5-byte Zhenhua RC transmitter"
select SERIO
diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
-index 92dc0de..78466d6 100644
+index dd0492ebbed7..7ecc74f6aa8b 100644
--- a/drivers/input/joystick/Makefile
+++ b/drivers/input/joystick/Makefile
-@@ -29,6 +29,7 @@ obj-$(CONFIG_JOYSTICK_TMDC) += tmdc.o
+@@ -32,6 +32,7 @@ obj-$(CONFIG_JOYSTICK_TMDC) += tmdc.o
obj-$(CONFIG_JOYSTICK_TURBOGRAFX) += turbografx.o
obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidjoy.o
obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o
@@ -53,7 +53,7 @@ index 92dc0de..78466d6 100644
obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o
diff --git a/drivers/input/joystick/wiichuck.c b/drivers/input/joystick/wiichuck.c
new file mode 100644
-index 0000000..ea7a1e0
+index 000000000000..939cf0c27100
--- /dev/null
+++ b/drivers/input/joystick/wiichuck.c
@@ -0,0 +1,423 @@
@@ -451,7 +451,7 @@ index 0000000..ea7a1e0
+MODULE_DEVICE_TABLE(i2c, wiichuck_id);
+
+#ifdef CONFIG_OF
-+static struct const of_device_id wiichuck_match_table[] __initdata = {
++static const struct of_device_id wiichuck_match_table[] __initdata = {
+ { .compatible = "nintendo,wiimote-extension", },
+ { }
+};
@@ -481,5 +481,5 @@ index 0000000..ea7a1e0
+}
+module_exit(wiichuck_exit);
--
-2.1.0
+2.20.1
diff --git a/lab-data/buildroot/buildroot-rootfs/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch b/lab-data/buildroot/buildroot-rootfs/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch
index edf141ef..c6c13c80 100644
--- a/lab-data/buildroot/buildroot-rootfs/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch
+++ b/lab-data/buildroot/buildroot-rootfs/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch
@@ -1,4 +1,4 @@
-From a995266e8a21583779002b9d14544a09aa2b0b3e Mon Sep 17 00:00:00 2001
+From 785f41a961a02659656e50c5b9020776d5499b00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20T=C3=A9nart?= <antoine.tenart at bootlin.com>
Date: Mon, 7 Apr 2014 11:55:56 +0200
Subject: [PATCH 2/2] Add i2c1 and nunchuk nodes in dts
@@ -9,15 +9,15 @@ Content-Transfer-Encoding: 8bit
Signed-off-by: Antoine Ténart <antoine.tenart at bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
- arch/arm/boot/dts/am335x-bone-common.dtsi | 7 +++++++
- arch/arm/boot/dts/am335x-boneblack.dts | 13 +++++++++++++
+ arch/arm/boot/dts/am335x-bone-common.dtsi | 7 +++++++
+ arch/arm/boot/dts/am335x-boneblack-common.dtsi | 13 +++++++++++++
2 files changed, 20 insertions(+)
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
-index c3255e0..bde42d7 100644
+index 73b514dddf65..8a3c6927f4b0 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
-@@ -81,6 +81,13 @@
+@@ -92,6 +92,13 @@
>;
};
@@ -30,14 +30,14 @@ index c3255e0..bde42d7 100644
+
uart0_pins: pinmux_uart0_pins {
pinctrl-single,pins = <
- 0x170 (PIN_INPUT_PULLUP | MUX_MODE0) /* uart0_rxd.uart0_rxd */
-diff --git a/arch/arm/boot/dts/am335x-boneblack.dts b/arch/arm/boot/dts/am335x-boneblack.dts
-index 5c42d25..778b80a 100644
---- a/arch/arm/boot/dts/am335x-boneblack.dts
-+++ b/arch/arm/boot/dts/am335x-boneblack.dts
-@@ -84,3 +84,16 @@
- &rtc {
- system-power-controller;
+ AM33XX_IOPAD(0x970, PIN_INPUT_PULLUP | MUX_MODE0) /* uart0_rxd.uart0_rxd */
+diff --git a/arch/arm/boot/dts/am335x-boneblack-common.dtsi b/arch/arm/boot/dts/am335x-boneblack-common.dtsi
+index 325daae40278..e13979dc555e 100644
+--- a/arch/arm/boot/dts/am335x-boneblack-common.dtsi
++++ b/arch/arm/boot/dts/am335x-boneblack-common.dtsi
+@@ -161,3 +161,16 @@
+ };
+ };
};
+
+&i2c1 {
@@ -53,5 +53,5 @@ index 5c42d25..778b80a 100644
+ };
+};
--
-2.1.0
+2.20.1
diff --git a/labs/buildroot-rootfs/buildroot-rootfs.tex b/labs/buildroot-rootfs/buildroot-rootfs.tex
index 492b1945..634edbec 100644
--- a/labs/buildroot-rootfs/buildroot-rootfs.tex
+++ b/labs/buildroot-rootfs/buildroot-rootfs.tex
@@ -32,51 +32,110 @@ Buildroot {\em output} tree, take some time to look inside
\end{itemize}
-\section{Configure the network on your host}
+\section{Use a {\em rootfs overlay} to setup the network}
-In the next sections of this lab, we will want to interact with the
-BeagleBone Black over the network. So in this section, we'll configure
-an Ethernet interface on your host machine.
+The BeagleBone Black Wireless does not have any Ethernet interface, so
+we will use Ethernet over USB to provide network connectivity between
+our embedded system and the development PC. To achieve this we will
+need to:
-With a network cable, connect the Ethernet port of your board to the
-one of your computer. If the main wired Ethernet port of your computer
-is already used, your instructor will provide you with a USB Ethernet
-adapter. A new network interface, probably \code{eth1} or \code{eth2},
-should appear on your Linux system.
+\begin{enumerate}
+\item Add an init script to setup network over USB
+\item Add a configuration file that configures the network interface
+ with the appropriate IP address
+\end{enumerate}
-To configure this network interface on the workstation side, click on
-the {\em Network Manager} tasklet on your desktop, and select {\em
-Edit Connections}.
+\subsection{Init script for USB network setup}
-\begin{center}
-\includegraphics[width=8cm]{labs/buildroot-rootfs/network-config-1.png}
-\end{center}
+There are different mechanisms to configure {\em USB gadget} with
+Linux: we will use the {\em gadget configfs} interface, which allows
+from user-space to create USB devices providing an arbitrary set of
+functionalities\footnote{See
+ \url{https://elinux.org/images/e/ef/USB_Gadget_Configfs_API_0.pdf}
+ for more details}.
-Select the new {\em wired network connection}:
+Since the setup of such a {\em USB gadget} is not trivial, we provide
+a ready-to-use shell script that we will add to the {\em init scripts}
+of the Buildroot system. The script is called \code{S30usbgadget} and
+is available from this lab data directory at
+\code{$HOME/buildroot-labs/buildroot-rootfs/}.
-\begin{center}
-\includegraphics[width=8cm]{labs/buildroot-rootfs/network-config-2.png}
-\end{center}
+We could copy this script directly to our SD card, but this would mean
+that the next time we reflash the SD card with the root filesystem
+produced by Buildroot, we would lose those changes.
-In the \code{IPv4 Settings} tab, press the \code{Add} button
-and make the interface use a static IP
-address, like \code{192.168.0.1} (of course, make sure that this
-address belongs to a separate network segment from the one of the main
-company network).
+In order to automate the addition of this script to the root
+filesystem as part of the Buildroot build, we will use the {\bf rootfs
+ overlay} mechanism. Since this {\em overlay} is specific to our
+project, we will create a custom directory for our project within the
+Buildroot sources: \code{board/felabs/beagleboneblack/}.
-\begin{center}
-\includegraphics[width=8cm]{labs/buildroot-rootfs/network-config-3.png}
-\end{center}
+Within this directory, create a \code{rootfs-overlay} directory, and
+in \code{menuconfig}, specify
+\code{board/felabs/beagleboneblack/rootfs-overlay} as the {\em rootfs
+ overlay} (option \code{BR2_ROOTFS_OVERLAY}).
+
+Copy the \code{S30usbgadget} script to your overlay so that it is
+located in
+\code{board/felabs/beagleboneblack/rootfs-overlay/etc/init.d/S30usbgadget}. At
+boot time, the default init system used by Buildroot will execute all
+scripts named \code{SXX*} in \code{/etc/init.d}.
+
+\subsection{IP address configuration}
-You can use \code{255.255.255.0} as \code{Netmask}, and leave the
-\code{Gateway} field untouched (if you click on the \code{Gateway} box, you
-will have to type a valid IP address, otherwise you won't be apply to
-click on the \code{Apply} button).
+By default, Buildroot uses the \code{ifup} program from Busybox, which
+reads the \code{/etc/network/interfaces} file to configure network
+interfaces. So, in \code{board/felabs/beagleboneblack/rootfs-overlay},
+create a file named \code{etc/network/interfaces} with the following
+contents:
+
+\begin{verbatim}
+auto lo
+iface lo inet loopback
+
+auto usb0
+iface usb0 inet static
+ address 192.168.0.2
+ netmask 255.255.255.0
+\end{verbatim}
+
+Then, rebuild your system by running \code{make}. Here as well, we
+don't need to do a full rebuild, since the {\em rootfs overlays} are
+applied at the end of each build. You can check in
+\code{output/target/etc/init.d/} and \code{output/target/etc/network/}
+if both the init script and network configuration files were properly
+copied.
+
+Reflash the root filesystem on the SD card, and boot your BeagleBone
+Black. It should now have an IP address configured for \code{usb0} by
+default.
+
+\section{Configure the network on your host}
+
+In the next sections of this lab, we will want to interact with the
+BeagleBone Black over the network, through USB. So in this section,
+we'll configure your host machine to assign an appropriate IP address
+for the USB network interface.
+
+On Ubuntu, the network interfaces corresponding to Ethernet-over-USB
+connections are named \code{enx<macaddr>}. The host MAC address is
+hardcoded in the \code{S30usbgadget} script to
+\code{f8:dc:7a:00:00:01}, so the interface will be name
+\code{enxf8dc7a000001}.
+
+To configure an IP address for this interface on your host machine,
+we'll use NetworkManager and its command line interface:
+
+\begin{verbatim}
+nmcli con add type ethernet ifname enxf8dc7a000001 ip4 192.168.0.1/24
+\end{verbatim}
{\em Note: using \code{ifconfig} in the command line is not
-recommended, because Network Manager will unconfigure and reconfigure
-the network interface each time the cable is unplugged or each time
-the board reboots.}
+recommended, because Network Manager will unconfigure and
+reconfigure the network interface each time the board is rebooted.}
+
+Once this is done, make sure you can communicate with your target
+using \code{ping}.
\section{Add {\em dropbear} as an SSH server}
@@ -114,60 +173,8 @@ message:
Starting dropbear sshd: OK
\end{verbatim}
-Log in the system, and configure an IP address manually by doing
-\code{ifconfig eth0 192.168.0.2}. Now, from your host machine, you can
-connect over the network to the board by doing \code{ssh
-root at 192.168.0.2}.
-
-However, configuring the IP address every time you boot the board is
-not very practical, so let's move to the next section, in which we
-will learn how to do this properly.
-
-\section{Use a {\em rootfs overlay} to configure the IP address}
-
-By default, Buildroot uses the \code{ifup} program from Busybox, which
-reads the \code{/etc/network/interfaces} file to configure network
-interfaces.
-
-So, we could write a \code{/etc/network/interfaces} file on our
-target, and reboot. However, the next time we will fully rebuild and
-reflash our system, such changes will have disappeared. It is
-important that our build process remains fully reproducible, so we
-want to ensure that the next build will include such custom
-configuration.
-
-To achieve this, the easiest way is to use the {\bf rootfs overlay}
-mechanism of Buildroot. Since this {\em overlay} is specific to our
-project, we will create a custom directory for our project within the
-Buildroot sources: \code{board/felabs/beagleboneblack/}.
-
-Within this directory, create a \code{rootfs-overlay} directory, and
-in \code{menuconfig}, specify
-\code{board/felabs/beagleboneblack/rootfs-overlay} as the {\em rootfs
-overlay} (option \code{BR2_ROOTFS_OVERLAY}).
-
-Then, in \code{board/felabs/beagleboneblack/rootfs-overlay}, create a
-file named \code{etc/network/interfaces} with the following contents:
-
-\begin{verbatim}
-auto lo
-iface lo inet loopback
-
-auto eth0
-iface eth0 inet static
- address 192.168.0.2
- netmask 255.255.255.0
-\end{verbatim}
-
-Then, rebuild your system by running \code{make}. Here as well, we
-don't need to do a full rebuild, since the {\em rootfs overlays} are
-applied at the end of each build. You can check in
-\code{output/target/etc/network/interfaces} if the contents of the
-file are good.
-
-Reflash the root filesystem on the SD card, and boot your BeagleBone
-Black. It should now have an IP address configured for \code{eth0} by
-default.
+From your host machine, you can connect over the network to the board
+by doing \code{ssh root at 192.168.0.2}.
\section{Use a post-build script}
@@ -194,7 +201,7 @@ will sit next to our {\em rootfs overlay} in our project-specific
directory:
\begin{verbatim}
-mkdir board/felabs/beagleboneblack/linux-patches/
+mkdir board/felabs/beagleboneblack/patches/linux/
\end{verbatim}
Copy in this directory the two patches that we provided with the data
@@ -202,7 +209,7 @@ of this lab, in \code{$HOME/buildroot-labs/buildroot-rootfs/linux/}:
\begin{verbatim}
cp $HOME/buildroot-labs/buildroot-rootfs/linux/*.patch \
- board/felabs/beagleboneblack/linux-patches/
+ board/felabs/beagleboneblack/patches/linux/
\end{verbatim}
The first patch adds the driver, the second patch adjusts the Device
@@ -211,9 +218,9 @@ our training course {\em Embedded Linux kernel driver development},
which precisely covers the development of this driver.
Now, we need to tell Buildroot to apply these patches before building
-the kernel. To do so, run \code{menuconfig}, go the to the {\em
-Kernel} menu, and adjust the \code{Custom kernel patches} variable to
-\code{board/felabs/beagleboneblack/linux-patches/}.
+the kernel. To do so, run \code{menuconfig}, go the to the {\em Build
+ options} menu, and adjust the \code{Global patch directories} option
+to \code{board/felabs/beagleboneblack/patches/}.
Let's now clean up completely the \code{linux} package so that its
sources will be re-extracted and our patches applied the next time we
@@ -223,8 +230,8 @@ do a build:
make linux-dirclean
\end{verbatim}
-If you check in \code{output/build/}, the \code{linux-4.13} directory
-will have disappeared.
+If you check in \code{output/build/}, the \code{linux-4.19.29}
+directory will have disappeared.
Now, we need to adjust our kernel configuration to enable the {\em Wii
Nunchuk} driver. To start the Linux kernel configuration tool, run:
@@ -253,7 +260,7 @@ 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:
+of the kernel:
\begin{verbatim}
make
@@ -447,36 +454,3 @@ log:
\begin{verbatim}
make 2>&1 | tee build.log
\end{verbatim}
-
-\section{Going further}
-
-If you have some time left, let's improve our setup to use TFTP and
-NFS, in order to avoid having to reflash the SD card for every
-test. What you need to do is:
-
-\begin{enumerate}
-
-\item Install a TFTP server (package \code{tftpd-hpa}) and a NFS
- server (package \code{nfs-kernel-server}) on your system. Configure
- the NFS server, in \code{/etc/exports} to export
- \code{/home/<user>/nfsroot} over NFS.
-
-\item Copy the Linux kernel image and Device Tree to
- \code{/var/lib/tftpboot} so that they are made available by the TFTP
- server.
-
-\item Extract (as root) \code{rootfs.tar} to
- \code{/home/<user>/nfsroot}.
-
-\item Change the U-Boot \code{bootcmd} to load the kernel image and
- the Device Tree over TFTP.
-
-\item Change the U-Boot \code{bootargs} variable to tell the Linux
- kernel that the root filesystem should be mounted over NFS:
- \code{root=/dev/nfs ip=<IP of board> nfsroot=<IP of
- PC>:/home/<user>/nfsroot}.
-
-\end{enumerate}
-
-See the training materials of our {\em Embedded Linux system
- development} course for details!
More information about the training-materials-updates
mailing list