I2c device speed with sysfs

I would like to change the i2c bus speed in a shell for use with i2ctools. Google found a sysfs device node for i2c bus speed but I do not see one in my file system.

Could you please provide more details about your setup?

  • Module name and HW revision
  • OS Image you are using

Sorry, I should have provided more details.

I’m using the Verdin imx8mp w/ wifi v1.1 on a Dahlia and a boot2qt flavor of yocto. uname -r says


I’m using the I2C_EXT port.

Have you used a Toradex provided OS image or builded your custom one? If you are using a custom image - could you try to reproduce an issue on one of the Toradex provided images?

Well its not an issue, its a lack of understanding. I am asking how to do it. How can I change the i2c bus speed in user space? I don’t have anything to try on this image or a Toradex image. I built the image but per Qt’s recipe and repositories. Tell me how to do it in one of the provided images and I’ll give it a try on the image I am using.

I followed the instructions here

and I was able to build the kernel, u-boot and device tree. It was much easier than I had expected, I’m glad I took the time to go through it. However, the I2C baud has not changed.

I modified the imx8mp-verdin.dtsi by changing the clock-frequency element in &i2c3. I then used the above link to compile the imx8mp-verdin-wifi-daliah.dtb. I checked the date to be sure it did in fact build and also compared it to the original dtb file to make sure it had changed. Comparing the 2 files showed only a few bytes changed which made sense to me. I copied the new dtb file to the /boot directory, rebooted and checked the clock on my scope but no change. I then dug into sysfs and found this

root@b2qt-verdin-imx8mp:/sys/bus/i2c/devices/i2c-3/of_node# hexdump -C clock-frequency
00000000 00 06 1a 80 |…|

which leads me to believe my change had no effect. At this point it could be an issue but probably user error. I’ve eliminated all of the 3rd party software at this point and I am only working with the Toradex repos and documentation.

Could you please verify if you U_Boot FDT_FILE environment variable set to imx8mp-verdin-wifi-daliah.dtb

would I do that by stopping the boot process and running printenv from the U-boot prompt? I did try that and I couldn’t find any variables pointing to any .dtb files. As I mentioned before I am using boot2qt which is a yocto flavor based on your bsp’s. I have a boot directory with the various dtb files but I dont have an overlays directory or an overlays.txt. If that environment variable is not set, where do I set it? Should I create a uEnv.txt in my boot directory?

Hi @rlushster Could you please start logging on debug UART, stop boot at U_boot and run printenv, then attach resulted bootlog.

Verdin iMX8MP # printenv
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefi x}${script}; source ${scriptaddr}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};el se bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootp art} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; then boo tefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontrolad dr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_targets=mmc1 mmc2 usb0 dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=setenv devtype dhcp; run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile} ; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp vci PXEClient:Arch:00011:UNDI:003000;setenv bootp_arch 0xb;if dhcp ${kernel_add r_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdt controladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_a rch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mfg=fastboot 0
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc2=devnum=2; run mmc_boot
bootcmd_usb0=devnum=0; run usb_boot
distro_bootcmd=for target in ${boot_targets}; do run bootcmd
${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix }${efi_fdtfile}
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
preboot=setenv fdtfile imx8mp-verdin-${variant}-${fdt_board}.dtb
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}…; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scrip ts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env ex ists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fs type ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_b oot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes }; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile} ; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpa rt} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/b ootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing…; fi; seten v efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefi x}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boo t_extlinux; echo SCRIPT FAILED: continuing…; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${d evnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${pr efix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing…; fi; done
setup=setenv setupargs console=${console},${baudrate} console=tty1 consoleblank= 0 earlycon
update_uboot=askenv confirm Did you load imx-boot (y/N)?; if test “$confirm” = " y"; then setexpr blkcnt ${filesize} + 0x1ff && setexpr blkcnt ${blkcnt} / 0x200; mmc dev 2 1; mmc write ${loadaddr} 0x0 ${blkcnt}; fi
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boo t_part; fi

Environment size: 4263/8188 bytes

I see it right there at the top after I paste it here.

I tried renaming that file (/boot/-dev.dtb & /boot/-dahlia.dtb) and the system booted with no complaints, is it looking somewhere else for the dtb?

Could you please collect full boot log from debug UART starting from power on and attach it here as a text file?

fullboot.txt (39.5 KB)

I revisited this for the first time today and it appears to be loading /media/mmcblk2p1/imx8mp-verdin-wifi-dev.dtb. When I replaced that file I was unable to boot so hooray! But now I need it to boot the original one while I figure out what is wrong with the one I created. How can I replace that file with a system I can’t boot? I remember seeing a way to mount the MMC so that it appears as a USB flash drive to another machine but I can’t seem to find it now. Is that the way to go or is there another way to access the MMC?

Thank you, that is exactly what I was looking for. However, I remember experimenting with this early on as a way of installing Linux but it wasn’t working. Does this work the same on the Verdin imx8mp? Do I need connect to the other USB port on the Dahlia? Other being the one that doesn’t present 4 com ports to the host.

It also seems like plugging something into either one of those ports causes the system to reboot. I don’t really have a need for it to work any other way but it would be nice if I could get into the system and connect to the com port without losing the current state of the system.

Sorry, I see you already answered my question as to which USB port. I’ll use the OTG port.

I copied the imx8mp-verdin-wifi-dev.dtb file from the board to my computer, decompiled it, changed the I2C clock speed and copied it back to the verdin board. It booted but had no effect on the i2c clock speed. I’m at a loss at this point. Who do I have to pay to get some assistance on this? I’ve probably spent more than a week total trying to figure this out and while I’m a lot smarter I still haven’t gotten any closer to a usable I2C port. And why does it default to 400kHz? I have a hard time believing anyone is getting a clean I2C signal when its connected to an external device. Maybe I2C_EXT isn’t supposed to be used with external devices but it’s named as such so I waste time trying?

Could you please share you decompiled and modified Device Tree sources?
Could you also do a cat /sys/kernel/debug/clk/clk_summary for both Device trees?