UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer tnjames
Observer
3,501 Views
Registered: ‎07-08-2013

u-boot zynq_i2c.c I2C driver flaky when reading large numbers of bytes

In case it helps anyone else, we have been trying to use an I2C EEPROM to store our Zynq u boot environment but struggled with the checksum occasionally failing after reset.  After trying a few things it appears that with the stock zynq_i2c.c driver chunks of data are routinely lost when reading large numbers of bytes from the I2C bus. 

 

We didn't fully figure out what the main while loop in zynq_i2c_read() was trying to do but it didn't appear to bear a huge resemblance the the polled example given in the TRM so we reimplemented it rom where the read FIFO is reset based on the TRM example and, touchwood, it now seems to work reliably. We haven't tried writing lots to the I2C bus so I can't comment on whether the write suffers a similar problem.

 

Our patch file to update zynq_i2c_read() is attached in case it is of use. We were using u-boot as downloaded from the master Xilinx git hub 14th April 2014.

0 Kudos
5 Replies
Visitor rocco.brandi
Visitor
2,398 Views
Registered: ‎07-22-2015

Re: u-boot zynq_i2c.c I2C driver flaky when reading large numbers of bytes

Hi,

how did you manage to access I2C EEPROM from U-boot?

 

Regards,

Rocco

0 Kudos
Observer tnjames
Observer
2,389 Views
Registered: ‎07-08-2013

Re: u-boot zynq_i2c.c I2C driver flaky when reading large numbers of bytes

Hi Rocco

 

From the U-Boot command prompt you can access I2C EEPROM devices using the i2c command (type help i2c for more info).

 

To enable I2C support we added the following to the configuration header file (eg, zynq_zc70x.h) used when building U-Boot:

 

/* Describe 8KB system EEPROM */
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x51 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 /* uses two-byte ROM address */ #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 5 /* supports 32-byte page writes */ #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 /* datasheet says 5 ms - double to be safe */ #define CONFIG_SYS_EEPROM_SIZE (8 * 1024) /* Bytes */ #ifndef CONFIG_SYS_DEF_EEPROM_ADDR #define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR #endif #ifndef CONFIG_CMD_EEPROM #define CONFIG_CMD_EEPROM #endif

If you mean how do you use an EEPROM to store the U-Boot environment then we added the following to the configuration header file used when building U-Boot:

 

/* Store the Environment in first 5 KB of the I2C EEPROM */
#define CONFIG_ENV_IS_IN_EEPROM
#define CONFIG_ENV_EEPROM_IS_ON_I2C
#define CONFIG_ENV_SIZE (5 << 10)
#define CONFIG_ENV_OFFSET 0
#define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE
#ifndef CONFIG_CMD_SAVEENV
   #define CONFIG_CMD_SAVEENV
#endif

Note that the more recent versions of U-Boot seem to replace the configuration header file with a .config file and to be honest we've not managed to get the latest version of U-Boot working with our hardware yet so I cannot comment on whether the above is still applicable.

 

Hope this is of some help

 

Tim

0 Kudos
Visitor rocco.brandi
Visitor
2,380 Views
Registered: ‎07-22-2015

Re: u-boot zynq_i2c.c I2C driver flaky when reading large numbers of bytes

Hi Tim,

thank you for your help.

 

I have seen that I2C support is enabled in zynq-common.h (line 186):

 

#define CONFIG_SYS_I2C_ZYNQ
/* I2C */
#if defined(CONFIG_SYS_I2C_ZYNQ)
# define CONFIG_CMD_I2C
# define CONFIG_SYS_I2C
# define CONFIG_SYS_I2C_ZYNQ_SPEED 100000
# define CONFIG_SYS_I2C_ZYNQ_SLAVE 0
#endif

 

zynq-common.h is included in zynq_zc70x.h file. but it seems that when I build u-boot through petalinux, the configuration header file zynq_zc70x.h is replaced by platform-top.h file that contains only the enviroment settings.

 

here the line from the verbose (in red the specific command):

 

[ALL  ] if [ -f "/home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/subsystems/linux/configs/u-boot/platform-top.h" ]; then rsync "/home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/subsystems/linux/configs/u-boot"/*.h "/home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/build/linux/u-boot/src/u-boot-plnx_ORIG/include/configs"/; mv "/home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/build/linux/u-boot/src/u-boot-plnx_ORIG/include/configs/platform-top.h"  "/home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/build/linux/u-boot/src/u-boot-plnx_ORIG/include/configs/zynq_zc70x.h"; fi 

 

after that, the configuration files are called :

 

[INFO ] generate linux/u-boot configuration files

[ALL ] make O=/home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/build/linux/u-boot/u-boot-plnx_ORIG -C /home/user/petalinux_projetcs/Software_337/Software/zynq/dtx_a350/build/linux/u-boot/src/u-boot-plnx_ORIG -j2 zynq_zc70x_config || exit 255

 

but where are the settings from the configuration header files if they have been replaced?

 

Thanks,

Rocco

 

P.S.: I have attached all the log for building u-boot

 

0 Kudos
Observer tnjames
Observer
2,374 Views
Registered: ‎07-08-2013

Re: u-boot zynq_i2c.c I2C driver flaky when reading large numbers of bytes

Hi Rocco

 

I'm not sure I can really provide and further assistance as we did not use petalinux to build U-Boot.  Instead we took a snapshot of the U-Boot source from Xilinx Github and built U-Boot using the make file that came with it.  Like I said the way in which U-Boot is now configured seems to have changed significantly from when we got it to build (which was over a year ago) as it now has a menuconfig/.config file front end instead of custom header files and make <configname> method of building it.  We tried briefly to build a more recent version of U-Boot for our target without a huge amount of success so decided to stick with what we had for the time being.

 

Tim

0 Kudos
Explorer
Explorer
2,350 Views
Registered: ‎10-14-2015

Re: u-boot zynq_i2c.c I2C driver flaky when reading large numbers of bytes

just to let you know,

I have managed to enable I2C in U-boot.

 

I have noticed that zynq_zc70x.h is replaced by platform-top.h

this file is stored in <$PETALINUX-PROJECT-DIRECTORY>/subsystems/linux/configs/u-boot.

so I have added  the following settings from file <$U-BOOT-SOURCE-DIRECTORY>/include/configs/zynq-common.h to file  <$PETALINUX-PROJECT-DIRECTORY>/subsystems/linux/configs/u-boot/platform-top.h:

 

#define CONFIG_SYS_I2C_ZYNQ
/* I2C */
#if defined(CONFIG_SYS_I2C_ZYNQ)
# define CONFIG_CMD_I2C
# define CONFIG_SYS_I2C
# define CONFIG_SYS_I2C_ZYNQ_SPEED  100000
# define CONFIG_SYS_I2C_ZYNQ_SLAVE  0
#endif

 

and it worked! Of course to have acces to the I2C buses, the bitsream file must be loaded before u-boot.

 

 

Best Regards,

Rocco

0 Kudos