summaryrefslogtreecommitdiff
path: root/flash-memory/flash-filesystems/pres_flashfilesystems_en.tex
blob: 5edcf91fa7c83d553c26722b1ae4e28e16975778 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
\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}