Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Note

NOTE: This means that any images built will NOT have the rootFS in the Image that is built by PetaLinux. This means you will need to edit any scripts or configuration that expects the rootFS to be included. This includes the Xen configs mentioned later.


You can still use the prebuilt Image file which does still include the rootFS to boot DomU.

We also want to edit the device tree to build in the extra Xen related configs.
Edit this file
Code Block
themeMidnight
project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
and add this line: /include/ "xen.dtsi".
It should look like this for harware:
Code Block
themeMidnight
/include/ "system-conf.dtsi"
/include/ "xen.dtsi"
/ { };
or like this for QEMU:
Code Block
themeMidnight
/include/ "system-conf.dtsi"
/include/ "xen.dtsi"
/ {
     cpus {
         cpu@1 {
             device_type = "none";
         };
         cpu@2 {
             device_type = "none";
         };
         cpu@3 {
             device_type = "none";
         };
     };
 };
NOTE: There is a bug on QEMU where the CPUs running in SMP sometimes cause hangs. To avoid this we only tell Xen about a single CPU.

Also edit this file:
Code Block
themeMidnight
project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend
and add this line to it: file://xen.dtsi.
The file should look like this:
Code Block
themeMidnight
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
 
SRC_URI += "file://system-user.dtsi"
SRC_URI += "file://xen.dtsi"
 

Then run petaliux-build:
Code Block
themeMidnight
$ petalinux-build

TFTP Booting Xen and Dom0

Run Xen dom0 on QEMU

To use the prebuilt Xen run:
Code Block
themeMidnight
$ petalinux-boot --qemu --prebuilt 2 --qemu-args "-net nic -net nic -net nic -net nic -net user,tftp=pre-built/linux/xen"
To use the Xen you built yourself run:
Code Block
themeMidnight
$ petalinux-boot --qemu --u-boot --qemu-args "-net nic -net nic -net nic -net nic -net user,tftp=images/linux"

Run Xen dom0 on HW

To use the prebuilt Xen on hardware:
Code Block
themeMidnight
$ petalinux-boot --jtag --prebuilt 2
To use the Xen you built yourself run:
Code Block
themeMidnight
$ petalinux-boot --jtag --u-boot
You should eventually see something similar to this, when you do press any key to stop the autoboot.
Code Block
themeMidnight
Hit any key to stop autoboot:
If u-boot wasn't able to get an IP address from the DHCP server you may need to manually set the serverip (it's typically 10.0.2.2 for QEMU):
Code Block
themeMidnight
u-boot> setenv serverip 10.0.2.2

Now to download and boot Xen, if running on QEMU, use xen-qemu.dtb otherwise use xen.dtb. Example:

TFTPing Xen using ImageBuilder

ImageBuilder is a set of Open Source community scripts to automatically configure a Xen system with Dom0 and multiple Dom0-less VMs for booting. ImageBuilder can generate a U-Boot script that loads all of the binaries automatically and boot the full system quickly. ImageBuilder is available here. The main script is scripts/uboot-script-gen and its usage is described in details on the Xen Project wikipage.

Petalinux prebuilt binaries can be used in a config file as follows for uboot-script-gen:

Code Block
themeMidnight
MEMORY_START="0x0"
MEMORY_END="0x80000000"

DEVICE_TREE="xen.dtb"
XEN="xen"
DOM0_KERNEL="xen-Image"
DOM0_RAMDISK="xen-rootfs.cpio.gz"

NUM_DOMUS=0

UBOOT_SOURCE="boot.source"
UBOOT_SCRIPT="boot.scr"

Now uboot-script-gen can be used to generate boot.scr:

Code Block
themeMidnight
$ bash ./scripts/uboot-script-gen -c config -d . -t tftp

Boot the system with the following uboot command (assuming the tftp serverip is 10.0.2.2, which is typically the value for QEMU):

Code Block
themeMidnight
u-boot> setenv serverip 10.0.2.2
u-boot> tftpb 0xC00000 boot.scr; source 0xC00000

The Xen and Dom0 command line are generated by uboot-script-gen. If you would like to change anything, for instance increase the dom0 memory allocation, it is always possible by editing boot.source. Simply do the following:

  • edit boot.source, change dom0_mem to dom0_mem=2G
  • regenerate boot.scr with the following command: mkimage -A arm64 -T script -C none -a 0xC00000 -e 0xC00000 -d boot.source boot.scr

...

Code Block
themeMidnight
    mask_write 0xFD690020 0x0000000F 0x0000000F


Starting a guest with passthrough UART1 serial

It is possible to assign serial@ff010000 to a domU.

Use the attached passthrough-example-uart1.dtb for a dom0less domU. For a regular domU, add the following lines to the domU config file:

Code Block
dtdev = [ "/amba/serial@ff010000" ]
device_tree = "/path/to/passthrough-example-uart1.dtb"
irqs = [54]
iomem = ["0xff010,1"]


You also need to add xen,passthrough; under the serial@ff010000 node in the host device tree so that it doesn't get automatically assigned to dom0:

Code Block
		serial@ff010000 {
			u-boot,dm-pre-reloc;
			compatible = "cdns,uart-r1p12", "xlnx,xuartps";
			status = "okay";
			interrupt-parent = <0x4>;
			interrupts = <0x0 0x16 0x4>;
			reg = <0x0 0xff010000 0x0 0x1000>;
			clock-names = "uart_clk", "pclk";
			power-domains = <0x26 0x22>;
			clocks = <0x3 0x39 0x3 0x1f>;
			pinctrl-names = "default";
			pinctrl-0 = <0x38>;
			cts-override;
			device_type = "serial";
			port-number = <0x1>;
			xen,passthrough; /* add this line */
		};


If your domU is Linux, make sure to add console=ttyPS1,115200 to its kernel command line. In case of dom0less DomUs, you have to edit the boot.source script to add the command line option, then recreate boot.scr with mkimage.