1

I have troubles with enabling SPI on BBB, ofc followed tutorial from the hipstercircuits.com. I even installed a fresh arch linux to the uSD in case I really messed up system on eMMC.

My settings are:

Since SPI1 has issues with HDMI I disabled anything HDMI related I found. Not sure about fdfile entry though, found it somewhere on the web. (I also tried without it) Currently I'm working on the SD card if that matters.

uEnv.txt

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

I took dts file straight from the hipstercircuits.com and compiled it with alarm/dtc-overlay 1.4.1-1 installed via pacman.

After disabling HDMI in uEnv.txt

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

went ok and I saw:

[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

I also tried echoing BB-SPIDEV0, BB-SPIDEV1 and BB-SPIDEV1A1 found here:

 [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

Result of the spidev_test is always the same.

What is more interesting I didn't see anything about P9_29, P9_31 etc, which are part of SPI1, in 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)

The spidevs are present in /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

To test the interface both python method mentioned in the tutorial and spidev_test.c (spidev_test.c) compiled on the BBB were used.

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

In case of python library there is no error but also nothing at the output - not even a clock signal on the SCL line.

spidev_test returns:

[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)

Do I have to make use of *.dts and *.dtb files provided at the beginning of the hipstercircuit's tutorial?

I probably screwed up sth easy. Any ideas what was it? Did you get it working just like that? All advices are welcome and will be very appreciated! ;)

fpspiter
  • 11
  • 4

2 Answers2

0

I used this .dts and worked fine (both spidev1.0 and spidev1.1 on the spidev_test.c). There are some more lines than in the linux documentation which allow to enable second chip select for being used by SPI1 and properly configure the GPIO on the pin 42.

You should see now the spi pin muxing correctly.

/*
* 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>;
        };
    };
};};
0

I think the problem is the ioctl.h.

When I search for 'iotl.h', the result is as follows,

/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

So there is no corresponding sys/ioctl.h I am trying to find the correct ioctl.h