Page 1 of 1
I2C bitrate
Posted: Wed Nov 23, 2016 10:15 am
by thomasliuchang
Hello everyone,
We used the i2c of RP to control some slave devices. Now, we find out that bitrate of I2C is 400k, which is too fast for our application. Is there a possibility to lower the rate to 100k? Thank you very much!
Best,
Chang
Re: I2C bitrate
Posted: Wed Nov 23, 2016 10:46 am
by pavel
It should be possible by specifying the following Linux kernel boot argument:
Boot arguments can be added by editing the bootargs variable in u-boot.script:
https://github.com/RedPitaya/RedPitaya/ ... oot.script
Re: I2C bitrate
Posted: Wed Nov 23, 2016 11:56 am
by thomasliuchang
Thanks for your fast response.
May I ask you where could I put the boot argument?
I didn't find the patches folder on the SD card. There is a boot.script in the sd card. I open the boot.script.
Code: Select all
setenv high 0x1c000000
setenv fdt_high ${high}
setenv initrd_high ${high}
echo Loading from SD card (FAT file system) to memory
mmcinfo
fatload mmc 0 0x2001000 uImage
fatload mmc 0 0x4000000 devicetree.dtb
echo Booting Linux kernel with ramdisk and devicetree
setenv bootargs console=ttyPS0,115200 root=/dev/mmcblk0p2 ro rootfstype=ext4 earlyprintk rootwait
setenv sdboot bootm 0x2001000 - 0x4000000
setenv bootdelay 0
bootd
I add the argument in the file, but the RP doesn't work anymore.
Could you please give me an example?
Best,
Chang
Re: I2C bitrate
Posted: Wed Nov 23, 2016 12:57 pm
by pavel
I'd add it to the bootargs variable:
Code: Select all
setenv bootargs console=ttyPS0,115200 root=/dev/mmcblk0p2 ro rootfstype=ext4 earlyprintk rootwait cdns-i2c.baudrate=100000
Re: I2C bitrate
Posted: Wed Nov 23, 2016 1:19 pm
by pavel
Correction to my previous posts. Apparently, I was looking at a wrong place and the cdns-i2c driver doesn't have baudrate parameter.
It's still possible to change the rate via the device tree:
- convert devicetree.dtb to devicetree.dts
Code: Select all
dtc -I dtb -O dts -o devicetree.dts devicetree.dtb
- edit devicetree.dts and replace
with
- convert devicetree.dts to devicetree.dtb
dtc -I dts -O dtb -o devicetree.dtb devicetree.dts
Re: I2C bitrate
Posted: Wed Nov 23, 2016 2:09 pm
by thomasliuchang
Hi Pavel,
It works perfectly with the revised devicetree.dtb. Thank you very much!
Best,
Chang