Skip to contentSkip to conversation

sdcard_image-rpi.bbclass: always include device tree files

PATCH New Jonathan Liu 1 participant 3 messages Oct 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 sdcard_image-rpi.bbclass: always include device tree files

This allows device tree support to be enabled when using U-Boot.

---
 classes/sdcard_image-rpi.bbclass | 42 +++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 20 deletions(-)
classes/sdcard_image-rpi.bbclass +22 -20
index 2e9bdb3..2efc36d 100644
@@ -102,32 +102,34 @@ IMAGE_CMD_rpi-sdimg () {
 	rm -f ${WORKDIR}/boot.img
 	mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
 	mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/
+
+	if test -n "${DTS}"; then
+		# Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder
+		DT_OVERLAYS="${@split_overlays(d, 0)}"
+		DT_ROOT="${@split_overlays(d, 1)}"
+
+		# Copy board device trees to root folder
+		for DTB in ${DT_ROOT}; do
+			DTB_BASE_NAME=`basename ${DTB} .dtb`
+
+			mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb
+		done
+
+		# Copy device tree overlays to dedicated folder
+		mmd -i ${WORKDIR}/boot.img overlays
+		for DTB in ${DT_OVERLAYS}; do
+			DTB_BASE_NAME=`basename ${DTB} .dtb`
+
+			mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::overlays/${DTB_BASE_NAME}.dtb
+		done
+	fi
+
 	case "${KERNEL_IMAGETYPE}" in
 	"uImage")
 		mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.img ::${SDIMG_KERNELIMAGE}
 		mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::uImage
 		;;
 	*)
-		if test -n "${DTS}"; then
-			# Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder
-			DT_OVERLAYS="${@split_overlays(d, 0)}"
-			DT_ROOT="${@split_overlays(d, 1)}"
-
-			# Copy board device trees to root folder
-			for DTB in ${DT_ROOT}; do
-				DTB_BASE_NAME=`basename ${DTB} .dtb`
-
-				mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::${DTB_BASE_NAME}.dtb
-			done
-
-			# Copy device tree overlays to dedicated folder
-			mmd -i ${WORKDIR}/boot.img overlays
-			for DTB in ${DT_OVERLAYS}; do
-				DTB_BASE_NAME=`basename ${DTB} .dtb`
-
-				mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb ::overlays/${DTB_BASE_NAME}.dtb
-			done
-		fi
 		mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${SDIMG_KERNELIMAGE}
 		;;
 	esac
Signature · 1 line
2.6.1
#1 lore raw

PATCH 2/3 sdcard_image-rpi.bbclass: include boot.scr if present

Allows including a script to use for U-Boot.

---
 classes/sdcard_image-rpi.bbclass | 3 +++
 1 file changed, 3 insertions(+)
classes/sdcard_image-rpi.bbclass +3 -0
index 2efc36d..c6995b6 100644
@@ -128,6 +128,9 @@ IMAGE_CMD_rpi-sdimg () {
 	"uImage")
 		mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.img ::${SDIMG_KERNELIMAGE}
 		mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::uImage
+		if [ -e "${DEPLOY_DIR_IMAGE}/boot.scr" ]; then
+			mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/boot.scr ::boot.scr
+		fi
 		;;
 	*)
 		mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::${SDIMG_KERNELIMAGE}
Signature · 1 line
2.6.1
#2 lore raw

PATCH 3/3 u-boot: add v2015.10 for Raspberry Pi 2 support

In reply to Jonathan Liu
---
 conf/machine/include/rpi-default-providers.inc |  3 ++-
 recipes-bsp/u-boot/files/boot.cmd              |  3 +++
 recipes-bsp/u-boot/u-boot_2015.10.bb           | 28 ++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 recipes-bsp/u-boot/files/boot.cmd
 create mode 100644 recipes-bsp/u-boot/u-boot_2015.10.bb
conf/machine/include/rpi-default-providers.inc +2 -1
index cabbd43..7d433a0 100644
@@ -1,7 +1,8 @@
 # RaspberryPi BSP default providers
 
 PREFERRED_PROVIDER_virtual/kernel ?= "linux-raspberrypi"
-PREFERRED_PROVIDER_u-boot ?= "u-boot-rpi"
+PREFERRED_PROVIDER_u-boot_raspberrypi ?= "u-boot-rpi"
+PREFERRED_PROVIDER_u-boot_raspberrypi2 ?= "u-boot"
 PREFERRED_PROVIDER_virtual/xserver ?= "xserver-xorg"
 PREFERRED_PROVIDER_virtual/egl ?= "userland"
 PREFERRED_PROVIDER_virtual/libgles2 ?= "userland"
recipes-bsp/u-boot/files/boot.cmd new file +3 -0
new file mode 100644
index 0000000..3f7e3b6
@@ -0,0 +1,3 @@
+fdt addr ${fdt_addr_r} && fdt get value bootargs /chosen bootargs
+fatload mmc 0:1 ${kernel_addr_r} uImage
+bootm ${kernel_addr_r} - ${fdt_addr_r}
recipes-bsp/u-boot/u-boot_2015.10.bb new file +28 -0
new file mode 100644
index 0000000..02fb39a
@@ -0,0 +1,28 @@
+require recipes-bsp/u-boot/u-boot.inc
+
+DEPENDS += "dtc-native rpi-mkimage-native"
+
+SRC_URI += "file://boot.cmd"
+
+# This revision corresponds to the tag "v2015.10"
+# We use the revision in order to avoid having to fetch it from the
+# repo during parse
+SRCREV = "5ec0003b19cbdf06ccd6941237cbc0d1c3468e2d"
+
+PV = "v2015.10+git${SRCPV}"
+
+COMPATIBLE_MACHINE = "raspberrypi2"
+
+do_compile_append() {
+    ${S}/tools/mkimage -A arm -O linux -T script -C none -n boot.scr -d ${WORKDIR}/boot.cmd ${WORKDIR}/${UBOOT_ENV_BINARY}
+}
+
+do_deploy_append() {
+    # Add RPi bootloader trailer to U-Boot image to enable Device Tree support
+    ${STAGING_DIR_NATIVE}/usr/lib/rpi-mkimage/mkknlimg --dtok ${DEPLOYDIR}/${UBOOT_IMAGE} ${DEPLOYDIR}/${UBOOT_IMAGE}
+}
+
+UBOOT_ENV = "boot"
+UBOOT_ENV_SUFFIX = "scr"
+UBOOT_IMAGE = "u-boot.img"
+UBOOT_MACHINE_raspberrypi2 = "rpi_2_defconfig"
Signature · 1 line
2.6.1