[FE training-materials-updates] Add NFS instructions to the Android labs

Maxime Ripard maxime.ripard at free-electrons.com
Fri Nov 22 10:51:53 CET 2013


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

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

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

commit 27d92d70a811b22dad78c0b8ad7471f25de73abf
Author: Maxime Ripard <maxime.ripard at free-electrons.com>
Date:   Fri Nov 22 10:50:38 2013 +0100

    Add NFS instructions to the Android labs
    
    Signed-off-by: Maxime Ripard <maxime.ripard at free-electrons.com>


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

27d92d70a811b22dad78c0b8ad7471f25de73abf
 labs/android-new-board/android-new-board.tex |  249 ++++++++++++++++++++++----
 labs/android-new-board/network-config-1.png  |    1 +
 labs/android-new-board/network-config-2.png  |    1 +
 labs/android-new-board/network-config-3.png  |    1 +
 4 files changed, 218 insertions(+), 34 deletions(-)

diff --git a/labs/android-new-board/android-new-board.tex b/labs/android-new-board/android-new-board.tex
index 6904a44..83767cb 100644
--- a/labs/android-new-board/android-new-board.tex
+++ b/labs/android-new-board/android-new-board.tex
@@ -23,8 +23,8 @@ give him and the current code we have. To do so, we first need to
 change the manifest we use to the rowboat's one.
 
 \begin{verbatim}
-repo init -u git://gitorious.org/rowboat/manifest.git \
-    -b master -m rowboat-jb-am335x.xml
+repo init -u git://git.free-electrons.com/android/rowboat/manifest.git \
+        -b free-electrons -m rowboat-jb-am335x.xml
 \end{verbatim}
 
 Now, let's run the big download job:
@@ -86,34 +86,11 @@ make OMAPES=4.x fs_tarball
 \end{verbatim}
 
 It will generate in \code{out/target/product/beagleboneblack} a
-rootfs.tar.bz2 tarball holding all the files needed for Android to
-boot.
+\code{rootfs.tar.bz2} tarball holding all the files needed for Android
+to boot.
 
-We then need to put this image on an SD card so that we can boot on
-the system we just generated.
-
-First, take the SD card provided by your instructor, and insert it
-into an SD card reader slot in your workstation, or into a USB card
-reader provided by your instructor too. Then, using the \code{dmesg}
-command, find which device your workstation uses for your SD card.
-Let's assume that this device is \code{/dev/sdc}.
-
-Rowboat comes with a script that will format the SD card with the
-geometry expected by the SoC to be able to boot it, with the correct
-partitions, and copy everything we compiled so that we end up with a
-ready-to-use SD card.
-
-You can use this script with the following commands:
-
-\begin{verbatim}
-sudo external/ti_android_utilities/am335x/mk-mmc/mkmmc-android.sh \
-    /dev/sdc u-boot/MLO u-boot/u-boot.img kernel/arch/arm/boot/uImage \
-    external/ti_android_utilities/am335x/u-boot-env/uEnv_beagleboneblack.txt \
-    out/target/product/beagleboneblack/rootfs.tar.bz2
-\end{verbatim}
-
-Once this command is over, you can remove the SD card and insert it
-into the corresponding slot on the BeagleBone board.
+We will now be able to boot on this image, using NFS to ease the
+development process.
 
 \section{Setting up serial communication with the board}
 
@@ -154,11 +131,215 @@ communication on \code{/dev/ttyUSB0}, with a baudrate of 115200. If
 you wish to exit \code{picocom}, press \code{[Ctrl][a]} followed by
 \code{[Ctrl][x]}.
 
