The Pi in question is a B from a few years ago, I believe made by RS. I've soldered pins onto what is usually referred to as the P5 header but is labelled P6 on my board.
Using the latest kernel (4.1.11+) and firmware (from https://github.com/raspberrypi/firmware), and this in `config.txt`:
Code: Select all
dtparam=i2c=on
dtparam=i2c0=on
- Removing the `i2c0` line to just enable i2c-1.
- Disabling device tree (`device_tree=`) and using the old method of inserting the i2c-dev module.
I'm sure at some point device tree did work with a stock kernel, at least for i2c-1. However, it is i2c-0 that's important to me.
The last kernel that will work (same firmware) is 3.17.7; I compiled this with the I2C module built-in and currently it boots with both `/dev/i2c-1` and `/dev/i2c-0` listed, although the later doesn't really work: `i2cdetect 0` will probe, but show nothing connected until I enable the alt functions.
Code: Select all
#include <bcm2835.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void on () {
bcm2835_gpio_fsel(0, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_fsel(1, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_ALT0);
bcm2835_gpio_set_pud(28, BCM2835_GPIO_PUD_UP);
bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_ALT0);
bcm2835_gpio_set_pud(29, BCM2835_GPIO_PUD_UP);
}
int main (void) {
bcm2835_init();
on();
bcm2835_close();
return 0;
}