Welcome, Guest

Author Topic: I2C  (Read 4442 times)

koennie

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
I2C
« on: October 31, 2012, 01:18:59 PM »
Hi all,

I want to work with I2C. But I am having problems accesing the I/O pins.
Code: [Select]
root@olinuxino:~# ./i2c -w 0 0x48 1 0x00
SLAVE ADDRESS: 0x48
NUMBER OF BYTES TO WRITE: 1
MEMORY ALLOCATED AT ADDRESS: 0x12008
Failed to open control file: No such file or directory
/dev/i2c-0 --> root@olinuxino:~#

It seems I have to enable /dev/i2c-0 somehow...
Can anyone help me?

Thanx

olimex

  • Administrator
  • Hero Member
  • *****
  • Posts: 813
  • Karma: +22/-3
Re: I2C
« Reply #1 on: October 31, 2012, 01:26:43 PM »

koennie

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: I2C
« Reply #2 on: October 31, 2012, 01:39:23 PM »
Currently working with Open Embedded generated Kernel 2.6.35

The rootfs I have tried the pre compiled debian and TV-concole enabled from Dimitar.
I also compiled my own with open embedded.

On all of these: /dev/i2c-0 seems to be missing.

I have checked the I2C pins on the uext connector as described in the nunchuck tutorial.

koennie

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: I2C
« Reply #3 on: October 31, 2012, 05:34:15 PM »
The problem might be the fact that I compiled the program on my host PC
So the executable runs but doesn't have the right dependencies.

I would like to compile the program on the olinuxino, how can I enable GCC there?

Thanx

jlumme

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +1/-1
Re: I2C
« Reply #4 on: November 01, 2012, 10:19:14 AM »
With "file" command, you can always see the type of the executable.
Indeed, you do need to either a) cross-compile your program b) get compiler on your distribution you are using on the olinuxino, and compile there.

If you are using a debian based distribution, such as Ubuntu, you can get arm compiler with this:
Code: [Select]
sudo apt-get install gcc-arm-linux-gnueabiIf your package manager doesn't have one, you can always compile one for yourself, you can find instructions for that around..

After that you need to compile your program with passing the cross compiling prefix to make:
Code: [Select]
make ARCH=arm CROSS_COMPILE=gcc-arm-linux-gnueabi- *your_normal_make_stuffs*

koennie

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: I2C
« Reply #5 on: November 01, 2012, 12:37:22 PM »
Thanx, I already compiled the program with arm-linux-gcc.
This way the executable works, but /dev/i2c-0 can't be found.

The problem is I have to build the program on the olinuxino, because that way i2c will be enabled there.

I have tried installing arm-linux-gcc on the sd card but this didn't seem to work.
It is described in the MOD-IO2 README.pdf:
First you must compile the i2c-tool:
Code: [Select]
# gcc i2c-tool.c -o i2c-tool
I just can't seem to find any instructions on how to enable gcc on the olinuxino...

olimex

  • Administrator
  • Hero Member
  • *****
  • Posts: 813
  • Karma: +22/-3
Re: I2C
« Reply #6 on: November 01, 2012, 01:36:58 PM »
if you use the Arch Linux image you will have I2C and GCC :-)

koennie

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Re: I2C
« Reply #7 on: November 01, 2012, 02:26:54 PM »
Thanks!