]> rtime.felk.cvut.cz Git - novaboot.git/blob - README.pod
nix: Update flake inputs
[novaboot.git] / README.pod
1 =encoding utf8
2
3 =head1 NAME
4
5 novaboot - Boots a locally compiled operating system on a remote
6 target or in qemu
7
8 =head1 SYNOPSIS
9
10 B<novaboot> --help
11
12 B<novaboot> [option]... [--] script...
13
14 B<./script> [option]...
15
16 =head1 DESCRIPTION
17
18 Novaboot makes booting of a locally compiled operating system (OS)
19 (e.g. NOVA or Linux) on remote targets as simple as running a program
20 locally. It automates things like copying OS images to a TFTP server,
21 generation of bootloader configuration files, resetting of target
22 hardware or redirection of target's serial line to stdin/out. Novaboot
23 is highly configurable and makes it easy to boot a single image on
24 different targets or different images on a single target.
25
26 Novaboot operation is controlled by configuration files, command line
27 options and by a so-called novaboot script, which can be thought as a
28 generalization of bootloader configuration files (see L</"NOVABOOT
29 SCRIPT SYNTAX">). The typical way of using novaboot is to make the
30 novaboot script executable and set its first line to I<#!/usr/bin/env
31 novaboot>. Then, booting a particular OS configuration becomes the
32 same as executing a local program – the novaboot script.
33
34 Novaboot uses configuration files to, among other things, define
35 command line options needed for different targets. Users typically use
36 only the B<-t>/B<--target> command line option to select the target.
37 Internally, this option expands to the pre-configured options.
38 Novaboot searches configuration files at multiple places, which allows
39 having per-system, per-user or per-project configurations.
40 Configuration file syntax is described in section L</"CONFIGURATION
41 FILES">.
42
43 Novaboot newcomers may be confused by a large number of configuration
44 options. Understanding all these options is not always needed,
45 depending on the used setup. The L<figure from the doc directory
46 |https://github.com/wentasah/novaboot/blob/master/doc/typical-setups.svg>
47 shows different setups that vary in how much effort is needed
48 to configure novaboot for them. The setups are:
49
50 =over 3
51
52 =item A: Laptop and target device only
53
54 This requires to configure everything on the laptop side, including a
55 serial line connection (L</--serial>, L</--remote-cmd>, ...), power
56 on/off/reset commands (L</--reset-cmd>, ...), TFTP server
57 (L</--copy>, L</--prefix>...), device IP addresses, etc.
58
59 =item B: Laptop, target device and external TFTP server
60
61 Like the previous setup, but the TFTP (and maybe DHCP) configuration
62 is handled by a server. Novaboot users need to understand where to
63 copy their files to the TFTP server (L</--copy>) and which IP
64 addresses their target will get, but do not need to configure the
65 servers themselves.
66
67 =item C: Novaboot server running novaboot-shell
68
69 With this setup, the configuration is done on the server. Users only
70 need to know the SSH account (L</--ssh>) used to communicate between
71 novaboot and novaboot server. The server is implemented as a
72 restricted shell (L<novaboot-shell(1)>) on the server. No need to give
73 full shell access to novaboot users on the server.
74
75 =back
76
77 =head2 Simple examples of using C<novaboot>:
78
79 To boot Linux (files F<bzImage> and F<rootfs.cpio> in current
80 directory), create F<mylinux> file with this content:
81
82     #!/usr/bin/env novaboot
83     load bzImage console=ttyS0,115200
84     load rootfs.cpio
85
86 =over 3
87
88 =item 1.
89
90 Booting an OS in Qemu can be accomplished by giving the B<--qemu> option.
91 Thus running
92
93  novaboot --qemu mylinux
94
95 (or C<./mylinux --qemu> as described above) will run Qemu and make it
96 boot the configuration specified in the F<mylinux> script. How is qemu
97 started can be configured in various ways (see below).
98
99 =item 2.
100
101 Create a bootloader configuration file (currently supported
102 bootloaders are GRUB, GRUB2, ISOLINUX, Pulsar, and U-Boot) and copy it
103 with all other files needed for booting to a remote TFTP server. Then
104 use a TCP/IP-controlled relay/serial-to-TCP converter to reset the
105 target and receive its serial output.
106
107  ./mylinux --grub2 --copy=192.168.1.1:/tftp --iprelay=192.168.1.2
108
109 Alternatively, you can put these switches to the configuration file
110 and run:
111
112  ./mylinux --target mytarget
113
114 =item 3.
115
116 Specifying all the options needed by novaboot to successfully control
117 the target, either on command line or in configuration files, can be
118 difficult for users. Novaboot supports configuring the target
119 centrally via L<novaboot-shell(1)> on a server. With such a
120 configuration, users only need to use the B<--ssh> option to specify
121 where to boot their OS:
122
123  ./mylinux --ssh myboard@example.com
124
125 Typically, the server is the computer connected to and controlling the
126 target board and running the TFTP server.
127
128 =item 4.
129
130 Run DHCP and TFTP server on developer's machine to boot the target
131 from it.
132
133  ./mylinux --dhcp-tftp
134
135 This usage is useful when no network infrastructure is in place, and
136 the target is connected directly to developer's box.
137
138 =item 5.
139
140 Create bootable ISO image.
141
142  novaboot --iso -- script1 script2
143
144 The created ISO image will have ISOLINUX bootloader installed on it,
145 and the boot menu will allow selecting between I<script1> and
146 I<script2> configurations.
147
148 =back
149
150 =head1 OPTIONS AND PHASES
151
152 Novaboot performs its work in several phases. Command line options
153 described bellow influence the execution of each phase or allow their
154 skipping. The list of phases (in the execution order) is as follows.
155
156 =over
157
158 =item 1. L<Configuration reading|/Configuration reading phase>
159
160 =item 2. L<Command line processing|/Command line processing phase>
161
162 =item 3. L<Script preprocessing|/Script preprocessing phase>
163
164 =item 4. L<File generation|/File generation phase>
165
166 =item 5. L<Target connection|/Target connection check>
167
168 =item 6. L<File deployment|/File deployment phase>
169
170 =item 7. L<Target power-on and reset|/Target power-on and reset phase>
171
172 =item 8. L<Interaction with the bootloader|/Interaction with the bootloader on the target>
173
174 =item 9. L<Target interaction|/Target interaction phase>
175
176 =back
177
178 Each phase is described in the following sections together with the
179 command line options that control it.
180
181 =head2 Configuration reading phase
182
183 After starting, novaboot reads zero or more configuration files. We
184 describe their content in section L</"CONFIGURATION FILES">. By default, the
185 configuration is read from multiple locations. First from the system
186 configuration directory (F</etc/novaboot.d/>), second from the user
187 configuration file (F<~/.config/novaboot>) and third from F<.novaboot>
188 files along the path to the current directory. Alternatively, a single
189 configuration file specified with the B<-c> switch or with the
190 C<NOVABOOT_CONFIG> environment variable is read. The latter read files
191 override settings from the former ones.
192
193 The system configuration directory is determined by the content of
194 NOVABOOT_CONFIG_DIR environment variable and defaults to
195 F</etc/novaboot.d>. Files in this directory with names consisting
196 solely of English letters, numbers, dashes '-' and underscores '_'
197 (note that dot '.' is not included) are read in alphabetical order.
198
199 Then, the user configuration file is read from
200 F<$XDG_CONFIG_HOME/novaboot>. If C<$XDG_CONFIG_HOME> environment
201 variable is not set F<~/.config/novaboot> is read instead.
202
203 Finally, novaboot searches for files named F<.novaboot> starting from the
204 directory of the novaboot script (or working directory, see bellow)
205 and continuing upwards up to the root directory. The found
206 configuration files are then read in the opposite order (i.e. from the
207 root directory downwards). This ordering allows having, for example, a project
208 specific configuration in F<~/project/.novaboot>.
209
210 Note the difference between F<~/.config/novaboot> and F<~/.novaboot>.
211 The former one is always read, whereas the latter only when novaboot
212 script or working directory is under the C<$HOME> directory.
213
214 In certain cases, the location of the novaboot script cannot be
215 determined in this early phase. This situation happens either when the script is
216 read from the standard input or when novaboot is invoked explicitly as
217 in the example L</"4."> above. In this case, the current working
218 directory is used as a starting point for configuration file search
219 instead of the novaboot script directory.
220
221 =over 8
222
223 =item -c, --config=I<filename>
224
225 Use the specified configuration file instead of the default one(s).
226
227 =back
228
229 =head2 Command line processing phase
230
231 =over 8
232
233 =item --dump-config
234
235 Dump the current configuration to stdout end exit. Useful as an
236 initial template for a configuration file.
237
238 =item -h, --help
239
240 Print short (B<-h>) or long (B<--help>) help.
241
242 =item -t, --target=I<target>
243
244 This option serves as a user configurable shortcut for other novaboot
245 options. The effect of this option is the same as specifying the
246 options stored in the C<%targets> configuration variable under key
247 I<target>. See also L</"CONFIGURATION FILES">.
248
249 When this option is not given, novaboot tries to determine the target
250 to use from either B<NOVABOOT_TARGET> environment variable or
251 B<$default_target> configuration file variable.
252
253 =item --ssh=I<user@hostname>
254
255 Configures novaboot to control the target via C<novaboot-shell>
256 running remotely via SSH.
257
258 Using this option is the same as specifying B<--remote-cmd>,
259 B<--remote-expect>, B<--copy> B<--rsync-flags>, B<--prefix> and
260 B<--reset-cmd> manually in a way compatible with C<novaboot-shell>.
261 The server can be configured to provide other, safe bootloader-related
262 options, to the client. When this happens, novaboot prints them to
263 stdout.
264
265 Currently, this in an initial experimental implementation. We plan to
266 change/extend this feature soon!
267
268 =back
269
270 =head2 Script preprocessing phase
271
272 This phase allows modifying the parsed novaboot script before it is
273 used in the later phases.
274
275 =over 8
276
277 =item -a, --append=I<parameters>
278
279 Append a string to the first C<load> line in the novaboot script. This option
280 can be used to append parameters to the kernel's or root task's
281 command line. This option can appear multiple times.
282
283 =item -b, --bender
284
285 Use L<Bender|https://github.com/TUD-OS/morbo/blob/master/standalone/bender.c>
286 chainloader. Bender scans the PCI bus for PCI serial ports and stores
287 the information about them in the BIOS data area for use by the
288 kernel.
289
290 =item --chainloader=I<chainloader>
291
292 Specifies a chainloader that is loaded before the kernel and other
293 files specified in the novaboot script. E.g. 'bin/boot/bender
294 promisc'.
295
296 =item --dump
297
298 Print the modules to boot and their parameters, after this phase
299 finishes. Then exit. This is useful for seeing the effect of other
300 options in this section.
301
302 =item -k, --kernel=F<file>
303
304 Replace the first word on the first C<load> line in the novaboot
305 script with F<file>.
306
307 =item --scriptmod=I<Perl expression>
308
309 When novaboot reads the script, I<Perl expression> is executed for every
310 line (in $_ variable). For example, C<novaboot
311 --scriptmod=s/sigma0/omega6/g> replaces every occurrence of I<sigma0>
312 in the script with I<omega6>.
313
314 When this option is present, it overrides I<$script_modifier> variable
315 from the configuration file, which has the same effect. If this option
316 is given multiple times all expressions are evaluated in the command
317 line order.
318
319 =back
320
321 =head2 File generation phase
322
323 In this phase, files needed for booting are generated in a so-called
324 I<build directory> (see L</--build-dir>). In most cases configuration
325 for a bootloader is generated automatically by novaboot. It is also
326 possible to generate other files using I<heredoc> or I<"<"> syntax in
327 novaboot scripts. Finally, novaboot can generate binaries in this phases by
328 running C<scons> or C<make>.
329
330 =over 8
331
332 =item --build-dir=I<directory>
333
334 Overrides the default build directory location.
335
336 The default build directory location is determined as follows: If the
337 configuration file defines the C<$builddir> variable, its value is
338 used. Otherwise, it is the directory that contains the first processed
339 novaboot script.
340
341 See also L</BUILDDIR> variable.
342
343 =item -g, --grub[=I<filename>]
344
345 Generates grub bootloader menu file. If the I<filename> is not
346 specified, F<menu.lst> is used. The I<filename> is relative to the
347 build directory (see B<--build-dir>).
348
349 =item --grub-preamble=I<prefix>
350
351 Specifies the I<preamble> that is at the beginning of the generated
352 GRUB or GRUB2 config files. This is useful for specifying GRUB's
353 timeout.
354
355 =item --prefix=I<prefix>
356
357 Specifies I<prefix> (e.g. F</srv/tftp>) that is put in front of every
358 filename in generated bootloader configuration files (or in U-Boot
359 commands).
360
361 If the I<prefix> contains string $NAME, it will be replaced with the
362 name of the novaboot script (see also B<--name>).
363
364 If the I<prefix> contains string $BUILDDIR, it will be replaced with
365 the build directory (see also B<--build-dir>).
366
367 =item --grub-prefix
368
369 Alias for B<--prefix>.
370
371 =item --grub2[=I<filename>]
372
373 Generate GRUB2 menu entry in I<filename>. If I<filename> is not
374 specified F<./boot/grub/grub.cfg> is used. The content of the menu entry can be
375 customized with B<--grub-preamble>, B<--grub2-prolog> or
376 B<--grub_prefix> options.
377
378 GRUB2 can boot multiboot-compliant kernels and a few kernels with specific
379 support. L</BOOT_METHOD> could be used to specify the command used by GRUB2 to
380 load the kernel. See L<GNU GRUB Manual|https://www.gnu.org/software/grub/manual/grub/grub.html#Booting>.
381
382 To use the generated menu entry on your development
383 machine that uses GRUB2, append the following snippet to
384 F</etc/grub.d/40_custom> file and regenerate your grub configuration,
385 i.e. run update-grub on Debian/Ubuntu.
386
387   if [ -f /path/to/nul/build/grub.cfg ]; then
388     source /path/to/nul/build/grub.cfg
389   fi
390
391 =item --grub2-prolog=I<prolog>
392
393 Specifies the text that novaboot puts at the beginning of the GRUB2 menu entry.
394
395 =item -m, --make[=make command]
396
397 Runs C<make> to build files that are not generated by novaboot itself.
398
399 =item --name=I<string>
400
401 Use the name I<string> instead of the name of the novaboot script.
402 This name is used for things like a title of grub menu or for the
403 server directory where the boot files are copied to.
404
405 =item --no-file-gen
406
407 Do not run external commands to generate files (i.e. "<" syntax and
408 C<run> keyword). This switch does not influence the generation of files
409 specified with "<<WORD" syntax.
410
411 =item -p, --pulsar[=mac]
412
413 Generates pulsar bootloader configuration file named F<config-I<mac>>
414 The I<mac> string is typically a MAC address and defaults to
415 I<novaboot>.
416
417 =item --scons[=scons command]
418
419 Runs C<scons> to build files that are not generated by novaboot
420 itself.
421
422 =item --strip-rom
423
424 Strip I<rom://> prefix from command lines and generated config files.
425 The I<rom://> prefix is used by NUL. For NRE, it has to be stripped.
426
427 =item --gen-only
428
429 Exit novaboot after file generation phase.
430
431 =back
432
433 =head2 Target connection check
434
435 In this phase novaboot connects to target's serial port (if it has
436 one). If another novaboot user/instance occupies the target, novaboot
437 exits here with an error message.
438
439 =over 8
440
441 =item --amt=I<"[user[:password]@]host[:port]>
442
443 Use Intel AMT technology to control the target machine. WS management
444 is used to powercycle it and Serial-Over-Lan (SOL) for input/output.
445 The hostname or (IP address) is given by the I<host> parameter. If the
446 I<password> is not specified, environment variable AMT_PASSWORD is
447 used. The I<port> specifies a TCP port for SOL. If not specified, the
448 default is 16992. The default I<user> is admin.
449
450 =item --iprelay=I<addr[:port]>
451
452 Use TCP/IP relay and serial port to access the target's serial port
453 and powercycle it. The I<addr> parameter specifies the IP address of
454 the relay. If I<port> is not specified, it defaults to 23.
455
456 Note: This option is supposed to work with HWG-ER02a IP relays.
457
458 =item --iprelay-cmd=I<command>
459
460 Similar to B<--iprelay> but uses I<command> to talk to the iprelay
461 rather than direct network connection.
462
463 =item -s, --serial[=device]
464
465 Target's serial line is connected to host's serial line (device). The
466 default value for device is F</dev/ttyUSB0>.
467
468 The value of this option is exported in NB_NOVABOOT environment
469 variable to all subprocesses run by C<novaboot>.
470
471 =item --stty=I<settings>
472
473 Specifies settings passed to C<stty> invoked on the serial line
474 specified with B<--serial> option. If this option is not given,
475 C<stty> is called with C<raw -crtscts -onlcr 115200> settings.
476
477 =item --remote-cmd=I<cmd>
478
479 Command that mediates connection to the target's serial line. For
480 example C<ssh server 'cu -l /dev/ttyS0'>.
481
482 =item --remote-expect=I<string>
483
484 Wait for reception of I<string> after establishing the remote serial
485 line connection. Novaboot assumes that after establishing the serial
486 line connection, the user running novaboot has exclusive access to the
487 target. If establishing of the serial line connection happens
488 asynchronously (e.g. running a command remotely via SSH), we need this
489 option to wait until the exclusive access is confirmed by the remote
490 side.
491
492 Depending on target configuration, this option can solve two practical
493 problems: 1) Overwriting of files deployed by another user currently
494 using the target. 2) Resetting the target board before serial line
495 connection is established and thus missing bootloader interaction.
496
497 Example of usage with the L<sterm
498 tool|https://rtime.felk.cvut.cz/gitweb/sojka/sterm.git>:
499
500   --remote-cmd='ssh -tt example.com sterm -v /dev/ttyUSB0' --remote-expect='sterm: Connected'
501
502 =item --remote-expect-silent=I<string>
503
504 The same as B<--remote-expect> except that the remote output is not
505 echoed to stdout while waiting for the I<string>. Everything after the
506 matched string is printed to stdout, so you may want to include line
507 end characters in the I<string> as well.
508
509 =item --remote-expect-timeout=I<seconds>
510
511 Timeout in seconds for B<--remote-expect> or
512 B<--remote-expect-seconds>. When negative, waits forever. The default
513 is -1 seconds.
514
515 =back
516
517 =head2 File deployment phase
518
519 In some setups, it is necessary to copy the files needed for booting
520 to a particular location, e.g. to a TFTP boot server or to the
521 F</boot> partition.
522
523 =over 8
524
525 =item -d, --dhcp-tftp
526
527 Turns your workstation into a DHCP and TFTP server so that the OS can
528 be booted via PXE BIOS (or similar mechanism) on the test machine
529 directly connected by a plain Ethernet cable to your workstation.
530
531 The DHCP and TFTP servers require root privileges and C<novaboot>
532 uses C<sudo> command to obtain those. You can put the following to
533 I</etc/sudoers> to allow running the necessary commands without asking
534 for a password.
535
536  Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/touch dhcpd.leases, /usr/bin/pkill --pidfile=dhcpd.pid, /usr/bin/pkill --pidfile=tftpd.pid
537  your_login ALL=NOPASSWD: NOVABOOT
538
539 =item --tftp
540
541 Starts a TFTP server on your workstation. This is similar to
542 B<--dhcp-tftp> except that DHCP server is not started.
543
544 The TFTP server requires root privileges and C<novaboot> uses C<sudo>
545 command to obtain those. You can put the following to I</etc/sudoers>
546 to allow running the necessary commands without asking for a password.
547
548  Cmnd_Alias NOVABOOT =  /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
549  your_login ALL=NOPASSWD: NOVABOOT
550
551 =item --tftp-port=I<port>
552
553 Port to run the TFTP server on. Implies B<--tftp>.
554
555 =item --netif=I<network interface>
556
557 Network interface used to deploy files to the target. This option
558 influences the configuration of the DHCP server started by
559 B<--dhcp-tftp> and the value that B<$NB_MYIP> get replaced with during
560 U-Boot conversation. The default value is C<$netif> variable from
561 configuration files, which defaults to I<eth0>.
562
563 =item --iso[=filename]
564
565 Generates the ISO image that boots NOVA system via GRUB. If no filename
566 is given, the image is stored under I<NAME>.iso, where I<NAME> is the name
567 of the novaboot script (see also B<--name>).
568
569 =item --server[=[[user@]server:]path]
570
571 Alias of B<--copy> (kept for backward compatibility).
572
573 =item --copy[=[[user@]server:]path]
574
575 Copy all files needed for booting to another location. The files will
576 be copied (by B<rsync> tool) to the directory I<path>. If the I<path>
577 contains string $NAME, it will be replaced with the name of the
578 novaboot script (see also B<--name>).
579
580 =item --rsync-flags=I<flags>
581
582 Specifies I<flags> to append to F<rsync> command line when
583 copying files as a result of I<--copy> option.
584
585 =item --concat
586
587 If B<--copy> is used and its value ends with $NAME, then after
588 copying the files, a new bootloader configuration file (e.g. menu.lst)
589 is created at I<path-wo-name>, i.e. the path specified by B<--copy>
590 with $NAME part removed. The content of the file is created by
591 concatenating all files of the same name from all subdirectories of
592 I<path-wo-name> found on the "server".
593
594 =item --ider
595
596 Use Intel AMT technology for IDE redirection. This allows the target
597 machine to boot from novaboot created ISO image. Implies B<--iso>.
598
599 The experimental C<amtider> utility needed by this option can be
600 obtained from https://github.com/wentasah/amtterm.
601
602 =back
603
604 =head2 Target power-on and reset phase
605
606 At this point, the target is reset (or switched on/off). There are
607 several ways how this can be accomplished. Resetting a physical target
608 can currently be accomplished by the following options: B<--amt>,
609 B<--iprelay>, B<--reset-cmd> and B<--reset-send>.
610
611 =over 8
612
613 =item --on, --off
614
615 Switch on/off the target machine and exit. The script (if any) is
616 completely ignored. Currently, it works only with the following
617 options: B<--iprelay>, B<--amt>, B<--ssh>.
618
619 =item -Q, --qemu[=I<qemu-binary>]
620
621 Boot the configuration in qemu. Optionally, the name of qemu binary
622 can be specified as a parameter.
623
624 =item --qemu-append=I<flags>
625
626 Append I<flags> to the default qemu flags (QEMU_FLAGS variable or
627 C<-cpu coreduo -smp 2>).
628
629 =item -q, --qemu-flags=I<flags>
630
631 Replace the default qemu flags (QEMU_FLAGS variable or C<-cpu coreduo
632 -smp 2>) with I<flags> specified here.
633
634 =item --reset-cmd=I<cmd>
635
636 Runs command I<cmd> to reset the target.
637
638 =item --reset-send=I<string>
639
640 Reset the target by sending the given I<string> to the remote serial
641 line. "\n" sequences are replaced with the newline character.
642
643 =item --no-reset, --reset
644
645 Disable/enable resetting of the target.
646
647 =back
648
649 =head2 Interaction with the bootloader on the target
650
651 =over 8
652
653 =item --uboot[=I<prompt>]
654
655 Interact with U-Boot bootloader to boot the thing described in the
656 novaboot script. I<prompt> specifies the U-Boot's prompt (default is
657 "=> ", other common prompts are "U-Boot> " or "U-Boot# ").
658
659 =item --no-uboot
660
661 Disable U-Boot interaction previously enabled with B<--uboot>.
662
663 =item --uboot-stop-key=I<key>
664
665 Character, which is sent as a response to U-Boot's "Hit any key to
666 stop autoboot" message. The default value is newline, but some devices
667 (e.g. TP-Link TD-W8970) require a specific key to be pressed.
668
669 =item --uboot-init
670
671 Command(s) to send the U-Boot bootloader before loading the images and
672 booting them. This option can be given multiple times. After sending
673 commands from each option novaboot waits for U-Boot I<prompt>.
674
675 If the command contains string I<$NB_MYIP> then this string is
676 replaced by IPv4 address of eth0 interface (see also B<--netif>).
677 Similarly, I<$NB_PREFIX> is replaced with prefix given by B<--prefix>.
678
679 See also C<uboot> keyword in L</"NOVABOOT SCRIPT SYNTAX">).
680
681 =item --uboot-addr I<name>=I<address>
682
683 Load address of U-Boot's C<tftpboot> command for loading I<name>,
684 where name is one of I<kernel>, I<ramdisk> or I<fdt> (flattened device
685 tree).
686
687 The default addresses are ${I<name>_addr_r}, i.e. U-Boot environment
688 variables used by convention for this purpose.
689
690 =item --uboot-cmd=I<command>
691
692 Specifies U-Boot command used to execute the OS. If the command
693 contains strings C<$kernel_addr>, C<$ramdisk_addr>, C<$fdt_addr>,
694 these are replaced with the addresses configured with B<--uboot-addr>.
695
696 The default value is
697
698     bootm $kernel_addr $ramdisk_addr $fdt_addr
699
700 or the C<UBOOT_CMD> variable if defined in the novaboot script.
701
702 =back
703
704 =head2 Target interaction phase
705
706 In this phase, target's serial output is redirected to stdout and if
707 stdin is a TTY, it is redirected to the target's serial input allowing
708 interactive work with the target.
709
710 =over 8
711
712 =item --exiton=I<string>
713
714 When the I<string> is sent by the target, novaboot exits. This option can
715 be specified multiple times, in which case novaboot exits whenever
716 either of the specified strings is sent.
717
718 If the I<string> is C<-re>, then the next B<--exiton>'s I<string> is
719 treated as a regular expression. For example:
720
721     --exiton -re --exiton 'error:.*failed'
722
723 =item --exiton-re=I<regex>
724
725 The same as --exiton -re --exiton I<regex>.
726
727 =item --exiton-timeout=I<seconds>
728
729 By default B<--exiton> waits for the string match forever. When this
730 option is specified, "exiton" timeouts after the specified number of
731 seconds and novaboot returns non-zero exit code.
732
733 =item -i, --interactive
734
735 Setup things for the interactive use of the target. Your terminal will
736 be switched to raw mode. In raw mode, your local terminal does not
737 process input in any way (no echoing of entered characters, no
738 interpretation of special characters). This, among others, means that
739 Ctrl-C is passed to the target and does not interrupt novaboot. To
740 exit from novaboot interactive mode type "~~.".
741
742 =item --no-interaction, --interaction
743
744 Skip resp. force target interaction phase. When skipped, novaboot exits
745 immediately after the boot is initiated.
746
747 =item --expect=I<string>
748
749 When the I<string> is received from the target, send the string specified
750 with the subsequent B<--send*> option to the target.
751
752 =item --expect-re=I<regex>
753
754 When target's output matches regular expression I<regex>, send the
755 string specified with the subsequent B<--send*> option to the target.
756
757 =item --expect-raw=I<perl-code>
758
759 Provides direct control over Perl's Expect module.
760
761 =item --send=I<string>
762
763 Send I<string> to the target after the previously specified
764 B<--expect*> was matched in the target's output. The I<string> may
765 contain escape sequences such as "\n".
766
767 Note that I<string> is actually interpreted by Perl, so it can contain
768 much more that escape sequences. This behavior may change in the
769 future.
770
771 Example: C<--expect='login: ' --send='root\n'>
772
773 =item --sendcont=I<string>
774
775 Similar to B<--send> but continue expecting more input.
776
777 Example: C<--expect='Continue?' --sendcont='yes\n'>
778
779 =item --final-eol, --no-final-eol
780
781 By default, B<novaboot> always prints an end-of-line character at the
782 end of its execution in order to ensure that the output of programs
783 started after novaboot appears at the beginning of the line. When this
784 is not desired B<--no-final-eol> option can be used to override this
785 behavior.
786
787 =back
788
789 =head1 NOVABOOT SCRIPT SYNTAX
790
791 The syntax tries to mimic POSIX shell syntax. The syntax is defined
792 by the following rules.
793
794 Lines starting with "#" and empty lines are ignored.
795
796 Lines that end with "\" are concatenated with the following line after
797 removal of the final "\" and leading whitespace of the following line.
798
799 Lines of the form I<VARIABLE=...> (i.e. matching '^[A-Z_]+=' regular
800 expression) assign values to internal variables. See L</VARIABLES>
801 section.
802
803 Otherwise, the first word on the line defines the meaning of the line.
804 The following keywords are supported:
805
806 =over 4
807
808 =item C<load>
809
810 These lines represent modules to boot. The
811 word after C<load> is a file name (relative to the build directory
812 (see B<--build-dir>) of the module to load and the remaining words are
813 passed to it as the command line parameters.
814
815 When booting Linux, the first C<load> line usually refers to the
816 kernel image and its command line parameters (unless you use some
817 special pre-loader). Other C<load> lines may refer to an initramfs
818 image and/or a device tree blob. Their order is not important, as the
819 device tree is recognized as the file name ending with C<.dtb>.
820
821 When the C<load> line ends with "<<WORD" then the subsequent lines
822 until the line containing solely WORD are copied literally to the file
823 named on that line. This is similar to the heredoc feature of UNIX
824 shells.
825
826 When the C<load> line ends with "< CMD" then command CMD is executed
827 with F</bin/sh> and its standard output is stored in the file named on
828 that line. The SRCDIR variable in CMD's environment is set to the
829 absolute path of the directory containing the interpreted novaboot
830 script.
831
832 =item C<copy>
833
834 These lines are similar to C<load> lines. The
835 file mentioned there is copied to the same place as in the case of C<load>
836 (e.g. tftp server), but the file is not used in the bootloader
837 configuration. Such a file can be used by the target for other
838 purposes than booting, e.g. at OS runtime or for firmware update.
839
840 =item C<chld>
841
842 Chainload another bootloader. Instead of loading multiboot modules
843 identified with C<load> keyword, run another bootloader. This is
844 currently supported only by pulsar and can be used to load e.g. Grub
845 as in the example below:
846
847  chld boot/grub/i386-pc/core.0
848
849
850 =item C<run>
851
852 Lines starting with C<run> keyword contain shell commands that are run
853 during file generation phase. This is the same as the "< CMD" syntax
854 for C<load> keyboard except that the command's output is not
855 redirected to a file. The ordering of commands is the same as they
856 appear in the novaboot script.
857
858 =item C<uboot>
859
860 These lines represent U-Boot commands that are sent to the target if
861 B<--uboot> option is given. Having a U-Boot line in the novaboot
862 script is the same as giving B<--uboot-init> option to novaboot. The
863 following syntax variants are supported:
864
865
866   uboot[:<timeout>] <string> [> <file>]
867   uboot[:<timeout>] < <shell> [> <file>]
868
869 C<string> is the literal U-Boot command.
870
871 The C<uboot> keyword can be suffixed with timeout specification. The
872 syntax is C<uboot:Ns>, where C<N> is the whole number of seconds. If
873 the U-Boot command prompt does not appear before the timeout, novaboot
874 fails. The default timeout is 10 seconds.
875
876 In the second variant with the C<<> character the shell code is
877 executed and its standard output is sent to U-Boot. Example:
878
879   uboot < printf "mmc write \$loadaddr 1 %x" $(($(/usr/bin/stat -c%s rootfs.ext4) / 512))
880
881 When C<E<gt> file> part is present, the output of the U-Boot command
882 is written into the given file.
883
884 =back
885
886 Example (Linux):
887
888   #!/usr/bin/env novaboot
889   load bzImage console=ttyS0,115200
890   run  make -C buildroot
891   load rootfs.cpio < gen_cpio buildroot/images/rootfs.cpio "myapp->/etc/init.d/S99myapp"
892
893 Example (NOVA User Land - NUL):
894
895   #!/usr/bin/env novaboot
896   WVDESC=Example program
897   load bin/apps/sigma0.nul S0_DEFAULT script_start:1,1 \
898                            verbose hostkeyb:0,0x60,1,12,2
899   load bin/apps/hello.nul
900   load hello.nulconfig <<EOF
901   sigma0::mem:16 name::/s0/log name::/s0/timer name::/s0/fs/rom ||
902   rom://bin/apps/hello.nul
903   EOF
904
905 This example will load three modules: F<sigma0.nul>, F<hello.nul> and
906 F<hello.nulconfig>. sigma0 receives some command line parameters and
907 F<hello.nulconfig> file is generated on the fly from the lines between
908 C<<<EOF> and C<EOF>.
909
910 Example (Zynq system update via U-Boot):
911
912   #!/usr/bin/env novaboot
913
914   uboot dhcp
915
916   # Write kernel to FAT filesystem on the 1st SD card partition
917   run mkimage -f uboot-image.its image.ub
918   copy image.ub
919   uboot:60s tftpboot ${loadaddr} $NB_PREFIX/image.ub
920   uboot fatwrite mmc 0:1 ${loadaddr} image.ub $filesize
921   uboot set bootargs console=ttyPS0,115200 root=/dev/mmcblk0p2
922
923   # Write root FS image to the 2nd SD card partition
924   copy rootfs/images/rootfs.ext4
925   uboot:60s tftpboot ${loadaddr} $NB_PREFIX/rootfs/images/rootfs.ext4
926   uboot mmc part > mmc-part.txt
927   uboot < printf "mmc write \$loadaddr %x %x" $(awk '{ if ($1 == "2") { print $2 }}' mmc-part.txt) $(($(/usr/bin/stat -L --printf=%s rootfs/images/rootfs.ext4) / 512))
928
929   UBOOT_CMD=boot
930
931
932 =head2 VARIABLES
933
934 The following variables are interpreted in the novaboot script:
935
936 =over 8
937
938 =item BOOT_METHOD
939
940 Specifies the way GRUB2 boots the kernel. For kernels with multiboot
941 support use C<multiboot> method (the default). For Linux kernel use C<linux> method.
942
943 =item BUILDDIR
944
945 Novaboot chdir()s to this directory before file generation phase. The
946 directory name specified here is relative to the build directory
947 specified by other means (see L</--build-dir>).
948
949 =item EXITON
950
951 Assigning this variable has the same effect as specifying L</--exiton>
952 option.
953
954 =item INTERACTION
955
956 Setting this variable to zero is the same as giving
957 L</--no-interaction>, specifying to one corresponds to
958 L</--interaction>.
959
960 =item HYPERVISOR_PARAMS
961
962 Parameters passed to the hypervisor. The default value is "serial", unless
963 overridden in the configuration file.
964
965 =item KERNEL
966
967 The kernel to use instead of the hypervisor specified in the
968 configuration file with the C<$hypervisor> variable. The value should
969 contain the name of the kernel image as well as its command line
970 parameters. If this variable is defined and non-empty, the variable
971 HYPERVISOR_PARAMS is not used.
972
973 =item NO_BOOT
974
975 If this variable is 1, the system is not booted. This is currently
976 only implemented for U-Boot bootloader where it is useful for
977 interacting with the bootloader without booting the system - e.g. for
978 flashing.
979
980 =item QEMU
981
982 Use a specific qemu binary (can be overridden with B<-Q>) and flags
983 when booting this script under qemu. If QEMU_FLAGS variable is also
984 specified flags specified in QEMU variable are replaced by those in
985 QEMU_FLAGS.
986
987 =item QEMU_FLAGS
988
989 Use specific qemu flags (can be overridden with B<-q>).
990
991 =item UBOOT_CMD
992
993 See L</--uboot-cmd>.
994
995 =item WVDESC
996
997 Description of the WvTest-compliant program.
998
999 =item WVTEST_TIMEOUT
1000
1001 The timeout in seconds for WvTest harness. If no complete line appears
1002 in the test output within the time specified here, the test fails. It
1003 is necessary to specify this for long running tests that produce no
1004 intermediate output.
1005
1006 =back
1007
1008 =head1 CONFIGURATION FILES
1009
1010 Novaboot can read its configuration from one or more files. By
1011 default, novaboot looks for files in F</etc/novaboot.d>, file
1012 F<~/.config/novaboot> and files named F<.novaboot> as described in
1013 L</Configuration reading phase>. Alternatively, configuration file
1014 location can be specified with the B<-c> switch or with the
1015 NOVABOOT_CONFIG environment variable. The configuration file has Perl
1016 syntax (i.e. it is better to put C<1;> as the last line) and should set
1017 values of certain Perl variables. The current configuration can be
1018 dumped with the B<--dump-config> switch. Some configuration variables
1019 can be overridden by environment variables (see below) or by command
1020 line switches.
1021
1022 Supported configuration variables include:
1023
1024 =over 8
1025
1026 =item $builddir
1027
1028 Build directory location relative to the location of the configuration
1029 file.
1030
1031 =item $default_target
1032
1033 Default target (see below) to use when no target is explicitly
1034 specified with the B<--target> command line option or
1035 B<NOVABOOT_TARGET> environment variable.
1036
1037 =item $netif
1038
1039 Default value for the B<--netif> option. If not specified, it defaults
1040 to I<eth0>.
1041
1042 =item %targets
1043
1044 Hash of target definitions to be used with the B<--target> option. The
1045 key is the identifier of the target, the value is the string with
1046 command line options. For instance, if the configuration file contains:
1047
1048  $targets{'mybox'} = '--copy=boot:/tftproot --serial=/dev/ttyUSB0 --grub',
1049
1050 then the following two commands are equivalent:
1051
1052  ./myos --copy=boot:/tftproot --serial=/dev/ttyUSB0 --grub
1053  ./myos -t mybox
1054
1055 =back
1056
1057 =head1 ENVIRONMENT VARIABLES
1058
1059 Some options can be specified not only via config file or command line
1060 but also through environment variables. Environment variables override
1061 the values from the configuration file and command line parameters
1062 override the environment variables.
1063
1064 =over 8
1065
1066 =item NOVABOOT_CONFIG
1067
1068 Name of the novaboot configuration file to use instead of the default
1069 one(s).
1070
1071 =item NOVABOOT_CONFIG_DIR
1072
1073 Name of the novaboot configuration directory. When not specified
1074 F</etc/novaboot.d> is used.
1075
1076 =item NOVABOOT_TARGET
1077
1078 Name of the novaboot target to use. This overrides the value of
1079 B<$default_target> from the configuration file and can be overridden
1080 with the B<--target> command line option.
1081
1082 =item NOVABOOT_BENDER
1083
1084 Defining this variable has the same effect as using B<--bender>
1085 option.
1086
1087 =back
1088
1089 =head1 AUTHORS
1090
1091 Michal Sojka <sojka@os.inf.tu-dresden.de>
1092
1093 Latest novaboot version can be found at
1094 L<https://github.com/wentasah/novaboot>.
1095