\def\lximg{/usr/share/lx/icons/fueller.png}

\input{configpres}

\subsection{Creating Flashfilesystems}

\title{Creating Flashfilesystems}
\maketitle

\def\lximg{none}

\begin{frame}
\frametitle{Contents}
\tableofcontents
\end{frame}

\subsubsection{Emulation}
\begin{frame}[fragile]
\frametitle{Emulating flash devices}
\begin{lstlisting}
$ sudo modprobe nandsim
$ cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 08000000 00004000 "NAND simulator partition 0"
$ dmesg
[...]
[  128.718421] flash size: 128 MiB
[  128.718423] page size: 512 bytes
[  128.718425] OOB area size: 16 bytes
[  128.718426] sector size: 16 KiB
[...]
\end{lstlisting}
\end{frame}

\subsubsection{JFFS2}
\begin{frame}[fragile]
\frametitle{Using JFFS2}
\begin{lstlisting}
# Create JFFS2 image
$ mkfs.jffs2 -e 131072 \
    -d source_directory \
    -o jffs2.img
# Erase flash partition
$ flash_erase -j /dev/mtd0 0 0
# Write jffs2 image
$ nandwrite /dev/mtd0 jffs2.img
# Mounting the image
$ mount /dev/mtdblock0 /mnt
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
Kernelparameters:
\begin{verbatim}
root=/dev/mtdblock0 rootfstype=jffs2
\end{verbatim}
\end{frame}

\subsubsection{UBI and UBIFS}
\begin{frame}[fragile]
\frametitle{Using UBIFS}
\begin{lstlisting}
# 1) Attaching UBI to an MTD device
modprobe ubi
ubiattach ubiattach -m 0
# or
modprobe ubi mtd=0
# 2) Gathering some information
$ dmesg
UBI: attaching mtd0 to ubi0
UBI: physical eraseblock size:   16384 bytes (16 KiB)
UBI: logical eraseblock size:    15872 bytes
UBI: smallest flash I/O unit:    512
UBI: sub-page size:              256
UBI: VID header offset:          256 (aligned 256)
UBI: data offset:                512
[...]
# 3) Creating a volume
$ ubimkvol /dev/ubi0 -N myvolume -s 64MiB
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using UBIFS}
\begin{lstlisting}
# 4) Creating an UBIFS image
$ mkfs.ubifs -r test -m 512 -e 15872 \
   -c 8450 -o ubifs.img
# 5) Writing the image
$ ubiupdatevol /dev/ubi0_0 ubifs.img
# 6) Mounting UBIFS
$ mount -t ubifs ubi0:myvolume /mnt/
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{UBI: Create flash images}
ubinize.cfg:
\begin{verbatim}
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=64MiB
vol_type=dynamic
vol_name=myvolume
vol_flags=autoresize
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{UBI: Create flash images}
\begin{lstlisting}
# 1) Create the ubi image
ubinize -o ubi.img -m 512 -s 256 -p 16384 ubinize.cfg
# 2) erase the flash partition
flash_erase /dev/mtd0 0 0
# 3) Write the image
nandwrite /dev/mtd0 ubi.img
# 4) Attach UBI
ubiattach -m 0
# 5) Mount UBIFS
mount -t ubifs ubi0:myvolume /mnt/
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{UBIFS as a rootfilesystem}
Kernelparameters:
\begin{verbatim}
ubi.mtd=0 root=ubi0:myvolume rootfstype=ubifs
\end{verbatim}
\end{frame}

\begin{frame}
\begin{thebibliography}{1}
\bibitem{UBIFS} http://mytechrants.wordpress.com/2010/01/20/ubiubifs-on-nandsim/
\end{thebibliography} 
\end{frame}

\input{tailpres}
