Jump to content

GPIO interferes with I2C


mboehmer

Recommended Posts

Armbianmonitor:

Hi,

I use the new kernel with I2CA being used for controlling some U/I meters and sensors.

There are three 1Wire masters included by overlay (and they work :) ):

> ls /sys/bus/w1/devices/
> 22-000000214032  28-00000a09aa8d  w1_bus_master2
> 28-00000a089919  w1_bus_master1   w1_bus_master3

I2C works also fine, all devices mounted so far are answering:

> i2cdetect -y 0
>      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
> 00:          -- -- -- -- -- -- -- -- -- 0c -- -- --
> 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 40: 40 41 -- -- -- 45 -- 47 48 -- 4a -- -- 4d -- --
> 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 60: -- -- -- -- -- -- -- -- -- -- -- -- 6c -- -- --
> 70: -- -- -- -- -- -- 76 --

Then I access the GPIO subsystem to initialize one pin for power control:

#! /bin/sh
echo 475 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio475/direction
echo 0   > /sys/class/gpio/gpio475/value

After that, I2C access is screwed up, and no normal access possible:

> i2cdetect -y 0
>      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
> 00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
> 10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
> 20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
> 30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
> 40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
> 50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
> 60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
> 70: 70 71 72 73 74 75 76 77

This is kind of a showstopper - anyone can help here? Seems that activating the GPIO subsystem is touching the I2C pins on J2, too.

 

Michael

Link to comment
Share on other sites

6 hours ago, mboehmer said:

Then I access the GPIO subsystem to initialize one pin for power control:


#! /bin/sh
echo 475 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio475/direction
echo 0   > /sys/class/gpio/gpio475/value

After that, I2C access is screwed up, and no normal access possible:

Which board it is ?

GPIO-475 seems to be GPIOX_5, but on my NanoPiK2, it is connected to WiFi SDIO ...

On your board, what it is connected to ?

Link to comment
Share on other sites

Just now, martinayotte said:

Which board it is ?

GPIO-475 seems to be GPIOX_5, but on my NanoPiK2, it is connected to WiFi SDIO ...

On your board, what it is connected to ?

I use an Odroid C2, GPIO-475 should be X_5, and is connected as spare GPIO line to J2.

Schematics

I have latest board revision.

 

For me it seems that touching GPIO sets all GPIOs to zero (or overrides the I2C access? don't know, need to measure by scope).

Including the 1Wire masters doesn't affect the GPIOs, troubles start once I export the GPIO_475.

 

In case I can test something for you please let me know!

Link to comment
Share on other sites

16 hours ago, martinayotte said:

Did you try to see if same behavior happened with some other GPIOX_x ? Is it the same with some GPIOY_x ?

Not yet, sorry, had some other issues to solve first. I'm pretty sure that I adress X_5, as the connected load on that pin is being switched on and off.

I can try tomorrow with some pins from X and Y, my PCB layout has some limitations on that.

 

Update: I could test some more pins.

X_0 (470) works

X_1 (471) works

X_2 (472) works

X_3 (473) works

X_4 (474) works

X_5 (475) fails after setting "out"

X_6 (476) works

X_7 (477) works

X_8 (478) works

X_9 (479) works

X_10 (480) fails after setting "out"

X_11 (481) works

X_19 (489) works

X_21 (491) UNKNOWN (fixed 1Wire slave attached)

Y_3 (456) works

Y_7 (460) works

Y_8 (461) works

Y_13 (466) works

Y_14 (461) UNKNOWN (switches off Odroid Vcc :) )

 

Double checked on second C2, results are consistent.
 

Link to comment
Share on other sites

Here we are: after booting, I2C works fine, and "cat /sys/kernel/debug/gpio" says:

