\input{configpres}

\subsection{Creating Flashfilesystems}

\title{Creating Flashfilesystems}
\maketitle

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

\subsubsection{MTD}
\begin{frame}[fragile]
\frametitle{MTD Flash partitioning}
\begin{itemize}
\item Redboot partition parsing
\item Boardsupport
\item Kernelparameters:
\begin{verbatim}
mtdparts=edb7312-nor:256k(ARMboot)ro,
-(root);edb7312-nand:-(home)
\end{verbatim}
\end{itemize}
\end{frame}

\subsubsection{Emulation}
\begin{frame}[fragile]
\frametitle{Emulating flash devices}
Exercise:
\begin{verbatim}
$ 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{verbatim}
\end{frame}

\subsubsection{JFFS2}
\begin{frame}
\frametitle{JFFS2}
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/jffs2.png}
\end{figure}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using JFFS2}
Exercise:
\begin{verbatim}
# Create JFFS2 image
$ /usr/sbin/mkfs.jffs2 -e 131072 \
             -d source_directory \
             -o jffs2.img
# Erase flash partition
$ sudo flash_erase -j /dev/mtd0 0 0
# Write jffs2 image
$ sudo nandwrite -p /dev/mtd0 jffs2.img
# Load mtdblock module
$ sudo modprobe mtdblock
# Mounting the image
$ sudo mount -t jffs2 /dev/mtdblock0 /mnt
\end{verbatim}
Clean-up:
\begin{verbatim}
# Unmount the image and erase flash partition
$ sudo umount /mnt
$ sudo flash_erase -j /dev/mtd0 0 0
\end{verbatim}
\end{frame}

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

\subsubsection{yaffs}
\begin{frame}
\frametitle{yaffs - yet another flash file system}
\begin{itemize}
\item fast
\item log-structured FS
\item not in mainline kernel
\item portable to other Operating Systems
\item yaffs1 for small FLASH sizes
\item yaffs2 for large FLASH sizes
\item either use existing ECC or built-in ECC
\item wear-leveling as side-effect
\end{itemize}
\end{frame}

\subsubsection{UBI and UBIFS}
\begin{frame}
\frametitle{UBI: Unsorted Block Images}
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/ubi.png}
\end{figure}
\end{frame}

\begin{frame}
\frametitle{UBIFS}
\begin{itemize}
\item journaling FS
\item mainline since 2.6.27
\item exploiting features of MTD and UBI
\item scalability
\item fast mount
\item write-back support
\item fast I/O
\item tolerance to unclean reboots
\item on-the-flight compression
\item integrity
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{UBIFS}
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/ubifs.png}
\end{figure}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using UBIFS}
Exercise:
\begin{verbatim}
# 1) Loading module and attach UBI to MTD device
$ sudo modprobe ubi
$ sudo ubiattach ubiattach -m 0
# or: 1a) Specify the MTD device during module load
$ sudo 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 an UBIFS image
$ /usr/sbin/mkfs.ubifs -r test -m 512 -e 15872 \
              -c 8450 -o ubifs.img
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Using UBIFS}
Exercise (cont.):
\begin{verbatim}
# 4) Creating a volume
$ sudo ubimkvol /dev/ubi0 -N myvolume -s 64MiB
# 5) Writing the image
$ sudo ubiupdatevol /dev/ubi0_0 ubifs.img
# 6) Mounting UBIFS
$ sudo mount -t ubifs ubi0:myvolume /mnt/
\end{verbatim}
Clean-up:
\begin{verbatim}
# Unmounting image, detach UBI from MTD device, and erase flash partition
$ sudo umount /mnt
$ sudo ubidetach -m 0
$ sudo flash_erase -j /dev/mtd0 0 0
\end{verbatim}
\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}
Exercise:
\begin{verbatim}
# 1) Create the ubi image
$ /usr/sbin/ubinize -o ubi.img -m 512 -s 256 -p 16384 ubinize.cfg
# 2) Write the image
$ sudo nandwrite /dev/mtd0 ubi.img
# 3) Attach UBI
$ sudo ubiattach -m 0
# 4) Mount UBIFS
$ sudo mount -t ubifs ubi0:myvolume /mnt/
\end{verbatim}
Clean-up:
\begin{verbatim}
# Unmounting image, detach UBI from MTD device, and erase flash partition
$ sudo umount /mnt
$ sudo ubidetach -m 0
$ sudo flash_erase -j /dev/mtd0 0 0
\end{verbatim}
\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}

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

\input{tailpres}
