summaryrefslogtreecommitdiff
path: root/misc/pres_fastboot_en.tex
blob: 866c1a67f0aad7b2da1d13ce1aacc49f4eaf4d5d (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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
\input{configpres}

\section{Basics}

\title{Linux Fastboot}
\maketitle

\subsection{Motivation}
\begin{frame}
\frametitle{Motivation}
\begin{itemize}
\item always greater requirements for energy saving functions
\item runtime of multimedia devices
\item automotive applications
\pause
\item \textbf{Solution:} power off when idle
\pause
\item \textbf{But:} users do not like ''waiting''
\end{itemize}
\end{frame}

\subsection{Theoretical Basics}
\begin{frame}
\frametitle{The first step: Requirements Definition}
\begin{itemize}
\item What is the maximum allowed boot time?
\item Which functionality must be availalbe after this time?
\item speed vs. flexibility
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Boot Process}
\includegraphics[height=0.7\textheight]{images/boot_overview.png}
\end{frame}

\begin{frame}
\frametitle{Actors in the Boot Process}
\begin{itemize}
\item hardware reset
\item bootloader
\item operating system (load drivers, mount filesystems)
\item start scripts / applications
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Critical Hardware Components}
\begin{itemize}
\item power supply
\item reset logic
\item boot logic / boot order
\item connection to the boot medium
\item connection to required peripherals
\end{itemize}
\textbf{Important: The hardware is an essential part of a fastboot concept!!}
\end{frame}

\begin{frame}
\frametitle{Bootloader}
\begin{itemize}
\item ''base configuration'' of the CPU
\item modifies the device tree and/or sets up the ''ATAGs structure''
\item flushes the caches
\item disables the MMU
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{The Linux Kernel}
\begin{itemize}
\item many features for boot time optimization
\item very flexible
\item compression
\item possible to initialize in parallel
\item approx. 150ms - 250ms to mount a filesystem
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{The Application}
\begin{itemize}
\item for systems, this usually has the most potential for optimizing
\item start scripts
\item linking
\end{itemize}
\end{frame}

\section{Optimization}
\subsection{Bootloader}
\begin{frame}[fragile]
\frametitle{Bootloader Optimization (U-Boot) 1}
remove features that are not needed in the field:
\begin{lstlisting}
/* include/configs/boardname.h */
[...]
#include <config_cmd_default.h>
#undef CONFIG_CMD_NET
[...]
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Bootloader Optimization (U-Boot) 2}
disable verification of the kernel image:
\begin{verbatim}
setenv verify n
\end{verbatim}
disable output on the U-Boot console:
\begin{verbatim}
setenv silent 1
\end{verbatim}
do not wait for user input:
\begin{verbatim}
setenv bootdelay 0
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{Bootloader Optimization (IPL)}
\begin{itemize}
\item replace a ''general purpose'' bootloader with an optimized IPL
\item IPL also as a basis for update concepts and ''rescue kernels''
\end{itemize}
\end{frame}

\subsection{Kernel}
\begin{frame}[fragile]
\frametitle{Kernel Optimization: Components}
\begin{itemize}
\item configuration and build
\item compression
\item boot parameters
\item driver initialization
\item root filesystem
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Optimization: Configuration}
\begin{verbatim}
General setup  --->
Kernel compression mode -->
\end{verbatim}
\begin{itemize}
\item LZO for embedded systems very interesting
\item copy vs. decompress
\item for storage medium with direct addressable read access, ''excecute in place (XIP)'' is available
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Optimization: Command Line Parameter}
\begin{itemize}
\item delay loop calibration: ''lpj=''; for ARM9 systems, this can save >100ms
\item parameters available for runtime analysis of the boot process: ''initcall\_debug'', ''printk.time=1''
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Optimization: Delay Loop}
\begin{verbatim}
...
Calibrating delay loop...
   99.12 BogoMIPS (lpj=495616)
...
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Optimization: initcall\_debug}
\begin{verbatim}
calling  populate_rootfs+0x0/0x1f8 @ 1
initcall populate_rootfs+0x0/0x1f8
	returned 0 after 281 usecs