gpiochip1: GPIOs 378-496, parent: platform/c8834000.periphs:pinctrl@4b0, periphs-banks:
 gpio-378 (Eth MDIO            )
 gpio-379 (Eth MDC             )
 gpio-380 (Eth RGMII RX Clk    )
 gpio-381 (Eth RX DV           )
 gpio-382 (Eth RX D0           )
 gpio-383 (Eth RX D1           )
 gpio-384 (Eth RX D2           )
 gpio-385 (Eth RX D3           )
 gpio-386 (Eth RGMII TX Clk    )
 gpio-387 (Eth TX En           )
 gpio-388 (Eth TX D0           )
 gpio-389 (Eth TX D1           )
 gpio-390 (Eth TX D2           )
 gpio-391 (Eth TX D3           )
 gpio-392 (Eth PHY nRESET      |mdio-reset          ) out hi    
 gpio-393 (Eth PHY Intc        )
 gpio-394 (HDMI HPD            )
 gpio-395 (HDMI DDC SDA        )
 gpio-396 (HDMI DDC SCL        )
 gpio-397 (                    )
 gpio-398 (eMMC D0             )
 gpio-399 (eMMC D1             )
 gpio-400 (eMMC D2             )
 gpio-401 (eMMC D3             )
 gpio-402 (eMMC D4             )
 gpio-403 (eMMC D5             )
 gpio-404 (eMMC D6             )
 gpio-405 (eMMC D7             )
 gpio-406 (eMMC Clk            )
 gpio-407 (eMMC Reset          |reset               ) out hi    
 gpio-408 (eMMC CMD            )
 gpio-409 (                    )
 gpio-410 (                    )
 gpio-411 (                    )
 gpio-412 (                    )
 gpio-413 (                    )
 gpio-414 (                    )
 gpio-415 (                    )
 gpio-416 (SDCard D1           )
 gpio-417 (SDCard D0           )
 gpio-418 (SDCard CLK          )
 gpio-419 (SDCard CMD          )
 gpio-420 (SDCard D3           )
 gpio-421 (SDCard D2           )
 gpio-422 (SDCard Det          |cd                  ) in  hi    
 gpio-423 (                    )
 gpio-424 (                    )
 gpio-425 (                    )
 gpio-426 (                    )
 gpio-427 (                    )
 gpio-428 (                    )
 gpio-429 (                    )
 gpio-430 (                    )
 gpio-431 (                    )
 gpio-432 (                    )
 gpio-433 (                    )
 gpio-434 (                    )
 gpio-435 (                    )
 gpio-436 (                    )
 gpio-437 (                    )
 gpio-438 (                    )
 gpio-439 (                    )
 gpio-440 (                    )
 gpio-441 (                    )
 gpio-442 (                    )
 gpio-443 (                    )
 gpio-444 (                    )
 gpio-445 (                    )
 gpio-446 (                    )
 gpio-447 (I2C A SDA           )
 gpio-448 (I2C A SCK           )
 gpio-449 (I2C B SDA           )
 gpio-450 (I2C B SCK           )
 gpio-451 (PWM D               )
 gpio-452 (PWM B               )
 gpio-453 (Revision Bit0       )
 gpio-454 (Revision Bit1       )
 gpio-455 (                    )
 gpio-456 (J2 Header Pin35     |onewire@1           ) in  hi    
 gpio-457 (                    )
 gpio-458 (                    )
 gpio-459 (                    )
 gpio-460 (J2 Header Pin36     |onewire@2           ) in  hi    
 gpio-461 (J2 Header Pin31     )
 gpio-462 (                    )
 gpio-463 (                    )
 gpio-464 (                    )
 gpio-465 (TF VDD En           |TFLASH_VDD          ) out lo    
 gpio-466 (J2 Header Pin32     )
 gpio-467 (J2 Header Pin26     )
 gpio-468 (                    )
 gpio-469 (                    )
 gpio-470 (J2 Header Pin29     )
 gpio-471 (J2 Header Pin24     |cs                  ) out hi    
 gpio-472 (J2 Header Pin23     |sck                 ) out lo    
 gpio-473 (J2 Header Pin22     |cs                  ) out hi    
 gpio-474 (J2 Header Pin21     |miso                ) in  hi    
 gpio-475 (J2 Header Pin18     )
 gpio-476 (J2 Header Pin33     )
 gpio-477 (J2 Header Pin19     |mosi                ) out hi    
 gpio-478 (J2 Header Pin16     )
 gpio-479 (J2 Header Pin15     )
 gpio-480 (J2 Header Pin12     )
 gpio-481 (J2 Header Pin13     )
 gpio-482 (J2 Header Pin8      )
 gpio-483 (J2 Header Pin10     )
 gpio-484 (                    )
 gpio-485 (                    )
 gpio-486 (                    )
 gpio-487 (                    )
 gpio-488 (                    )
 gpio-489 (J2 Header Pin11     )
 gpio-490 (                    )
 gpio-491 (J2 Header Pin7      |onewire@0           ) in  hi    
 gpio-492 (                    )
 gpio-493 (                    )
 gpio-494 (                    )
 gpio-495 (                    )
 gpio-496 (                    )