+\section{Load the kernel from TFTP}
+
+Later on, we will transfer files from the development workstation to
+the board using the TFTP protocol, which works on top of an Ethernet
+connection.
+
+To start with, install and configure a TFTP server on your development
+workstation, as detailed in the bootloader slides.
+
+With a network cable, connect the Ethernet port of your board to the
+one of your computer. If your computer already has a wired connection
+to the network, 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.
+
+To configure this network interface on the workstation side, click on
+the {\em Network Manager} tasklet on your desktop, and select {\em
+  Edit Connections}.
+
+\begin{center}
+\includegraphics[width=8cm]{labs/android-new-board/network-config-1.png}
+\end{center}
+
+Select the new {\em wired network connection}:
+
+\begin{center}
+\includegraphics[width=8cm]{labs/android-new-board/network-config-2.png}
+\end{center}
+
+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).
+
+\begin{center}
+\includegraphics[width=8cm]{labs/android-new-board/network-config-3.png}
+\end{center}
+
+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).
+
+Now, configure the network on the board in U-Boot by setting the \code{ipaddr}
+and \code{serverip} environment variables:
+
+\begin{verbatim}
+setenv ipaddr 192.168.0.100
+setenv serverip 192.168.0.1
+\end{verbatim}
+
+In case the board was previously configured in a different way, we
+also turn off automatic booting after commands that can be used to
+copy a kernel to RAM:
+
+\begin{verbatim}
+setenv autostart no
+\end{verbatim}
+
+To make these settings permanent, save the environment:
+
+\begin{verbatim}
+saveenv
+\end{verbatim}
+
+Now switch your board off and on again\footnote{Power cycling your
+  board is needed to make your \code{ethaddr} permanent, for obscure
+  reasons. If you don't, U-boot will complain that \code{ethaddr} is not
+  set.}.
+
+You can then test the TFTP connection. First, put a small text file in
+the directory exported through TFTP on your development
+workstation. Then, from U-Boot, do:
+
+\begin{verbatim}
+tftp 0x80000000 textfile.txt
+\end{verbatim}
+
+{\bf Caution: known issue in Ubuntu 12.04 and later}:
+if this command doesn't work, you may have to stop the server
+and start it again every time you boot your workstation:
+
+\begin{verbatim}
+/etc/init.d/tftpd-hpa restart
+\end{verbatim}
+
+The \code{tftp} command should have downloaded
+the \code{textfile.txt} file from your development
+workstation into the board's memory at location 0x80000000 (this
+location is part of the board DRAM). You can verify that the download
+was successful by dumping the contents of the memory:
+
+\begin{verbatim}
+md 0x80000000
+\end{verbatim}
+
+Now, we can start loading our kernel.
+
+\begin{itemize}
+\item On your workstation, copy the file
+  \code{kernel/arch/arm/boot/uImage} to the directory exposed by the
+  TFP server.
+\item On the target, load \code{uImage} from TFTP into RAM at address
+  \code{0x80000000}
+  \begin{itemize}
+  \item \code{tftp 0x80000000 uImage}
+  \end{itemize}
+\item Boot the kernel
+  \begin{itemize}
+  \item \code{bootm 0x80000000}
+  \end{itemize}
+\end{itemize}
+
+You should see Linux boot and finally hang with the following message:
+
+\begin{verbatim}
+Waiting for root device /dev/mmcblk0p2...
+\end{verbatim}
+
+This is expected: we haven't provided a working root filesystem for
+our device yet.
+
+You can now automate all this every time the board is booted or
+reset. Reset the board, and specify a different \code{bootcmd}:
+
+\begin{verbatim}
+setenv bootcmd 'tftp 80000000 uImage; bootm 8000000'
+saveenv
+\end{verbatim}
+
+\section{Setting up the NFS server}
+
+Create a \code{nfsroot} directory in the \code{felabs/android}
+directory. This \code{nfsroot} directory will be used to store the
+contents of our new root filesystem.
+
+Install the NFS server by installing the \code{nfs-kernel-server}
+package if you don't have it yet. Once installed, edit the
+\code{/etc/exports} file as root to add the following line, assuming that the
+IP address of your board will be \code{192.168.0.100}:
+
+\footnotesize
+\begin{verbatim}
+/home/<user>/felabs/android/nfsroot 192.168.0.100(rw,no_root_squash,no_subtree_check)
+\end{verbatim}
+\normalsize
+
+Make sure that the path and the options are on the same line.
+Also make sure that there is no space between the IP address and the NFS
+options, otherwise default options will be used for this IP address,
+causing your root filesystem to be read-only.
+
+Then, restart the NFS server:
+
+\begin{verbatim}
+sudo /etc/init.d/nfs-kernel-server restart
+\end{verbatim}
+
+\section{Booting the system}
+
+First, boot the board to the U-Boot prompt. Before booting the kernel,
+we need to tell it that the root filesystem should be mounted over
+NFS, by setting some kernel parameters.
+
+Use the following U-Boot command to do so, {\bf in just 1 line}
+(Caution: in \code{ttyO0} below, it's the capital letter \code{O}, like in
+{\bf O}MAP and then the number zero):
+
+\begin{verbatim}
+setenv bootargs console=ttyO0,115200 root=/dev/nfs ip=192.168.0.100
+   nfsroot=192.168.0.1:/home/<user>/felabs/android/nfsroot rw
+   androidboot.console=ttyO0 init=/init
+\end{verbatim}
+
+Of course, you need to adapt the IP addresses to your exact network
+setup. Save the environment variables (with \code{saveenv}).
+
+Now, boot your system. The kernel should be able to mount the root
+filesystem over NFS:
+
+\begin{verbatim}
+[    7.467895] VFS: Mounted root (nfs filesystem) readonly on device 0:12.
+\end{verbatim}
+
+If the kernel fails to mount the NFS filesystem, look carefully at the
+error messages in the console. If this doesn't give any clue, you can
+also have a look at the NFS server logs in \code{/var/log/syslog}.
+
+However, at this stage, the kernel should complain, saying that it
+can't find an init application:
+
+\footnotesize
+\begin{verbatim}
+Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
+  See Linux Documentation/init.txt for guidance.
+\end{verbatim}
+\normalsize
+
+Obviously, our root filesystem being empty, there isn't such an
+application yet.
+
 \section{Booting the board}
 
