ImageBuilder: Difference between revisions
(Change ImageBuilder repo to gitlab xen-project) |
|||
(10 intermediate revisions by one other user not shown) | |||
Line 15: | Line 15: | ||
The whole process can be automated with '''ImageBuilder''': |
The whole process can be automated with '''ImageBuilder''': |
||
[https://gitlab.com/ |
[https://gitlab.com/xen-project/imagebuilder https://gitlab.com/xen-project/imagebuilder] |
||
ImageBuilder can be invoked as a container for build automation, but its useful scripts can also be called manually. Specifically, '''script/uboot-script-gen''' generates a U-Boot script that loads all the necessary binaries and automatically adds the required entries to device tree at boot time. In order to use it, you need to write a config file first. |
ImageBuilder can be invoked as a container for build automation, but its useful scripts can also be called manually. Specifically, '''script/uboot-script-gen''' generates a U-Boot script that loads all the necessary binaries and automatically adds the required entries to device tree at boot time. In order to use it, you need to write a config file first. |
||
Line 24: | Line 24: | ||
MEMORY_START="0x0" |
MEMORY_START="0x0" |
||
MEMORY_END="0x80000000" |
MEMORY_END="0x80000000" |
||
UBOOT_DIR="uboot" |
|||
DEVICE_TREE="board.dtb" |
DEVICE_TREE="board.dtb" |
||
Line 50: | Line 48: | ||
<nowiki> |
<nowiki> |
||
⚫ | |||
$ export LOAD_CMD="tftpb" |
|||
⚫ | |||
</nowiki> |
</nowiki> |
||
uboot-script-gen generates a U-Boot script named '''boot.scr''' that will load all your binaries automatically using tftp. |
|||
⚫ | |||
All the path specified in the config file are relative to the directory passed as an argument to -d. In this case, ''Image-dom0'' and ''dom1/Image-domU'' must be relative to the current directory, because we are passing -d . to uboot-script-gen. |
|||
⚫ | |||
<nowiki> |
<nowiki> |
||
u-boot> tftpb 0xC00000 boot.scr; source 0xC00000 |
|||
</nowiki> |
</nowiki> |
||
The command used to load the binaries can be customized, for instance you can have uboot-script-gen generate a U-Boot script that loads binaries from |
The command used to load the binaries can be customized, for instance you can have uboot-script-gen generate a U-Boot script that loads binaries from a SD card passing -t sd, which is a syntactic sugar for -t "load scsi 0:1": |
||
<nowiki> |
<nowiki> |
||
⚫ | |||
$ export LOAD_CMD="load scsi 0:1" |
|||
⚫ | |||
</nowiki> |
</nowiki> |
||
Line 71: | Line 70: | ||
== Xen and Dom0 command line == |
== Xen and Dom0 command line == |
||
ImageBuilder uses sched=null by default. If you want to change it, and also modify other Xen and/or Dom0 command line options you'll make to edit the generated U-Boot script: '''boot.source'''. Look for sched=null in the source and edit as needed. Then you need to regenerate '''boot.scr''' using mkimage: |
ImageBuilder uses sched=null by default. If you want to change it, and also modify other Xen and/or Dom0 command line options you'll make to edit the generated U-Boot script: '''boot.source'''. Look for sched=null in the source and edit as needed. Then you need to regenerate '''boot.scr''' using mkimage and specifying the same loading address for the boot.scr as printed earlier by uboot-script-gen: |
||
<nowiki> |
<nowiki> |
||
Line 84: | Line 83: | ||
$ dd if=uboot-binary-source of=raw-binary-dest bs=64 skip=1 |
$ dd if=uboot-binary-source of=raw-binary-dest bs=64 skip=1 |
||
</nowiki> |
</nowiki> |
||
== Xen booting as raw binary == |
|||
If you use a version of Xen older than 4.12, you need to make sure to have the following commit backported in your Xen tree: |
|||
<nowiki> |
|||
4f3d0ed5d9 xen:arm: Populate arm64 image header |
|||
</nowiki> |
|||
It is necessary to be able to boot Xen as a raw binary from U-Boot. |
Latest revision as of 16:04, 25 September 2024
Booting Xen from U-Boot
Booting Xen from U-Boot requires:
- loading all the required binaries, manually specifying the loading address for each of them making sure they don't overlap
- Xen, Dom0 kernel, Dom0 ramdisk, device tree binary, any Dom0-less DomUs kernels, ramdisk and partial dtbs for passthrough
- adding relevant nodes to device tree
- the Dom0 kernel and ramdisk loading addresses need to be specified in device tree under /chosen
See booting.txt as a reference.
ImageBuilder
The whole process can be automated with ImageBuilder:
https://gitlab.com/xen-project/imagebuilder
ImageBuilder can be invoked as a container for build automation, but its useful scripts can also be called manually. Specifically, script/uboot-script-gen generates a U-Boot script that loads all the necessary binaries and automatically adds the required entries to device tree at boot time. In order to use it, you need to write a config file first.
Config file
MEMORY_START="0x0" MEMORY_END="0x80000000" DEVICE_TREE="board.dtb" XEN="xen-hypervisor" DOM0_KERNEL="Image-dom0" DOM0_RAMDISK="ramdisk-dom0.rootfs.cpio.gz" NUM_DOMUS=2 DOMU_KERNEL[0]="dom1/Image-domU" DOMU_RAMDISK[0]="dom1/ramdisk-domU" DOMU_PASSTHROUGH_DTB[0]="dom1/passthrough-domU.dtb" DOMU_KERNEL[1]="dom2/Image-domU" DOMU_RAMDISK[1]="dom2/ramdisk-domU2" UBOOT_SOURCE="boot.source" UBOOT_SCRIPT="boot.scr"
The fields are self explanatory but you can find more detailed information on the readme. Make sure to use raw binaries for Xen, all the kernels and rootfs's, not U-Boot binaries (do not use the output of mkimage).
uboot-script-gen
Once you have the config file, you can call uboot-script-gen as follows:
$ bash ./scripts/uboot-script-gen -c /path/to/config -d . -t tftp
uboot-script-gen generates a U-Boot script named boot.scr that will load all your binaries automatically using tftp.
All the path specified in the config file are relative to the directory passed as an argument to -d. In this case, Image-dom0 and dom1/Image-domU must be relative to the current directory, because we are passing -d . to uboot-script-gen.
Now, you just need to load the generated boot.scr and source it from U-Boot:
u-boot> tftpb 0xC00000 boot.scr; source 0xC00000
The command used to load the binaries can be customized, for instance you can have uboot-script-gen generate a U-Boot script that loads binaries from a SD card passing -t sd, which is a syntactic sugar for -t "load scsi 0:1":
$ bash ./scripts/uboot-script-gen -c /path/to/config -d . -t sd
Important Notes
Xen and Dom0 command line
ImageBuilder uses sched=null by default. If you want to change it, and also modify other Xen and/or Dom0 command line options you'll make to edit the generated U-Boot script: boot.source. Look for sched=null in the source and edit as needed. Then you need to regenerate boot.scr using mkimage and specifying the same loading address for the boot.scr as printed earlier by uboot-script-gen:
$ mkimage -A arm64 -T script -C none -a 0xC00000 -e 0xC00000 -d boot.source boot.scr
U-Boot binaries vs. raw binaries
uboot-script-gen takes only raw binaries as input. If you have a U-Boot binary in your hands and you want to convert it back to a raw binary, you can do that with the following command:
$ dd if=uboot-binary-source of=raw-binary-dest bs=64 skip=1
Xen booting as raw binary
If you use a version of Xen older than 4.12, you need to make sure to have the following commit backported in your Xen tree:
4f3d0ed5d9 xen:arm: Populate arm64 image header
It is necessary to be able to boot Xen as a raw binary from U-Boot.