gpiochip0: GPIOs 497-511, parent: platform/c8100000.bus:pinctrl@14, aobus-banks:
 gpio-497 (UART TX             )
 gpio-498 (UART RX             )
 gpio-499 (VCCK En             )
 gpio-500 (TF 3V3/1V8 En       |TF_IO               ) out lo    
 gpio-501 (USB HUB nRESET      |usb-hub-reset       ) out hi    
 gpio-502 (USB OTG Power En    |USB_OTG_PWR         ) out hi    
 gpio-503 (J7 Header Pin2      )
 gpio-504 (IR In               )
 gpio-505 (J7 Header Pin4      )
 gpio-506 (J7 Header Pin6      )
 gpio-507 (J7 Header Pin5      )
 gpio-508 (J7 Header Pin7      )
 gpio-509 (HDMI CEC            )
 gpio-510 (SYS LED             |c2:blue:alive       ) out hi    
 gpio-511 (                    )

After this little script:

#!/bin/sh
echo 475 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio475/direction
echo 0   > /sys/class/gpio/gpio475/value

it says:

gpiochip1: GPIOs 378-496, parent: platform/c8834000.periphs:pinctrl@4b0, periphs-banks:
 gpio-378 (Eth MDIO            )
 gpio-379 (Eth MDC             )
 gpio-380 (Eth RGMII RX Clk    )
 gpio-381 (Eth RX DV           )
 gpio-382 (Eth RX D0           )
 gpio-383 (Eth RX D1           )
 gpio-384 (Eth RX D2           )
 gpio-385 (Eth RX D3           )
 gpio-386 (Eth RGMII TX Clk    )
 gpio-387 (Eth TX En           )
 gpio-388 (Eth TX D0           )
 gpio-389 (Eth TX D1           )
 gpio-390 (Eth TX D2           )
 gpio-391 (Eth TX D3           )
 gpio-392 (Eth PHY nRESET      |mdio-reset          ) out hi    
 gpio-393 (Eth PHY Intc        )
 gpio-394 (HDMI HPD            )
 gpio-395 (HDMI DDC SDA        )
 gpio-396 (HDMI DDC SCL        )
 gpio-397 (                    )
 gpio-398 (eMMC D0             )
 gpio-399 (eMMC D1             )
 gpio-400 (eMMC D2             )
 gpio-401 (eMMC D3             )
 gpio-402 (eMMC D4             )
 gpio-403 (eMMC D5             )
 gpio-404 (eMMC D6             )
 gpio-405 (eMMC D7             )
 gpio-406 (eMMC Clk            )
 gpio-407 (eMMC Reset          |reset               ) out hi    
 gpio-408 (eMMC CMD            )
 gpio-409 (                    )
 gpio-410 (                    )
 gpio-411 (                    )
 gpio-412 (                    )
 gpio-413 (                    )
 gpio-414 (                    )
 gpio-415 (                    )
 gpio-416 (SDCard D1           )
 gpio-417 (SDCard D0           )
 gpio-418 (SDCard CLK          )
 gpio-419 (SDCard CMD          )
 gpio-420 (SDCard D3           )
 gpio-421 (SDCard D2           )
 gpio-422 (SDCard Det          |cd                  ) in  hi    
 gpio-423 (                    )
 gpio-424 (                    )
 gpio-425 (                    )
 gpio-426 (                    )
 gpio-427 (                    )
 gpio-428 (                    )
 gpio-429 (                    )
 gpio-430 (                    )
 gpio-431 (                    )
 gpio-432 (                    )
 gpio-433 (                    )
 gpio-434 (                    )
 gpio-435 (                    )
 gpio-436 (                    )
 gpio-437 (                    )
 gpio-438 (                    )
 gpio-439 (                    )
 gpio-440 (                    )
 gpio-441 (                    )
 gpio-442 (                    )
 gpio-443 (                    )
 gpio-444 (                    )
 gpio-445 (                    )
 gpio-446 (                    )
 gpio-447 (I2C A SDA           )
 gpio-448 (I2C A SCK           )
 gpio-449 (I2C B SDA           )
 gpio-450 (I2C B SCK           )
 gpio-451 (PWM D               )
 gpio-452 (PWM B               )
 gpio-453 (Revision Bit0       )
 gpio-454 (Revision Bit1       )
 gpio-455 (                    )
 gpio-456 (J2 Header Pin35     |onewire@1           ) in  hi    
 gpio-457 (                    )
 gpio-458 (                    )
 gpio-459 (                    )
 gpio-460 (J2 Header Pin36     |onewire@2           ) in  hi    
 gpio-461 (J2 Header Pin31     )
 gpio-462 (                    )
 gpio-463 (                    )
 gpio-464 (                    )
 gpio-465 (TF VDD En           |TFLASH_VDD          ) out lo    
 gpio-466 (J2 Header Pin32     )
 gpio-467 (J2 Header Pin26     )
 gpio-468 (                    )
 gpio-469 (                    )
 gpio-470 (J2 Header Pin29     )
 gpio-471 (J2 Header Pin24     |cs                  ) out hi    
 gpio-472 (J2 Header Pin23     |sck                 ) out lo    
 gpio-473 (J2 Header Pin22     |cs                  ) out hi    
 gpio-474 (J2 Header Pin21     |miso                ) in  hi    
 gpio-475 (J2 Header Pin18     |sysfs               ) out lo    
 gpio-476 (J2 Header Pin33     )
 gpio-477 (J2 Header Pin19     |mosi                ) out hi    
 gpio-478 (J2 Header Pin16     )
 gpio-479 (J2 Header Pin15     )
 gpio-480 (J2 Header Pin12     )
 gpio-481 (J2 Header Pin13     )
 gpio-482 (J2 Header Pin8      )
 gpio-483 (J2 Header Pin10     )
 gpio-484 (                    )
 gpio-485 (                    )
 gpio-486 (                    )
 gpio-487 (                    )
 gpio-488 (                    )
 gpio-489 (J2 Header Pin11     )
 gpio-490 (                    )
 gpio-491 (J2 Header Pin7      |onewire@0           ) in  hi    
 gpio-492 (                    )
 gpio-493 (                    )
 gpio-494 (                    )
 gpio-495 (                    )
 gpio-496 (                    )

