fit for xen joshua whitehead getting u-boot paul skentzos ... fit for xen.pdfif a customer has an...
TRANSCRIPT
Getting U-Boot FIT for Xen
Xen Developers Summit 2015
Robbie VanVossenKarl ApsitePaul SkentzosJoshua Whitehead
where hardware and software design meet
.....
Presentation Outline
□ U-Boot□ FIT Image□ FIT Image Source File□ Loadables□ Building & Booting□ Benefits of Using FIT
2
where hardware and software design meet
U-Boot
The Universal Bootloader
3
where hardware and software design meet
.....
U-Boot - History
□ Open Source Bootloader for embedded devices□ Originally 8xxROM□ 1999 - PPCBoot□ 2000 - Publicly released v0.4.1
□ Strictly for Power PC architecture□ 2002
□ Forked into a product called ARMBoot □ Renamed to Das U-Boot (Universal Bootloader) to reflect new
architecture support□ 2003 - Added MIPS32, MIPS64, Coldfire, Altera NIOS−32 □ 2008 - Added Flattened Image Tree support
4
where hardware and software design meet
.....
U-Boot - Features
□ Multiple loading methods□ TFTP, mmc devices, various flash devices, PXE, IDE, SATA, USB
□ Lots of supported architectures□ 68k, ARM, AVR32, Blackfin,
MicroBlaze, MIPS, Nios,PPC, and x86
□ Filesystem handling□ Including Cramfs, ext2, ext3, ext4,
FAT, FDOS, JFFS2, ReiserFS, UBIFS, and ZFS
□ Network handling□ ping, DHCP, TFTP
□ FDT handling□ Direct memory reads and writes
5
where hardware and software design meet
FIT Image
Flattened Image Tree
6
where hardware and software design meet
.....
FIT Image - Introduction
□ Uses a tree-like structure□ Flexible, monolithic binary that includes everything for
booting□ Benefits
□ Image Hashing□ Multiple Configurations
□ FIT can not load more than one kernel
7
where hardware and software design meet
.....
FIT Image - Build Requirements
□ Utilities□ mkimage□ dtc - device tree compiler
□ Binaries□ Device Tree Binaries□ Kernels□ Optional ramdisks□ Optional Loadables (DornerWorks Contribution)
□ Image Source File (*.its)
8
where hardware and software design meet
.....
FIT Image - Generation
9
Image Source File (*.its)
FIT Image (*.itb)
mkimage
Binaries (kernels, fdts, ramdisks)
where hardware and software design meet
Image Source File
FIT Configuration (Before our updates)
10
where hardware and software design meet
.....
Image Source File - Example.its
/dts-v1/;/ {
description = "Single Linux kernel and FDT blob";#address-cells = <1>;
images {
kernel@1 {description = "Vanilla Linux kernel";data = /incbin/("./vmlinux.bin.gz");type = "kernel";arch = "arm";os = "linux";compression = "gzip";load = <00000000>;entry = <00000000>;hash@1 {
algo = "crc32";};hash@2 {
algo = "sha1";};
};
11
fdt@1 {description = "Flattened Device Tree
blob";data = /incbin/("./target.dtb");type = "flat_dt";arch = "arm";compression = "none";
load = <00700000>;hash@1 {
algo = "crc32";};hash@2 {
algo = "sha1";};
};};
fdt@2 {description = "Flattened Device Tree
blob";data = /incbin/("./target2.dtb");type = "flat_dt";arch = "arm";compression = "none";
load = <00700000>;};
};
where hardware and software design meet
.....
Image Source File - Example.its(cont)
ramdisk@1 {description = "ramdisk";data = /incbin/("./ramdisk");type = "ramdisk";arch = "arm";os = "linux";compression = "gzip";load = <00800000>;entry = <00800000>;hash@1 {
algo = "sha1";};
};};
12
configurations {default = "conf@1";
conf@1 {description = "Linux kernel with FDT
blob";kernel = "kernel@1";fdt = "fdt@1";
};
conf@2 {description = "Linux kernel, fdt, &
ramdisk";kernel = "kernel@1";
ramdisk = “ramdisk@1”;fdt = "fdt@2";
};};
};
where hardware and software design meet
.....
Image Source File - Format
□ The image source file format is defined here:http://git.denx.de/?p=u-boot.git;a=blob_plain;f=doc/uImage.
FIT/source_file_format.txt;hb=HEAD
13
where hardware and software design meet
Loadables
New Configuration Property
14
where hardware and software design meet
.....
Loadables - Problem
□ To use a FIT Image to load a Xen system, we need a configuration for □ Xen kernel□ Xen Device Tree Blob (DTB)□ Dom0 kernel
□ The existing configuration properties:□ Allowed only one image per configuration□ Perform specific tasks and checks based on the type
□ The kernel property is the image that gets executed, so it needs to be the Xen kernel
□ The fdt property needs to be set to our DTB□ The ramdisk property can’t be used for our Dom0 kernel□ Therefore, we need a way to load a generic image (loadable) to a specific
location
15
where hardware and software design meet
.....
Loadables - Solution
□ Created a new configuration property□ Loadables - A list of image sub-nodes of any type
□ The loadables property doesn’t have any extra tasks or checks□ Multiple images□ Now there is a configuration property for the Dom0 Linux Kernel
16
where hardware and software design meet
.....
Updating U-Boot - U-Boot
□ Updated U-Boot to look for and handle the new loadables field□ Added bootm_find_loadables()/boot_get_loadable()
□ Refactored relevant functions for readability and simplicity□ Added tests for loadables□ U-Boot mainline at the tag v2015.07
17
where hardware and software design meet
.....
Updating U-Boot - mkimage
□ We modified mkimage to include the new loadables field.
18
$ ./u-boot/tools/mkimage -f xen.its /tftpboot/xen.itbFIT description: Configuration to load a Xen Kernel... Default Configuration: 'config@1' Configuration 0 (config@1) Description: Xen 4.6.0-one loadable Kernel: xen_kernel@1 FDT: fdt@1 Loadables: linux_kernel@1 Configuration 1 (config@2) Description: Plain Linux Kernel: linux_kernel@1 FDT: fdt@2
where hardware and software design meet
.....
Loadables - xen.its
/dts-v1/;/ { description = "Configuration to load a Xen Kernel"; #address-cells = <1>;
images { xen_kernel@1 { description = "xen-4.6.0-unstable"; data = /incbin/("./xen"); type = "kernel"; arch = "arm"; os = "linux"; compression = "none"; load = <0xaea00000>; entry = <0xaea00000>; hash@1 { algo = "md5"; }; };
19
fdt@1 { description = "Cubietruck Xen tree blob"; data = /incbin/("./xen.dtb"); type = "flat_dt"; arch = "arm"; compression = "none"; load = <0xaec00000>; hash@1 { algo = "md5"; }; };
fdt@2 { description = "Cubietruck tree blob"; data = /incbin/("./sun7i-a20-cubietruck.dtb"); type = "flat_dt"; arch = "arm"; compression = "none"; load = <0xaec00000>; hash@1 { algo = "md5"; }; };
where hardware and software design meet
.....
Loadables - xen.its (cont)
linux_kernel@1 { description = "Linux zImage"; data = /incbin/("./vmlinuz"); type = "kernel"; arch = "arm"; os = "linux"; compression = "none"; load = <0xaf600000>; entry = <0xaf600000>; hash@1 { algo = "md5"; }; }; };
20
configurations { default = "config@1";
config@1 { description = "Xen 4.6.0-one loadable"; kernel = "xen_kernel@1"; fdt = "fdt@1"; loadables = "linux_kernel@1"; };
config@2 { description = "Plain Linux"; kernel = "linux_kernel@1"; fdt = "fdt@2"; };
};};
where hardware and software design meet
Example of how to build and boot from a FIT image
21
Building & Booting
where hardware and software design meet
.....
Building the FIT Image
□ Build U-Boot with FIT support (CONFIG_FIT=y)□ Build images (Dom0 Kernel, Xen Kernel, and DTB) as usual□ Place images as specified in the image source file□ Build the output FIT image
$ mkimage -f xen.its xen.itb
□ Copy U-Boot to where it needs to be for your board□ Move the FIT image to where you will be booting from
□ We will use an SD card, with a boot partition, as an example
22
where hardware and software design meet
.....
Booting the FIT Image
□ Place the SD Card in your board□ Boot the board (Our example uses the cubietruck)□ Stop the U-Boot autoboot□ Load the FIT Image into Memory
sunxi# fatload mmc 0 0x80000000 /xen.itb
□ Boot configuration 1sunxi# bootm 0x80000000#config@1
□ U-Boot will then check the specified hashes for those images, move them to their proper load addresses, and boot into the specified kernel, Xen
□ Before booting a configuration, you can get information about your FIT image with the following commandsunxi# iminfo 0x80000000
23
where hardware and software design meet
.....
Booting - Example Output
sunxi# bootm 0x80000000#config@1## Loading kernel from FIT Image at 80000000 ... Using 'config@1' configuration Trying 'xen_kernel@1' kernel subimage Description: xen-4.6.0-unstable Type: Kernel Image Compression: uncompressed Data Start: 0x800000dc Data Size: 688912 Bytes = 672.8 KiB Architecture: ARM OS: Linux Load Address: 0xaea00000 Entry Point: 0xaea00000 Hash algo: md5 Hash value:
51424697da4d1523a8c87150c7cbad00 Verifying Hash Integrity ... md5+ OK## Loading fdt from FIT Image at 80000000 ... Using 'config@1' configuration
24
Trying 'fdt@1' fdt subimage Description: Cubietruck Xen tree blob Type: Flat Device Tree Compression: uncompressed Data Start: 0x800a84d8 Data Size: 21940 Bytes = 21.4 KiB Architecture: ARM Hash algo: md5 Hash value:
3c27715e5c19226064186193e3f30bc4 Verifying Hash Integrity ... md5+ OK Loading fdt from 0x800a84d8 to 0xaec00000 Booting using the fdt blob at 0xaec00000## Loading loadables from FIT Image at
80000000 ... Trying 'linux_kernel@1' loadables subimage Description: Linux zImage Type: Kernel Image Compression: uncompressed Data Start: 0x800b3108 Data Size: 5247832 Bytes = 5 MiB
where hardware and software design meet
.....
Booting - Example Output (cont)
Architecture: ARM OS: Linux Load Address: 0xaf600000 Entry Point: 0xaf600000 Hash algo: md5 Hash value:
84c9630522c9737f6ded803177c967e8 Verifying Hash Integrity ... md5+ OK Loading loadables from 0x800b3108 to
0xaf600000 Loading Kernel Image ... OK Loading Device Tree to 4eff7000, end 4efff5b3
... OKCannot setup simplefb: node not found
Starting kernel ...
- UART enabled -- CPU 00000000 booting -- Xen starting in Hyp mode -- Zero BSS -
25
- Setting up control registers -- Turning on paging -- Ready -Checking for initrd in /chosen[...]
Placing Xen at 0x00000000bfe00000-0x00000000c0000000
Xen heap: 000000009e000000-00000000ae000000 (65536 pages)
Dom heap: 458752 pagesLooking for UART console
/soc@01c00000/serial@01c28000 Xen 4.4.1-rc1(XEN) Xen version 4.4.1-rc1 (robertvanvossen@)
(arm-linux-gnueabihf-gcc (Ubuntu/Linaro 4.8.2-16ubuntu4) 4.8.2) debug=y Mon Jul 20 16:20:46 EDT 2015
where hardware and software design meet
Benefits of Using FIT
General and Xen Specific Benefits
26
where hardware and software design meet
.....
Benefits of Using FIT
□ Hashing Images□ Make sure they weren’t corrupted during transfer□ Make sure you have the correct images during production□ Cryptographic signatures for verified boot
□ Multiple configurations □ Could have different DTB’s for different passthrough configurations□ Could more easily boot into your linux kernel without Xen
27
where hardware and software design meet
.....
Benefits of Using FIT (cont)
□ Improved support□ Xilinx Zynq UltraScale+ MPSoC - Xen Zynq Distribution□ If a customer has an issue, they can provide their image source file□ Boot configurations could be maintained in builders
□ Potential future uses given further development:□ Memory mapped Co-processor images□ FPGA Images□ Databases□ DomU kernels
28
where hardware and software design meet
.....
Try It Yourself
If you want to duplicate our example for the CubieTruck, use the fit branch of our fork of the xen-arm-builder:
https://github.com/dornerworks/xen-arm-builder
29
where hardware and software design meet
Questions?
30