Hi,
We have building petalinux on our TE0720 board and want to run spi example program but it freeze during sending first message.
Our dts file:
&axi_quad_spi_0 {
clock-names = "ref_clk","pclk";
clocks = <&clkc 26>,<&clkc 35>;
compatible = "xlnx,xps-spi-2.00.a";
interrupts = <0 33 1>;
interrupt-parent = <&intc>;
num-cs = <0x3>;
status = "okay";
reg = <0x41e00000 0x10000>;
spidev0:spidev@0{
compatible = "spidev";
reg = <0>;
spi-max-frequency= <3125000>;
};
spidev1:spidev@1{
compatible = "spidev";
reg = <1>;
spi-max-frequency= <3125000>;
};
spidev2:spidev@2{
compatible = "spidev";
reg = <2>;
spi-max-frequency= <3125000>;
};
};
static void transfer(int fd)
{
int ret;
uint8_t tx[] ={0x80};
uint8_t rx[1];
struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = (unsigned long)rx,
.len = ARRAY_SIZE(tx),
.delay_usecs = delay,
.speed_hz = 0,
.bits_per_word = 0,
};
ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); // -->the program freeze here
if (ret == 1)
pabort("can't send spi message");
}
Where the problem can be? Vivado schem is OK. We think that can be a device tree problem but no idea
it is always better to check out that the peripheral actually works using the debugger or standalone test application. If that is proven working then proceed to linux testing.
Standalone application works fine. We have a problem with linux app which freeze on the ioctl function
then try with the linux user space spi tool first before writing own code
or use devmem to check that the axi address is at least responding
Devices are found correctly:
root@zynq:~# ls -al /dev/spi*
crw-rw---- 1 root root 153, 0 Jan 1 00:00 /dev/spidev0.0
crw-rw---- 1 root root 153, 1 Jan 1 00:00 /dev/spidev0.1
crw-rw---- 1 root root 153, 2 Jan 1 00:00 /dev/spidev0.2
But when we try to send sth linux freeze.
echo abc > /dev/spidev0.0
We have to restart linux because the ctrl-c doesn't help.
The same problem is using ioctl function in c code
The irq in device tree is correct? Why spi can't end the transmission
did you test that the device axi address is correct?
if you read with devmem?
erm..
why are you using AXI_SPI ? and not the Zynq PS SPI? In the later case you need no IP Cores at all.. just route via emio and done
Ok, but we need to have spi with 3 slaves. In PS SPI we couldn't find how to config number of slaves
Hi,
go on "MIO Configuration" and select the SPI-Core (SPI 0 or SPI 1). You can use up to 3 SS IOs.
br
John
in decoded mode up to 8 Chip selects are available with PS SPI