diff --git a/recipes-bsp/u-boot/scripts/boot.xen.its b/recipes-bsp/u-boot/scripts/boot.xen.its new file mode 100644 index 0000000..b43c367 --- /dev/null +++ b/recipes-bsp/u-boot/scripts/boot.xen.its @@ -0,0 +1,19 @@ +/dts-v1/; +/ { + description = "Configuration from Imagebuilder to load Xen/Linux"; + #address-cells = <1>; + images { + default = "boot_scr"; + boot_scr { + description = "default xen boot script"; + data = /incbin/("boot.xen.source"); + type = "script"; + compression = "none"; + load = <0x82000000>; + entry = <0x82000000>; + hash { + algo = "md5"; + }; + }; + }; +}; diff --git a/recipes-bsp/u-boot/scripts/boot.xen.source.in b/recipes-bsp/u-boot/scripts/boot.xen.source.in new file mode 100644 index 0000000..d27a8b7 --- /dev/null +++ b/recipes-bsp/u-boot/scripts/boot.xen.source.in @@ -0,0 +1,117 @@ +xen_name=@@XEN_IMAGE_NAME@@ +kernel_name=@@XEN_KERNEL_IMAGE_NAME@@ + +xen_addr=@@XEN_ADDRESS@@ +kernel_addr=@@XEN_KERNEL_ADDRESS@@ + +for boot_target in ${boot_targets}; +do + # only support searching mmc for now and break if kernel is scanned + if test -z "${kernel_size}" && test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1"; then + setenv devtype mmc + setenv bootdir /boot + setenv dtbdir ${bootdir}/dtb + + if test "${boot_target}" = "mmc0"; then + setenv devnum 0 + elif test "${boot_target}" = "mmc1"; then + setenv devnum 1 + fi + + setenv loadboot ${devtype} ${devnum}:1 + setenv loadroot ${devtype} ${devnum}:2 + + # check xen image in boot partition then root partition + if test -e ${loadboot} ${xen_name}; then + echo "Loading ${xen_name}"; + fatload ${loadboot} ${xen_addr} ${xen_name}; + elif test -e ${loadroot} ${bootdir}/${xen_name}; then + echo "Loading ${xen_name}"; + load ${loadroot} ${xen_addr} ${bootdir}/${xen_name}; + fi + + # check kernel image in boot partition then root partition + if test -e ${loadboot} ${kernel_name}; then + echo "Loading ${kernel_name}"; + fatload ${loadboot} ${kernel_addr} ${kernel_name}; + setenv kernel_size 0x$filesize; + elif test -e ${loadroot} ${bootdir}/$kernel_name}; then + echo "Loading ${kernel_name}"; + load ${loadroot} ${kernel_addr} ${bootdir}/${kernel_name}; + setenv kernel_size 0x$filesize; + fi + + # load fdt from root partition + if test -e ${loadroot} ${dtbdir}/${fdtfile}; then + echo "Loading ${dtbdir}/${fdtfile}"; + load ${loadroot} ${fdtaddr} ${dtbdir}/${fdtfile}; + part uuid ${loadroot} rootfs_partuuid + fi + fi +done + +if test -z "${kernel_size}"; then + echo "No kernel image found" + exit +fi + +fdt addr ${fdtaddr} +fdt resize 0x1000 +setenv fdt_high 0xffffffffffffffff + +# fdt operations +fdt set /chosen \#address-cells <0x2> +fdt set /chosen \#size-cells <0x2> +setenv xen_bootargs "console=dtuart dtuart=@@XEN_DTUART_SERIAL@@ dom0_mem=@@DOM0_MEM@@ dom0_max_vcpus=@@DOM0_MAX_VCPUS@@ bootscrub=0 vwfi=native" +fdt set /chosen xen,xen-bootargs \"${xen_bootargs}\" + +fdt mknod /chosen dom0 +fdt set /chosen/dom0 compatible "xen,linux-zimage" "xen,multiboot-module" "multiboot,module" +fdt set /chosen/dom0 reg <0x0 ${kernel_addr} 0x0 ${kernel_size}> +setenv dom0_bootargs "console=hvc0 earlyprintk=xen root=PARTUUID=${rootfs_partuuid} rw rootfstype=ext4 rootwait clk_ignore_unused" + +# shared memory +if test -n "@@XEN_SHMEM_ID@@"; then + shmem_start=@@XEN_SHMEM_START@@ + shmem_size=@@XEN_SHMEM_SIZE@@ + shmem_node=xen_shmem@@@XEN_SHMEM_START@@ + uio_node=xen_uio@@@XEN_SHMEM_START@@ + + # mark it as shared + fdt mknod /chosen ${shmem_node} + fdt set /chosen/${shmem_node} compatible "xen,domain-shared-memory-v1" + fdt set /chosen/${shmem_node} xen,shm-id "@@XEN_SHMEM_ID@@" + fdt set /chosen/${shmem_node} xen,shared-mem <0x00 ${shmem_start} 0x00 ${shmem_start} 0x00 ${shmem_size}> + + # expose as UIO to Dom0 + fdt mknod / ${uio_node} + fdt set /${uio_node} compatible @@XEN_SHMEM_UIO_NAME@@ + fdt set /${uio_node} reg <0x00 ${shmem_start} 0x00 ${shmem_size}> + + # append uio to bootargs + setenv dom0_bootargs "${dom0_bootargs} uio_pdrv_genirq.of_id=@@XEN_SHMEM_UIO_NAME@@" +fi + +fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\" + +# Specify interrupts explicitly for the following instead of relying on ti,interrupt-ranges +for dev_path in @@XEN_IRQ_DEVICES@@; do + fdt get value irq_cur ${dev_path} ti,interrupt-ranges 0 + fdt get value irq_num ${dev_path} ti,interrupt-ranges 2 + + setexpr irq_cur ${irq_cur} + 0x20 + setexpr irq_end ${irq_cur} + ${irq_num} + setenv irq_prop "<" + + while itest ${irq_cur} < ${irq_end}; do + setenv irq_prop "${irq_prop}0 0x${irq_cur} 4 " + setexpr irq_cur ${irq_cur} + 1 + done + + setenv irq_prop "${irq_prop}>" + fdt set ${dev_path} interrupts ${irq_prop} +done + +echo "Booting" + +booti ${xen_addr} - ${fdtaddr} diff --git a/recipes-bsp/u-boot/scripts/bootcommand.cfg b/recipes-bsp/u-boot/scripts/bootcommand.cfg new file mode 100644 index 0000000..a1c9f7c --- /dev/null +++ b/recipes-bsp/u-boot/scripts/bootcommand.cfg @@ -0,0 +1 @@ +CONFIG_BOOTCOMMAND="run envboot; setenv bootmeths 'script'; bootflow scan -lb" diff --git a/recipes-bsp/u-boot/u-boot-ti-staging_%.bbappend b/recipes-bsp/u-boot/u-boot-ti-staging_%.bbappend index d36fa2e..dd4f330 100644 --- a/recipes-bsp/u-boot/u-boot-ti-staging_%.bbappend +++ b/recipes-bsp/u-boot/u-boot-ti-staging_%.bbappend @@ -11,5 +11,7 @@ TI_DM="${STAGING_DIR_HOST}${nonarch_base_libdir}/firmware/ti-dm/${PLAT_SFX}/${DM EXTRA_OEMAKE += "TI_DM=${TI_DM}" +include ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'u-boot-xen-scr.inc', '', d)} + PR:append = "_tisdk_5" diff --git a/recipes-bsp/u-boot/u-boot-xen-scr.inc b/recipes-bsp/u-boot/u-boot-xen-scr.inc new file mode 100644 index 0000000..477fd24 --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-xen-scr.inc @@ -0,0 +1,47 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/scripts:" + +DEPENDS:append:k3 = " u-boot-mkimage-native" + +SRC_URI:append:k3 = " \ + file://boot.xen.source.in \ + file://boot.xen.its \ + file://bootcommand.cfg \ + " + +XEN_IMAGE_NAME ??= "xen" +XEN_KERNEL_IMAGE_NAME ??= "Image" +XEN_ADDRESS ??= "0x82040000" +XEN_KERNEL_ADDRESS ??= "0x83000000" +XEN_DTUART_SERIAL ??= "serial2" +DOM0_MEM ??= "2G" +DOM0_MAX_VCPUS ??= "1" +XEN_SHMEM_ID ??= "xen-shmem" +XEN_SHMEM_UIO_NAME ??= "xen-uio" +XEN_SHMEM_START ??= "0x80000000" +XEN_SHMEM_SIZE ??= "0x1000" + +XEN_IRQ_DEVICES ??= "" +XEN_IRQ_DEVICES:am62pxx ??= "\/bus@f0000\/bus@48000000\/interrupt-controller@48000000" + +do_compile:append:k3() { + sed -e 's/@@XEN_IMAGE_NAME@@/${XEN_IMAGE_NAME}/' \ + -e 's/@@XEN_KERNEL_IMAGE_NAME@@/${XEN_KERNEL_IMAGE_NAME}/' \ + -e 's/@@XEN_ADDRESS@@/${XEN_ADDRESS}/' \ + -e 's/@@XEN_KERNEL_ADDRESS@@/${XEN_KERNEL_ADDRESS}/' \ + -e 's/@@XEN_DTUART_SERIAL@@/${XEN_DTUART_SERIAL}/' \ + -e 's/@@DOM0_MEM@@/${DOM0_MEM}/' \ + -e 's/@@DOM0_MAX_VCPUS@@/${DOM0_MAX_VCPUS}/' \ + -e 's/@@XEN_IRQ_DEVICES@@/${XEN_IRQ_DEVICES}/' \ + -e 's/@@XEN_SHMEM_ID@@/${XEN_SHMEM_ID}/' \ + -e 's/@@XEN_SHMEM_UIO_NAME@@/${XEN_SHMEM_UIO_NAME}/' \ + -e 's/@@XEN_SHMEM_START@@/${XEN_SHMEM_START}/' \ + -e 's/@@XEN_SHMEM_SIZE@@/${XEN_SHMEM_SIZE}/' \ + "${WORKDIR}/boot.xen.source.in" > "${WORKDIR}/boot.xen.source" + + mkimage -f ${WORKDIR}/boot.xen.its ${WORKDIR}/boot.xen.scr +} + +do_deploy:append:k3() { + install -d ${DEPLOYDIR} + install -m 0644 ${WORKDIR}/boot.xen.scr ${DEPLOYDIR} +}