calling  timer_init_sysfs+0x0/0x38 @ 1
initcall timer_init_sysfs+0x0/0x38
	returned 0 after 590 usecs
calling  leds_init+0x0/0x3c @ 1
initcall leds_init+0x0/0x3c
	returned 0 after 488 usecs
calling  leds_init+0x0/0x50 @ 1
initcall leds_init+0x0/0x50
	returned -19 after 1 usecs
calling  fpe_init+0x0/0x78 @ 1
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Optimization: printk.time}
\begin{verbatim}
[    0.800000] mice: PS/2 mouse device 
[    0.810000] rtc-at91sam9 at91_rtt.0:
[    0.820000] rtc-at91sam9 at91_rtt.0: 
[    0.830000] TCP cubic registered
[    0.830000] NET: Registered protocol 
[    0.830000] rtc-at91sam9 at91_rtt.0:
[    2.610000] VFS: Mounted root (jffs2 
[    2.610000] Freeing init memory: 116K
\end{verbatim}
\end{frame}

\subsection{File Systems}
\begin{frame}[fragile]
\frametitle{Initramfs}
\begin{verbatim}
dir /dev 755 0 0
nod /dev/console 644 0 0 c 5 1
nod /dev/loop0 644 0 0 b 7 0
dir /bin 755 1000 1000
slink /bin/sh busybox 777 0 0
file /bin/busybox initfs/busybox 755 0 0
[...]
dir /proc 755 0 0
dir /sys 755 0 0
dir /mnt 755 0 0
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{Ubifs}
\begin{itemize}
\item for Linux systems, this is \textbf{the} flash filesystem to choose
\item fast mount times
\item power-fail safe
\item \dots
\end{itemize}
\end{frame}

\subsection{Application}

\begin{frame}
\frametitle{Optimizing the Application}
\begin{itemize}
\item analyze the start processes with bootchartd
\item possibly starting the application directly with init=
\item dynamic vs. static linking
\item prelink for dynamically linked applications
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Start Script Tasks in the Application}
\begin{verbatim}
ret = mount("sysfs", "/sys",
              "sysfs", 0, NULL);

if(ret < 0)
      perror("Can't mount sysfs\n");
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Dynamic Linking}
\begin{enumerate}
\item DT\_RPATH section in ELF executables
\item paths that are specified in LD\_LIBRARY\_PATH
\item DT\_RUNPATH section in ELF executables
\item dynamic loader cache: /etc/ld.so.cache
\item default paths /lib, /usr/lib, \dots
\end{enumerate}
\end{frame}

\begin{frame}[fragile]
\frametitle{Dynamic Linking: Analysis}
\begin{verbatim}
$ LD_DEBUG=libs ls
   3082: find library=librt.so.1 [0];
         searching
   3082: search cache=/etc/ld.so.cache
   3082: trying file=/lib/librt.so.1
\end{verbatim}
\end{frame}

\section{Example}
\subsection{Analysis of a Test System}

\begin{frame}
\frametitle{Test System}
\begin{itemize}
\item ARM9 CPU from the Atmel AT91 series
\item starting point: busybox image from the Angstrom distribution
\item storage medium: NAND flash
\item test application: toggling a GPIO via sysfs interface
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{AT91 Controller Boot Process}
\includegraphics[height=0.7\textheight]{images/boot_at91_overview.png}
\end{frame}

\begin{frame}
\frametitle{The AT91 Family Boot Modes}
\begin{itemize}
\item RomBOOT: boot via an internal boot logic
\item boot via chip-select 0 (CS0) of the external bus interface
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{AT91 RomBOOT}
\includegraphics[height=0.7\textheight]{images/boot_at91_romboot.png}
\end{frame}

\begin{frame}
\frametitle{Power-On Behavior / Power Supply}
\includegraphics[height=0.7\textheight]{images/at91_netzteil.png}
\end{frame}

\begin{frame}
\frametitle{Reset Behavior}
\includegraphics[height=0.7\textheight]{images/at91_reset.png}
\end{frame}

