lixiaoming90 发表于 2012-2-18 19:50:21

Linux3.0.1中源码中spidev_test.c编译出错

想测试一下内核的SPI驱动,可是连内核自带的测试程序怎么编译都编译不过,
# arm-linux-gcc spidev_test.c -o spidev_test
出现一下错误:
spidev_test.c: In function 'parse_opts':
spidev_test.c:145: error: 'SPI_NO_CS' undeclared (first use in this function)
spidev_test.c:145: error: (Each undeclared identifier is reported only once
spidev_test.c:145: error: for each function it appears in.)
spidev_test.c:148: error: 'SPI_READY' undeclared (first use in this function)
大家是怎么编译的呢?

lixiaoming90 发表于 2012-2-19 10:21:33

大家都可以编译成可执行性文件?

飞凌-fatfish 发表于 2012-2-19 11:28:12

SPI_NO_CS' undeclared (first use in this function)
这里说没有声明,找找这个定义在哪个头文件里。

lixiaoming90 发表于 2012-2-19 12:21:40

在include/linux/spi/spidev.h中声明了
#define SPI_NO_CS                0x40
#define SPI_READY                0x80

lixiaoming90 发表于 2012-2-19 12:55:10

我把
#define SPI_NO_CS                0x40
#define SPI_READY                0x80
复制到在spidev_test.c中声明后编译过了,将开发板的USER IO中SPIMISO和SPIMOSI短接,在开发板注册
#mknod /dev/spidev1.1 c 1 1
#chmod 777 spidev_test
#./spidev_test
又出现以下错误:
can't set spi mode: Inappropriate ioctl for device
Aborted

飞凌-fatfish 发表于 2012-2-20 08:55:23

can't set spi mode: Inappropriate ioctl for device
看看哪里打印了这个信息,继续调试

i52011 发表于 2014-3-25 20:24:27

页: [1]
查看完整版本: Linux3.0.1中源码中spidev_test.c编译出错