gpiochip0: GPIOs 497-511, parent: platform/c8100000.bus:pinctrl@14, aobus-banks:
 gpio-497 (UART TX             )
 gpio-498 (UART RX             )
 gpio-499 (VCCK En             )
 gpio-500 (TF 3V3/1V8 En       |TF_IO               ) out lo    
 gpio-501 (USB HUB nRESET      |usb-hub-reset       ) out hi    
 gpio-502 (USB OTG Power En    |USB_OTG_PWR         ) out hi    
 gpio-503 (J7 Header Pin2      )
 gpio-504 (IR In               )
 gpio-505 (J7 Header Pin4      )
 gpio-506 (J7 Header Pin6      )
 gpio-507 (J7 Header Pin5      )
 gpio-508 (J7 Header Pin7      )
 gpio-509 (HDMI CEC            )
 gpio-510 (SYS LED             |c2:blue:alive       ) out hi    
 gpio-511 (                    )

Hope that one helps.

Edit: output from 4.19.6 stretch build, neweset kernel has console problems as discussed in other thread.

 

 

Link to comment
Share on other sites

1 hour ago, martinayotte said:

It appear normal. So, we don't have clues how it could interfering with I2C ...

Well, fact is, that activating GPIO 475 or 480 (see table above) kills I2C access.

