MCP23017 Overlay: Probe Fails with Error -EREMOTEIO

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version |
    G_DIETPI_VERSION_CORE=9 G_DIETPI_VERSION_SUB=8 G_DIETPI_VERSION_RC=0 G_GITBRANCH='master' G_GITOWNER='MichaIng'
  • Distro version | bookworm 1
  • Kernel version | Linux DietPi 6.1.21+ #1642 Mon Apr 3 17:19:14 BST 2023 armv6l GNU/Linux
  • Architecture | armhf
  • SBC model | RPi Zero W (armv6l)
  • Power supply used | 5V 3A
  • SD card used | SanDisk ultra

Steps to reproduce

Hi DietPi community,

I’m trying to set up an MCP23017 GPIO expander on my Raspberry Pi running DietPi, but I’ve run into an issue. Here’s what I’ve done:

  1. I copied this device tree source file:
    linux/arch/arm/boot/dts/overlays/mcp23017-overlay.dts at 80533a952218696c0ef1b346bab50dc401e6b74c · raspberrypi/linux · GitHub
  2. Compiled it with the following command:
dtc -@ -I dts -O dtb -o mcp23017.dtbo mcp23017-overlay.dts

result was

mcp23017-overlay.dts:19.36-22.6: Warning (unit_address_vs_reg): /fragment@1/__overlay__/mcp23017_pins@20: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:26.13-31.4: Warning (unit_address_vs_reg): /fragment@2: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:70.15-75.4: Warning (unit_address_vs_reg): /fragment@101: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:77.15-82.4: Warning (unit_address_vs_reg): /fragment@102: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:35.29-43.5: Warning (interrupt_provider): /fragment@3/__overlay__: Missing #address-cells in interrupt provider
  1. Copied the compiled overlay file to /boot/overlays and updated the /boot/config.txt file as follows:
dtoverlay=mcp23017
  1. Rebooted the system.

After rebooting, I see the following error in the dmesg output:

[   18.079543] mcp230xx 1-0020: error -EREMOTEIO: can't write IOCON 32  
[   18.081558] mcp230xx: probe of 1-0020 failed with error -121  

My setup:

  • Raspberry Pi running DietPi.
  • MCP23017 connected via I2C.

Questions:

  1. What does this error mean (-EREMOTEIO and -121)?
  2. Could this be a wiring or addressing issue with the I2C bus?
  3. Are there additional steps or configurations required to properly load the MCP23017 overlay?

Any help would be greatly appreciated!

Thanks in advance.

As you are using kernel 6.1, you could try overlay from branch rpi-6.1.y linux/arch/arm/boot/dts/overlays/mcp23017-overlay.dts at fbd8b3facb36ce888b1cdcf5f45a78475a8208f2 · raspberrypi/linux · GitHub maybe it will work?

1 Like

Same behaviour

root@DietPi:~# dtc -@ -I dts -O dtb -o mcp23017.dtbo mcp23017-overlay.dts
mcp23017-overlay.dts:19.36-22.6: Warning (unit_address_vs_reg): /fragment@1/__overlay__/mcp23017_pins@20: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:26.13-31.4: Warning (unit_address_vs_reg): /fragment@2: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:70.15-75.4: Warning (unit_address_vs_reg): /fragment@101: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:77.15-82.4: Warning (unit_address_vs_reg): /fragment@102: node has a unit name, but no reg or ranges property
mcp23017-overlay.dts:35.29-41.5: Warning (interrupt_provider): /fragment@3/__overlay__: Missing #address-cells in interrupt provider

and

[ 18.088788] mcp230xx 1-0020: error -EREMOTEIO: can't write IOCON 32 [ 18.105436] mcp230xx: probe of 1-0020 failed with error -121

It was a shot in the dark. Hopefully someone who understand it better will help.

1 Like

Maybe @MichaIng has an idea

Why are you compiling the overlay by yourself, instead of using the one that is shipped already with the kernel package? If that one causes the same error, then at best check back with the manufacturer or RPi kernel maintainers. I do not understand the error message either.

Since you were overwriting the original overlay with your self-compiled one, you’d need to reinstall the kernel package:

apt install --reinstall raspberrypi-kernel

And you might want to test it with the new RPi firmware/kernel suite: Image | Raspberry Pi 5: Testing and firmware migration script · Issue #6676 · MichaIng/DietPi · GitHub

It’s a RPi Zero W, not supporting the new kernel right?

new error

[    9.787178] mcp230xx 1-0020: error -EIO: can't write IOCON 32
[    9.790285] mcp230xx: probe of 1-0020 failed with error -5

Every RPi model has a matching new kernel package :slight_smile:.

Did you try it with the original overlay now? In case the WiFi chip is somewhat newer, the new kernel might have some better support. Worth to give a try before contacting manufacturer or RPi devs.

oh I thought it was 64bit only. My bad

I tried it but I don’t see the devices on the i2c bus

pi@remote:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                       

but the pcb is hard soldered

see here the schematics hardware/remote/PCB/main_board_schematics.pdf at 78e37051ccac6da9069fdf55776314be4f2dc344 · YIO-Remote/hardware · GitHub

if I use the original buildroot from here

I see the devices…

Do I need to activate anything else for dietpi i2c support?

You enabled I2C support via dietpi-config advanced options?

yes

lsmod | grep i2c_
i2c_dev                12288  0
i2c_bcm2835            12288  0

solved it with

dtoverlay=i2c-gpio,i2c_gpio_sda=10,i2c_gpio_scl=11
i2cdetect -l
i2c-1	i2c       	bcm2835 (i2c@7e804000)          	I2C adapter
i2c-2	i2c       	bcm2835 (i2c@7e805000)          	I2C adapter
i2c-11	i2c       	ffffffff.i2c                    	I2C adapter
pi@remote:~ $ sudo i2cdetect -y 11
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- 14 -- -- -- -- -- -- -- -- -- -- -- 
20: 20 21 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- 55 -- -- -- -- 5a -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@remote:~ $ dmesg | grep mcp
[    9.901357] mcp230xx 1-0020: error -EIO: can't write IOCON 32
[    9.904524] mcp230xx: probe of 1-0020 failed with error -5

I guess I need to change now the pins and target in the overlay…but I don’t know how to do that :face_with_spiral_eyes:

here is the overlay
(linux/arch/arm/boot/dts/overlays/mcp23017-overlay.dts at 80533a952218696c0ef1b346bab50dc401e6b74c · raspberrypi/linux · GitHub)

1 Like

Great, where did you find the info about which pins are needed?

Question is how can I say the overlay the right i2c bus to use?

1 Like