News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Interface ZynqBerry with I2C device

Started by sergio, January 09, 2017, 07:21:38 PM

Previous topic - Next topic

sergio

Hello guys!

I'm new to Vivado and Zynq devices and I'm facing a few problems that I can't get past them.

Right now I want connect an I2C device to the ZynqBerry J8 connector and try to communicate with it from PetaLinux.

My question is: how can I map the I2C MIO pins configured at the Zynq PS on Vivado to specific board ports at the J8 connector (let's say pins 3 and 5)?

I've searched the schematics to try to figure it out if they are automatically connected to something but couldn't reach any conclusion.

Thanks for your help!

Best regards!

sergio

UPDATE

Hello again guys. So this is what I've done.

- Created a new Vivado project targeting my ZynqBerry board model.
- Created a new block design and added the Zynq PS IP block. Run block automation with board preset enabled. Customized the Zynq PS to add I2C at the EMIO pins. Made I2C external.
- Created the hdl wrapper, run the implementation and opened the implemented design.
- At I/O Ports window I chose the J14(PIN 5 of J8 connector) for the iic_0_scl_io and K15 (PIN 3 of J8 connector) for iic_0_sda_io. For both of them made the I/O STD LVCMOS33.
- Re-run the implementation, generated the bitstream and exported the hardware description file.

- Created a new PetaLinux project targeting the new hardware description file.
- Enabled i2c-tools on the rootfs configuration menu and enabled the Xilinx I2C controller at the device drivers on the kernel configuration menu.
- Build the PetaLinux image.
- Booted the board connected to a serial terminal and from there entered the following command: i2cdetect -y -r 0. The response is the following:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
...

Can you guys give me any hint on how to get past this? Is there anything I'm missing in Vivado or PetaLinux? Maybe a device driver or something on the device tree?

Best regards!


Oleksandr Kiyenko

Hello MJ,

To made such project
1. Configure I2C0 as EMIO in ZynqPS
2. Make I2C external
3. Create wrapper for block design
4. Add constraints file *.xdc
with
# GPIO2 J8:3
set_property PACKAGE_PIN K15 [get_ports iic_0_scl_io]
set_property IOSTANDARD LVCMOS33 [get_ports iic_0_scl_io]
# GPIO3 J8:5
set_property PACKAGE_PIN J14 [get_ports iic_0_sda_io]
set_property IOSTANDARD LVCMOS33 [get_ports iic_0_sda_io]
5. Generate bitstream
6. Export hardware
7. Regenerate FSBL
8. Regenerate BOOT.BIN
9. Copy hdf to petalinux
10. petalinux-config --get-hw-description
11. petalinux-build
12. Test with new BOOT.bin and umage.ub

Best regards
Oleksandr Kiyenko

sergio

Hello Oleksandr, thank you for the help.

That is basically what I did.

The output for the i2cdetct -y -r 0 remains the same:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
-- cdns-i2c e0004000.i2c: timeout waiting on completion
...

When i enter i2cdetect -y -r 1 the output is:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --

I believe i2c-1 is connected to the eeprom.
I didn't add anything to my system-top.dts file. Maybe something is missing in my device tree? I checked the system-conf.dtsi file and nothing referes to i2c.

Thanks for the reply!

Oleksandr Kiyenko

Hello MJ,

"timeout waiting on completion" usually mean that you have some problem on bus. Do you have something connected to bus?
J8:3 and J8:5 have pullup resistors, so without any external I2C devices it should show you just empty table.

i2c-1 is connected to clock generator chip with I2C address 0x70.
Usually if you don't want to load drivers for your I2C devices or tune clock speed, you need nothing related to I2C in system-top.dts

Best regards
Oleksandr Kiyenko

sergio

Thank you Oleksandr !

Yes I've been using an AtltIMU breakout board from Pololu and I've also tried with a LSM9DS0 breakout board from Adafruit, both with the same results.

I have also checked with an oscilloscope and both pins are at a 3v3 voltage (J8:3 and J8:5).

When I do not connect anything on those pins the output is the same.

In a previous attempt I changed in Vivado the Pull Type on those pins to pullup to see if it would change anything, but I got the same results.

Maybe is something wrong with the mapping of the pins?

Do I need to include any special drivers in PetaLinux for I2C support or to access the GPIO pins?

Best regards!


Oleksandr Kiyenko

Hello MJ

I just remove GPIO and add external I2C connection to reference project. After rebuild and regenerate FSBL I connect PmodAD2 I2C signals to J8:3 and J8:5
root@petalinux:~# i2cdetect -r -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
So it's working. If you have timeout when nothing connected think that there is pin mappign problem or some project regeneration/reflashing issue.

Best regards
Oleksandr Kiyenko

sergio

Once again thanks for the reply Oleksandr!

Just one question, what do you mean when you say remove GPIO and add external I2C connection to reference project?

Best regards!

Oleksandr Kiyenko

Hello MJ,


In my initial project all pins from J8 was connected to GPIO, so I remove this connection to free pins for I2C.
In constraints file I remove GPIO pin declarations and add I2C for J8:3 and J8:5.

Best regards
Oleksandr Kiyenko

sergio

But that it's not the case on my project. I've created a brand new project targeting my ZynqBerry board and run the block automation option on the Zynq PS IP block.

For what I've seen, nothing is connected on the J8 connector with the board preset option enabled.

The only thing I've changed was the enabling of the I2C 0 bus, selected EMIO and made it external.

My constraints file only has:

set_property IOSTANDARD LVCMOS33 [get_ports iic_0_scl_io]
set_property IOSTANDARD LVCMOS33 [get_ports iic_0_sda_io]
set_property PACKAGE_PIN J14 [get_ports iic_0_scl_io]
set_property PACKAGE_PIN K15 [get_ports iic_0_sda_io]

I really do not know what could be causing the timeout, since i'm doing everything as you've been telling me.

Best regards!

Oleksandr Kiyenko

Hello MJ,

I create and build project from scratch, you can download it at https://conbr.io/d/Dmoq9AJ5

Best regards
Oleksandr Kiyenko

sergio

Hello Oleksandr and thanks for the resources.

I've exported the hardware description file from your project and then created the PetaLinux image from the hardware description file.

However the result is the same.. I still get the timeout.

I must be doing something wrong.
After the petalinux-config --get-hw-description command I configure the Root filesystem type to be SD card.
Then I configure rootfs to enable i2c-tools.
Then I run petalinux-build.
After, I run: petalinux-package --boot  --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/zsys_wrapper.bit --u-boot
Then I run: petalinux-package --image -c rootfs --format initramfs

And copy BOOT.bin and image.ub to the boot partition of an SD card and the rootfs.cpio to the rootfs partition.

The board boots okay but the timeout occurs. I've followed these steps to configure ethernet and everything worked fine in that scenario.

Am I doing something wrong?

I didn't change anything on your Vivado project. I've only exported the hardware description file with the bitstream to Desktop and then copied it to Ubuntu Virtual Machine.

Best regards,
mj

Oleksandr Kiyenko

Hello MJ,

BOOT.bin should be written to Flash. TE0726 boot only from Flash.

Best regards
Oleksandr Kiyenko

sergio

root@i2c:~# i2cdetect -r -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- 1d -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- 6b -- -- -- --
70: -- -- -- -- -- -- -- --

I can't believe I missed TE0726 boots only from Flash.

I've programmed Flash with the BOOT.BIN file and everything is working fine. I've also tried this with my own Vivado projects.

I assume that the board comes pre-programmed with an example project and because of that I've been able to boot the board from the sd card.

I'm sorry to have wasted your time Oleksandr. Your support has been incredible. Thank you so much.

This problem has been solved.

Next stop: SPI. I believe that the process should be very similar.

Best regards,

mj