• Ei tuloksia

Because creation of a live USB flash drive and flashing the DCU40 with it takes some time, a flexible UEFI network boot environment was set up. With network boot, the DCU40’s eMMC memory does not need to be flashed at all but it is booted up from TFTP and NFS servers which are running on the build host.

This is achieved with iPXE, which is an open source network boot firmware implementation following Intel’s PXE specification. This works by running a DCHP server on the build host which provides the address of a TFTP server to DCU40 which is hosting three files:

• bzImage, the kernel image

• install.ipxe, the iPXE menu configuration file

• ipxe.efi, the iPXE boot loader executable

First, the iPXE boot loader executable is downloaded from the TFTP server to DCU40 and executed, which then uses the iPXE menu configuration file to download the kernel image and set the NFS share as root filesystem.

iPXE was chosen for this environment because of its flexibility and features which include:

• Controlling the boot process with a menu script

• Support for UEFI network boot over different protocols

• Chainloading with DCU40’s network card’s PXE implementation by Intel

5.5.1 Setting up a TFTP server

tftp-hpawas chosen as the TFTP server on the build host, and the only configu-ration which was done for it was to change the default/srv/tftp/directory to be writable by everyone:

$ s u d o c h m o d 755 / srv / t f t p /

This is for the automated network boot deploying script, which is located at:

yocto/build/dcu40-image/scripts/network_boot_deploy.sh

The TFTP server can host multiple different kernels which can be configured in the install.ipxeiPXE menu configuration file. During the network boot, the wanted boot selection can be chosen on the DCU40 and default set in the iPXE menu configuration file.

5.5.2 Setting up a DHCP server

A DHCP server is needed to be configured for network boot, which tells the location of network boot files to the client DCU40.

On Debian and Ubuntu a DHCP server is installed and configured with:

$ s u d o apt isc - dhcp - s e r v e r

$ e c h o ’ I N T E R F A C E S v 4 =" < i n t e r f a c e >" ’ | s u d o tee - a / etc / d e f a u l t / isc - dhcp - s e r v e r

$ s u d o tee - a / etc / d h c p / d h c p d . c o n f < < EOF

# Network for DHCP server

s u b n e t < subnet > n e t m a s k < netmask > { o p t i o n r o u t e r s < host_ip >;

o p t i o n domain - name - s e r v e r s < host_ip >;

o p t i o n subnet - m a s k < netmask >;

o p t i o n b r o a d c a s t - a d d r e s s < b r o a d c a s t >;

}

# PXE network boot a l l o w b o o t i n g ;

next - s e r v e r < host_ip >;

o p t i o n client - a r c h c o d e 93 = u n s i g n e d i n t e g e r 16;

if o p t i o n client - a r c h != 0 0 : 0 0 { f i l e n a m e " i p x e . efi " ;

}

# DCU40 static IP h o s t cu {

h a r d w a r e e t h e r n e t < d c u 4 0 _ m a c >;

fixed - a d d r e s s < d c u 4 0 _ i p >;

} EOF

$ s u d o s e r v i c e isc - dhcp - s e r v e r r e s t a r t

where:

• <subnet>is the subnet used for the connection

• <netmask>is the network mask for the subnet

• <broadcast>is the broadcast address for the connection

• <interface>is the name of the interface used for connecting to DCU40

• <host_ip>is the host’s IP address on the<interface>

• <dcu40_mac>is the MAC address of the DCU40

• <dcu40_ip>is the IP address wanted for the DCU40

It is assumed, that the interface does not have any other DHCP servers running and it is configured with static IP for the host. A convenient way, is to set up a separate VLAN for <interface>. The "PXE network boot" section of the configuration follows DHCP specification for PXE by defining "Client System Architecture Type Option Definition" [18]. This configuration allows booting of clients with different architecture and both BIOS and UEFI boot. Currently, DHCP returns the filename

"ipxe.efi" if the client gives any other DHCP option 93 than 0, which is standard PC BIOS. For example DHCP options can be defined for ARM systems also.

5.5.3 Chainloading iPXE

Because DCU40 already has a basic PXE implementation on its network card iPXE’s chainloading is used to first boot with PXE, and then chainload to iPXE’s boot menu. Doing this requires building an EFI file with iPXE’s source code. The build ofipxe.efibinary requires achain.ipxe, which has the host’s TFTP server IP address andmenu.ipxeas a chain target.

A template for chain.ipxe:

#!ipxe d h c p

c h a i n t f t p : / / % H O S T _ I P %/ m e n u . i p x e

and a template formenu.ipxe, which has the boot option fordcu40-image:

#!ipxe : s t a r t

m e n u P l e a s e c h o o s e b o o t i m a g e i t e m - - gap D C U 4 0

i t e m dcu40 - i m a g e dcu40 - i m a g e i t e m - - gap i p x e s h e l l

i t e m s h e l l D r o p to i P X E s h e l l i t e m r e b o o t R e b o o t m a c h i n e

c h o o s e - - d e f a u l t dcu40 - i m a g e - - t i m e o u t 5 0 0 0 t a r g e t \

&& g o t o $ { t a r g e t } : s h e l l

e c h o T y p e ’ e x i t ’ to get the b a c k to the m e n u s h e l l

g o t o s t a r t : r e b o o t

e c h o R e b o o t i n g r e b o o t

: f a i l e d

e c h o B o o t i n g failed , g o i n g b a c k to s t a r t g o t o s t a r t

# DCU40 image in the build directory : dcu40 - i m a g e

k e r n e l t f tp : / / % H O S T _ I P %/ b z I m a g e \

r o o t =/ dev / nfs n f s r o o t =% H O S T _ I P %:% Y O C T O _ D I R %/ b u i l d / dcu40 i m a g e / nfs -boot , n f s v e r s =3 , p o r t =3049 , udp , m o u n t p o r t = 3 0 4 8 \

ip = d h c p r ai d = n o a u t o d e t e c t r o o t w a i t c o n s o l e = t t y 0 b o o t || g o t o f a i l e d

For convenience, a script yocto/scripts/make_ipxe_boot.shwas written, which automates the file generation from templates by using sed stream editor, and building of theipxe.efibinary with help of the iPXE GIT repository added as a submodule, and deploying the files to the TFTP server. As can be seen from the goto statements inmenu.ipxe, the iPXE’s command language is fairly primitive but it provides a configurable bootloader menu like in Figure 5.2. iPXE’s command reference has all the available commands documented which can be used in iPXE shell or in scripts [19].

Figure 5.2. iPXE bootloader menu

5.5.4 NFS root filesystem

After the kernel has been downloaded to the DCU40 then the NFS server address is given as a kernel command line option. To deploy the NFS server in user space following commands can be user:

$ runqemu - extract - sdk < r o o t f s _ t a r b a l l > < n f s _ r o o t f s _ d i r >

$ runqemu - export - r o o t f s < n f s _ r o o t f s _ d i r >

where:

• rootfs_tarballis the tar package of the root filesystem in the build output directory

• nfs_rootfs_diris the directory which is to be used as a NFS share

The root filesystem can be interacted with and modified when the DCU40 is running from it.

6 A COMPARISON OF BITBAKE AND TELESTE’S

IMAGETOOLS