Overlay format help

I’m really new at creating overlays and I tried to make my own, but once I add the dtbo to the overlay.txt file, it fails to boot. Below is what I have. This is mostly from you AI. I understand most of the syntax, but fuzzy on exactly what it needs. I looked at the binding for the i2c and that has an example, but I looks more like a device tree example, and not an overlay. Any hint, clues things to read, would be helpfull. Also, point out what I have right in the dts.

/dts-v1/;
/plugin/;

/ {
compatible = “toradex,verdin-imx8mp”;

fragment@0 {
    target = <&i2c3>; 				//device is on i2c-3 Addres 0x40
    __overlay__ {
        #address-cells = <1>;
        #size-cells = <0>;

        pca9685@40 {
            compatible = "nxp,pca9685" "fsl,imx8mp-i2c";
            reg = <0x40>;
            #pwm-cells = <2>;			//not sure if this is needed
            pwms = <&pca9685 0 0>;		//not sure if this is needed
        };
    };
};

};

Hey @jeffbelz,

Just so your aware, the ToradexAI → Artificial Intelligence bot. So that response always needs to be taken with care. I believe the first paragraph mentions this in its response.

It looks like your on the verdin imx8m plus. Can you tell me which carrier board you are using. And are you using a BSP 5 or BSP 6 based OS? If on BSP 6 you can type in sudo tdx-info on the module and it will output a bunch of useful information.

-Eric

Hey @jeffbelz,

Using BSP 6 references…

We can look at the imx8mp-verdin.dtsi file in our linux-toradex source code

We can see a few I2C nodes, it would be good to crossreference with our imx8mp verdin datasheet to get a better understanding of what I2C is doing, and with which pins.

Taking the first reference &i2c1

  16 &i2c1 {
  15     clock-frequency = <400000>;
  14     pinctrl-names = "default", "gpio";
  13     pinctrl-0 = <&pinctrl_i2c1>;
  12     pinctrl-1 = <&pinctrl_i2c1_gpio>;
  11     scl-gpios = <&gpio5 14 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
  10     sda-gpios = <&gpio5 15 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
   9     status = "okay";
   8
   7     pca9450: pmic@25 {
   6         compatible = "nxp,pca9450c";
   5         interrupt-parent = <&gpio1>;
   4         /* PMIC PCA9450 PMIC_nINT GPIO1_IO3 */
   3         interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
   2         pinctrl-names = "default";
   1         pinctrl-0 = <&pinctrl_pmic>;
521          reg = <0x25>;
   1         sd-vsel-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;

To find out what the I2C node should include, you can look to the device tree bindings in the linux-toradex source code.

So yours might look something like this:

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx8mp-clock.h>
#include <dt-bindings/gpio/gpio.h>

/ {
	compatible = "toradex,verdin-imx8mp";
};


&i2c1 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

        pca9685@40 {
           compatible = "nxp,pca9685" "fsl,imx8mp-i2c";
           reg=<0x40>;
           status = "okay";
        };
};

Almost there. I got the overlay working and I can control channel 0 of the pca9685.

Issues left:

  1. From he command line I can exports all channels # echo 10 > export (will make a pwm10 folder in /sys/class/pwm/pwmchip2 folder)

  2. I can only control channel 0 all others are permission denied

    torizon@mallow:/sys/class/pwm/pwmchip2$ echo 1 > pwm10/enable
    -sh: pwm10/enable: Permission denied
    Even using sudo does not work

  3. I tried it out with in a C++ application inside a container and I can export all channels, but can not enable any. Error number 13 - permission denied

It seems weird, that from the command prompt I can control channel 0, and all others are not permitted even with sudo

update:

  1. I open a container and mounted my pwm folder.
    Everything works from with in a container - not it logs me in as root

  2. used the C++ program and made sure I added the volumes to the docker compose.
    I was able to export, but not write to a file like enable

  3. I opened a terminal for the container that was created by my C++ program
    everything worked - note it logs me is as root

4)I added user: root to the compose file
result same as number 2

It seems that my c++ application does not have rw permissions. any idea on how to let my c++ application have rw permission for pwm?

I’s like to try the C++ app but logged into root. I have found no documentation on the root password for the Torizon OS.

  1. What is the default root password for Torizon OS v 6
  2. Can a user group be given root privilege’s with Torizon OS

Hey @jeffbelz,

There is no root user for Torizon OS by default, this is a safety measure for production value.

You can modify the /.vscode/settings.json file and set “torizon_run_as”: “torizon” as root:
"torizon_run_as": "root",

The O.S will be majority read only, this is by design and implemented with how our updates work with OStree. If you need files in these locations, its best to build them into the OS customization build (say with TorizonCore Builder) There are some files that are special cases such as /var and /etc that persist between updates.

-Eric

Eric:

Perfect I modified the json file and I got everything to work. Thank you for all the help. I documented how I got it to work incase someone else needs it.

Toradex using pca9685 linux driver.txt (3.2 KB)