diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass index 6d34a29..6b7433e 100644 --- a/classes/sdcard_image-rpi.bbclass +++ b/classes/sdcard_image-rpi.bbclass @@ -55,7 +55,7 @@ do_image_rpi_sdimg[depends] = " \ dosfstools-native:do_populate_sysroot \ virtual/kernel:do_deploy \ ${IMAGE_BOOTLOADER}:do_deploy \ - ${@bb.utils.contains('KERNEL_IMAGETYPE', 'uImage', 'u-boot:do_deploy', '',d)} \ + ${@bb.utils.contains('RPI_USE_U_BOOT', '1', 'u-boot:do_deploy', '',d)} \ " # SD card image name @@ -136,16 +136,13 @@ IMAGE_CMD_rpi-sdimg () { mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.${DTB_EXT} ::overlays/${DTB_BASE_NAME}.${DTB_EXT} done fi - case "${KERNEL_IMAGETYPE}" in - "uImage") + if [ "${RPI_USE_U_BOOT}" = "1" ]; then mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.bin ::${SDIMG_KERNELIMAGE} - mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::uImage + mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${KERNEL_IMAGETYPE} mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::boot.scr - ;; - *) + else mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${SDIMG_KERNELIMAGE} - ;; - esac + fi if [ -n ${FATPAYLOAD} ] ; then echo "Copying payload into VFAT" @@ -160,14 +157,10 @@ IMAGE_CMD_rpi-sdimg () { mcopy -i ${WORKDIR}/boot.img -v ${WORKDIR}/image-version-info :: # Deploy vfat partition (for u-boot case only) - case "${KERNEL_IMAGETYPE}" in - "uImage") + if [ "${RPI_USE_U_BOOT}" = "1" ]; then cp ${WORKDIR}/boot.img ${IMGDEPLOYDIR}/${SDIMG_VFAT} ln -sf ${SDIMG_VFAT} ${SDIMG_LINK_VFAT} - ;; - *) - ;; - esac + fi # Burn Partitions dd if=${WORKDIR}/boot.img of=${SDIMG} conv=notrunc seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && sync diff --git a/conf/machine/include/rpi-base.inc b/conf/machine/include/rpi-base.inc index f29db29..970f4d8 100644 --- a/conf/machine/include/rpi-base.inc +++ b/conf/machine/include/rpi-base.inc @@ -41,7 +41,17 @@ KERNEL_DEVICETREE ?= " \ overlays/pi3-miniuart-bt.dtbo \ overlays/vc4-kms-v3d.dtbo \ " -KERNEL_IMAGETYPE ?= "Image" + +# By default: +# +# * When u-boot is disabled use the "Image" format which can be directly loaded +# by the rpi firmware. +# +# * When u-boot is enabled use the "uImage" format and the "bootm" command +# within u-boot to load the kernel. +KERNEL_BOOTCMD ??= "bootm" +KERNEL_IMAGETYPE_UBOOT ??= "uImage" +KERNEL_IMAGETYPE ?= "${@bb.utils.contains('RPI_USE_U_BOOT', '1', '${KERNEL_IMAGETYPE_UBOOT}', 'Image', d)}" MACHINE_FEATURES += "apm usbhost keyboard vfat ext2 screen touchscreen alsa bluetooth wifi sdio" @@ -83,7 +93,7 @@ def make_dtb_boot_files(d): IMAGE_BOOT_FILES ?= "bcm2835-bootfiles/* \ ${@make_dtb_boot_files(d)} \ - ${@bb.utils.contains('KERNEL_IMAGETYPE', 'uImage', \ + ${@bb.utils.contains('RPI_USE_U_BOOT', '1', \ '${KERNEL_IMAGETYPE} u-boot.bin;${SDIMG_KERNELIMAGE} boot.scr', \ '${KERNEL_IMAGETYPE};${SDIMG_KERNELIMAGE}', d)} \ " diff --git a/conf/machine/raspberrypi3-64.conf b/conf/machine/raspberrypi3-64.conf index 237684a..ebc9f38 100644 --- a/conf/machine/raspberrypi3-64.conf +++ b/conf/machine/raspberrypi3-64.conf @@ -39,3 +39,8 @@ VC4_CMA_SIZE ?= "cma-256" UBOOT_MACHINE = "rpi_3_config" MACHINE_FEATURES_append = " vc4graphics" + +# When u-boot is enabled we need to use the "Image" format and the "booti" +# command to load the kernel +KERNEL_IMAGETYPE_UBOOT ?= "Image" +KERNEL_BOOTCMD ?= "booti" diff --git a/docs/extra-build-config.md b/docs/extra-build-config.md index 8d4f897..380d969 100644 --- a/docs/extra-build-config.md +++ b/docs/extra-build-config.md @@ -105,10 +105,12 @@ To disable rpi boot logo, set this variable in local.conf: To have u-boot load kernel image, set in your local.conf: - KERNEL_IMAGETYPE = "uImage" + RPI_USE_U_BOOT = "1" -This will make kernel.img be u-boot image which will load uImage. By default, -kernel.img is the actual kernel image (ex. Image). +This will select the appropriate image format for use with u-boot automatically. +For further customisation the KERNEL_IMAGETYPE and KERNEL_BOOTCMD variables can +be overridden to select the exact kernel image type (eg. zImage) and u-boot +command (eg. bootz) to be used. ## Image with Initramfs diff --git a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd deleted file mode 100644 index 2e8452e..0000000 --- a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd +++ /dev/null @@ -1,3 +0,0 @@ -fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs -fatload mmc 0:1 ${kernel_addr_r} uImage -bootm ${kernel_addr_r} - ${fdt_addr} diff --git a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in new file mode 100644 index 0000000..ad54cd0 --- /dev/null +++ b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in @@ -0,0 +1,3 @@ +fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs +fatload mmc 0:1 ${kernel_addr_r} @@KERNEL_IMAGETYPE@@ +@@KERNEL_BOOTCMD@@ ${kernel_addr_r} - ${fdt_addr} diff --git a/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bb b/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bb index c938c3b..3457300 100644 --- a/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bb +++ b/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bb @@ -5,9 +5,12 @@ COMPATIBLE_MACHINE = "^rpi$" DEPENDS = "u-boot-mkimage-native" -SRC_URI = "file://boot.cmd" +SRC_URI = "file://boot.cmd.in" do_compile() { + sed -e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \ + -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \ + "${WORKDIR}/boot.cmd.in" > "${WORKDIR}/boot.cmd" mkimage -A arm -T script -C none -n "Boot script" -d "${WORKDIR}/boot.cmd" boot.scr }