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