Hi @Pipe ,
Right, so if you only want to use MXM3_15 as GPIO you only need an overlay that disables reg_pcie_switch
.
Normally you would also have to do some additional steps in the overlay to enable the pin to be used in userspace as GPIO, but this pin in particular already has this setup made, so disabling the reg_pcie_switch
should be enough.
So the overlay (let’s call it apalis-imx6_enable_gpio1_2_overlay.dts
) will be:
/dts-v1/;
/plugin/;
/ {
compatible = "toradex,apalis_imx6q";
};
®_pcie_switch {
status = "disabled";
};
Now, for the Yocto part: I’ll do a quick overview on what you need to do in order to include a DT overlay in our BSP ref. images and enable it during boot. I did the same steps below and generated a ref. minimal image that has MXM3_15 working as GPIO with gpioset 0 2=1
and gpioset 0 2=0
, as instructed here:
First thing you need to do is create and add a new Yocto layer where you will put the recipe directory, like instructed in the Splash Screen article.
- Go to the directory where you have your Yocto file (if you followed this article the directory will be named
oe-core
). In it export the build environment with:
. export
After that be sure that build/conf/local.conf
has MACHINE=apalis-imx6
.
- Create a new layer in the
layers
directory with bitbake-layers
similar to this:
kirkstone@9080a3e561bf:/home/yocto/oe-core-6/build$ bitbake-layers create-layer ../layers/meta-custom-dtoverlays
kirkstone@9080a3e561bf:/home/yocto/oe-core-6/build$ bitbake-layers add-layer ../layers/meta-custom-dtoverlays
In this example I’ll call this layer meta-custom-dtoverlays
. You can delete the recipes-example
directory in it if you want, we won’t use it.
- In the new layer create a new directory called
recipes-kernel
and inside of it a directory called linux
. In linux
create a text file called device-tree-overlays-mainline_git.bbappend
and a directory named device-tree-overlays-mainline
. This is where the overlay .dts
file will be.
Your file/directory structure should be something similar to this:
meta-custom-dtoverlays/
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-kernel
└── linux
├── device-tree-overlays-mainline
│ └── apalis-imx6_enable_gpio1_2_overlay.dts
└── device-tree-overlays-mainline_git.bbappend
This custom layer we just did will append changes to an existing recipe called device-tree-overlays-mainline_git.bb (found in meta-toradex-bsp-common), hence the .bbappend
format. The directory organization for the .bbappend
file has to follow the same organization as the .bb
one, so that’s why it is like this.
- The
.bbappend
file should be like this:
device-tree-overlays-mainline_git.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/device-tree-overlays-mainline:"
CUSTOM_OVERLAYS_SOURCE = " \
apalis-imx6_enable_gpio1_2_overlay.dts \
"
CUSTOM_OVERLAYS_BINARY = " \
apalis-imx6_enable_gpio1_2_overlay.dtbo \
"
SRC_URI += " \
file://apalis-imx6_enable_gpio1_2_overlay.dts \
"
TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT:use-mainline-bsp += " \
${CUSTOM_OVERLAYS_BINARY} \
"
do_collect_overlays:prepend() {
for DTS in ${CUSTOM_OVERLAYS_SOURCE}; do
cp ${WORKDIR}/${DTS} ${S}
done
}
I won’t go into detail on the syntax, but basically we’re adding an additional step in recipe device-tree-overlays-mainline
to include our overlay into the build.
- After that build the image with either
bitbake tdx-reference-minimal-image
or
bitbake tdx-reference-multimedia-image
I strongly recommend you read through our articles on Yocto and the Yocto documentation to better understand some general concepts, like bbclass, bbappend, recipe tasks, etc.:
You can also consult the Mega manual to seach for Yocto/Bitbake variables that are frequently used in recipes/recipes append like those for example:
As an alternative option to Yocto built images, you may want to consider using Torizon OS for future projects: With it you can avoid doing Yocto builds depending on what OS customization you want, and all apps run inside containers, which can simplify application development.
For instance, adding a custom DT Overlay in a Torizon OS image is much simpler than the Yocto route I just showed you: Apalis i.MX6 GPIO control - #18 by lucas_a.tx
Hope this helps.
Best regards,
Lucas Akira