Skip to contentSkip to conversation

i2c-dev cross-compile error

DISCUSSION Roberto Marino 2 participants 2 messages Jan 2, 2008 – Jan 3, 2008 1 message not in the archive I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

Hi all,
I've a problem with i2c-dev on arm.
I'm trying to cross-compile i2c-dev example (Documentation/i2c/dev-interface) for arm passing these arguments to cross-compiler

arm-linux-gcc-3.4.1 -I/usr/local/arm/3.4.1/arm-linux/include -O2 prova_max1363.c -o prova_max1363

The error is this (too long to paste completely):
-------------------------
In file included
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:12,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/i2c.h:31,

                 from prova_max1363.c:1:

/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/jiffies.h:16: error: parse error before "jiffies_64" /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/jiffies.h:20: error: parse error before "get_jiffies_64" In file included
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:18,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/i2c.h:31,

                 from prova_max1363.c:1:

/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:18: error: parse error before "wait_queue_head_t" /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h: In function `sema_init':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:46: error: dereferencing pointer to incomplete type /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:47: error: dereferencing pointer to incomplete type /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:48: error: dereferencing pointer to incomplete type /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h: In function `sema_count':
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/semaphore.h:66: error: dereferencing pointer to incomplete type In file included
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/signal.h:4,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:25,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/i2c.h:31,

                 from prova_max1363.c:1:

/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/list.h:682:2: warning: #warning "don't include kernel headers in userspace" In file included
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm/siginfo.h:4,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/signal.h:7,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:25,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/i2c.h:31,

                 from prova_max1363.c:1:

/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/siginfo.h: At top level:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/asm-generic/siginfo.h:58: error: size of array `_pad' is too large In file included
from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/sched.h:29,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/module.h:10,

from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/i2c.h:31,

                 from prova_max1363.c:1:

-----------------------------

This is the source, any idea? :

#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define I2C_SLAVE 0x0703 /* Change slave address */

int main(void)

{
        int file;
        int adapter_nr = 0;
        char filename[20];
        int addr = 0x34;
        char command[3];
        char buf[3];

        sprintf(filename,"/dev/i2c-%d", adapter_nr);

        if ((file = open(filename,O_RDWR)) < 0) {
                printf("Open error\n");
                /* ERROR HANDLING; you can check errno to see what went
wrong */
                exit(1);
        }

        if (ioctl(file,I2C_SLAVE,addr) < 0) {
                printf("ioctl error");
                /* ERROR HANDLING; you can check errno to see what went
wrong */
                exit(1);
        }

        command[0] = addr;
        buf[1] = 0x61;
        buf[2] = 0xd0;
        if ( write(file,buf,3) != 3) {
                printf("Write error");
        }
        /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */
        if (read(file,buf,2) != 2) {
                /* ERROR HANDLING: i2c transaction failed */
        } else {
                /* buf[0] contains the read byte */
                printf("%c, %c", buf[0],buf[1]);
	}
	return 0;
}
Signature · 7 lines
(o_     Roberto (aka formica) Marino
//\     Computer Engineering Student
V_/_    Free Software User - Me|Lug Member
        keyID = 641AE37D on pgp.mit.edu

Per favore non mandatemi allegati in Word o PowerPoint.
Si veda http://www.gnu.org/philosophy/no-word-attachments.html
#2 lore raw
In reply to a message not in the archive

Hi Roberto,

Quoted 8 lines · Roberto Marino

I've a problem with i2c-dev on arm.
I'm trying to cross-compile i2c-dev example (Documentation/i2c/dev-interface) for arm passing these arguments to cross-compiler

arm-linux-gcc-3.4.1 -I/usr/local/arm/3.4.1/arm-linux/include -O2 prova_max1363.c -o prova_max1363

Quoted 8 lines

The error is this (too long to paste completely):
(...)
-----------------------------

This is the source, any idea? :

#include <linux/i2c.h>
#include <linux/i2c-dev.h>

You are not supposed to include i2c.h from user-space. You should only include i2c-dev.h, and this should be the one that is shipped in the i2c-tools [1] package, NOT the one in the kernel tree.

I know that this is error-prone (although it _is_ explained in the document you mentioned) and that's one thing I intend to fix in the course of year 2008.

[1] http://www.lm-sensors.org/wiki/I2CTools

Quoted 6 lines

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
(...)

--
Jean Delvare