Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4848

Advanced users • Re: MCP23017 overlay error -EIO: can't write IOCON 32

$
0
0
You have the I2C bus, but the overlay is still looking at the wrong bus.

https://github.com/raspberrypi/linux/pull/6541 implements my thought for the mcp23017 overlay (and ads1115).
Once CI has built it (about 40 mins), you should be able to use "sudo rpi-update pulls/6541" to get the test build. Normal advice on not using rpi-update on a critical Pi or without a backup.

With that you should be able to do

Code:

dtoverlay=i2c-gpio,i2c_gpio_sda=10,i2c_gpio_scl=11dtoverlay=mcp23017,i2c-path=/i2c@0
and it will bind the mcp23017 to that bus.

(If you add eg ",bus=3" to the i2c-gpio line because you want multiple or a known bus number, then "i2c-path=/i2c@3" would be the appropriate override for the mcp23017 line).
looks like a pretty neat implementation .

Anyhow, wanted to show another idea to OP which might come handy for him/her too (dependent on if he/she is willing to write hs/her own overlay).
As OP has several sensors on the bit-banged I2C bus it might me more simple to include them in one overlay. Once made the one below for using an EEPROM on a bit-bashed bus.
The EEPROM was 'at24@50' --> additional nodes can be added quite easily to fragment 11 and/or dedicated fragments which can be enabled/disabled via overrides. Name of the SW-I2C bus is to be specified as parameter.

Code:

// Simple EEPROM overlay on bit-bashed I2C// pull-ups on I2C GPIO's enabled!!// // at24compatible-eeprom-swi2c-overlay.dts//// aBUGSworstnightmare#include <dt-bindings/gpio/gpio.h>#include <dt-bindings/pinctrl/bcm2835.h>/dts-v1/;/plugin/;/ {compatible = "brcm,bcm2711";fragment@0 {target-path = "/";__overlay__ {i2c_gpio: i2c@0 {reg = <0xffffffff>;compatible = "i2c-gpio";gpios = <&gpio 10 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP) /* sda */ &gpio 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP) /* scl */>;i2c-gpio,delay-us = <2>;        /* ~100 kHz */#address-cells = <1>;#size-cells = <0>;};};};fragment@1 {target-path = "/aliases";__overlay__ {i2c_gpio = "/i2c@0";};};fragment@2 {target-path = "/__symbols__";__overlay__ {i2c_gpio = "/i2c@0";};};fragment@10 {target = <&gpio>;__overlay__ {e2prom_pins: e2prom_pins {                                brcm,pins = <4>;                                brcm,function = <1>; /* out */};};};  fragment@11 {target = <&i2c_gpio>;__overlay__ {#address-cells = <1>;#size-cells = <0>;  status = "okay";    at24@50 {compatible = "atmel,24c32","at24";#address-cells = <1>;#size-cells = <0>;label = "dummye2prom";address-width = <16>;num-addresses = <1>;reg = <0x50>;pagesize = <32>;size = <4096>;wp-gpios = <&gpio 4 0>;  };};};__overrides__ {i2c_gpio_sda = <&i2c_gpio>,"gpios:4";i2c_gpio_scl = <&i2c_gpio>,"gpios:16";i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0";bus = <&i2c_gpio>, "reg:0";};};

Statistics: Posted by aBUGSworstnightmare — Mon Dec 16, 2024 3:36 pm



Viewing all articles
Browse latest Browse all 4848

Trending Articles