-Once you inserted the SD card, you can boot the board by holding the
-\code{boot} key while switching the board on. On the serial port, you
-should see Android going through its boot process, until you finally
-have a shell on the serial link and the screen working properly.
+Go into the \code{nfsroot} directory, and extract the rootfs tarball
+we created previously using
+\code{sudo tar xvf ../source/out/target/product/beagleboneblack/rootfs.tar.bz2}.
 
-\section{TODO: Fix the screen resolution}
+Once there's extraction's done, you can reboot the board. On the
+serial port, you should see Android going through its boot process,
+until you finally have a shell on the serial link and the screen
+working properly.
diff --git a/labs/android-new-board/network-config-1.png b/labs/android-new-board/network-config-1.png
new file mode 120000
index 0000000..0354fef
--- /dev/null
+++ b/labs/android-new-board/network-config-1.png
@@ -0,0 +1 @@
+../sysdev-u-boot/network-config-1.png
\ No newline at end of file
diff --git a/labs/android-new-board/network-config-2.png b/labs/android-new-board/network-config-2.png
new file mode 120000
index 0000000..2982b0f
--- /dev/null
+++ b/labs/android-new-board/network-config-2.png
@@ -0,0 +1 @@
+../sysdev-u-boot/network-config-2.png
\ No newline at end of file
diff --git a/labs/android-new-board/network-config-3.png b/labs/android-new-board/network-config-3.png
new file mode 120000
index 0000000..0077b84
--- /dev/null
+++ b/labs/android-new-board/network-config-3.png
@@ -0,0 +1 @@
+../sysdev-u-boot/network-config-3.png
\ No newline at end of file



More information about the training-materials-updates mailing list