[bootlin/training-materials updates] master: sysdev/beagleplay: add sysdev-toolchain lab (7b8b7600)

Michael Opdenacker michael.opdenacker at bootlin.com
Mon Aug 7 16:25:54 CEST 2023


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/7b8b76001e2e0bdce470e5a50c0858d1ce37ebc7

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

commit 7b8b76001e2e0bdce470e5a50c0858d1ce37ebc7
Author: Clément Ramirez <clement.ramirez at bootlin.com>
Date:   Mon Jul 24 16:27:44 2023 +0200

    sysdev/beagleplay: add sysdev-toolchain lab


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

7b8b76001e2e0bdce470e5a50c0858d1ce37ebc7
 labs/sysdev-toolchain/sysdev-toolchain.tex | 87 +++++++++++++++++++++++++-----
 mk/embedded-linux-beagleplay.mk            |  3 +-
 2 files changed, 76 insertions(+), 14 deletions(-)

diff --git a/labs/sysdev-toolchain/sysdev-toolchain.tex b/labs/sysdev-toolchain/sysdev-toolchain.tex
index a23b5df6..59ba9bc2 100644
--- a/labs/sysdev-toolchain/sysdev-toolchain.tex
+++ b/labs/sysdev-toolchain/sysdev-toolchain.tex
@@ -74,9 +74,12 @@ listed by using \code{./ct-ng list-samples}.
 We will load the
 \ifdefstring{\labboard}{qemu}{Cortex A9}{}
 \ifdefstring{\labboard}{beaglebone}{Cortex A8}{}
+\ifdefstring{\labboard}{beagleplay}{\code{aarch64-unknown-linux-uclibc}}{}
 \ifdefstring{\labboard}{stm32mp1}{Cortex A5}{}
 sample\ifdefstring{\labboard}{stm32mp1}{, as Crosstool-ng doesn't have
-any sample for Cortex A7 yet}. Load it with the \code{./ct-ng} command.
+any sample for Cortex A7 yet}{}
+\ifdefstring{\labboard}{beagleplay}{, as Crosstool-ng doesn't have
+any sample for musl yet}{}. Load it with the \code{./ct-ng} command.
 
 Then, to refine the configuration, let's run the \code{menuconfig} interface:
 
@@ -105,7 +108,24 @@ In \code{Target options}:
 \end{itemize}
 }{}
 
+\ifdefstring{\labboard}{beagleplay}{
+In \code{Target options}:
+\begin{itemize}
+\item Set \code{Emit assembly for CPU} (\code{ARCH_CPU}) to \code{cortex-a53}.
+\item Check \code{Endianness} (\code{ARCH_ENDIAN}) is set to \code{Little endian}
+\end{itemize}
+}{}
+
 In \code{Toolchain options}:
