diff options
author | Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com> | 2023-07-27 17:22:29 -0600 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2023-08-01 14:41:45 -0400 |
commit | 7332b594729085c5cd74fdad516ff977578017fc (patch) | |
tree | 27fb5c3f081dde9f48460d45fa8bcd6e83b110f6 | |
parent | c9b65ee0e53cba999b8061b72039f108187b9600 (diff) | |
download | meta-virtualization-7332b594729085c5cd74fdad516ff977578017fc.tar.gz |
recipes-bsp: Add u-boot-xlnx scripts for Xen support
Add new boot.cmd.xen to u-boot-xlnx-scr bbappend to enable
Xen support for ZynqMP and Versal devices.
User can enable xen u-boot script by adding below variable from
configuration file.
BOOTMODE = "xen"
This u-boot script also supports to configure below Xen params from
configuration file
params variable assignment
------ -------------------
duart XEN_SERIAL_CONSOLES = "serial0"
dom0_mem DOM0_MEM = "1500M"
dom0_max_vcpus DOM0_MAX_VCPUS = "1"
extra params XEN_CMDLINE_APPEND = "loglvl=all"
Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
3 files changed, 120 insertions, 0 deletions
diff --git a/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend new file mode 100644 index 00000000..ae847cbc --- /dev/null +++ b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr.bbappend | |||
@@ -0,0 +1,2 @@ | |||
1 | # Include xen-boot-cmd.inc only if xen distro features is enabled. | ||
2 | include ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'xen-boot-cmd.inc', '', d)} | ||
diff --git a/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen new file mode 100644 index 00000000..25e5842c --- /dev/null +++ b/dynamic-layers/xilinx/recipes-bsp/u-boot/u-boot-xlnx-scr/boot.cmd.xen | |||
@@ -0,0 +1,80 @@ | |||
1 | # This is a boot script for U-Boot with Xen parameters used by yocto machine | ||
2 | # configuration file. | ||
3 | # Generate boot.scr: | ||
4 | # mkimage -c none -A arm -T script -d boot.cmd.xen boot.scr | ||
5 | # | ||
6 | ################ | ||
7 | xen_name=@@XEN_IMAGE_NAME@@ | ||
8 | kernel_name=@@KERNEL_IMAGE@@ | ||
9 | rootfs_name=@@RAMDISK_IMAGE@@ | ||
10 | @@PRE_BOOTENV@@ | ||
11 | |||
12 | for boot_target in ${boot_targets}; | ||
13 | do | ||
14 | echo "Trying to load boot images from ${boot_target}" | ||
15 | if test "${boot_target}" = "jtag" ; then | ||
16 | tftpboot @@KERNEL_LOAD_ADDRESS@@ ${kernel_name} | ||
17 | setenv kernel_size 0x$filesize; | ||
18 | tftpboot @@RAMDISK_IMAGE_ADDRESS@@ ${rootfs_name} | ||
19 | setenv ramdisk_size 0x$filesize; | ||
20 | tftpboot @@XEN_LOAD_ADDRESS@@ ${xen_name} | ||
21 | tftpboot @@DEVICETREE_ADDRESS@@ system.dtb | ||
22 | fi | ||
23 | if test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1" || test "${boot_target}" = "usb0" || test "${boot_target}" = "usb1"; then | ||
24 | if test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1"; then | ||
25 | setenv bootdev mmcblk${devnum}p | ||
26 | fi | ||
27 | if test "${boot_target}" = "usb0" || test "${boot_target}" = "usb1"; then | ||
28 | setenv bootdev sda | ||
29 | fi | ||
30 | echo "Checking for /${xen_name}" | ||
31 | if test -e ${devtype} ${devnum}:${distro_bootpart} /${xen_name}; then | ||
32 | echo "Loading ${xen_name}"; | ||
33 | fatload ${devtype} ${devnum}:${distro_bootpart} @@XEN_LOAD_ADDRESS@@ ${xen_name}; | ||
34 | fi | ||
35 | echo "Checking for /${kernel_name}" | ||
36 | if test -e ${devtype} ${devnum}:${distro_bootpart} /${kernel_name}; then | ||
37 | echo "Loading ${kernel_name}"; | ||
38 | fatload ${devtype} ${devnum}:${distro_bootpart} @@KERNEL_LOAD_ADDRESS@@ ${kernel_name}; | ||
39 | setenv kernel_size 0x$filesize; | ||
40 | fi | ||
41 | echo "Checking for /system.dtb" | ||
42 | if test -e ${devtype} ${devnum}:${distro_bootpart} /system.dtb; then | ||
43 | echo "Loading system.dtb"; | ||
44 | fatload ${devtype} ${devnum}:${distro_bootpart} @@DEVICETREE_ADDRESS@@ system.dtb; | ||
45 | fi | ||
46 | echo "Checking for /${rootfs_name}" | ||
47 | if test -e ${devtype} ${devnum}:${distro_bootpart} /${rootfs_name} && test "${skip_ramdisk}" != "yes"; then | ||
48 | echo "Loading ${rootfs_name}"; | ||
49 | fatload ${devtype} ${devnum}:${distro_bootpart} @@RAMDISK_IMAGE_ADDRESS@@ ${rootfs_name}; | ||
50 | setenv ramdisk_size 0x$filesize; | ||
51 | fi | ||
52 | fi | ||
53 | fdt addr @@DEVICETREE_ADDRESS@@ | ||
54 | fdt resize 0x1000 | ||
55 | fdt get value bootargs /chosen bootargs | ||
56 | fdt set /chosen \#address-cells <0x2> | ||
57 | fdt set /chosen \#size-cells <0x2> | ||
58 | setenv xen_bootargs "console=dtuart dtuart=@@XEN_SERIAL_CONSOLES@@ dom0_mem=@@DOM0_MEM@@ dom0_max_vcpus=@@DOM0_MAX_VCPUS@@ bootscrub=0 vwfi=native @@XEN_CMDLINE_APPEND@@" | ||
59 | fdt set /chosen xen,xen-bootargs \"${xen_bootargs}\" | ||
60 | |||
61 | # Check that env $ramdisk_size is 0 or not. | ||
62 | if test -n ${ramdisk_size}; then | ||
63 | fdt mknod /chosen dom0-ramdisk | ||
64 | fdt set /chosen/dom0-ramdisk compatible "xen,linux-initrd" "xen,multiboot-module" "multiboot,module" | ||
65 | fdt set /chosen/dom0-ramdisk reg <0x0 @@RAMDISK_IMAGE_ADDRESS@@ 0x0 ${ramdisk_size}> | ||
66 | setenv rootfs_param @@KERNEL_ROOT_RAMDISK@@ | ||
67 | else | ||
68 | setenv rootfs_param @@KERNEL_ROOT_SD@@ | ||
69 | fi | ||
70 | |||
71 | fdt mknod /chosen dom0 | ||
72 | fdt set /chosen/dom0 compatible "xen,linux-zimage" "xen,multiboot-module" "multiboot,module" | ||
73 | fdt set /chosen/dom0 reg <0x0 @@KERNEL_LOAD_ADDRESS@@ 0x0 ${kernel_size}> | ||
74 | setenv dom0_bootargs "console=hvc0 earlycon=xen earlyprintk=xen clk_ignore_unused ${rootfs_param}" | ||
75 | fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\" | ||
76 | |||
77 | setenv fdt_high 0xffffffffffffffff | ||
78 | |||
79 | @@KERNEL_BOOTCMD@@ @@XEN_LOAD_ADDRESS@@ - @@DEVICETREE_ADDRESS@@ | ||
80 | done | ||
diff --git a/dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc b/dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc new file mode 100644 index 00000000..38f6f267 --- /dev/null +++ b/dynamic-layers/xilinx/recipes-bsp/u-boot/xen-boot-cmd.inc | |||
@@ -0,0 +1,38 @@ | |||
1 | FILESEXTRAPATHS:append := ":${THISDIR}/u-boot-xlnx-scr" | ||
2 | |||
3 | SRC_URI += "file://boot.cmd.xen" | ||
4 | |||
5 | # Image offsets for Xen boot | ||
6 | KERNEL_OFFSET:zynqmp ?= "0xE00000" | ||
7 | KERNEL_OFFSET:versal ?= "0xE00000" | ||
8 | |||
9 | DEVICETREE_OFFSET:zynqmp ?= "0xC000000" | ||
10 | DEVICETREE_OFFSET:versal ?= "0xC000000" | ||
11 | |||
12 | RAMDISK_OFFSET:zynqmp ?= "0x2400000" | ||
13 | RAMDISK_OFFSET:versal ?= "0x2400000" | ||
14 | |||
15 | XEN_OFFSET:zynqmp ?= "0xBA00000" | ||
16 | XEN_OFFSET:versal ?= "0xBA00000" | ||
17 | XEN_LOAD_ADDRESS ?= "${@append_baseaddr(d,d.getVar('XEN_OFFSET'))}" | ||
18 | |||
19 | # If dom0-ramdisk is used for Xen boot then set RAMDISK image to cpio.gz | ||
20 | XEN_IMAGE_NAME ?= "xen" | ||
21 | RAMDISK_IMAGE = "rootfs.cpio.gz" | ||
22 | |||
23 | # Set the amount of memory for dom0 depending on total available memory size(DDR). | ||
24 | DOM0_MEM ?= "1500M" | ||
25 | |||
26 | # Specify which UART console Xen should use. You can sepecify the devicetree | ||
27 | # alias or full path to a node in the devicetree | ||
28 | # XEN_SERIAL_CONSOLES ?= "serial0" or XEN_SERIAL_CONSOLES ?= "/axi/serial@ff000000" | ||
29 | XEN_SERIAL_CONSOLES ?= "serial0" | ||
30 | |||
31 | # Specify additional Xen paramaters which will be appended to xen-bootargs | ||
32 | # This can alos be used for debugging purposes. | ||
33 | # Examples: XEN_CMDLINE_APPEND ?= "sched=credit loglvl=all guest_loglvl=debug" | ||
34 | XEN_CMDLINE_APPEND ?= "" | ||
35 | |||
36 | # Specify the max number of vcpus for dom0 | ||
37 | # Example usage: DOM0_MAX_VCPUS = "2" or DOM0_MAX_VCPUS = "2-4" | ||
38 | DOM0_MAX_VCPUS ?= "1" | ||