Commit 56891b34 authored by Alessandro Rubini's avatar Alessandro Rubini

boot scripts: better examples

This updates binaries/wrboot-* to be more commented and complete.
It also adds wrboot-install and wrboot-nand, that I personally used.

As a side effect, "mem=64m" is removed by all command lines, as it has
been properly autodetected for a few years now, so it is not needed
any more.

Documentation is updated too.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 3789e8b5
#!/bin/sh #!/bin/sh
bootargs="quiet console=ttyS0,115200 panic=10 mem=64m" # This is an example wrboot script. The switch first does a DHCP pass
bootargs="$bootargs root=nfs ip=dhcp" # to get this script while using a valid IP address. You can
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" # keep that address or replace it from within the script itself.
#
# A few "wrboot" scripts are provided in wr-switch-sw/binaries/ Your
# script should be placed in your /tftpboot or equivalent directory,
# using one of the following names, that are tried in this order:
#
# wrboot-$eth0.ethaddr (i.e. using the specific MAC address of the wrs)
# $eth0.ipaddr/wrboot (i.e. in the default filesystem for your DHCP IP)
# wrboot (a generic catch-all name)
#### This example uses the current IP address, i.e. from DHCP
# choose your personal name for zImage
kernelname=zImage-wrs4
# Since this is for development, verbose is better than quiet (default)
bootargs="verbose console=ttyS0,115200 panic=10"
# if we didn't do it already, get our dhcp-based address in barebox # Pass IP information to the kernel (or ipinfo="dhcp" to re-request)
if [ "x$eth0.ipaddr" = "x" ]; then ipinfo="$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:wrs:eth0"
dhcp 5; bootargs="$bootargs root=nfs rw ip=$ipinfo"
fi
# I you want, specify a non-default root directory
bootargs="$bootargs nfsroot=/opt/root/wrs,tcp"
# And pass the WR base MAC address, that barebox retrieved from SDB
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr"
tftp zImage-wrs3 /dev/mem.kernel # Load the kernel using the personal name chosen above, and boot it
bootz /dev/mem.kernel tftp $kernelname /dev/mem.kernel; bootz /dev/mem.kernel
#!/bin/sh
# This is an example wrboot script. The switch first does a DHCP pass
# to get this script while using a valid IP address. You can
# keep that address or replace it from within the script itself.
#
# A few "wrboot" scripts are provided in wr-switch-sw/binaries/ Your
# script should be placed in your /tftpboot or equivalent directory,
# using one of the following names, that are tried in this order:
#
# wrboot-$eth0.ethaddr (i.e. using the specific MAC address of the wrs)
# $eth0.ipaddr/wrboot (i.e. in the default filesystem for your DHCP IP)
# wrboot (a generic catch-all name)
#### This example performs installation without using the USB cable.
#
# It relies on a working boot loader being present and use useful to
# recover the whole filesystem, in case you lost your /boot partition.
# or other mishaps. Users are not expected to run this, developers may.
# You need the following files in the tftp server.
#
# wrs-firmware.tar used by installation itself
# zImage extracted from above, used by this script
# wrs-initramfs.gz extracted from above, used by this script
#
# You can extract by using this on the host, in your TFTP directory:
# tar xf wrs-firmware.tar zImage wrs-initramfs.gz
# The first command below is not needed if we got this from tftp
# but if you lost barebox environment, you may copy it to the console
dhcp 5
# Creating the partitions should not be needed, unless you lost environment
addpart /dev/ram0 4M@0x01000000(kernel)
addpart /dev/ram0 4M@0x01800000(initramfs)
addpart /dev/mem 4M@0x71000000(kernel)
addpart /dev/mem 4M@0x71800000(initramfs)
# These files are sent in by sam-ba tools when installing from usb
tftp zImage/dev/mem.kernel
tftp wrs-initramfs.gz /dev/mem.initramfs
# The following stanza comes from env/bin/init in the install case
echo "Booting kernel for NAND flashing procedure"
bootargs="console=ttyS0,115200 panic=10 mem=64M"
bootargs="$bootargs initrd=0x71800000,4M"
bootargs="$bootargs root=/dev/ram0"
bootargs="$bootargs SERVERIP=$eth0.serverip WRS_INSTALLING=y"
bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:wrs:eth0"
bootm /dev/mem.kernel
# Now it installs, thanks to WRS_INSTALLING=y and the in-memory filesystem
#!/bin/sh
# This is an example wrboot script. The switch first does a DHCP pass
# to get this script while using a valid IP address. You can
# keep that address or replace it from within the script itself.
#
# A few "wrboot" scripts are provided in wr-switch-sw/binaries/ Your
# script should be placed in your /tftpboot or equivalent directory,
# using one of the following names, that are tried in this order:
#
# wrboot-$eth0.ethaddr (i.e. using the specific MAC address of the wrs)
# $eth0.ipaddr/wrboot (i.e. in the default filesystem for your DHCP IP)
# wrboot (a generic catch-all name)
#### This example is a copy of /env/bin/boot-nand, so you can edit it
# boot kernel from the UBI partition, already mounted by init script
cp /boot/zImage /dev/mem.kernel
cp /boot/wrs-initramfs.gz /dev/mem.initramfs
#bootargs="verbose console=ttyS0,115200 panic=10"
bootargs="quiet console=ttyS0,115200 panic=10"
bootargs="$bootargs initrd=0x71800000,0x400000"
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr"
bootz /dev/mem.kernel
# Sleep 2 seconds so you can see the message and return to menu
echo "Can't boot from NAND: going back to menu in 2s"
sleep 2
menu -s boot
#!/bin/sh #!/bin/sh
bootargs="quiet console=ttyS0,115200 panic=10 mem=64m" # This is an example wrboot script. The switch first does a DHCP pass
bootargs="$bootargs root=nfs ip=192.168.16.9:192.168.16.1:255.255.255.0" # to get this script while using a valid IP address. You can
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" # keep that address or replace it from within the script itself.
#
# A few "wrboot" scripts are provided in wr-switch-sw/binaries/ Your
# script should be placed in your /tftpboot or equivalent directory,
# using one of the following names, that are tried in this order:
#
# wrboot-$eth0.ethaddr (i.e. using the specific MAC address of the wrs)
# $eth0.ipaddr/wrboot (i.e. in the default filesystem for your DHCP IP)
# wrboot (a generic catch-all name)
#### This example uses static IP addresses. I personally use this.
eth0.ipaddr=192.168.16.9 # write your IP addresses here and your personal name for zImage
eth0.ipaddr=192.168.16.9
eth0.serverip=192.168.16.1 eth0.serverip=192.168.16.1
eth0.gateway=192.168.16.2
kernelname=zImage-wrs4
# Since this is for development, verbose is better than quiet (default)
bootargs="verbose console=ttyS0,115200 panic=10"
# Pass IP information to the kernel
ipinfo="$eth0.ipaddr:$eth0.serverip:$eth0.gateway:255.255.255.0:wrs:eth0"
bootargs="$bootargs root=nfs rw ip=$ipinfo"
# I you want, specify a non-default root directory
bootargs="$bootargs nfsroot=/opt/root/wrs,tcp"
# And pass the WR base MAC address, that barebox retrieved from SDB
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr"
tftp zImage-wrs3 /dev/mem.kernel # Load the kernel using the personal name chosen above, and boot it
bootz /dev/mem.kernel tftp $kernelname /dev/mem.kernel; bootz /dev/mem.kernel
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
@setchapternewpage off @setchapternewpage off
@set update-month Novembre 2014 @set update-month November 2014
@c the release name below is substituted at build time @c the release name below is substituted at build time
@set release __RELEASE_GIT_ID__ @set release __RELEASE_GIT_ID__
...@@ -1005,6 +1005,10 @@ the following command in a newly-created empty directory: ...@@ -1005,6 +1005,10 @@ the following command in a newly-created empty directory:
tar xzf $WRS_OUTPUT_DIR/images/wrs-image.tar.gz tar xzf $WRS_OUTPUT_DIR/images/wrs-image.tar.gz
@end example @end example
To boot with NFS-root you should use a custom boot script,
as described in the section @i{Using wrboot}, in the @i{@sc{wrs} User's
Manual}.
The archives include a number of device special files in The archives include a number of device special files in
@i{dev}. The pre-created devices come from @i{dev}. The pre-created devices come from
@i{userspace/devices.tar.gz}. Note that the buildroot output @i{userspace/devices.tar.gz}. Note that the buildroot output
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
@setchapternewpage off @setchapternewpage off
@set update-month October 2014 @set update-month November 2014
@c the release name below is substituted at build time @c the release name below is substituted at build time
@set release __RELEASE_GIT_ID__ @set release __RELEASE_GIT_ID__
...@@ -424,7 +424,8 @@ The individual menu items perform the following actions: ...@@ -424,7 +424,8 @@ The individual menu items perform the following actions:
change the MAC address of the ARM network port. Please note change the MAC address of the ARM network port. Please note
that saving save the whole @file{/env} file tree, so you that saving save the whole @file{/env} file tree, so you
can also change the init scripts interactively and have them can also change the init scripts interactively and have them
stored persistently on the flash. stored persistently on the flash. Users are not expected to
change any configuration, though, as further updates may fail.
@item 4: exit to shell @item 4: exit to shell
...@@ -437,8 +438,8 @@ The individual menu items perform the following actions: ...@@ -437,8 +438,8 @@ The individual menu items perform the following actions:
This entry is useful to see and log the exact boot messages. This entry is useful to see and log the exact boot messages.
Since the serial-USB converter is @i{switch-powered} and not Since the serial-USB converter is @i{switch-powered} and not
@i{USB-powered}, you won't be able to hook at the serial port @i{USB-powered}, you won't be able to hook at the serial port
soon enough after power-on. Actually, the menu timeout is soon enough after power-on. Actually, the menu startup time
left to 10 seconds and not less for the very same reason. is a few seconds long for the very same reason.
@end table @end table
...@@ -456,12 +457,26 @@ system with a separate @t{/usr} partition in flash memory. ...@@ -456,12 +457,26 @@ system with a separate @t{/usr} partition in flash memory.
@sp 1 @sp 1
The provided procedure tries to load the script from TFTP under three The @i{boot from TFTP script} menu entry looks for the script
different names, from most specific to most generic, and the first using three
match will be used. The first name is MAC-address-based, the different names, from most specific to most generic; the first found
second is IP-address-based and the third is just @file{wrboot}. is be used. When using the boot script, the @sc{wrs} first performs
a @sc{dhcp} query, and then uses that IP address to retrieve
the script using the following names (the @t{eth0.ethaddr} is
stored by the manufacturer in static storage and retrieved by the
boot loader; the @t{eth0.ipaddr} comes from @sc{dhcp}):
This is for example what I see in my logs when only providing @file{wrboot}: @smallexample
wrboot-$eth0.ethaddr
$eth0.ipaddr/wrboot
wrboot
@end smallexample
As an example, the following excerpt shows what I see in my logs when
only providing @file{wrboot}. The last message uses a different IP
address because my script forces a static address into the kernel,
whereas the initial one was assigned to the boot loader using
@sc{dhcp}.
@smallexample @smallexample
dhcpd: DHCPOFFER on 192.168.16.224 to 02:0b:ad:c0:ff:ee via eth0 dhcpd: DHCPOFFER on 192.168.16.224 to 02:0b:ad:c0:ff:ee via eth0
...@@ -480,15 +495,34 @@ from, as shown in the log excerpt above. So you'll have your ...@@ -480,15 +495,34 @@ from, as shown in the log excerpt above. So you'll have your
leading @t{#!/bin/sh}. Examples in @i{wr-switch-sw} did not include the leading @t{#!/bin/sh}. Examples in @i{wr-switch-sw} did not include the
line until April 2014 included. line until April 2014 included.
The @file{binaries} subdirectory of @t{wr-switch-sw} includes two known-working The @file{binaries} subdirectory of @t{wr-switch-sw} includes a number
wrboot scripts as examples; one if for use with static IP addresses and of known-working wrboot scripts as examples;
the other relies on DHCP. If you want to override the default NFS-Root
directory mounted from the server (which is @code{/tftpboot/<ip-address>})
you can add something like the following line to your @file{wrboot} script:
@example @table @t
bootargs="$bootargs nfsroot=/opt/root/wrs-3"
@end example @item wrboot-static-ip
The script forces a static IP address, server and gateway, and
a custom mount point for an NFS-root system.
@item wrboot-dhcp
The script preserves the @sc{dhcp}-assigned address, and runs
a custom NFS-root system.
@item wrboot-install
This performs an installation, by loading everything to RAM
and forcing install mode. Please check comments in the script.
@item wrboot-nand
This script is a copy of the default boot script executed
bt standalone switches. Booting from a script allows
changing the kernel command line or anything else it may
be useful to developers.
@end table
@c ========================================================================== @c ==========================================================================
@node Creating an NFS-Root Environment for WRS @node Creating an NFS-Root Environment for WRS
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
cp /boot/zImage /dev/mem.kernel cp /boot/zImage /dev/mem.kernel
cp /boot/wrs-initramfs.gz /dev/mem.initramfs cp /boot/wrs-initramfs.gz /dev/mem.initramfs
#bootargs="verbose console=ttyS0,115200 panic=10 mem=64M" #bootargs="verbose console=ttyS0,115200 panic=10"
bootargs="quiet console=ttyS0,115200 panic=10 mem=64M" bootargs="quiet console=ttyS0,115200 panic=10"
bootargs="$bootargs initrd=0x71800000,0x400000" bootargs="$bootargs initrd=0x71800000,0x400000"
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr"
bootz /dev/mem.kernel bootz /dev/mem.kernel
......
...@@ -17,7 +17,7 @@ memcmp -s /dev/mem -d /env/magicstr 0x717FFFF8 0x0 8 ...@@ -17,7 +17,7 @@ memcmp -s /dev/mem -d /env/magicstr 0x717FFFF8 0x0 8
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Booting kernel for NAND flashing procedure" echo "Booting kernel for NAND flashing procedure"
dhcp 5 dhcp 5
bootargs="console=ttyS0,115200 panic=10 mem=64M" bootargs="console=ttyS0,115200 panic=10"
bootargs="$bootargs initrd=0x71800000,4M" bootargs="$bootargs initrd=0x71800000,4M"
bootargs="$bootargs root=/dev/ram0" bootargs="$bootargs root=/dev/ram0"
bootargs="$bootargs SERVERIP=$eth0.serverip WRS_INSTALLING=y" bootargs="$bootargs SERVERIP=$eth0.serverip WRS_INSTALLING=y"
......
...@@ -369,7 +369,7 @@ CONFIG_ALIGNMENT_TRAP=y ...@@ -369,7 +369,7 @@ CONFIG_ALIGNMENT_TRAP=y
# #
CONFIG_ZBOOT_ROM_TEXT=0x0 CONFIG_ZBOOT_ROM_TEXT=0x0
CONFIG_ZBOOT_ROM_BSS=0x0 CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_CMDLINE="mem=64M console=ttyS0,115200 initrd=0x21100000,3145728 root=/dev/ram0 rw" CONFIG_CMDLINE="console=ttyS0,115200 initrd=0x21100000,3145728 root=/dev/ram0 rw"
# CONFIG_CMDLINE_FORCE is not set # CONFIG_CMDLINE_FORCE is not set
# CONFIG_XIP_KERNEL is not set # CONFIG_XIP_KERNEL is not set
# CONFIG_KEXEC is not set # CONFIG_KEXEC is not set
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment