devicetree: Add minimal support with RPi bootloader

[RPi DT info] https://github.com/raspberrypi/documentation/blob/master/configuration/device-tree.md#part-3-using-device-trees-on-raspberry-pi

RPi bootloader detects a DT-ready kernel by checking for a specific trailer in kernel.img.
Using latest raspberrypi/firmware (firmware.inc) enables this check ability.
Using latest raspberrypi/tools (rpi-mkimage.bb) gives access to mkknlimg for adding the
required trailer to kernel image.


If KERNEL_DEVICETREE is filled in, the trailer is added to the kernel image before
kernel install task. While creating the SDCard image, this modified kernel is
put on boot partition (as kernel.img) as well as DeviceTree blobs (.dtb files).
If KERNEL_DEVICETREE is empty, this new process isn't operated, legacy one does.

KERNEL_DEVICETREE for RPi is really supported only starting from linux-rapsberry 3.18+
kernels, so as for now it defaults to empty (in machine config file).

Change-Id: Ifea71bbda729b8f3c47be7ba0ba03be5ad2ceeaa
Signed-off-by: Francois Muller <francois@concept-embarque.fr>
This commit is contained in:
Francois Muller 2015-02-05 14:07:00 +01:00
parent 327c0c12b5
commit 4dc75cedf7
6 changed files with 52 additions and 9 deletions

View File

@ -50,7 +50,7 @@ IMAGE_DEPENDS_rpi-sdimg = " \
dosfstools-native \ dosfstools-native \
virtual/kernel \ virtual/kernel \
${IMAGE_BOOTLOADER} \ ${IMAGE_BOOTLOADER} \
${@base_contains("KERNEL_IMAGETYPE", "uImage", "u-boot", "",d)} \ ${@bb.utils.contains('KERNEL_IMAGETYPE', 'uImage', 'u-boot', '',d)} \
" "
# SD card image name # SD card image name
@ -99,12 +99,23 @@ IMAGE_CMD_rpi-sdimg () {
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/ mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* ::/
case "${KERNEL_IMAGETYPE}" in case "${KERNEL_IMAGETYPE}" in
"uImage") "uImage")
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.img ::kernel.img mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/u-boot.img ::kernel.img
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 ::uImage
;; ;;
*) *)
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::kernel.img if test -n "${KERNEL_DEVICETREE}"; then
;; for DTB in ${KERNEL_DEVICETREE}; do
if echo ${DTB} | grep -q '/dts/'; then
bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
fi
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
fi
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::kernel.img
;;
esac esac
if [ -n ${FATPAYLOAD} ] ; then if [ -n ${FATPAYLOAD} ] ; then

View File

@ -24,6 +24,9 @@ XSERVER = " \
KERNEL_IMAGETYPE ?= "Image" KERNEL_IMAGETYPE ?= "Image"
# Really supported starting from linux-rapsberry 3.18.y only !
#KERNEL_DEVICETREE ?= "bcm2708-rpi-b.dtb bcm2708-rpi-b-plus.dtb"
MACHINE_FEATURES = "kernel26 apm usbhost keyboard vfat ext2 screen touchscreen alsa bluetooth wifi sdio" MACHINE_FEATURES = "kernel26 apm usbhost keyboard vfat ext2 screen touchscreen alsa bluetooth wifi sdio"
#RaspberryPi has no hardware clock #RaspberryPi has no hardware clock

View File

@ -1,5 +1,5 @@
RPIFW_SRCREV ?= "43c5b2fc9bdb0a43ba67661b8677445e71ae9e82" RPIFW_SRCREV ?= "d426cd1e79f0785fae6c37db79da7d6dae39716d"
RPIFW_DATE ?= "20140817" RPIFW_DATE ?= "20150204"
RPIFW_SRC_URI ?= "git://github.com/raspberrypi/firmware.git;protocol=git;branch=master" RPIFW_SRC_URI ?= "git://github.com/raspberrypi/firmware.git;protocol=git;branch=master"
RPIFW_S ?= "${WORKDIR}/git" RPIFW_S ?= "${WORKDIR}/git"

View File

@ -5,7 +5,7 @@ SECTION = "bootloader"
DEPENDS = "python" DEPENDS = "python"
SRCREV = "330c72c2412f75a32932c4d9b51c9c678bce4180" SRCREV = "b9d7a8ac626e377577aa6900da5c5a965cafb66c"
SRC_URI = " \ SRC_URI = " \
git://github.com/raspberrypi/tools.git;branch=master;protocol=git \ git://github.com/raspberrypi/tools.git;branch=master;protocol=git \
file://License \ file://License \

View File

@ -21,6 +21,20 @@ CMDLINE_raspberrypi = "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA
UDEV_GE_141 ?= "1" UDEV_GE_141 ?= "1"
# Set programmatically some variables during recipe parsing
# See http://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#anonymous-python-functions
python __anonymous () {
kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
kerneldt = d.getVar('KERNEL_DEVICETREE', True)
# Add dependency to 'rpi-mkimage-native' package only if RPi bootloader is used with DT-enable kernel
if kerneldt:
if kerneltype != 'uImage' and len(kerneldt.strip()) > 1:
depends = d.getVar("DEPENDS", True)
depends = "%s rpi-mkimage-native" % depends
d.setVar("DEPENDS", depends)
}
do_kernel_configme_prepend() { do_kernel_configme_prepend() {
install -m 0644 ${S}/arch/${ARCH}/configs/${KERNEL_DEFCONFIG} ${WORKDIR}/defconfig || die "No default configuration for ${MACHINE} / ${KERNEL_DEFCONFIG} available." install -m 0644 ${S}/arch/${ARCH}/configs/${KERNEL_DEFCONFIG} ${WORKDIR}/defconfig || die "No default configuration for ${MACHINE} / ${KERNEL_DEFCONFIG} available."
} }
@ -34,3 +48,13 @@ do_deploy_append() {
install -d ${DEPLOYDIR}/bcm2835-bootfiles install -d ${DEPLOYDIR}/bcm2835-bootfiles
echo "${CMDLINE}" > ${DEPLOYDIR}/bcm2835-bootfiles/cmdline.txt echo "${CMDLINE}" > ${DEPLOYDIR}/bcm2835-bootfiles/cmdline.txt
} }
do_rpiboot_mkimage() {
if test "x${KERNEL_IMAGETYPE}" != "xuImage" ; then
if test -n "${KERNEL_DEVICETREE}"; then
# Add RPi bootloader trailer to kernel image to enable DeviceTree support
${STAGING_DIR_NATIVE}/usr/lib/rpi-mkimage/mkknlimg --dtok ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}
fi
fi
}
addtask rpiboot_mkimage before do_install after do_compile

View File

@ -0,0 +1,5 @@
SRCREV = "a6cf3c99bc89e2c010c2f78fbf9e3ed478ccfd46"
SRC_URI = "git://github.com/raspberrypi/linux.git;protocol=git;branch=rpi-3.18.y \
file://sl030raspberrypii2ckernel.patch \
"
require linux-raspberrypi.inc