+\ifdefstring{\labboard}{beagleplay}{
+\begin{itemize}
+\item Set \code{Tuple's vendor string} (\code{TARGET_VENDOR}) to \code{training}.
+\item Set \code{Tuple's alias} (\code{TARGET_ALIAS}) to \code{aarch64-linux}.
+      This way, we will be able to use the compiler as \code{aarch64-linux-gcc}
+      instead of \code{aarch64-training-linux-musl-gcc}, which is
+      much longer to type.
+\end{itemize}
+}{
 \begin{itemize}
 \item Set \code{Tuple's vendor string} (\code{TARGET_VENDOR}) to \code{training}.
 \item Set \code{Tuple's alias} (\code{TARGET_ALIAS}) to \code{arm-linux}.
@@ -113,14 +133,25 @@ In \code{Toolchain options}:
       instead of \code{arm-training-linux-musleabihf-gcc}, which is
       much longer to type.
 \end{itemize}
+}
 
 In \code{Operating System}:
+\ifdefstring{\labboard}{beagleplay}{
+\begin{itemize}
+\item Set \code{Version of linux} to the 6.3.2 version that is
+proposed. We choose this version because the kernel we will
+be using is the \workingkernel \; kernel. Indeed, the linux kernel is
+backward compatible and therefore older linux headers will work fine on
+a newer running kernel.
+\end{itemize}
+}{
 \begin{itemize}
 \item Set \code{Version of linux} to the \workingkernel.x version that is
       proposed. We choose this version because this matches the
       version of the kernel we will run on the board. At least, the
       version of the kernel headers are not more recent.
 \end{itemize}
+}
 
 In \code{C-library}:
 \begin{itemize}
@@ -130,10 +161,17 @@ In \code{C-library}:
 \end{itemize}
 
 In \code{C compiler}:
+\ifdefstring{\labboard}{beagleplay}{
+\begin{itemize}
+  \item Make sure that the \code{Version of gcc} is set to \code{12.3.0}.
+  \item Make sure that \code{C++} (\code{CC_LANG_CXX}) is enabled
+\end{itemize}
+}{
 \begin{itemize}
   \item Set \code{Version of gcc} to \code{12.3.0}.
   \item Make sure that \code{C++} (\code{CC_LANG_CXX}) is enabled
 \end{itemize}
+}
 
 In \code{Debug facilities}:
 \begin{itemize}
@@ -165,17 +203,18 @@ And wait!
 \section{Testing the toolchain}
 
 You can now test your toolchain by adding
-\code{$HOME/x-tools/arm-training-linux-musleabihf/bin/} to your
+\ifdefstring{\labboard}{beagleplay}{\code{$HOME/x-tools/aarch64-training-linux-musl/bin/}}
+{\code{$HOME/x-tools/arm-training-linux-musleabihf/bin/}} to your
 \code{PATH} environment variable and compiling the simple
 \code{hello.c} program in your main lab directory with
-\code{arm-linux-gcc}:
+\ifdefstring{\labboard}{beagleplay}{\code{aarch64-linux-gcc}}{\code{arm-linux-gcc}}:
 
 \begin{bashinput}
-$ arm-linux-gcc -o hello hello.c
+$ %\ifdefstring{\labboard}{beagleplay}{aarch64-linux-gcc}{arm-linux-gcc}% -o hello hello.c
 \end{bashinput}
-
 You can use the \code{file} command on your binary to make sure it has
-correctly been compiled for the ARM architecture.
+correctly been compiled for the \ifdefstring{\labboard}{beagleplay}{AARCH64}{ARM}
+architecture.
 
 Did you know that you can still execute this binary from your x86 host?
 To do this, install the QEMU user emulator, which just emulates target
@@ -185,30 +224,52 @@ instruction sets, not an entire system with devices:
 $ sudo apt install qemu-user
 \end{bashinput}
 
-Now, try to run QEMU ARM user emulator:
+Now, try to run QEMU \ifdefstring{\labboard}{beagleplay}{AARCH64}{ARM}
+user emulator:
 
+\if\defstring{\labboard}{beagleplay}
+\begin{bashinput}
+$ qemu-aarch64 hello
+qemu-aarch64: Could not open '/lib/ld-musl-aarch64.so.1': No such file or directory
+\end{bashinput}
+\else
 \begin{bashinput}
 $ qemu-arm hello
 qemu-arm: Could not open '/lib/ld-musl-armhf.so.1': No such file or directory
 \end{bashinput}
+\fi
 
-What's happening is that \code{qemu-arm} is missing the shared C library
-(compiled for ARM) that this binary uses. Let's find it in our newly
-compiled toolchain:
+What's happening is that \ifdefstring{\labboard}{beagleplay}{\code{qemu-aarch64}}
+{\code{qemu-arm}} is missing the shared C library
+(compiled for \ifdefstring{\labboard}{beagleplay}{AARCH64}{ARM}) that this
+binary uses. Let's find it in our newly compiled toolchain:
 
 \begin{bashinput}
-$ find ~/x-tools -name ld-musl-armhf.so.1
+$ find ~/x-tools -name %\ifdefstring{\labboard}{beagleplay}{ld-musl-aarch64.so.1}{ld-musl-armhf.so.1}%
 \end{bashinput}
+
+\if\defstring{\labboard}{beagleplay}
+\begin{terminaloutput}
+/home/tux/x-tools/aarch64-training-linux-musl/aarch64-training-linux-musl/sysroot/lib/ld-musl-aarch64.so.1
+\end{terminaloutput}
+\else
 \begin{terminaloutput}
 /home/tux/x-tools/arm-training-linux-musleabihf/arm-training-linux-musleabihf/sysroot/lib/ld-musl-armhf.so.1
 \end{terminaloutput}
+\fi
 
-We can now use the \code{-L} option of \code{qemu-arm} to let it know
-where shared libraries are:
+We can now use the \code{-L} option of \ifdefstring{\labboard}{beagleplay}
+{\code{qemu-aarch64}}{\code{qemu-arm}} to let it knowwhere shared libraries are:
 
+\if\defstring{\labboard}{beagleplay}
+\begin{bashinput}
+$ qemu-aarch64 -L ~/x-tools/aarch64-training-linux-musl/aarch64-training-linux-musl/sysroot hello
+\end{bashinput}
+\else
 \begin{bashinput}
 $ qemu-arm -L ~/x-tools/arm-training-linux-musleabihf/arm-training-linux-musleabihf/sysroot hello
 \end{bashinput}
+\fi
 
 \begin{terminaloutput}
 Hello world!
diff --git a/mk/embedded-linux-beagleplay.mk b/mk/embedded-linux-beagleplay.mk
index 4de8f6b2..68847343 100644
--- a/mk/embedded-linux-beagleplay.mk
+++ b/mk/embedded-linux-beagleplay.mk
@@ -49,4 +49,5 @@ EMBEDDED_LINUX_BEAGLEPLAY_SLIDES = \
 		last-slides \
 		sysdev-extra-slides
 
-EMBEDDED_LINUX_BEAGLEPLAY_LABS = setup
+EMBEDDED_LINUX_BEAGLEPLAY_LABS = setup \
+		sysdev-toolchain \




More information about the training-materials-updates mailing list