Just checked with the logic analyer: exporting the pin doesn't do any harm, chaning its direction to "out" sets SDA low and leaves SCL high.

 

In more details:

(1) C2 bootet, i2cdetect finds all I2C slaves, I2C accesses are normal on logic analyzer.

(2) exporting 475 doesn't change anything

(3) setting 475 as output sets SDA low and leaves SCL high (pullup or active driven? don't know)

(4) setting 475 as input again releases the SDA line again

(4) I2C works again

steps (3) and (4) can be repeated several times, no changes.

 

So for me it looks like the SDA pin direction is "by chance" set also when accessing GPIO 475.

Same applies for GPIO 480.

 

If I can provide more input, please let me know. I urgently need working GPIO...

 

EDIT: how can I peek/poke registers on the SoC directly? Would be the easiest way to see changes in I/O registers...

EDIT2: busybox is your friend...

Link to comment
Share on other sites

ISSUE SOLVED.

 

I found a really tiny and well hidden solder bridge on a "strategical" point where the I/O lines 475, 480 and SDA came close (and were not insulated by solder stop due to vias).

Using "busybox devmem" I could readback the I/O line states and trace that one back.

Link to comment
Share on other sites

1 minute ago, mboehmer said:

I found a really tiny and well hidden solder bridge on a "strategical" point where the I/O lines 475, 480 and SDA came close (and were not insulated by solder stop due to vias).

Using "busybox devmem" I could readback the I/O line states and trace that one back.

I though it was something like that few hours ago, but I was relucant to post a comment about that seeing the pins were far away of each other on the header ...

Glad you've figured out ! :thumbup:

Link to comment
Share on other sites

Indeed, the readback of input status revealed it in the end. Could have thought of that earlier.

Still, console problem is present, but that's another story.

As well, a "shutdown -h now" allows the C2 to reboot, instead of powering down (which is not a good idea in a system on the sea floor).

Link to comment
Share on other sites

20 minutes ago, mboehmer said:

As well, a "shutdown -h now" allows the C2 to reboot, instead of powering down

The "-h" means "halt" ... Simply use the "reboot" command !

21 minutes ago, mboehmer said:

Still, console problem is present, but that's another story.

I don't remember the issue here, could you restate it ?

 

Link to comment
Share on other sites

On 4/26/2019 at 6:26 PM, martinayotte said:

The "-h" means "halt" ... Simply use the "reboot" command !

I don't remember the issue here, could you restate it ?

 

Simply said, I want to switch off the C2 by "shutdown -h now" - which seems to work when it is powered by the small connector.

If it is powered by +5V pins of expansion port, it doesn't work: it shuts down, enters Uboot and starts again.

For our deep sea operation we need both: powering by expansion port, and switching it off reliably.

The first version of this board (with old kernel, approx. one year ago) did that job, and as there were no changes on powering scheme on my board, I assume that there is some problem with C2 switching off its power.

I think it would be worth checking the AO bank - the "broken" console is there, and the VCCK regulator is being controlled from there. I will try to locate the signal on the PCB and check the signal by scope, in case that helps.

 

EDIT: issue solved. The Odroid C2 doesn't like any voltage applied to GPIOs while it's off. I have two pins which are used to switch a DC/DC converter, in normal operation 3.0V are present there (by 10k0 resistor).

This is sufficient to power some stuff inside the SoC and "boot through" in case of powerdown. Lines cut, and shutdown works as expected.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines