Beaglebone black(BBB)rev C 3.8.13-38-ARCH SPI不起作用,设备不合适ioctl

时间:2015-01-30 11:31:57

标签: beagleboneblack spi archlinux-arm

我在BBB上启用SPI时遇到麻烦,ofc跟着tutorial from the hipstercircuits.com. 我甚至在uSD上安装了一个新的arch linux,以防我在eMMC上搞乱了系统。

我的设置是:

由于SPI1存在HDMI问题,我禁用了与我相关的任何HDMI相关信息。 不确定fdfile入口,发现它在网络上的某个地方。 (我也试过没有它) 目前我正在使用SD卡。

uEnv.txt

optargs=quiet coherent_pool=1M fdtfile=am335x-boneblack.dtb capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN

我直接从hipstercircuits.com上获取了dts文件,并通过pacman安装了alarm / dtc-overlay 1.4.1-1进行编译。

在uEnv.txt中禁用HDMI后

[root@alarm ~]# echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots

好了,我看到了:

[root@alarm ~]# cat /sys/devices/bone_capemgr.9/slots
 0: 54:PF---
 1: 55:PF---
 2: 56:PF---
 3: 57:PF---
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
 6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
 7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI1-01

我也尝试过回复BB-SPIDEV0,BB-SPIDEV1和BB-SPIDEV1A1:

 [root@alarm spi_a]# ls -l /lib/firmware | grep SPI
    -rw-r--r-- 1 root root    1351 Jan 29 17:04 BB-SPI1-01-00A0.dtbo
    -rw-r--r-- 1 root root    1185 Jan 25 01:06 BB-SPIDEV0-00A0.dtbo
    -rw-r--r-- 1 root root    1185 Jan 25 01:06 BB-SPIDEV1-00A0.dtbo
    -rw-r--r-- 1 root root    1185 Jan 25 01:06 BB-SPIDEV1A1-00A0.dtbo

spidev_test的结果始终相同。

更有趣的是,我没有看到关于P9_29,P9_31等的任何内容,它们是SPI1的一部分,在pingroups中:

[root@alarm ~]# cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups
registered pin groups:
group: pinmux_userled_pins
pin 21 (44e10854)
pin 22 (44e10858)
pin 23 (44e1085c)
pin 24 (44e10860)

group: pinmux_rstctl_pins
pin 20 (44e10850)

group: pinmux_i2c0_pins
pin 98 (44e10988)
pin 99 (44e1098c)

group: pinmux_i2c2_pins
pin 94 (44e10978)
pin 95 (44e1097c)

group: pinmux_mmc1_pins
pin 88 (44e10960)

group: pinmux_emmc2_pins
pin 32 (44e10880)
pin 33 (44e10884)
pin 0 (44e10800)
pin 1 (44e10804)
pin 2 (44e10808)
pin 3 (44e1080c)
pin 4 (44e10810)
pin 5 (44e10814)
pin 6 (44e10818)
pin 7 (44e1081c)

group: pinmux_userled_pins
pin 21 (44e10854)
pin 22 (44e10858)
pin 23 (44e1085c)
pin 24 (44e10860)

spidev存在于/ dev

[root@alarm ~]# ls -l /dev | grep spi
crw------- 1 root root 153,   1 Jan 29 17:13 spidev1.0
crw------- 1 root root 153,   0 Jan 29 17:13 spidev1.1

为了测试接口,使用了教程中提到的python方法和在BBB上编译的spidev_test.c(spidev_test.c)。

[root@alarm ~]# gcc spidev_test.c -o spidev_test

在python库的情况下,输出没有错误,也没有任何错误 - 甚至SCL线上的时钟信号都没有。

spidev_test返回:

[root@alarm spi_a]# ./spidev_test
can't set spi mode: Inappropriate ioctl for device
Aborted (core dumped)
[root@alarm spi_a]# ./spidev_test -D /dev/spidev1.0
can't set spi mode: Inappropriate ioctl for device
Aborted (core dumped)
[root@alarm spi_a]# ./spidev_test -D /dev/spidev1.1
can't set spi mode: Inappropriate ioctl for device
Aborted (core dumped)

我是否必须使用在hipstercircuit教程开头提供的* .dts和* .dtb文件?

我可能很容易搞砸了。有什么想法是什么? 你有这样的工作吗? 欢迎提出所有建议,我们将非常感谢! ;)

2 个答案:

答案 0 :(得分:0)

我使用了这个.dts并且运行良好(spidev1.0和spidev1.1都在spidev_test.c上)。还有一些线路比linux documentation更多,允许SPI1使用第二个芯片选择,并在引脚42上正确配置GPIO。

你现在应该看到spi pin正确复用了。

/*
* Copyright (C) 2013 CircuitCo
*
* Virtual cape for SPI1 on connector pins P9.29 P9.31 P9.30 P9.28
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;

/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";

/* identification */
part-number = "BB-SPI1-01";
version = "00A0";

/* state the resources this cape uses */
exclusive-use =
    /* the pin header uses */
    "P9.31",    /* spi1_sclk */
    "P9.29",    /* spi1_d0 */
    "P9.30",    /* spi1_d1 */
    "P9.28",    /* spi1_cs0 */
        "P9.42",    /* spi1_cs1 */
    /* the hardware ip uses */
    "spi1";

fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
        /* default state has all gpios released and mode set to uart1 */
        bb_spi1_pins: pinmux_bb_spi1_pins {
            pinctrl-single,pins = <
                0x190 0x33  /* mcasp0_aclkx.spi1_sclk,  INPUT_PULLUP | MODE3 */
                0x194 0x33  /* mcasp0_fsx.spi1_d0,      INPUT_PULLUP | MODE3 */
                0x198 0x13  /* mcasp0_axr0.spi1_d1,     OUTPUT_PULLUP | MODE3 */
                0x19c 0x13  /* mcasp0_ahclkr.spi1_cs0,      OUTPUT_PULLUP | MODE3 */
                0x164 0x12  /* eCAP0_in_PWM0_out.spi1_cs1   OUTPUT_PULLUP | MODE2 */
                0x1A0 0x32  /* Other P42 pin, INPUT_PULLUP */
            >;
        };
    };
};

fragment@1 {
    target = <&spi1>;   /* spi1 is numbered correctly */
    __overlay__ {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&bb_spi1_pins>;

        #address-cells = <1>;
        #size-cells = <0>;

        spi1_0{
            #address-cells = <1>;
            #size-cells = <0>;

            compatible = "spidev";

            reg = <0>;
            spi-max-frequency = <16000000>;
        };


        spi1_1{
            #address-cells = <1>;
            #size-cells = <0>;

            compatible = "spidev";

            reg = <1>;
            spi-max-frequency = <16000000>;
        };
    };
};};

答案 1 :(得分:0)

我认为问题是ioctl.h。

当我搜索'iotl.h'时,结果如下,

/usr/include/arm-linux-gnueabihf/sys/ioctl.h
/usr/include/arm-linux-gnueabihf/asm/ioctl.h
/usr/include/linux/ioctl.h
/usr/include/linux/hdlc/ioctl.h
/usr/include/linux/mmc/ioctl.h
/usr/include/asm-generic/ioctl.h

所以没有相应的sys / ioctl.h 我想找到正确的ioctl.h