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