]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Add initial support for uBoot
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 5 Nov 2013 13:05:30 +0000 (14:05 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 5 Nov 2013 13:05:30 +0000 (14:05 +0100)
README.md
novaboot

index 4081e8436aa4f4e16a14c57a7a889578e7a69d6f..8dd573caae49fa3dbaef19fc63344bdf60581c7a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -33,8 +33,8 @@ specified by command line switches. Thus running `novaboot ./script`
 (or `./script` as described above) will run Qemu and make it boot the
 configuration specified in the _script_.
 2. Create a bootloader configuration file (currently supported
-bootloaders are GRUB, GRUB2 and Pulsar) and copy it with all other
-files needed for booting to another, perhaps remote, location.
+bootloaders are GRUB, GRUB2, Pulsar and uBoot) and copy it with all
+other files needed for booting to another, perhaps remote, location.
 
         ./script --server --iprelay=192.168.1.2
 
@@ -319,6 +319,13 @@ to a particular location, e.g. to a TFTP boot server or to the
 
 See __\--serial__. There will be new options soon.
 
+- \--uboot
+
+    Interact with uBoot bootloader to boot the thing described in the
+    novaboot script. Implementation of this option is currently tied to a
+    particular board that we use. It may be subject to changes in the
+    future!
+
 ## Target's output reception phase
 
 - \-s, --serial\[=device\]
index 46f172884d0b7a2d30612c3078b5be65ead43b31..2e6d260c8378a17bfe612621ecb849438cd441b0 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -88,7 +88,7 @@ read_config($_) foreach $cfg or reverse @cfgs;
 
 ## Command line handling
 
-my ($append, $bender, @chainloaders, $concat, $config_name_opt, $dhcp_tftp, $dump_opt, $dump_config, $gen_only, $grub_config, $grub_prefix, $grub_preamble, $grub2_prolog, $grub2_config, $help, $iprelay, $iso_image, $man, $no_file_gen, $off_opt, $on_opt, $pulsar, $pulsar_root, $qemu, $qemu_append, $qemu_flags_cmd, $rom_prefix, $rsync_flags, @scriptmod, $scons, $serial, $server, $stty);
+my ($append, $bender, @chainloaders, $concat, $config_name_opt, $dhcp_tftp, $dump_opt, $dump_config, $gen_only, $grub_config, $grub_prefix, $grub_preamble, $grub2_prolog, $grub2_config, $help, $iprelay, $iso_image, $man, $no_file_gen, $off_opt, $on_opt, $pulsar, $pulsar_root, $qemu, $qemu_append, $qemu_flags_cmd, $rom_prefix, $rsync_flags, @scriptmod, $scons, $serial, $server, $stty, $uboot);
 
 $rsync_flags = '';
 $rom_prefix = 'rom://';
@@ -132,6 +132,7 @@ my %opt_spec;
     "target|t=s"     => sub { my ($opt_name, $opt_value) = @_;
                              exists $CFG::targets{$opt_value} or die("Unknown target '$opt_value' (valid targets are: ".join(", ", sort keys(%CFG::targets)).")");
                              GetOptionsFromString($CFG::targets{$opt_value}, %opt_spec); },
+    "uboot"         => \$uboot,
     "h"             => \$help,
     "help"          => \$man,
     );
@@ -671,6 +672,50 @@ if (defined $target_reset) {
     print "done\n";
 }
 
+if (defined $uboot) {
+    print "novaboot: Waiting for uBoot prompt...\n";
+    $exp->log_stdout(1);
+    $exp->expect(20,
+                [qr/Hit any key to stop autoboot:/, sub { $exp->send('.'); exp_continue; }],
+                '=> ') || die "No uBoot prompt deteceted";
+
+    $exp->send("dhcp\n");
+    $exp->expect(1, '=> ');
+
+    my ($kbin, $kcmd) = split(' ', shift(@$modules), 2);
+    my $dtb;
+    @$modules = map { print "DTBBBB $_\n"; if (/\.dtb$/) { $dtb=$_; (); } else { $_ } } @$modules;
+    my $initrd = shift @$modules;
+
+    my $kern_addr = '800000';
+    my $initrd_addr = '-';
+    my $dtb_addr = '';
+
+    sleep(1);
+    $exp->send("tftp $kern_addr $kbin\n");
+    $exp->expect(1,
+                [qr/#/, sub { exp_continue; }],
+                '=> ') || die "Kernel load failed";
+    if (defined $dtb) {
+       $dtb_addr = '7f0000';
+       $exp->send("tftp $dtb_addr $dtb\n");
+       $exp->expect(1,
+                    [qr/#/, sub { exp_continue; }],
+                    '=> ') || die "Device tree load failed";
+    }
+    if (defined $initrd) {
+       $initrd_addr = 'b00000';
+       $exp->send("tftp $initrd_addr $initrd\n");
+       $exp->expect(1,
+                    [qr/#/, sub { exp_continue; }],
+                    '=> ') || die "Initrd load failed";
+    }
+    $exp->send('mw f0000b00 ${psc_cfg}');
+    $exp->send("set bootargs $kcmd\n");
+    $exp->expect(1, '=> ');
+    $exp->send("bootm $kern_addr $initrd_addr $dtb_addr\n");
+}
+
 if (defined $exp) {
     # Serial line of the target is available
     print "novaboot: Serial line interaction (press Ctrl-C to interrupt)...\n";
@@ -732,8 +777,8 @@ configuration specified in the I<script>.
 =item 2.
 
 Create a bootloader configuration file (currently supported
-bootloaders are GRUB, GRUB2 and Pulsar) and copy it with all other
-files needed for booting to another, perhaps remote, location.
+bootloaders are GRUB, GRUB2, Pulsar and uBoot) and copy it with all
+other files needed for booting to another, perhaps remote, location.
 
  ./script --server --iprelay=192.168.1.2
 
@@ -1048,6 +1093,17 @@ Replace the default qemu flags (QEMU_FLAGS variable or C<-cpu coreduo
 
 See B<--serial>. There will be new options soon.
 
+=over 8
+
+=item --uboot
+
+Interact with uBoot bootloader to boot the thing described in the
+novaboot script. Implementation of this option is currently tied to a
+particular board that we use. It may be subject to changes in the
+future!
+
+=back
+
 =head2 Target's output reception phase
 
 =over 8