[FE training-materials-updates] Add Marvell Armada specific lab

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Tue Jul 22 11:07:29 CEST 2014


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

On branch  : marvell-armada
Link       : http://git.free-electrons.com/training-materials/commit/?id=c1a7ae550befb4fb503b48e7619d4439ee7a9fa9

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

commit c1a7ae550befb4fb503b48e7619d4439ee7a9fa9
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Tue Jul 22 11:06:06 2014 +0200

    Add Marvell Armada specific lab
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


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

c1a7ae550befb4fb503b48e7619d4439ee7a9fa9
 Makefile                                           |    1 +
 agenda/kernel-agenda.tex                           |   25 ++-
 lab-data/linux/marvell-armada/rootfs.cpio.be       |  Bin 0 -> 3163648 bytes
 lab-data/linux/marvell-armada/rootfs.cpio.le       |  Bin 0 -> 3195904 bytes
 lab-data/linux/marvell-armada/scu-fix.patch        |   12 ++
 .../kernel-marvell-armada.tex                      |  224 ++++++++++++++++++++
 6 files changed, 259 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e7d8cc7..01df5f0 100644
--- a/Makefile
+++ b/Makefile
@@ -272,6 +272,7 @@ KERNEL_LABS   = setup \
 		kernel-serial-interrupt \
 		kernel-locking \
 		kernel-debugging \
+		kernel-marvell-armada \
 		kernel-git \
 #		backup # Currently broken for kernel course
 
diff --git a/agenda/kernel-agenda.tex b/agenda/kernel-agenda.tex
index fc8198f..d6bafcb 100644
--- a/agenda/kernel-agenda.tex
+++ b/agenda/kernel-agenda.tex
@@ -461,7 +461,7 @@ Embedded Linux kernel and driver development training\\
 
 \section{Day 5 - Afternoon}
 
-\feagendatwocolumn
+\feagendaonecolumn
 {Lecture - ARM board support and SoC support}
 {
   \begin{itemize}
@@ -470,6 +470,27 @@ Embedded Linux kernel and driver development training\\
     board
   \end{itemize}
 }
+
+\feagendatwocolumn
+{Lecture - Marvell Armada mainline support}
+{
+  \begin{itemize}
+  \item Process of mainlining the Marvell Armada support
+  \item Timeline of the mainlining process
+  \item Location of Marvell Armada specific code in the kernel
+  \end{itemize}
+}
+{Lab - Building and booting mainline on Armada 385 RD}
+{
+  \begin{itemize}
+  \item Building and configuring a little endian mainline kernel
+  \item Booting on Marvell Armada 385 RD
+  \item Exploring useful {\em debugfs} entries
+  \item Building and booting a big endian mainline kernel
+  \end{itemize}
+}
+
+\feagendatwocolumn
 {Lecture - Power management}
 {
   \begin{itemize}
@@ -479,8 +500,6 @@ Embedded Linux kernel and driver development training\\
     regulators, etc.
   \end{itemize}
 }
