Building .dtbo overlay for BBB using bitbake - linux-kernel

I built a yocto distro (rocko) for my BBB using kernel linux-ti-staging-4.14 with a custom device tree. Since I need to port an old project from Debian to Yocto, I also needed to enable the UIO features in the kernel, which works fine too.
Now I need to also create an additonal device-tree-overlay for the UIO PRUSS. I use a dts file from here and extended the kernel recipe via bbappend:
inherit kernel-devicetree
FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:${THISDIR}/files/beaglebone:"
# Make custom kernel with PRU enabled
SRC_URI += " \
file://bbb-pru-minimal.dts;subdir=git/arch/${ARCH}/boot/dts \
file://AM335X-PRU-UIO-00A0-overlay.dts;subdir=git/arch/${ARCH}/boot/dts/overlays \
file://0001-add-UIO-dtbo.patch \
file://defconfig \
"
KERNEL_DEVICETREE = " \
AM335X-PRU-UIO-00A0.dtbo \
bbb-pru-minimal.dtb \
"
The above listed patch file contains:
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7949c213a434..fe2513074893 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
## -610,6 +610,7 ## dtb-$(CONFIG_SOC_TI81XX) += \
dm8168-evm.dtb \
dra62x-j5eco-evm.dtb
dtb-$(CONFIG_SOC_AM33XX) += \
+ AM335X-PRU-UIO-00A0.dtbo \
am335x-baltos-ir2110.dtb \
am335x-baltos-ir3220.dtb \
am335x-baltos-ir5221.dtb \
However, the kernel build fails as it seems there is no rule for .dtbo targets:
| CC scripts/mod/empty.o
| CC scripts/mod/devicetable-offsets.s
| MKELF scripts/mod/elfconfig.h
| HOSTCC scripts/mod/modpost.o
| HOSTCC scripts/mod/sumversion.o
| CHK scripts/mod/devicetable-offsets.h
| HOSTCC scripts/mod/file2alias.o
| HOSTLD scripts/mod/modpost
| NOTE: make -j 24 HOSTCC=gcc -isystem[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/include -O2 -pipe -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=[TOPDIR]/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 HOSTCPP=gcc -E AM335X-PRU-UIO-00A0.dtbo
| CHK scripts/mod/devicetable-offsets.h
| make[3]: *** No rule to make target 'arch/arm/boot/dts/AM335X-PRU-UIO-00A0.dtbo'. Stop.
| arch/arm/Makefile:345: recipe for target 'AM335X-PRU-UIO-00A0.dtbo' failed
| make[2]: *** [AM335X-PRU-UIO-00A0.dtbo] Error 2
| Makefile:146: recipe for target 'sub-make' failed
| make[1]: *** [sub-make] Error 2
| Makefile:24: recipe for target '__sub-make' failed
| make: *** [__sub-make] Error 2
| ERROR: oe_runmake failed
Please note, I replaced the absolute paths in the error message with [TOPDIR] due to privacy reasons.
Since I am fairly new to overlay creation I don't really know what I am missing or how to fix it. Any hints?
Thank you in advance!
Update: Added patch file to description above.

Here is what I found after analyzing Toradex's git projects that can inspire you for a solution:
They have a custom class that handles their device tree files and device tree overlays, here.
The class inherits devicetree that is an official poky class here.
The devicetree class tests if a device tree is an overlay or normal and then it compiles all of them.
So, you can basically use devicetree class in a custom recipe to compile device tree overlays and deploy them manually into your rootfs.
Toradex also has a simple recipe like that here. They have a git project that holds all of their device tree overlays.
That being said, I think Toradex doesn't use the custom recipe, rather they use the custom toradex-devicetree class which inherits from devicetree, compiles all device tree overlays from their device tree overlays git project and then deploy them all into the rootfs.
In that custom class, they append to do_deploy of devicetree class to install the .dtbo files and add them to overlays.txt file under the boot partition.
So finally, you can create a bbappend file for you kernel recipe if you don't have one, and try to follow these steps:
Inherit from devicetree
Add your dts files that are overlays to SRC_URI via local files or URL
Add the path for your overlays to DT_FILES_PATH of the devicetree class
In the kernel recipe, append to do_deploy to add them to rootfs.
Now, here is my advice to achieve this step by step:
Create a custom recipe that uses devicetree class with dts overlay example file
Check if it compiles it correctly
If you understand that, you can then apply the 4 steps above.

Thanks to the hints from #BelHadjSalem I was able to manage the dtbo build.
The class file devicetree.bbclass was introduced in Yocto with release "thud", therefore I updated my whole workspace to the latest Yocto release (dunfell). Afterwards I created a new recipe just to build my dtbo overlay:
inherit devicetree
FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:"
SRC_URI = " \
file://AM335X-PRU-UIO-00A0.dts;subdir=git/overlays \
"
S = "${WORKDIR}/git/overlays"
COMPATIBLE_MACHINE = ".*(ti33x|beaglebone).*"
The recipe is pretty simple and works in my project as required.
However, one important note: Inheriting the devicetree.bbclass in any kernel recipe or kernel bbappend file, will NOT work! Not sure what exactly happens, but the inheritance of devicetree.bbclass will invalidate the kernel recipe configuration and fail with ERROR: Nothing PROVIDES 'virtual/kernel'

Related

How to queue patches in Yocto

Background
I have a microcontroller board which has STM32MP157 chip on it, with a development board. The manufacturer provides a Yocto BSP layer for this device and the development board and it is found on an open Github repository.
The important thing to note is that the BSP layer applies important devicetree patches to the stable release of the Linux kernel.
What I want
I would like to modify parts of the devicetree that is provided by the manufacturer's BSP layer, basically add to it.
What I have done
I have created a layer, named meta-mx-dts, put it after the manufacturer supplied layer in the build/conf/bblayers.conf file, and made it with higher priority by setting BBFILE_PRIORITY_meta-mx-dts in meta-mx-dts/conf/layer.conf (so that it applies after the manufacturer supplied layer). Finally, I made a file linux-stable_5.4.bbappend as follows:
FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
SRC_URI_append = "file://dts.patch"
and placed the dts.patch file properly.
The error I get
The error stack can be summarized by this line (from the error stack):
error: arch/arm/boot/dts/stm32mp157c-dhcom-pdk2.dts: does not exist in index
Where stm32mp157c-dhcom-pdk2.dts is the devicetree file to be created by the patches in the manufacturer's BSP layer. My patch applies to that file specifically.
What I have tried so far
I have tried different ways to append/prepend the dts.patch to the SRC_URI variable, until I got it appear after the patches directory applied by the BSP layer, by checking in the following ways in the treminal:
bitbake -e linux-stable | grep SRC_URI
bitbake -e virtual/kernel | grep SRC_URI
However, that didn't solve the issue. I also tried to make the SRC_URI append operation to be specific to the machine:
SRC_URI_append_dh-stm32mp1-dhcom-pdk2 = "file://dts.patch"
That didn't help either.
UPDATE
I have also tried to append to KERNEL_FEATURES variable and use .scc file, where I specify patches, as follows:
# The .bbappend file
KERNEL_FEATURES_append = " mx.scc "
SRC_URI_append = " file://mx.scc;type=kmeta "
with the file mx.scc being like:
define KMACHINE dh-stm32mp1-dhcom-pdk2
define KTYPE standard
define KARCH arm
branch dh-stm32mp1-dhcom-pdk2
patch dts.patch
With no effect.
Need your help
Thanks

Buildroot gcc headers don't match linux-headers

I'm using Buildroot 2018.02.7 to build a simple Linux system for i386 PC, as a precursor to doing the same thing for an embedded ARM system. I keep running into problems like this one, in building the util-linux module:
CC lib/libcommon_la-path.lo
lib/pager.c:11:17: fatal error: err.h: No such file or directory
#include <err.h>
^
compilation terminated.
Makefile:8596: recipe for target 'lib/libcommon_la-pager.lo' failed
make[3]: *** [lib/libcommon_la-pager.lo] Error 1
When I look in the linux-headers source tree in .../output/build/linux-headers-4.13.8, the file is found. But Buildroot is pointing to a different set of headers, the one built into its GCC:
devuser#3faf730b4a1b:~/pc/buildroot-2018.02.7/output/build/util-linux-2.31.1$ ../../host/bin/i686-buildroot-linux-uclibc-gcc -print-sysroot
/home/devuser/pc/buildroot-2018.02.7/output/host/i686-buildroot-linux-uclibc/sysroot
devuser#3faf730b4a1b:~/pc/buildroot-2018.02.7/output/build/util-linux-2.31.1$
And the two /usr/include subdirectories are significantly different.
Have I missed a configuration setting somewhere in the defconfig file? This is the defconfig:
BR2_x86_core2=y
BR2_SSP_REGULAR=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y
BR2_UCLIBC_CONFIG="board/pc/dsa_pc_i386_uclibc.config"
BR2_TOOLCHAIN_BUILDROOT_USE_SSP=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_TARGET_GENERIC_GETTY_PORT="tty1"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image.sh support/scripts/genimage.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-bios.cfg"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.13.8"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config"
BR2_LINUX_KERNEL_INSTALL_TARGET=y
BR2_LINUX_KERNEL_EXT_XENOMAI=y
BR2_PACKAGE_BUSYBOX_CONFIG="board/pc/dsa_pc_i386_busybox.config"
BR2_PACKAGE_LINUX_FIRMWARE=y
BR2_PACKAGE_LINUX_FIRMWARE_ATHEROS_9170=y
BR2_PACKAGE_LINUX_FIRMWARE_ATHEROS_9271=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_3160=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_3168=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_5000=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_6000G2A=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_6000G2B=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_7260=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_7265D=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_8000C=y
BR2_PACKAGE_LINUX_FIRMWARE_IWLWIFI_8265=y
BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT73=y
BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_88XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_8169=y
BR2_PACKAGE_ACPID=y
BR2_PACKAGE_DBUS=y
BR2_PACKAGE_ZLIB=y
BR2_PACKAGE_LIBFFI=y
BR2_PACKAGE_PCRE=y
BR2_PACKAGE_PCRE_UCP=y
BR2_PACKAGE_READLINE=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_DBUS_NEW=y
BR2_PACKAGE_KMOD=y
BR2_PACKAGE_UTIL_LINUX=y
BR2_PACKAGE_UTIL_LINUX_LIBMOUNT=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_GENIMAGE=y
Enable UCLIBC_HAS_BSD_ERR in uClibc.
You have a custom uClibc configuration. That falls squarely in the "you know what you are doing" category, since it allows you to remove features that other packages rely on.
In this case, util-linux relies on the non-Posix err.h include. This is only installed if UCLIBC_HAS_BSD_ERR is enabled in the uClibc configuration.
There is a high risk of running into similar issues with a custom uClibc configuration.

Failing to build Boost components locally with Bazel build

I am trying to build Boost library locally and want to use it as a local_repository in my own project. I am referring to this (https://github.com/nelhage/rules_boost) for help.
I have a directory tree like this:
boost/ // root of the boost project
|
bazel/
| |
| boost.bzl // contains "boost_library" function from https://github.com/nelhage/rules_boost/blob/master/boost/boost.bzl
| |
| BUILD // empty
boost/ // the original boost headers folder from original boost dist
|
lib/ // the original boost sources folder from original boost dist
|
BUILD
|
WORKSPACE
The BUILD file looks like this one:
https://github.com/nelhage/rules_boost/blob/master/BUILD.boost
with properly loading boost.bzl
The WORKSPACE is just:
workspace( name = "boost" )
The issue:
Now I am trying to build individual components (bazel build //:<component>).
Some of the components (Boost.Container, Boost.Test) are failing to build for a similar reason (not finding header files).
bazel build //:container 1 ↵
INFO: Found 1 target...
ERROR: /home/spyder/codebase/boost/BUILD:103:1: C++ compilation of rule '//:container' failed: Process exited with status 1 [sandboxed].
libs/container/src/global_resource.cpp:12:51: fatal error: boost/container/pmr/memory_resource.hpp: No such file or directory
compilation terminated.
Use --strategy=CppCompile=standalone to disable sandboxing for the failing actions.
Target //:container failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.519s, Critical Path: 0.18s
bazel build //:test 1 ↵
INFO: Found 1 target...
ERROR: /home/spyder/codebase/boost/BUILD:581:1: C++ compilation of rule '//:test' failed: Process exited with status 1 [sandboxed].
libs/test/src/junit_log_formatter.cpp:11:51: fatal error: boost/test/impl/junit_log_formatter.ipp: No such file or directory
compilation terminated.
Use --strategy=CppCompile=standalone to disable sandboxing for the failing actions.
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.027s, Critical Path: 0.82s
Can anyone guide me on fixing it ?
EDIT:
I also tried to query the expanded cc_library rule by bazel query --output=build //:container and got this
cc_library(
name = "container",
visibility = ["//visibility:public"],
generator_name = "container",
generator_function = "boost_library",
generator_location = "/home/spyder/codebase/boost/BUILD:103",
licenses = ["notice"],
deps = ["//:config", "//:core", "//:intrusive", "//:move"],
defines = [],
includes = ["boost/container/"],
copts = ["-Wno-unused-value"],
srcs = ["//:libs/container/src/alloc_lib.c", "//:libs/container/src/dlmalloc.cpp", "//:libs/container/src/dlmalloc_2_8_6.c", "//:libs/container/src/dlmalloc_ext_2_8_6.c", "//:libs/container/src/global_resource.cpp", "//:libs/container/src/monotonic_buffer_resource.cpp", "//:libs/container/src/pool_resource.cpp", "//:libs/container/src/synchronized_pool_resource.cpp", "//:libs/container/src/unsynchronized_pool_resource.cpp"],
hdrs = [ ....... , "//:boost/container/pmr/map.hpp", "//:boost/container/pmr/memory_resource.hpp", "//:boost/container/pmr/monotonic_buffer_resource.hpp", "//:boost/container/pmr/polymorphic_allocator.hpp", ........ ],
)
Very shockingly, the source file which is complaining (libs/container/src/global_resource.cpp) and the header that it is complaining about (boost/container/pmr/memory_resource.hpp) are both correctly included in the srcs and hdrs list.
I played with your rules a bit and the biggest problem I see is incomplete dependencies. For example I tried :algorithm component, and that needs to depend on :tuple. I guess you just needs to make sure all dependencies are set correctly.
I played more with container, and the problem I encountered was incorrect include dirs. If you run your build with -s flag, bazel will output all the command lines so you can inspect them and check that -isystem flags contain the directory that contains boost/container/... . What can also help you is the bazel flag --sandbox_debug, which will prevent the sandbox directory from being deleted so you can see which files are where and also you can reproduce the compiler invocation without running through bazel.
Last, bazel does not understand .ipp header extension yet (tbh I've never heard of it, but I also know next to nothing about boost). I have a change in flight that will introduce this.

Pulseaudio build issue in yocto

I am using Raspberry Pi 3 model B. I am facing build issue while building bitbake pulseaudio. Please find my configuration details:
Yocto : Jethro branch
pulseaudio.inc RDEPENDS_pulseaudio-server +=
"alsa-plugins-pulseaudio-conf"
we are using alsa-plugins_1.0.29.bb
bitbake pulseaudio
ERROR: Nothing RPROVIDES 'alsa-plugins-pulseaudio-conf' (but /home/guest/openembedded-core/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb RDEPENDS on or otherwise requires it)
NOTE: Runtime target 'alsa-plugins-pulseaudio-conf' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['alsa-plugins-pulseaudio-conf']
ERROR: Required build target 'pulseaudio' has no buildable providers.
Missing or unbuildable dependency chain was: ['pulseaudio', 'alsa-plugins-pulseaudio-conf']
Based on the recipe the package alsa-plugins-pulseaudio-conf is generated if "pulseaudio" is in the alsa-plugins PACKAGECONFIG. By default that happens if your DISTRO_FEATURES includes "pulseaudio".
So check your DISTRO_FEATURES, ensure "pulseaudio" is in there (and make sure you don't modify the alsa-plugins PACKAGECONFIG in a bad way).
To see what your DISTRO_FEATURES contains:
bitbake -e pulseaudio |grep "^DISTRO_FEATURES="
To add pulseaudio if it's not there right now (you can do this in local or distro config):
DISTRO_FEATURES_append = " pulseaudio "
The whitespace preceding the feature name is required.
To check what PACKAGECONFIG is getting used for alsa-plugins (this should contain "pulseaudio"):
bitbake -e alsa-plugins|grep "^PACKAGECONFIG="

Not able to make tipc module

I am not able to build tipc module when executed Makefile using make command in the path /tipc-1.7.7-bundle/net/tipc. The errors comes as target not found. I extracted the tipc 1.7 package in root directory. My operating system is CentOs 6.3. The Makefile contents are
#
# Makefile for the Linux TIPC layer
#
obj-$(CONFIG_TIPC) := tipc.o
tipc-y += tipc_addr.o tipc_bcast.o tipc_bearer.o tipc_cfgsrv.o \
tipc_core.o tipc_handler.o tipc_link.o tipc_discover.o tipc_msg.o \
tipc_name_distr.o tipc_topsrv.o tipc_name_table.o tipc_net.o \
tipc_netlink.o tipc_node.o tipc_port.o tipc_ref.o \
tipc_socket.o tipc_user_reg.o tipc_dbg.o tipc_eth_media.o
# End of file
Please help, i am newbie to linux.

Resources