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