Hi Dave,

It works:

Hi Elias ,

> I need to transfer I2C packets of more than 32 bytes between the gumstix and
> the robostix. The transfer with 32 bytes or less is working fine. I tried to
> figure out where to change the 32 bytes limit following the includes and
> makefiles but no success. So...
>
> 1. Is it possible to transfer bigger than 32 bytes packets between robostix
> and gumstix ?

Yes.

> 2. If so, what config and/or source file changes should I make to transfer
> bigger than 32 bytes packets ?

The current code is using the SMBus protocol which limits packet sizes
to 32 bytes. However, you could write your own i2c driver (on the
robostix) which can allow the transfer of arbitrary sized packets.

You could try modifying the I2C_MAX_DATA_LEN in robostix/Shared/ i2c.h
to create a non-SMBUS compliant version. Note that if you increase the
packet size to something approaching 255 then you'll probably start to
get failures as I belive uint8_t are used in a variety of places.

I haven't tested this so, I'm not sure if it will work or not.
These were the steps followed:

1. Copied i2c.h to my test directories: robostix/gumstix/i2c-bulk and robostix/i2c-bulk so the compiler would find this one before the one in the Shared directory.
2. Copied robostix/gumstix/i2c-io/* into robostix/gumstix/i2c-bulk and modified the original i2c-io.c into i2c-bulk.c. This new program, called i2c-bulk, sends many big packets over i2c calling the  I2cWriteBlock function. The number and size of packets is passed as a command line parameter. At the end the program prints transfer times.
3. Copied robostix/i2c-io/* to robostix/i2c-bulk and renamed i2c-io to i2c-bulk. I could have used the shipped robostix/i2c-io but this way we have the new i2c-bulk and i2c-bulk.hex pair.
4. Modified the I2C_MAX_DATA constant in the copied i2c.h (in both i2c-bulk folders) and set it to 200.
5. Compiled modified robostix/gumstix/i2c-bulk/i2c-bulk
6. Compiled modified robostix/i2c-bulk/i2c-bulk
7. Copied the  i2c-bulk and  i2c-bulk.hex to the gumstix and  i2c  flashed  the  .hex into the  robostix
8. Worked for  packets of 32 or less bytes. Bigger ones generate an error:

Example output: 1000 packets size = 1 byte each:
# i2c-bulk --verbose 0xb Set 1 1000
va a enviar 1000 buffers de 1 bytes
buffer 1000
 1000 bytes en 2408 mseg
       0.00 bytes/seg
#
Example output: 1000 packets size = 10 bytes each:
# i2c-bulk --verbose 0xb Set 10 1000
va a enviar 1000 buffers de 10 bytes
buffer 1000
 10000 bytes en 3192 mseg
      -0.00 bytes/seg
#

Example output: 1000 packets size = 32 bytes each:
# i2c-bulk --verbose 0xb Set 32 1000
va a enviar 1000 buffers de 32 bytes
buffer 1000
 32000 bytes en 5510 mseg
       0.00 bytes/seg
#

Example output:  packet size = 33 bytes :
# i2c-bulk --verbose 0xb Set 33 2
va a enviar 2 buffers de 33 bytes
ERROR: I2cTransfer: ioctl failed: Remote I/O error (121)
ERROR: I2cWriteBlock failed
ERROR: Failed to bulk 2
#

9. Seems like the bootloader is involved... so let check out.  Armed with grep and vi we found a constant  BL_MAX_DATA_BYTES  in robostix/i2c-BootLoader. Copied this folder to i2c-bulk-BootLoader and renamed target files to i2c-bulk-Boot.... in Makefile..  According to the include file comments the ML_MAX_DATA_BYTES constant should be set to the maximum packet size minus 4, so I set it to 196 .
10. make the new i2c bootloader and copied it to the gumstix.
11. Loaded the new i2c bootloader and the the i2c-bulk.hex.

The limitation has moved to 127!!!! And this seems to be, plese correct me if wrong Dave, to the size beeing a uint8_t. I am not sure why. Note that the 128 bytes packet test takes the time of a 1 byte packets test from which we can conclude that the high order bit is beeing masked and the count starts again.

Example output 33 bytes packets:
# i2c-bulk --verbose 0xb Set 33 100
va a enviar 100 buffers de 33 bytes
buffer 100
 3300 bytes en 565 mseg
       0.00 bytes/seg
#

Example output 100 bytes packets:
# i2c-bulk --verbose 0xb Set 100 1000
va a enviar 1000 buffers de 100 bytes
buffer 1000
 100000 bytes en 12655 mseg
      -0.00 bytes/seg
#

# i2c-bulk --verbose 0xb Set 10 10000
va a enviar 10000 buffers de 10 bytes
buffer 10000
 100000 bytes en 32417 mseg
       0.00 bytes/seg
#
Example output 127 bytes packets:
# i2c-bulk --verbose 0xb Set 127 1000
va a enviar 1000 buffers de 127 bytes
buffer 1000
 127000 bytes en 15476 mseg
   0.00 bytes/seg
#

and Example output 127 bytes packets:
# i2c-bulk --verbose 0xb Set 128 1000
va a enviar 1000 buffers de 128 bytes
buffer 1000
 128000 bytes en 2260 mseg
       0.00 bytes/seg
#

So at least we can send packets of up to 127 bytes without going deeper into the modifications of the protocols. It would be great to push it a bit further if possible. Why ? Note the times for 10000 packets of 10 bytes compared to 1000 packets of 100 bytes. It is the same amount of payload data but it is around 2.5 times faster with 100 byte packets.

P.S. I couldn't find the way to printf doubles or floats to print the average bytes per second....

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/



--
Elias Crespin