1

I've been modifying the low-level driver for I2C on the Raspberry Pi 2. But after not seeing much effect after recompilation and deploy, I'm wondering if I'm actually editing the correct source file.

I can confirm that I'm am writing to I2C-1 bus with a scope. I'm messing around with some of the registers on the BSC from the source code, and it doesn't seem to be taking effect.

This is the file I have been editing, changing some register writes in a function such as 'bcm2708_bsc_setup(struct bcm2708_i2c *bi)':

linux/drivers/i2c/busses/i2c-bcm2708.c

When I use the I2C driver, I am calling IOCTL from C code in userspace on "i2c-1".

Edit There is also a source file: linux/drivers/i2c/busses/i2c-bcm2835.c in the same directory.

Can someone confirm this is the correct source file for the Broadcom BSC I2C peripheral on the Raspberry Pi 2?

  • You're compiling and then loading the module directly right? That should not leave any doubt... – goldilocks May 1 '15 at 17:57
  • I'm installing modules to sd card according to this: raspberrypi.org/documentation/linux/kernel/building.md and I've set raspi-config to load i2c on start. – gtozzi May 1 '15 at 18:50
  • You only need to build the kernel once, then you can keep re-building just your module and trying to load it over and over again w/ the kernel running -- no reboot. Keep in mind that when you are searching for information about this stuff, you are poking your eyes out if you include the term "raspberry pi" in your search. That's irrelevant. It's the linux kernel, it has been around for decades, it is running right now on hundreds of millions of machines worldwide. You are tinkering with an LKM. Use both eyes, no masochism ;) – goldilocks May 1 '15 at 19:37
  • Thanks for the tip on module loading. I don't think I'm poking my eyes out; the question is in regards to I2C driver source for RPi2. – gtozzi May 1 '15 at 20:15
  • >_< Okay, but WRT compiling, loading, and unloading a linux LKM, it is not special. You do not have to depend upon raspi-config for this. Part of my point is that I and other people who might have the knowledge to explain this stuff to you are not going to bother because it has all been explained elsewhere already if you look with your eyes properly. But if you believe you know better than I do, then just ignore me. If you alter the source, compile it, and load it directly, then, once again: where's the doubt? Have you looked at dmesg when you load it? Etc. These are all basic things. – goldilocks May 1 '15 at 20:19
1

drivers/i2c/busses/i2c-bcm2708.c looks correct to me. Authors Chris Boot and Frank Buss.

It's got the strange combined module parameter for repeated starts.

Perhaps you could add a dummy parameter and check that it's present in the loaded module with sudo modinfo i2c-bcm2708 or add a printk or two.


EDITED TO ADD

modinfo i2c-bcm2708
filename:       /lib/modules/3.18.7-v7+/kernel/drivers/i2c/busses/i2c-bcm2708.ko
alias:          platform:bcm2708_i2c
license:        GPL v2
author:         Chris Boot <bootc@bootc.net>
description:    BSC controller driver for Broadcom BCM2708
srcversion:     0ACD78A7932FB3F3042F78B
alias:          of:N*T*Cbrcm,bcm2708-i2c*
depends:        
intree:         Y
vermagic:       3.18.7-v7+ SMP preempt mod_unload modversions ARMv7 
parm:           baudrate:The I2C baudrate (uint)
parm:           combined:Use combined transactions (bool)
  • You can load modules from outside /lib/modules directly, e.g., insmod ~/test/i2c-bcm2780.ko (you need the .ko if you are using a specific path), as long as they are compatible with the running kernel. – goldilocks May 1 '15 at 17:59
  • I've tried printks and I'm not seeing them anywhere (I've echoed "7" to /proc/sys/kernel/printk also). I also noticed that there is a "i2c-bcm2835.c" in the same directory. I tried adding printk in there as well but I'm not getting anything. Do you know what the difference between the bcm2708 and bcm2835 source file is (why are there two separate drivers for the same peripheral)? – gtozzi May 1 '15 at 18:48
  • @gtozzi bcm2835.c looks like an unsuccessful attempt to write an I2C driver for all variants of the bcm 2835 SOC. See edited post for the used modules modinfo. – joan May 1 '15 at 19:06
  • @gtozzi This is certainly the correct answer. Yes, you are working on the right file. As to why you are not getting the compiled module loaded properly is a somewhat different question. – goldilocks May 1 '15 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.