Re: [open-lighting] ola spi cubieboard

266 views
Skip to first unread message

Simon Newton

unread,
May 18, 2013, 11:17:56 AM5/18/13
to open-lighting

What do the olad logs say? I'm betting it's a permissions issue.

Simon



On Fri, May 17, 2013 at 1:21 AM, mrdevis <fblat...@gmail.com> wrote:
Hi,

I got ola running on a cubieboard 512 under a 3.076 kernel.
Also I got spi implemented on the board, which comes up as /dev/spidev0.0 ::

[    1.360000] [spi]: sw spi init !!
[    1.360000] [spi]: Found 1 spi devices in config files
[    1.370000] [spi]: boards num modalias         max_spd_hz       bus_num  cs   mode
[    1.390000] [spi]: spi_board0 irq gpio not used
[    1.390000] [spi]: 0          spidev           2000000          0        0    0x0
[    1.410000] [spi]: bus num = 0, spi used = 1
[    1.410000] [spi]: source = sdram_pll_p, src_clk = 480000000, mclk 96000000
[    1.430000] [spi]: allwinners SoC SPI Driver loaded for Bus SPI-0 with 2 Slaves attached
[    1.440000] [spi]: [spi-0]: driver probe succeed, base dc8b8000, irq 10, dma_id 37!

It would be great to make use of the spi plug on ola, but it doesn't show up in the list of plugins available for output.

/var/lib/ola/config/ola-spi.conf::

base_uid = 7a70:00000100
device_prefix = spidev
enabled = true
spidev0.0-dmx-address = 1
spidev0.0-personality = 1
spidev0.0-pixel-count = 25
spidev0.0-spi-speed = 100000

This is the conf used for a Raspi, so I suspect there is another base_uid for a Cubieboard. Is it the base in the last line of the dmesg output? If yes, then how do I write that in the conf/files format of xxxx:xxxxxxxx


Thanks for any directions!!

Jeroen


--
The Open Lighting Group: open-l...@googlegroups.com, #openlighting (irc.freenode.org)
To unsubscribe from this group, send email to open-lightin...@googlegroups.com
For more options, visit https://groups.google.com/groups/opt_out?hl=en
 
 

mrdevis

unread,
May 21, 2013, 6:34:32 AM5/21/13
to open-l...@googlegroups.com
Good bet, /dev/spidev had only root permissions, changed that now to 660 owned by root:olad. Made a little UDEV rule for it which works.

BUT, although I can add SPI output now in ola, the pins (MOSI, SCLK) don't produce anything.

MOSI is (according to my scope and me) stuck to 3.3V, while SCLK sticks to GND. Pins 46 & 47 IIRC.

??

Have an idea??

cheers, jeroen

Simon Newton

unread,
May 21, 2013, 10:40:50 AM5/21/13
to open-lighting
On Tue, May 21, 2013 at 3:34 AM, mrdevis <fblat...@gmail.com> wrote:
Good bet, /dev/spidev had only root permissions, changed that now to 660 owned by root:olad. Made a little UDEV rule for it which works.

BUT, although I can add SPI output now in ola, the pins (MOSI, SCLK) don't produce anything.

Did you patch the output port to a universe?  How are you generating data?

Simon

mrdevis

unread,
May 21, 2013, 11:41:17 AM5/21/13
to open-l...@googlegroups.com
Thanks for getting back!

Yes I did path the spi port to the output, and used this config:


base_uid = 7a70:00000100
device_prefix = spidev
enabled = true
spidev0.0-dmx-address = 1
spidev0.0-personality = 2

spidev0.0-pixel-count = 25
spidev0.0-spi-speed = 100000

using WS2801 individual control

I tried some console actions, which didn't do anything. But even if there is 0 dmx, and no action, the spi port should be giving out 0 dmx right? That is, at least some SCLK ???

best, jeroen

Simon Newton

unread,
May 21, 2013, 11:50:25 AM5/21/13
to open-lighting
On Tue, May 21, 2013 at 8:41 AM, mrdevis <fblat...@gmail.com> wrote:
Thanks for getting back!

Yes I did path the spi port to the output, and used this config:


base_uid = 7a70:00000100
device_prefix = spidev
enabled = true
spidev0.0-dmx-address = 1
spidev0.0-personality = 2
spidev0.0-pixel-count = 25
spidev0.0-spi-speed = 100000

using WS2801 individual control


What does the output of ola_uni_info show?

 
I tried some console actions, which didn't do anything. But even if there is 0 dmx, and no action, the spi port should be giving out 0 dmx right? That is, at least some SCLK ???

No, it'll write 0 once when olad starts and then only when it receives DMX for the universe.

Simon
Message has been deleted

mrdevis

unread,
May 21, 2013, 3:39:54 PM5/21/13
to open-l...@googlegroups.com
Hey,

So I compiled this little spidev_test.c and changed the device to 0,0 with this output:
>$ sudo spitest/a.out
>spi mode: 0
>bits per word: 8
>max speed: 500000 Hz (500 KHz)
>can't send spi message: Invalid argument