\begin{frame}
\frametitle{RomBOOT}
\includegraphics[height=0.7\textheight]{images/at91_romboot_measure.png}
\end{frame}

\begin{frame}
\frametitle{Summary / Hardware Optimization}
\begin{itemize}
\item use the internal oscillator for slowclock: >1s savings
\item boot from CS0: ~100ms - 150ms savings
\end{itemize}
\end{frame}

\subsection{Optimizing the Test System}

\begin{frame}
\frametitle{Boot Time Measurement via GPIO}
\includegraphics[width=10cm]{images/gpio_measure.png}
\end{frame}

\begin{frame}
\frametitle{Parts of the Boot Time Measurement}
\begin{itemize}
\item from bootstrap until U-Boot
\item from U-Boot until early boot code in the kernel (also includes copying the kernel into RAM and unpacking the kernel)
\item from kernel until application (also includes mounting the filesystem)
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Initial Boot Times}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - U-Boot  & --- \\
\hline
U-Boot - kernel  & 6.5s  \\
\hline
kernel - application & 4.5s \\
\hline
\textbf{Total} & \textbf{11s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{U-Boot without Netzwerk Support}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - U-Boot  & --- \\
\hline
U-Boot - kernel  & 4.25s  \\
\hline
kernel - application & 4.5s \\
\hline
\textbf{Total} & \textbf{8.75s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{U-Boot verify=n}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - U-Boot  & --- \\
\hline
U-Boot - kernel  & 3.89s  \\
\hline
kernel - application & 4.5s \\
\hline
\textbf{Total} & \textbf{8.39s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{Kernel ''Trimming''}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - U-Boot  & --- \\
\hline
U-Boot - kernel  & 3.77s  \\
\hline
kernel - application & 4.33s \\
\hline
\textbf{Total} & \textbf{8.1s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{Analyze the Start Scripts: bootchartd}
\includegraphics[height=0.85\textheight]{images/bootchart.png}
\end{frame}

\begin{frame}
\frametitle{Optimizing the Start Scripts}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - U-Boot  & --- \\
\hline
U-Boot - kernel  & 3.77s  \\
\hline
kernel - application & 3.61s \\
\hline
\textbf{Total} & \textbf{7.38s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{Initramfs Compressed with LZO}
The application is started directly with the init= parameter.
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - U-Boot  & --- \\
\hline
U-Boot - kernel  & 3.79s  \\
\hline
kernel - application & 0.372s \\
\hline
\textbf{Total} & \textbf{4.162s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{Modified AT91 Bootstrap}
AT91 bootstrap starts Linux directly, i.e. the system boots without U-Boot.
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - kernel  & 676ms  \\
\hline
kernel - application & 584ms \\
\hline
\textbf{Total} & \textbf{1.260s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{lpj=}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - kernel  & 676ms  \\
\hline
kernel - application & 384ms \\
\hline
\textbf{Total} & \textbf{1.060s} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{No Output on the Serial Interface (quiet)}
\begin{table}[!h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - kernel  & 524ms  \\
\hline
kernel - application & 212ms \\
\hline
\textbf{Total} & \textbf{736ms} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{Kernel Image Compressed with LZO}
\begin{table}[h]
\centering
\begin{tabular}{ | c | c | }
\hline
Boot Part & Time \\
\hline 
bootstrap - kernel  & 444ms  \\
\hline
kernel - application & 212ms \\
\hline
\textbf{Total} & \textbf{656ms} \\
\hline
\end{tabular}
\end{table}
\end{frame}

\begin{frame}
\frametitle{Boot Times After the Optimizations}
\includegraphics[height=0.7\textheight]{images/at91_ipl_quiet_lpj_lzo.png}
\end{frame}

\begin{frame}
\frametitle{Summary}
\begin{itemize}
\item Linux provides an optimal platform for anyone that wants a modern operating system, yet also needs to boot in under 1s
\item using just the simple optimizations can save multiple seconds
\item the hardware is an essential part of a fastboot concept
\item the fastboot concept is mostly platform independent
\end{itemize}
\end{frame}

\input{tailpres}