Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Visitor
ggancio
Posts: 11
Registered: ‎05-13-2010
0

Problem to use SPI on petalinux.

Hi to all, Im trying to use the SPI IP core from the uclinux from petalinux (v0.4).

When the kernel starts it recognizes the SPI device with irq, and get the spi device on /dev/spi0 , but I can´t acces to it from an application.

From the kernel build I chose the Xilinx SPI on Char device and SPI support with bitbang , on device drivers.
The EDK SPI driver is 2.01.b

Some transcripts here.

boot screen:

io scheduler cfq registered (default)
xilinx_spi 0: at 0x8630C000 mapped to 0x8630C000, irq=5
xilinx_spi 1: at 0x88208000 mapped to 0x88208000, irq=6


From command line:

# cat /proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
 10 misc
 89 i2c
 90 mtd
123 xilinx_spi
128 ptm
136 pts
204 ttyUL


# ls -l /dev/spi
/dev/spi0   /dev/spi1
# ls -l /dev/spi*
crw-r--r--    1 root     0        123,   0 Jan  1 00:00 /dev/spi0
crw-r--r--    1 root     0        123,   1 Jan  1 00:00 /dev/spi1


I has been trying with several examples with no succes I only manage to open the device.


# ./spi_1 -D /dev/spi0
can't set spi mode: Inappropriate ioctl for device
Abort


Part of the program.
( I added spidev manually)

..............................
#include <linux/spi/spidev.h>
...................................................
    fd = open(device, O_RDWR);
    if (fd < 0)
        printf("can't open device");


    ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
    if (ret == -1)
        printf("can't set spi mode");

................................................


Oh, and the SPI device works OK from a sample code running directly from the microblaze.


Thanks in advance.

Visitor
ggancio
Posts: 11
Registered: ‎05-13-2010

Re: Problem to use SPI on petalinux.

Problem solved!

 

I was sending 8bits word, and actually I needed 16 bits.....