last couple of lines when running it in strace:
*******************
set_tls(0x4000f800, 0x4000fed8, 0x40093048, 0x4000f800, 0x4000f138) = 0
mprotect(0x40304000, 8192, PROT_READ)   = 0
mprotect(0x40092000, 4096, PROT_READ)   = 0
munmap(0x4016a000, 18824)               = 0
open("/dev/spidev0.0", O_RDWR)          = 3
ioctl(3, 0x40016b01, 0x111ea)           = 0
ioctl(3, 0x80016b01, 0x111ea)           = 0
ioctl(3, 0x40016b03, 0x111dc)           = 0
ioctl(3, 0x80016b03, 0x111dc)           = 0
ioctl(3, 0x40046b04, 0x111e0)           = 0
ioctl(3, 0x80046b04, 0x111e0)           = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4008d000
write(1, "spi mode: 0\n", 12spi mode: 0
)           = 12
write(1, "bits per word: 8\n", 17bits per word: 8
)      = 17
write(1, "max speed: 500000 Hz (500 KHz)\n", 31max speed: 500000 Hz (500 KHz)
) = 31
ioctl(3, 0x40206b00, 0xbef206c0)        = -1 EINVAL (Invalid argument)
dup(2)                                  = 4
fcntl64(4, F_GETFL)                     = 0x20002 (flags O_RDWR|O_LARGEFILE)
brk(0)                                  = 0x1b1a000
brk(0x1b3b000)                          = 0x1b3b000
fstat64(4, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4013b000
_llseek(4, 0, 0xbef20598, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
write(4, "can't send spi message: Invalid "..., 41can't send spi message: Invalid argument
) = 41
close(4)                                = 0
munmap(0x4013b000, 4096)                = 0
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
gettid()                                = 1994
tgkill(1994, 1994, SIGABRT)             = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
*******************************************************

Is the cubieboard handling spi different in respect to the raspi?


thanks for any directions!

jeroen

Simon Newton

unread,
May 21, 2013, 11:00:15 PM5/21/13
to open-lighting
Can you paste the relevant code where you populate the spi_ioc_transfer struct and call ioctl.


Simon


mrdevis

unread,
May 22, 2013, 7:48:09 AM5/22/13
to open-l...@googlegroups.com
Sure, it is the test program from the kernel tree:

http://www.mjmwired.net/kernel/Documentation/spi/spidev_test.c
Same as the one I used...
50 uint8_t rx[ARRAY_SIZE(tx)] = {0, }; 51 struct spi_ioc_transfer tr = { 52 .tx_buf = (unsigned long)tx, 53 .rx_buf = (unsigned long)rx, 54 .len = ARRAY_SIZE(tx), 55 .delay_usecs = delay, 56 .speed_hz = speed, 57 .bits_per_word = bits, 58 }; 59 60 ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); 61 if (ret < 1) 62 pabort("can't send spi message"); 63 64 for (ret = 0; ret < ARRAY_SIZE(tx); ret++) { 65 if (!(ret % 6)) 66 puts(""); 67 printf("%.2X ", rx[ret]); 68 } 69 puts(""); 70 }

Simon Newton

unread,
May 22, 2013, 11:05:54 AM5/22/13
to open-lighting

That code is working for me on the Pi:

./a.out  -D /dev/spidev0.0 
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 00 00 00 00 
00 00 

Maybe your hardware is different?

Simon

mrdevis

unread,
May 22, 2013, 11:34:42 AM5/22/13
to open-l...@googlegroups.com
Yes it is, that's why I put it in the subject line ;)

greets, jeroen

mrdevis

unread,
May 23, 2013, 4:57:25 AM5/23/13
to open-l...@googlegroups.com
So the relevant portions of the cubieboard.fex config shows:

[spi0_para]
spi_used = 1
spi_cs_bitmap = 1
spi_cs0 = port:PI10<2><default><default><default>
spi_sclk = port:PI11<2><default><default><default>
spi_mosi = port:PI12<2><default><default><default>
spi_miso = port:PI13<2><default><default><default>

[spi_board0]
modalias = "spidev"
max_speed_hz = 2000000
bus_num = 0
chip_select = 0
mode = 0
full_duplex = 0
manual_cs = 0

Is that the normal config for a Cubieboard wanting to drive ws2801??

Thanks!

Simon Newton

unread,
May 24, 2013, 12:02:39 AM5/24/13
to open-lighting
On Thu, May 23, 2013 at 1:57 AM, mrdevis <fblat...@gmail.com> wrote:
So the relevant portions of the cubieboard.fex config shows:

[spi0_para]
spi_used = 1
spi_cs_bitmap = 1
spi_cs0 = port:PI10<2><default><default><default>
spi_sclk = port:PI11<2><default><default><default>
spi_mosi = port:PI12<2><default><default><default>
spi_miso = port:PI13<2><default><default><default>

[spi_board0]
modalias = "spidev"
max_speed_hz = 2000000
bus_num = 0
chip_select = 0
mode = 0
full_duplex = 0
manual_cs = 0

Is that the normal config for a Cubieboard wanting to drive ws2801??

I have no idea.

Simon

mrdevis

unread,
May 24, 2013, 5:49:35 AM5/24/13
to open-l...@googlegroups.com
Pity, thought you had it working.

Thanks anyway,

Jeroen

Alex Nikitenko

unread,
Jun 3, 2014, 8:39:24 AM6/3/14
to open-l...@googlegroups.com
Add this string to your include/linux/spi/spidev.h
struct spi_ioc_transfer {
        __u64           tx_buf;
        __u64           rx_buf;

        __u32           len;
        __u32           speed_hz;

        __u16           delay_usecs;
+      __u16           interbyte_usecs;
        __u8            bits_per_word;
        __u8            cs_change;
        __u32           pad;

        /* If the contents of 'struct spi_ioc_transfer' ever change


пятница, 24 мая 2013 г., 12:49:35 UTC+3 пользователь mrdevis написал:
Reply all
Reply to author
Forward
0 new messages