Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: vainamoinen on February 07, 2025, 11:15:40 AM
-
Hello all,
I'm new to tinyCore, and still discovering a lot of things...
I want to connect to a sensor in I2C, which is connected with a long cable (I know that's not a good practice, but I need this length...)
It first worked with a Raspberry Pi Zero WH. I then changed it to a Raspberry Pi Zero 2 WH. And it's not working anymore.
I suspect that the problem comes from the default speed for I2C bus : I may have increased between those boards, and want the Zero 2 I2C clock speed back to 100kHz, if it's feasible.
Can you give me hints on how to do that ?
I'm using a tinycore13 based OS.
If there is some info that can be useful, I'll be glad to post it here.
Thanks,
Vainamoinen
-
Hi vainamoinen
Welcome to the forum.
If you are using the i2c-bcm2708 driver, this might work:
sudo modprobe -r i2c_bcm2708
sudo modprobe i2c_bcm2708 baudrate=100000
To see if that driver is in use, run:
lsmod
-
Thanks :-)
I executed
[b]tc@pypilot:~$[/b] lsmod
Module Size Used by Not tainted
gpio_ir_recv 16384 0
ir_rc6_decoder 16384 0
brcmfmac 303104 0
brcmutil 20480 1 brcmfmac
cfg80211 798720 1 brcmfmac
rfkill 32768 2 cfg80211
sha256_generic 16384 0
i2c_dev 20480 0
squashfs 40960 83
spidev 20480 4
i2c_bcm2835 16384 0
raspberrypi_hwmon 16384 0
spi_bcm2835 20480 0
zram 28672 1
zsmalloc 28672 1 zram
So I replaced i2c_bcm2708 by the one I've seen in lsmod i2c_bcm2835.
Didn't get any error, so I guess it worked.
But I don't see any improvements in seeing my sensor.
I also tried to remove i2c_bcm2835, and insert in place i2c_bcm2708.
But no more result.
I'll try to find a way to measure the clock with a logic analyzer I have, to check the clock speed.
I will probably not be able to do more test before 2 or 3 days.
-
Hi vainamoinen
I took a look through the i2c drivers and i2c-bcm2708
had baudrate as an optional parameter:
tc@E310:~$ modinfo PiCore/TC14/ARMv7l/Modules7/lib/modules/6.1.68-piCore-v7/kernel/drivers/i2c/busses/i2c-bcm2708.ko.gz | grep "parm:"
parm: combined:Use combined transactions
parm: baudrate:The I2C baudrate
tc@E310:~$
i2c_bcm2835 had no such parameter:
tc@E310:~$ modinfo PiCore/TC14/ARMv7l/Modules7/lib/modules/6.1.68-piCore-v7/kernel/drivers/i2c/busses/i2c-bcm2835.ko.gz | grep "parm:"
parm: clk_tout_ms:clock-stretch timeout (mS)
parm: debug:1=err, 2=isr, 3=xfer
tc@E310:~$
-
The kernel drivers already default to 100000
CONFIG_I2C_BCM2708_BAUDRATE=100000
Raspberry Pi boards do not have a very precise clock rate for i2c. You may need to set it differently. What are you using to driver your board. Most userspace drivers can change the clock rate without having to play with the kernel driver.
-
I guess I should also say that the proper way in raspi to change the clockrate of the kernel drivers is through device-tree.
Which i2c channel are you connected too? arm or videocore?
https://github.com/raspberrypi/linux/blob/fbd8b3facb36ce888b1cdcf5f45a78475a8208f2/arch/arm/boot/dts/overlays/README#L269
https://github.com/raspberrypi/linux/blob/fbd8b3facb36ce888b1cdcf5f45a78475a8208f2/arch/arm/boot/dts/overlays/README#L284
to fallback to the older bcm2708 driver, you also need to do that via device-tree
https://github.com/raspberrypi/linux/blob/fbd8b3facb36ce888b1cdcf5f45a78475a8208f2/arch/arm/boot/dts/overlays/README#L1995
-
Hi,
Thanks for the hints.
It seems that the speed isn't the problem.
I'll explore some other paths.
The library used is RTIMULib. I don't know what I2C library that library use, but I didn't see any I2C clock speed parameter, only for SPI.
I'm using the channel that is out on pins 3 and 5. So I guess it's the ARM one, which is channel 1.
For my personal knowledge, as I'm a beginner, can you specify me some little things ?
Sorry, I'm a bit lost here... I don't know which device-tree modify.
Is it in a i2c specific file ?
Or is there somewhere a general file ?
Thanks for your lights.
-
Read the links I gave you. These settings would go in config.txt on the boot partition
-
I found the config.txt file when reading the SD card, but didn't in ssh exploring.
Thanks !
I found the problem I had : there was no link with I2C configuration on the raspberry, the sensor was dead. After replacing it, it's working well.
Thanks for your help.
-
Hi vainamoinen
I found the config.txt file when reading the SD card, but didn't in ssh exploring. ...
That's because the mmcblk0p1 partition gets unmounted after
you boot because it's not needed while running the operating
system. You can remount it like this:
mount /dev/mmcblk0p1
You should then find config.txt under /mnt/mmcblk0p1.