PYNQ: PYTHON PRODUCTIVITY

I2C setup hang the system

Hi,

pynq is a bit new to me, and I am using ZCU104. I am trying to use the PS’s I2C peripheral, and run the following code on notebook, but it always hang the system. Does anyone know the reason? maybe I am not using the PS’s i2c in a correct way, if so, is there any document and examples on how to use it?

import pynq
import pynq.lib.pmod.pmod_iic as i2c
mb_info = {'ip_name': 'fmch_axi_iic', 'rst_name': 'mb_iop_pmod0_reset', 'intr_pin_name': 'gpio_sws/ip2intc_irpt', 'intr_ack_name': 'mb_iop_pmod0_intr_ack'}
i2c0 = i2c.Pmod_IIC(mb_info, 3, 7, 0x50) ## code hang the system

One thing I noticed that the base address in xparameters.h shows 0x40800000, not 0x00FF020000 shown on register reference.

#define XPAR_IO_SWITCH_0_I2C0_BASEADDR 0x40800000

Hi @stone - could you describe what IIC device you are trying to access and if its external to the board, how that device is physically connected to the board?

Hi,

We are using ZCU104 EVB board, and got J160 connected a customzed i2c device with jumper cables . We are trying to use the PS i2C if it is already supported and linked to the ZCU104 EVB board.

After looking to the schematics of the ZCU104 board, looks like only PS I2C1 is linked out to J160 on the board, and i2c0 is not linked out to board, may you please confirm? but I can see i2c-0 and i2c-1 under /dev.

Another question is how to use the PS I2C directly on Ubuntu with ubuntu image v2.6 provided by xilinx here: PYNQ - Python productivity for Zynq - Board (for zcu104)? should I use the pmod_iic? or Should I call the linux C function pen(), read(), and write() function directly?

last question is how to set the PS i2c speed to 100K or 400K?

Thanks very much

Here’s the jumper cable connection: SCL on J160 pin 6, SDA on J160 pin 8. I run the linux open() and write() to /dev/i2c-1, the open() return file descriptor 3, however the write() return errorno 19 (No Such Device).

Then I probe SCL and SDA on oscilloscope, both pins are pulled to 3.3v by default as expected, but I do not see any signal on oscilloscope when running the open() and write() functions for i2c-1 device.

Appreciate if you could help to analyze what is the possible cause of this problem, thanks.

Hi stone,

You are using a I2C that is connected to the Processing System directly. And the class you are trying to use is for I2C controllers that are in the Programmable Logic. That’s not going to work.

You need to use standard Linux methods to access to that device. You can also try python-periphery if you want to use python.

Mario

Hi Mario,

Thanks for taking a look of the issue. Please ignore my first post which uses pmod I2C which is under PL. I have dropped that method, and instead uses the PS i2c1 with linux /dev/i2c-1, as mentioned in my 2nd and 3rd post.

I wrote some C code and calls linux file operations like open(), read(), and write() directly targets device /dev/i2c-1, but looks like it does not work. After checked the schematics, the PS i2c-1 is confirmed to be routed to PMOD2 (pin 5/6 for scl and 7/8 for sda). Now I am wondering how is the i2c driver built in the linux kernel, may I know where can I find the source code that is used to build the pynq image for zcu104? here’s the link of the image: PYNQ - Python productivity for Zynq - Board. Thanks.

Just a quick update, the PMOD I2C works now, the cause is the mb_info I put in is incorrect, after it’s fixed, the i2c works. But the PS I2C1 still does not work and need to figure out the cause.

petalinux builds the the Linux drivers from the linux-xlnx repository

What are you connecting to J160? I recommend to review the User Guide pages 50 and 51

Latest update. the PS I2C works now, however it’s mapped to /dev/i2c-0, not /dev/i2c-1, that’s weird, from the schematics the i2c-1 is routed out, not i2c-0.