static assertion failed: "/soc/i2c@40004000 has legacy *-pin properties defined although PINCTRL is enabled"

I am trying to implement an already made sample from Nordic for INA219 sensor. As always it didn't work initially and showed many errors even though it was a sample code Joy but then I figured out that sensor INA219 should be configured in the deviceTree and as usual no valid or straigh forward information was available on internet also not on NordicSemiconductor website. Then I came up on this platform and spent a lot of time in reading long Q&A sessions and figured out how to configure sensor in deviceTree. But again after adding this configuration in overlay I end up with a new error (static assertion failed: "/soc/i2c@40004000 has legacy *-pin properties defined although PINCTRL is enabled"). I changed the I2C, disabled other UART and I2C and even tried pin control but nothing worked. Even if all the problems are removed still the board cannot get flashed because of one error in the terminal that is so big that I cant even paste it here.  But the thing I figured out is that if I remove the Pins from my overlay the configuration built very well. 

Here is overlay code:

i2c1 {
        status = "okay";
        sda-pin = < 34 >;
        scl-pin = < 35 >;
        clock-frequency = <100000>;
    ina219@40 {
        status = "okay";
        compatible = "ti,ina219";
        reg = <0x40>;
        label = "INA219";
        brng = <0>;
        pg = <0>;
        sadc = <13>;
        badc = <13>;
        shunt-milliohm = <100>;
        lsb-microamp = <10>;
    };
};
&uart1 {
    status = "disabled";
};
  • Did you manage to get I2C working with any other port?

  • My I2C2 port is enabled by default. I think my application was based on an example, but it's been a while and I don't even know what one it was.

  • I've finally got it working. I changed from trying to get i2c0 working to i2c3, as I figured I had to disable uart0, which might already be used for the terminal (could be wrong). The only thing I changed was my prj.conf file, which probably could be improved such as changing i2c0_default_alt to i2c3_default_alt. But it works and I'm happy. Side note: I have never had to work so hard to figure out how to get a peripheral working on any microcontroller, as I had to do with this.

    Also, I'm using the nRF9160 DK board.

    prj.conf

    &pinctrl {
        i2c0_default_alt: i2c0_default_alt {
           group1 {
              psels = <NRF_PSEL(TWIM_SDA, 0, 12)>,
                      <NRF_PSEL(TWIM_SCL, 0, 11)>;
           };
        };

     };

    &i2c3 {
        status = "okay";
        compatible = "nordic,nrf-twim";
        pinctrl-0 = <&i2c0_default_alt>;
        pinctrl-names = "default";
        // pinctrl-1 = <&i2c0_sleep_alt>;
        clock-frequency = <I2C_BITRATE_STANDARD>;  
    };

    /* These two lines are probably not needed below as I'm not using i2c0 */
    &spi0 {
        status = "disabled";
    };

    &pwm0 {
        status = "disabled";
    };


  • If you go to pinctrl.dtsi file you will find the pinctrl for i2c1 as follow 

        i2c1_default: i2c1_default {
            group1 {
                psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
                    <NRF_PSEL(TWIM_SCL, 0, 31)>;
            };
        };

        i2c1_sleep: i2c1_sleep {
            group1 {
                psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
                    <NRF_PSEL(TWIM_SCL, 0, 31)>;
                low-power-enable;
            };
        };   
    From there you can find the Pins for i2c1 or i2c0 whatever you are using. Then you can remove pin configuration from overlay and it will start communicating. At least this works for me
Related