From fb0b6fa144465775e8be8b92afbaa8662638507c Mon Sep 17 00:00:00 2001
From: Jan Altenberg <jan@linutronix.de>
Date: Wed, 1 Dec 2010 10:21:46 +0100
Subject: Rewrote ''RFS crom scratch'' version for ARM

-> Moved old version to pres_cross-devel-ppc-qemu_de.tex
---
 .../cross-devel/pres_cross-devel-ppc-qemu_de.tex   | 387 +++++++++++++++++++++
 1 file changed, 387 insertions(+)
 create mode 100644 application-devel/cross-devel/pres_cross-devel-ppc-qemu_de.tex

(limited to 'application-devel/cross-devel/pres_cross-devel-ppc-qemu_de.tex')

diff --git a/application-devel/cross-devel/pres_cross-devel-ppc-qemu_de.tex b/application-devel/cross-devel/pres_cross-devel-ppc-qemu_de.tex
new file mode 100644
index 0000000..b4822c6
--- /dev/null
+++ b/application-devel/cross-devel/pres_cross-devel-ppc-qemu_de.tex
@@ -0,0 +1,387 @@
+\documentclass{beamer}
+\usetheme{linutronix}
+\usepackage{german}
+\usepackage[utf8]{inputenc}
+\usepackage{pgf}
+\usepackage{graphicx}
+\usepackage{lxextras}
+
+
+\title{Block \lq Cross Development\rq}
+\institute{Linutronix GmbH}
+
+\lstset{keywordstyle=\color{blue},commentstyle=\color{orange}}
+
+\begin{document}
+
+\maketitle
+
+\begin{frame}
+\frametitle{Übersicht}
+\tableofcontents
+\end{frame}
+
+\section{Cross Übersetzen}
+\begin{frame}[containsverbatim]
+\frametitle{Cross ''Hello world''}
+\begin{lstlisting}[language=c]
+/* cross_hello.c */
+#include <stdio.h>
+
+int main(void)
+{
+        printf("Hello cross compiling world\n");
+        return 0;
+}
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Übersetzen für das Zielsystem}
+\begin{lstlisting}[language=bash]
+# Uebersetzen
+powerpc-linux-gnu-gcc -static -o cross_hello \
+cross_hello.c
+\end{lstlisting}
+\begin{lstlisting}[language=bash]
+# Executable ueberpruefen
+$ file cross_hello
+cross_hello: ELF 32-bit MSB executable, PowerPC
+or cisco 4500, version 1 (SYSV),
+dynamically linked (uses shared libs),
+for GNU/Linux 2.6.10, with unknown
+[...]
+not stripped
+\end{lstlisting}
+\end{frame}
+
+\section{Testing auf dem Host}
+
+\begin{frame}
+\frametitle{Qemu als Werkzeug zur Cross Entwicklung}
+\begin{alertblock}{Was ist Qemu?}
+Qemu ist eine sehr performante Emulations- und Virtualisierungsumgebung für alle
+gängigen CPU Architekturen.
+\end{alertblock}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Testen eines Executables mit der Qemu user emulation}
+\begin{lstlisting}[language=bash]
+$ ./cross_hello
+bash: ./cross_hello: cannot execute binary file
+$ qemu-ppc ./cross_hello
+Hello cross compiling world
+\end{lstlisting}
+\end{frame}
+
+\section{Rootfilesystem}
+\subsection{Filesystem from scratch}
+\begin{frame}
+\frametitle{Komponenten des Zielsystems}
+\begin{overprint}
+\onslide <1>
+\begin{figure}[h]
+\centering
+\includegraphics[width=6cm]{images/target.png}
+\end{figure}
+\onslide <2>
+\begin{figure}[h]
+\centering
+\includegraphics[width=6cm]{images/target_highlight_rfs.png}
+\end{figure}
+\end{overprint}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Erstellen eines Rootfilesystems für die Zielarchitektur}
+1) Busybox
+\begin{lstlisting}[language=bash]
+mkdir -p /tftpboot/nfsroot
+cd busybox-1.16.1
+make menuconfig
+make CROSS_COMPILE=powerpc-linux-gnu- install
+rsync -Hav _install/ /tftpboot/nfsroot
+cd /tftpboot/nfsroot
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}
+\frametitle{Device nodes}
+\begin{figure}[h]
+\centering
+\includegraphics[width=8cm]{images/mknod.png}
+\end{figure}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Erstellen eines Rootfilesystems für die Zielarchitektur}
+2) Grundstruktur erstellen:
+\begin{lstlisting}[language=bash]
+# Verzeichnisstruktur
+mkdir lib etc tmp dev mnt sys proc
+
+# Devices nodes (als root!)
+mknod dev/console c 5 1
+mknod dev/null c 1 3
+mknod dev/ttyS0 c 4 64
+mknod dev/tty0 c 4 0
+mknod dev/tty1 c 4 1
+mknod dev/tty2 c 4 2
+mknod dev/tty3 c 4 3
+mknod dev/tty4 c 4 4
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Erstellen eines Rootfilesystems für die Zielarchitektur}
+3) Startscript(e) erstellen
+\begin{lstlisting}[language=bash]
+cd /tftpboot/nfsroot
+mkdir etc/init.d
+vim etc/init.d/rcS
+\end{lstlisting}
+/etc/rc.d/rcS:
+\begin{verbatim}
+#!/bin/sh
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+
+mount -o remount,rw /
+\end{verbatim}
+\begin{lstlisting}[language=bash]
+chmod u+x etc/rc.d/rcS
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Erstellen eines Rootfilesystems für die Zielarchitektur}
+4) Libraries kopieren
+\begin{lstlisting}[language=bash]
+# Loader
+$ cp /path_to_my_libc/lib/ld.so.1 \
+/tftpboot/nfsroot/lib
+# Getting the dependencies and copy them
+$ powerpc-linux-gnu-objdump -x \
+/tftpboot/nfsroot/bin/busybox | grep NEEDED
+  NEEDED               libm.so.6
+  NEEDED               libc.so.6
+$ cp /path_to_my_libc/lib/libm.so.6 \
+/tftpboot/nfsroot/lib
+$ cp /path_to_my_libc/lib/libc.so.6 \
+/tftpboot/nfsroot/lib
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Erstellen eines Rootfilesystems für die Zielarchitektur}
+5) Berechtigungen korrigieren:
+\begin{lstlisting}[language=bash]
+chown -R root:root /tftpboot/nfsroot
+\end{lstlisting}
+That's it!! :)
+\end{frame}
+
+\subsection{Exportieren per NFS}
+\subsubsection{Konfiguration}
+\begin{frame}[containsverbatim]
+\frametitle{Exportieren per NFS}
+1) nfs-kernel-server installieren
+\begin{lstlisting}
+# Auf Debian basierten Systemen (als root)
+apt-get install nfs-kernel-server
+\end{lstlisting}
+\end{frame}
+\begin{frame}[containsverbatim]
+\frametitle{Exportieren per NFS}
+2) Directory exportieren
+\begin{lstlisting}[language=bash]
+vim /etc/exports
+\end{lstlisting}
+\begin{verbatim}
+/tftpboot/nfsroot \
+192.168.0.0/255.255.255.0\
+(rw,no_root_squash,no_subtree_check,insecure) \
+127.0.0.1\
+(rw,no_root_squash,no_subtree_check,insecure) \
+10.0.2.0/255.255.255.0\
+(rw,no_root_squash,no_subtree_check,insecure)
+\end{verbatim}
+\begin{lstlisting}[language=bash]
+/etc/init.d/nfs-kernel-server restart
+\end{lstlisting}
+\end{frame}
+\subsubsection{Filesystem mit Qemu testen}
+\begin{frame}[containsverbatim]
+\frametitle{RFS mit Qemu booten}
+\begin{lstlisting}
+qemu-system-ppc -nographic \
+-kernel images/vmlinux \
+-append \
+"console=ttyS0 ip=dhcp \
+root=/dev/nfs \
+nfsroot=10.0.2.2:/tftpboot/nfsroot" \
+-net nic -net user
+\end{lstlisting}
+\end{frame}
+\begin{frame}[containsverbatim]
+\frametitle{RFS mit Qemu booten}
+\begin{verbatim}
+[...]
+IP-Config: Got DHCP answer from 10.0.2.2, my address
+IP-Config: Complete:
+      device=eth0, addr=10.0.2.15, mask=255.255.255.0
+     host=10.0.2.15, domain=, nis-domain=(none),
+     bootserver=10.0.2.2, rootserver=10.0.2.2, rootpath=
+Looking up port of RPC 100003/2 on 10.0.2.2
+Looking up port of RPC 100005/1 on 10.0.2.2
+VFS: Mounted root (nfs filesystem) readonly.
+Freeing unused kernel memory: 208k init
+
+Please press Enter to activate this console.
+\end{verbatim}
+\end{frame}
+
+\begin{frame}
+\frametitle{Congrats!!!}
+Ihr erstes eigenes Linux System!! :)
+\end{frame}
+
+\subsection{RFS um SSH erweitern}
+\begin{frame}
+\frametitle{dropbear}
+Dropbear ist eine schlanke SSH Server und Client Implementierung
+und wird daher recht häufig in Embedded Systemen verwendet.
+\begin{alertblock}{Vorteile}
+\begin{itemize}
+\item Einfach zu übersetzen
+\item Schlank / Wenig Footprint
+\item Einfach Konfiguration
+\end{itemize}
+\end{alertblock}
+\begin{alertblock}{Nachteile}
+\begin{itemize}
+\item Keine eigene SFTP Implementierung
+\end{itemize}
+\end{alertblock}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Dropbear übersetzen}
+\begin{lstlisting}[language=bash]
+$ ./configure --host=powerpc-linux-gnu \
+   --disable-zlib --prefix=/usr
+make
+# Als root
+make DESTDIR=/tftpboot/nfsroot install
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Dropbear: Benötigte Bibliotheken}
+\begin{lstlisting}[language=bash]
+# Schritt 1: libnss
+cp /path_to_my_libc/lib/libnss_* lib/
+# Schritt 2: It's your turn!
+\end{lstlisting}
+Aufgabe: Ermitteln der benötigten Bibliotheken von Dropbear
+und kopieren an die richtige Stelle im RFS.
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Dropbear: Benötigte Bibliotheken / Lösung}
+\begin{lstlisting}[language=bash]
+$ powerpc-linux-gnu-objdump -x \
+/tftpboot/nfsroot/usr/sbin/dropbear | grep NEEDED
+  NEEDED               libutil.so.1
+  NEEDED               libcrypt.so.1
+  NEEDED               libc.so.
+$ cp /path_to_my_libc/libcrypt.so.1 \
+     /tftpboot/nfsroot/lib
+$ cp /path_to_my_libc/libutil.so.1 \
+     /tftpboot/nfsroot/lib
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{RFS um SSH erweitern}
+Vorbereitungen:
+\begin{lstlisting}[language=bash]
+cd /tftpboot/nfsroot
+mknod dev/urandom c 1 9
+mknod dev/ptmx c 5 2
+mkdir root
+echo "root:x:0:0::/root:/bin/sh" >> etc/passwd
+echo "root:x:0:" >> etc/group
+mkdir dev/pts
+mkdir etc/dropbear
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Password für root setzen}
+\begin{lstlisting}[language=bash]
+qemu-system-ppc -nographic \
+-kernel images/vmlinux \
+-append "console=ttyS0 ip=dhcp root=/dev/nfs \
+nfsroot=10.0.2.2:/tftpboot/nfsroot" \
+-net nic -net user,hostfwd=tcp::12345-:22
+\end{lstlisting}
+\begin{lstlisting}[language=bash]
+# Im gebooteten System:
+passwd
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{Dropbear: Startskript erweitern}
+\begin{lstlisting}[language=bash]
+vim /tftpboot/nfsroot/etc/init.d/rcS
+\end{lstlisting}
+\begin{lstlisting}[language=bash,basicstyle=\ttfamily\fontsize{7}{7}\selectfont]
+[...]
+
+mount devpts /dev/pts -t devpts
+
+if [ ! -f /etc/dropbear/dropbear_rsa_host_key ]
+then
+  dropbearkey -type rsa -f /etc/dropbear/dropbear_rsa_host_key
+fi
+
+if [ ! -f /etc/dropbear/dropbear_dss_host_key ]
+then
+  dropbearkey -type dss -f /etc/dropbear/dropbear_dss_host_key
+fi
+
+/usr/sbin/dropbear
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[containsverbatim]
+\frametitle{SSH testen}
+\begin{enumerate}
+\item Qemu session starten:
+\begin{lstlisting}[language=bash]
+qemu-system-ppc -nographic \
+-kernel images/vmlinux \
+-append "console=ttyS0 ip=dhcp root=/dev/nfs \
+nfsroot=10.0.2.2:/tftpboot/nfsroot" \
+-net nic -net user,hostfwd=tcp::12345-:22
+\end{lstlisting}
+\item Vom Host-System:
+\begin{lstlisting}[language=bash]
+ssh -p 12345 root@localhost
+\end{lstlisting}
+\begin{verbatim}
+root@localhost's password: 
+#
+\end{verbatim}
+\end{enumerate}
+\end{frame}
+
+\subsection{Filesystem auf dem Target testen}
+\begin{frame}
+\frametitle{Auf dem Target}
+HAND'S ON! :)
+\end{frame}
+\end{document}
-- 
cgit v1.2.3

