I am working on a Beaglebone Black, using Yocto.
Using this implementation of a PWM driver as a guide, I am unable to add my PWMs to the device tree.
The best solution would be to create a device tree overlay as Mr. Saad Ahmad is doing, but I don't understand how to do this using Yocto.
I am not using capemgr, but I am using meta-bbb. I also have custom layer meta-tfe which currently holds the pwm-driver and some examples. This layer also defines a new bitbake image recipe:
include recipes-core/images/core-image-base.bb
IMAGE_INSTALL += "\
helloworld \
hellokernel \
bbb-pwm \
"
KERNEL_MODULE_AUTOLOAD += "\
hellokernel \
bbb-pwm \
"
export IMAGE_BASENAME = "tfe-image-base"
Following is the .bb file of the pwm-driver:
DESCRIPTION = "PWM kernel module"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=d41d8cd98f00b204e9800998ecf8427e"
PR = "r0"
inherit module
SRC_URI = "file://bbb-pwm.c \
file://Makefile \
file://COPYING \
"
S = "${WORKDIR}"
Does anyone know how to do this?
Edit: A colleague hinted that I could use a .bbappend file, appending to the kernel build-rules in meta-bbb. Hence this is what I did, and now my recipes-kernel directory now looks like this:
.
├── bbb-pwm
│ ├── bbb-pwm.bb
│ └── files
│ ├── bbb-pwm.c
│ ├── COPYING
│ └── Makefile
├── hellokernel
│ └── {...}
└── linux
├── linux-stable_4.1
│ └── {...}
├── linux-stable_4.1.bbappend
├── linux-stable_4.4
│ └── {...}
├── linux-stable_4.4.bbappend
├── linux-stable_4.5
│ └── dts
│ ├── bbb-pwm.dts
│ └── sc_pwm_P8_13-00A0.dtsi
└── linux-stable_4.5.bbappend
The directories linux-stable_4.*/ all have the same structure, to reflect the mirrored structure in meta-bbb.
My .bbappend files look like this:
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}/dts:"
KERNEL_DEVICETREE_beaglebone += " \
bbb-pwm.dtb \
"
However, when bitbaking, an error occurs saying there are no build rules for bbb-pwm.dtb:
| make[3]: *** No rule to make target 'arch/arm/boot/dts/bbb-pwm.dtb'. Stop.
| arch/arm/Makefile:333: recipe for target 'bbb-pwm.dtb' failed
Edit: Here is sc_pwm_P8_13-00A0.dtsi
When you want to use a custom device tree and edit the KERNEL_DEVICETREE
variable, the device tree sources (*.dts files and *.dtsi files) are searched in arch/arm/boot/dts
(according to your architecture).
In your example your files are placed in a separate folder and not fetched by the bbappend file. The correct layer structure would be following:
└── linux
├── linux-stable_4.5
│ └── git
│ └── arch
│ └── arm
│ └── boot
│ └── dts
│ ├── bbb-pwm.dts
│ └── sc_pwm_P8_13-00A0.dtsi
└── linux-stable_4.5.bbappend
To make bitbake sensible for those new files they have to be added via the SRC_URI
variable in the bbappend file:
SRC_URI += "file://git/arch/arm/boot/dts/bbb-pwm.dts"
SRC_URI += "file://git/arch/arm/boot/dts/sc_pwm_P8_13-00A0.dtsi"