Hi Robert,
you’re right. If using a pin that would be reallocated by a default overlay, the corresponding overlay has to be disabled in uEnv.txt. Thanks.
But that doesn’t solve all problems for the &ocp pinmux version. Still freezing during boot and resulting in static five blue LED. It seems like the bus allocation with the &bone_spi_0 command results in the freeze and couldn’t figure out why and how to fix it. But I found a temporary solution with the new “sugar syntax”, you can find below.
The (old) fragment@ version now works (for SPI0 the “channel@” with “symlink” and the corresponding “#include <dt-bindings/interrupt-controller/irq.h>” and the #address-cells = <1>
and #size-cells = <0>
were previously missing and are now integrated) with this cleaned up dts file:
// SPDX-License-Identifier: GPL-2.0-only
/*
* * Inspired by dts files BB-CAN1-00A0.dts, BeagleBone_Black.dts
*
* Copyright (C) 2022 Sebastian Manko <s.manko@werner-lieb.de>
* Resulting in pinmux for cape with SPI0, CAN1 and GPIO
*/
/dts-v1/;
/plugin/;
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/interrupt-controller/irq.h>
/ {
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
fragment@0 {
target-path="/";
__overlay__ {
chosen {
overlays {
LIEB-BBB-UNIVERSAL-00A9 = __TIMESTAMP__;
};
};
};
};
/*
* Free up the pins used by the cape from the pinmux helpers.
*/
fragment@1 {
target = <&ocp>;
__overlay__ {
P9_17_pinmux { status = "disabled"; }; /* P9_17 (A16) spi0_cs0.spi0_cs0 */
P9_18_pinmux { status = "disabled"; }; /* P9_18 (B16) spi0_d1.spi0_d1 */
P9_21_pinmux { status = "disabled"; }; /* P9_21 (B17) spi0_d0.spi0_d0 */
P9_22_pinmux { status = "disabled"; }; /* P9_22 (A17) spi0_sclk.spi0_sclk */
P9_24_pinmux { status = "disabled"; }; /* P9_24 (D15) uart1_txd.d_can1_rx */
P9_26_pinmux { status = "disabled"; }; /* P9_26 (D16) uart1_rxd.d_can1_tx */
P9_25_pinmux { status = "disabled"; }; /* P9_25 (A14) mcasp0_ahclkx.gpio3_21 */ /* additionally "disable_uboot_overlay_audio=1" in uEnv.txt is needed to prevent error message with sudo /opt/scripts/tools/version.sh, because otherwise pin is allocated to group mcasp0 */
};
};
/*
* Update the default pinmux of the pins.
* See these file for the phandles (&P9_* & &P8_*)
* https://github.com/beagleboard/bb.org-overlays/blob/master/tools/pinmux-generator/BeagleBone_Black.dts
*/
fragment@2 {
target = <&am33xx_pinmux>;
__overlay__ {
spi0_pins: pinmux_spi0_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x0950, PIN_INPUT_PULLUP | MUX_MODE0) /* P9_22 (A17) spi0_sclk.spi0_sclk */
AM33XX_IOPAD(0x0954, PIN_INPUT_PULLUP | MUX_MODE0) /* P9_21 (B17) spi0_d0.spi0_d0 */
AM33XX_IOPAD(0x0958, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE0) /* P9_18 (B16) spi0_d1.spi0_d1 */
AM33XX_IOPAD(0x095c, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE0) /* P9_17 (A16) spi0_cs0.spi0_cs0 */
>;
};
can1_pins: pinmux_can1_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x0980, PIN_OUTPUT_PULLUP | MUX_MODE2) /* P9_26 (D16) uart1_rxd.dcan1_tx */
AM33XX_IOPAD(0x0984, PIN_INPUT_PULLUP | MUX_MODE2) /* P9_24 (D15) uart1_txd.dcan1_rx */
>;
};
gpio_pins: pinmux_gpio_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x09ac, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7) /* P9_25 (A14) mcasp0_ahclkx.gpio3_21 */
>;
};
};
};
fragment@3 {
target = <&ocp>;
__overlay__ {
spi0_pinmux {
#address-cells = <1>;
#size-cells = <0>;
compatible = "bone-pinmux-helper";
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
channel@0 {
compatible = "spidev";
symlink = "bone/spi/0.0";
reg = <0>;
spi-max-frequency = <16000000>;
spi-cpha;
};
channel@1 {
compatible = "spidev";
symlink = "bone/spi/0.1";
reg = <1>;
spi-max-frequency = <16000000>;
};
};
};
};
fragment@4 {
target = <&ocp>;
__overlay__ {
can1_pinmux {
compatible = "bone-pinmux-helper";
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&can1_pins>;
};
};
};
};
From my investigation it looks like the new/prefered version is with “sugar syntax” / " &label { }; syntax" because it is the newer way, how to do, so I really was looking forward to get it work. After uncounted trials and hours, but lastly I could find a way that compiled without errors and included it in uEnv.txt without freezing during boot. The sugar syntax version that works for me now, is cleaned up and looks like this:
// SPDX-License-Identifier: GPL-2.0-only
/*
* Inspired by dts files BB-SPIDEV0-00A0.dts, BeagleBone_Black.dts
*
* Copyright (C) 2022 Sebastian Manko <s.manko@werner-lieb.de>
* Resulting in pinmux for cape with SPI0, CAN1 and GPIO
*/
/dts-v1/;
/plugin/;
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/interrupt-controller/irq.h>
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
&{/chosen} {
overlays {
LIEB-BBB-UNIVERSAL-00A0 = __TIMESTAMP__;
};
};
/*
* Free up the pins used by the cape from the pinmux helpers.
*/
&ocp {
P9_17_pinmux { status = "disabled"; }; /* P9_17 (A16) spi0_cs0.spi0_cs0 */
P9_18_pinmux { status = "disabled"; }; /* P9_18 (B16) spi0_d1.spi0_d1 */
P9_21_pinmux { status = "disabled"; }; /* P9_21 (B17) spi0_d0.spi0_d0 */
P9_22_pinmux { status = "disabled"; }; /* P9_22 (A17) spi0_sclk.spi0_sclk */
P9_24_pinmux { status = "disabled"; }; /* P9_24 (D15) uart1_txd.d_can1_rx */
P9_26_pinmux { status = "disabled"; }; /* P9_26 (D16) uart1_rxd.d_can1_tx */
P9_25_pinmux { status = "disabled"; }; /* P9_25 (A14) mcasp0_ahclkx.gpio3_21 */ /* additionally "disable_uboot_overlay_audio=1" in uEnv.txt is needed to prevent error message with sudo /opt/scripts/tools/version.sh, because otherwise pin is allocated to group mcasp0 */
};
&am33xx_pinmux {
spi0_pins: pinmux_spi0_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x0950, PIN_INPUT_PULLUP | MUX_MODE0) /* P9_22 (A17) spi0_sclk.spi0_sclk */
AM33XX_IOPAD(0x0954, PIN_INPUT_PULLUP | MUX_MODE0) /* P9_21 (B17) spi0_d0.spi0_d0 */
AM33XX_IOPAD(0x0958, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE0) /* P9_18 (B16) spi0_d1.spi0_d1 */
AM33XX_IOPAD(0x095c, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE0) /* P9_17 (A16) spi0_cs0.spi0_cs0 */
>;
};
can1_pins: pinmux_can1_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x0980, PIN_OUTPUT_PULLUP | MUX_MODE2) /* P9_26 (D16) uart1_rxd.dcan1_tx */
AM33XX_IOPAD(0x0984, PIN_INPUT_PULLUP | MUX_MODE2) /* P9_24 (D15) uart1_txd.dcan1_rx */
>;
};
gpio_pins: pinmux_gpio_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x09ac, PIN_OUTPUT_PULLUP | INPUT_EN | MUX_MODE7) /* P9_25 (A14) mcasp0_ahclkx.gpio3_21 */
>;
};
};
&spi0 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
/*
* Select the D0 pin as output and D1 as
* input. The default is D0 as input and
* D1 as output.
*/
//ti,pindir-d0-out-d1-in;
channel@0 {
compatible = "spidev";
symlink = "bone/spi/0.0";
reg = <0>;
spi-max-frequency = <16000000>;
spi-cpha;
};
channel@1 {
compatible = "spidev";
symlink = "bone/spi/0.1";
reg = <1>;
spi-max-frequency = <16000000>;
};
};
&dcan1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&can1_pins>;
};
Note for “sugar syntax” version: I think for the latest version with sugar syntax the compiler/bindings components should be more up to date than the distribution Debian Buster 10.3 (bone-eMMC-flasher-debian-10.3-iot-armhf-2020-04-06-4gb.img.xz) and kernel 4.19 (linux-image-4.19.165-bone-rt-r59_1buster_armhf.deb) can deliver. Becuase of this, the bus allocation with &bone_spi_0 and &bone_can_1 can be compiled w/o erros but result in freeze at boot. If you’re willing to, we can figure out together what is missing or typed the wrong way, to get it work with latest syntax and stable distro and kernel.
Then copied the dts file to directory /opt/source/bb.org-overlays/src/arm, navigate to directory /opt/source/bb.org-overlays and compile it with make src/arm/LIEB-BBB-UNIVERSAL-00A0.dtbo
.
Afterwards enable the custom cape and disabling the audio overlay, by editing the uEnv.txt in directory /boot like this:
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
uname_r=4.19.165-bone-rt-r59
#uuid=
#dtb=
###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/<file0>.dtbo
#uboot_overlay_addr1=/lib/firmware/<file1>.dtbo
#uboot_overlay_addr2=/lib/firmware/<file2>.dtbo
#uboot_overlay_addr3=/lib/firmware/<file3>.dtbo
###
###Additional custom capes
#uboot_overlay_addr4=/lib/firmware/<file4>.dtbo
uboot_overlay_addr4=/lib/firmware/LIEB-BBB-UNIVERSAL-00A0.dtbo
#uboot_overlay_addr5=/lib/firmware/<file5>.dtbo
#uboot_overlay_addr6=/lib/firmware/<file6>.dtbo
#uboot_overlay_addr7=/lib/firmware/<file7>.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/<file8>.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
#disable_uboot_overlay_emmc=1
#disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
#disable_uboot_overlay_wireless=1
#disable_uboot_overlay_adc=1
###
###PRUSS OPTIONS
###pru_rproc (4.14.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_rproc (4.19.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###
cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet
#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:1024x768@60e
##enable Generic eMMC Flasher:
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
In my version the GPIOs are not allocated to a bus anymore, like in the LED examples from https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec. Luckily my application with added CODESYS (which muxes at least the GPIOs) is OK with the code. But the sudo /opt/scripts/device/bone/show-pins.pl
is sadly resulting in greyed out group/bus allocation as you can see in screenshot:
Additionally the names for CAN1 at pins P9.24 and P9.26 are missing. But for my application it is al OK.
I hope that I can bring back some benefits to help others in creating their custom .dts files with things combined with these dts template files, after soaking up so much infos.