-
-\feagendaonecolumn
 {Lecture - The Linux kernel development process}
 {
   \begin{itemize}
diff --git a/lab-data/linux/marvell-armada/rootfs.cpio.be b/lab-data/linux/marvell-armada/rootfs.cpio.be
new file mode 100644
index 0000000..da7020d
Binary files /dev/null and b/lab-data/linux/marvell-armada/rootfs.cpio.be differ
diff --git a/lab-data/linux/marvell-armada/rootfs.cpio.le b/lab-data/linux/marvell-armada/rootfs.cpio.le
new file mode 100644
index 0000000..00fc8f5
Binary files /dev/null and b/lab-data/linux/marvell-armada/rootfs.cpio.le differ
diff --git a/lab-data/linux/marvell-armada/scu-fix.patch b/lab-data/linux/marvell-armada/scu-fix.patch
new file mode 100644
index 0000000..ad4fbe8
--- /dev/null
+++ b/lab-data/linux/marvell-armada/scu-fix.patch
@@ -0,0 +1,12 @@
+diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
+index 2c35f0f..87f6c2e 100644
+--- a/arch/arm/kernel/head.S
++++ b/arch/arm/kernel/head.S
+@@ -506,6 +506,7 @@ __fixup_smp:
+ 	@ below address check will need to be #ifdef'd or equivalent
+ 	@ for the Aegis platform.
+ 	mrc	p15, 4, r0, c15, c0	@ get SCU base address
++	ldr	r0, =0xf100c000
+ 	teq	r0, #0x0		@ '0' on actual UP A9 hardware
+ 	beq	__fixup_smp_on_up	@ So its an A9 UP
+ 	ldr	r0, [r0, #4]		@ read SCU Config
diff --git a/labs/kernel-marvell-armada/kernel-marvell-armada.tex b/labs/kernel-marvell-armada/kernel-marvell-armada.tex
new file mode 100644
index 0000000..19c3804
--- /dev/null
+++ b/labs/kernel-marvell-armada/kernel-marvell-armada.tex
@@ -0,0 +1,224 @@
+\subchapter{Marvell Armada}{Objective: build and boot a mainline kernel}
+
+During this lab, you will:
+
+\begin{itemize}
+\item Build a little endian mainline kernel and boot it on Armada 385 RD
+\item Explore a few useful {\em debugfs} files
+\item Build a big endian mainline kernel and boot it on Armada 385 RD
+\end{itemize}
+
+\section{Getting the kernel sources}
+
+Checkout the \code{v3.16-rc6} tag, which will allow us to test one of
+the latest release candidate of the kernel. If there is a newer one,
+you can also try it.
+
+Apply the \code{scu-fix.patch} patch available from the labs data
+directory (\code{$HOME/felabs/linux/marvell-armada}). It works around
+a problem in the Marvell U-Boot bootloader, which has been fixed in
+more recent versions of U-Boot (maybe it is even already fixed on the
+board you're using).
+
+\section{Configuring the kernel}
+
+Since we'll do both a little endian build and a big endian build,
+we'll use out of tree build. This means we'll have one source tree,
+and two separate build trees. Start by creating a build directory:
+
+\begin{verbatim}
+mkdir $HOME/felabs/linux/mvebu-le
+\end{verbatim}
+
+And move to this directory.
+
+We'll start with the \code{mvebu_v7_defconfig}, which is the reference
+configuration for ARMv7 Marvell EBU platforms in the kernel (i.e
+Armada 370, XP, 375, 38x and Dove) :
+
+\begin{verbatim}
+make -C $HOME/felabs/linux/src O=$(pwd) ARCH=arm mvebu_v7_defconfig
+\end{verbatim}
+
+This command tells \code{make} to use the Makefile in
+\code{$HOME/felabs/linux/src}, but also tells the kernel that the
+current directory (passed through \code{O=}) should be used as the
+build tree. After this command has been executed, a small {\em
+  wrapper} Makefile has been generated in the build directory, so we
+don't have to pass \code{-C} and \code{O=} again.
+
+We now need to refine the configuration, so run:
+
+\begin{verbatim}
+make ARCH=arm menuconfig
+\end{verbatim}
+
+We will have to:
+
+\begin{itemize}
+\item In {\em General setup} $\rightarrow$ {\em Initial RAM filesystem
+    and RAM disk (initramfs/initrd) support} $\rightarrow$ {\em
+    Initramfs source file(s)}, set the path to the pre-built {\em
+    initramfs} we are providing. It is available in
+  \code{$HOME/felabs/linux/marvell-armada/rootfs.cpio.le}.
+\item In {\em System Type}, explore the options available under {\em
+    Marvell Engineering Business Unit (MVEBU) SoCs}
+\item In {\em Boot Options}, make sure {\em Use appended device tree
+    blob to zImage} and {\em Supplement the appended DTB with
+    traditional ATAG information} are enabled. The first option allows
+  to use a Device Tree appended to the zImage, which is useful on
+  platforms where the bootloader does not have Device Tree
+  support. The second allows the kernel to read the legacy ATAGs
+  information passed by a non-DT-capable bootloader.
+\item In {\em Kernel hacking}, enable the {\em Kernel low-level
+    debugging functions} option. Then you should choose the right UART
+  for the platform we're using. For Marvell EBU platforms, there are
+  two options:
+  \begin{itemize}
+  \item {\em Kernel low-level debugging messages via MVEBU UART (old
+      bootloaders)}, which uses the UART at physical address
+    \code{0xd0012000}. This is what is used on old Armada 370/XP
+    platforms where the bootloader was leaving the internal registers
+    mapped at \code{0xd0000000}.
+  \item {\em Kernel low-level debugging messages via MVEBU UART (new
+      bootloaders)}, which uses the UART at physical address
+    \code{0xf1012000}. This is what should be used with recent Armada
+    370/XP platforms, and on all Armada 375/38x platforms. Therefore,
+    select this choice.
+  \end{itemize}
+\item Still in {\em Kernel hacking}, make sure to enable {\em Early
+    printk}.
+\item Also, our initramfs makes the assumption that {\em devtmpfs}
+  will be available. Therefore, in {\em Device Drivers} $\rightarrow$
+  {\em Generic Driver Options}, enable {\em Maintain a devtmpfs
+    filesystem to mount at /dev} and {\em Automount devtmpfs at /dev,
+    after the kernel mounted the rootfs}.
+\end{itemize}
+
+\section{Building the kernel}
+
+Now that the configuration is done, it's time to build the kernel:
+
+\begin{verbatim}
+make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4
+\end{verbatim}
+
+Since the bootloader on the Armada 385 RD board does not have DT
+support (at least in the \code{Marvell version: 2014_T1.0_eng_drop_v6}
+we have used), we will use the appended Device Tree technique. So,
+first, append the Device Tree blob to the zImage:
+
+\begin{verbatim}
+cat arch/arm/boot/zImage arch/arm/boot/dts/armada-385-rd.dtb > zImage-with-dtb
+\end{verbatim}
+
+Now, we need to produce a U-Boot {\em uImage}. In order to avoid the
+relocation of the kernel, we'll set the load address in the {\em
+  uImage} to be the same as the place where we will actually load the
+kernel in memory, and we'll set the entry point 64 bytes after that,
+to skip the {\em uImage header}.
+
+\begin{verbatim}
+mkimage -A arm -O linux -T kernel -C none -a 0x2000000 -e 0x2000040 -d zImage-with-dtb uImage-with-dtb
+\end{verbatim}
+
+Our \code{uImage-with-dtb} is ready for booting.
+
+\section{Booting the kernel}
+
+In U-Boot, adjust the \code{serverip} and \code{ipaddr} environment
+variables to match your environment.
+
+Then, define the kernel command line argument:
+
+\begin{verbatim}
+setenv bootargs console=ttyS0,115200 earlyprintk
+\end{verbatim}
+
+Load the kernel image in memory:
+
+\begin{verbatim}
+tftp 0x2000000 uImage-with-dtb
+\end{verbatim}
+
+And boot:
+
+\begin{verbatim}
+bootm
+\end{verbatim}
+
+At the end of the boot, the {\em Buildroot} login prompt should
+appear. You can log in as root and start exploring the system.
+
+\section{Exploring useful debugfs entries}
+
+There are a few interesting things to look at in {\em debugfs}, so
+we'll start by mounting debugfs:
+
+\begin{verbatim}
+mount -t debugfs none /sys/kernel/debug/
+\end{verbatim}
+
+Then, have a look at:
+
+\begin{itemize}
+\item \code{/sys/kernel/debug/mvebu-mbus/devices}, which contains a
+  list of the CPU $\rightarrow$ devices MBus windows that are
+  currently configured. You can see their base, size, MBus target ID
+  and MBus attribute ID.
+\item \code{/sys/kernel/debug/mvebu-mbus/sdram} contains the list of
+  the CPU $\rightarrow$ memory MBus windows.
+\item \code{/sys/kernel/debug/clk/clk_summary} contains the list of
+  the clocks, whether they are enabled or not, and their current rate.
+\item
+  \code{/sys/kernel/debug/pinctrl/f1018000.pinctrl/pinconf-groups},
+  and other files in
+  \code{/sys/kernel/debug/pinctrl/f1018000.pinctrl/}, allows to
+  explore the {\em pinctrl} configuration. On Marvell EBU platforms,
+  this is used to configure the MPPs.
+\item \code{/sys/kernel/irq_domain_mapping} to look at the virtual to
+  physical IRQ mappings.
+\end{itemize}
+
+\section{Testing the big endian kernel}
+
+Since the big endian kernel is completely different from the little
+endian one in terms of generated code, we'll use a separate build
+tree. Let's create it first:
+
+\begin{verbatim}
+mkdir $HOME/felabs/linux/mvebu-be
+\end{verbatim}
+
+Go in this directory, and then copy the configuration file we have
+created for the little endian build:
+
+\begin{verbatim}
+cp $HOME/felabs/linux/mvebu-le/.config .config
+\end{verbatim}
+
+Now, we'll adjust the configuration:
+
+\begin{verbatim}
+make -C $HOME/felabs/linux/src O=$(pwd) ARCH=arm menuconfig
+\end{verbatim}
+
+Note that since it's the first time we run a \code{make} command from
+this build directory, we explicitly pass \code{-C} and \code{O=}, so
+that the {\em wrapper} Makefile gets generated.
+
+In the configuration, adjust the following items:
+
+\begin{itemize}
+\item Adjust the path of the {\em initramfs}, to point to
+  \code{$HOME/felabs/linux/marvell-armada/rootfs.cpio.be}, which
+  contains a big endian userspace.
+\item In {\em System type}, enable the {\em Build big-endian kernel}
+  option.
+\end{itemize}
+
+Start the build of your kernel, generate the appended zImage, then the
+uImage, and boot your kernel. You can verify with \code{uname} that
+you are indeed running a \code{armv7b} system, i.e a big-endian ARM
+system.
+



More information about the training-materials-updates mailing list