diff options
| -rw-r--r-- | classes/linux-raspberrypi-base.bbclass | 39 | ||||
| -rw-r--r-- | classes/sdcard_image-rpi.bbclass | 15 | ||||
| -rw-r--r-- | recipes-kernel/linux/linux-raspberrypi.inc | 4 |
3 files changed, 51 insertions, 7 deletions
diff --git a/classes/linux-raspberrypi-base.bbclass b/classes/linux-raspberrypi-base.bbclass new file mode 100644 index 0000000..40beef1 --- /dev/null +++ b/classes/linux-raspberrypi-base.bbclass | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | inherit linux-kernel-base | ||
| 2 | |||
| 3 | |||
| 4 | def get_dts(d, ver): | ||
| 5 | staging_dir = d.getVar("STAGING_KERNEL_BUILDDIR", True) | ||
| 6 | dts = d.getVar("KERNEL_DEVICETREE", True) | ||
| 7 | |||
| 8 | # d.getVar() might return 'None' as a normal string | ||
| 9 | # leading to 'is None' check isn't enough. | ||
| 10 | # TODO: Investigate if this is a bug in bitbake | ||
| 11 | if ver is None or ver == "None": | ||
| 12 | ''' if 'ver' isn't set try to grab the kernel version | ||
| 13 | from the kernel staging ''' | ||
| 14 | ver = get_kernelversion_file(staging_dir) | ||
| 15 | |||
| 16 | if ver is not None: | ||
| 17 | min_ver = ver.split('.', 3) | ||
| 18 | else: | ||
| 19 | return dts | ||
| 20 | |||
| 21 | # Always turn off device tree support for kernel's < 3.18 | ||
| 22 | try: | ||
| 23 | if int(min_ver[0]) <= 3: | ||
| 24 | if int(min_ver[1]) < 18: | ||
| 25 | dts = "" | ||
| 26 | except IndexError: | ||
| 27 | min_ver = None | ||
| 28 | |||
| 29 | return dts | ||
| 30 | |||
| 31 | |||
| 32 | def split_overlays(d, out): | ||
| 33 | dts = get_dts(d, None) | ||
| 34 | if out: | ||
| 35 | overlays = oe.utils.str_filter_out('\S+\-overlay\.dtb$', dts, d) | ||
| 36 | else: | ||
| 37 | overlays = oe.utils.str_filter('\S+\-overlay\.dtb$', dts, d) | ||
| 38 | |||
| 39 | return overlays | ||
diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass index 1ff664d..7592cc1 100644 --- a/classes/sdcard_image-rpi.bbclass +++ b/classes/sdcard_image-rpi.bbclass | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | inherit image_types | 1 | inherit image_types |
| 2 | inherit linux-raspberrypi-base | ||
| 2 | 3 | ||
| 3 | # | 4 | # |
| 4 | # Create an image that can by written onto a SD card using dd. | 5 | # Create an image that can by written onto a SD card using dd. |
| @@ -70,11 +71,6 @@ SDIMG = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.rpi-sdimg" | |||
| 70 | # Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS. | 71 | # Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS. |
| 71 | FATPAYLOAD ?= "" | 72 | FATPAYLOAD ?= "" |
| 72 | 73 | ||
| 73 | # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder | ||
| 74 | DT_ALL = "${@d.getVar('KERNEL_DEVICETREE', True) or ''}" | ||
| 75 | DT_OVERLAYS = "${@oe.utils.str_filter('\S+\-overlay\.dtb$', '${DT_ALL}', d)}" | ||
| 76 | DT_ROOT = "${@oe.utils.str_filter_out('\S+\-overlay\.dtb$', '${DT_ALL}', d)}" | ||
| 77 | |||
| 78 | IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}" | 74 | IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}" |
| 79 | 75 | ||
| 80 | IMAGE_CMD_rpi-sdimg () { | 76 | IMAGE_CMD_rpi-sdimg () { |
| @@ -90,6 +86,9 @@ IMAGE_CMD_rpi-sdimg () { | |||
| 90 | 86 | ||
| 91 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS ${ROOTFS_SIZE_ALIGNED} KiB" | 87 | echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS ${ROOTFS_SIZE_ALIGNED} KiB" |
| 92 | 88 | ||
| 89 | # Check if we are building with device tree support | ||
| 90 | DTS="${@get_dts(d, None)}" | ||
| 91 | |||
| 93 | # Initialize sdcard image file | 92 | # Initialize sdcard image file |
| 94 | dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE} | 93 | dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE} |
| 95 | 94 | ||
| @@ -112,7 +111,11 @@ IMAGE_CMD_rpi-sdimg () { | |||
| 112 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::uImage | 111 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin ::uImage |
| 113 | ;; | 112 | ;; |
| 114 | *) | 113 | *) |
| 115 | if test -n "${KERNEL_DEVICETREE}"; then | 114 | if test -n "${DTS}"; then |
| 115 | # Device Tree Overlays are assumed to be suffixed by '-overlay.dtb' string and will be put in a dedicated folder | ||
| 116 | DT_OVERLAYS="${@split_overlays(d, 0)}" | ||
| 117 | DT_ROOT="${@split_overlays(d, 1)}" | ||
| 118 | |||
| 116 | # Copy board device trees to root folder | 119 | # Copy board device trees to root folder |
| 117 | for DTB in ${DT_ROOT}; do | 120 | for DTB in ${DT_ROOT}; do |
| 118 | DTB_BASE_NAME=`basename ${DTB} .dtb` | 121 | DTB_BASE_NAME=`basename ${DTB} .dtb` |
diff --git a/recipes-kernel/linux/linux-raspberrypi.inc b/recipes-kernel/linux/linux-raspberrypi.inc index 84d4f9e..7e36408 100644 --- a/recipes-kernel/linux/linux-raspberrypi.inc +++ b/recipes-kernel/linux/linux-raspberrypi.inc | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | require linux.inc | 1 | require linux.inc |
| 2 | inherit linux-raspberrypi-base | ||
| 2 | 3 | ||
| 3 | DESCRIPTION = "Linux Kernel for Raspberry Pi" | 4 | DESCRIPTION = "Linux Kernel for Raspberry Pi" |
| 4 | SECTION = "kernel" | 5 | SECTION = "kernel" |
| @@ -26,7 +27,8 @@ UDEV_GE_141 ?= "1" | |||
| 26 | # See http://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#anonymous-python-functions | 27 | # See http://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#anonymous-python-functions |
| 27 | python __anonymous () { | 28 | python __anonymous () { |
| 28 | kerneltype = d.getVar('KERNEL_IMAGETYPE', True) | 29 | kerneltype = d.getVar('KERNEL_IMAGETYPE', True) |
| 29 | kerneldt = d.getVar('KERNEL_DEVICETREE', True) | 30 | kerneldt = get_dts(d, d.getVar('LINUX_VERSION', True)) |
| 31 | d.setVar("KERNEL_DEVICETREE", kerneldt) | ||
| 30 | 32 | ||
| 31 | # Add dependency to 'rpi-mkimage-native' package only if RPi bootloader is used with DT-enable kernel | 33 | # Add dependency to 'rpi-mkimage-native' package only if RPi bootloader is used with DT-enable kernel |
| 32 | if kerneldt: | 34 | if kerneldt: |
