cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
573 Views
Registered: ‎04-07-2014

AXI SPI driver bug in petalinux 2018.2 for 32bit or 16bit wordsize

Dear Xilinx support,

there is most certainly a massive bug in the pointer arithmetic inside the axi_spi's driver for the 2018.2 petalinux kernel. The functions

xspi_read_rx_fifo and xspi_fill_tx_fifo are both using wrong access methods to xqspi->rx_ptr and xqspi->tx_ptr in my opinion.

This results in wrong spi transfers. For TX only the least significant byte is transferred. For RX the buffer will be corrupted.

I attach a proposal for a patch to this post. The patch suggests a minimal change to two lines of the driver. Efficiency could be better when changing the increment behaviour of the loop variable i instead.

Comments are highly welcome.

Leave Kudos if you find this patch useful. At my side I was successfully able to do 32bit spi transfers after applying this patch.

Regards,

Sebastian

4 Replies
Highlighted
Observer
Observer
186 Views
Registered: ‎08-26-2020

Hello,

 

thanks for your post, @sgeorgi_sen ! I have exactly the problem you are describing, sending 32 Bits, but the first 24 Bits are all zeros. After reading lots of posts and trying different things, I hope your post might solve my problem, as I am using Petalinux 2018.2. I am trying to AXI SPI with 

Where can I find spi-xilinx.c file to add your patch? I would really appreciate your help.

 

Best regards

0 Kudos
Highlighted
Explorer
Explorer
168 Views
Registered: ‎04-07-2014

Hi @Nizlas ,

the best way to add the patch to the kernel is the bitbake procedure of petalinux. I assume, that you are in your petalinux project folder:

mkdir -p project-spec/meta-user/recipes-kernel/linux/files
cp spi-xilinx.c.patch project-spec/meta-user/recipes-kernel/linux/files
echo "FILESEXTRAPATHS_prepend := \"\${THISDIR}/files:\"" > project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend
echo "SRC_URI += \"file://spi-xilinx.c.patch\"" >> project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend

then call petalinux-builld. The patch should be applied to the kernel.

I use the same method to add my config options to the kernel build:

cp user_kernel.cfg project-spec/meta-user/recipes-kernel/linux/files
echo "SRC_URI += \"file://user_kernel.cfg\"" >> project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend

The user_kernel.cfg contains lines such as

CONFIG_SPI_SPIDEV=y

and so on.

I hope that helps.

Sebastian

Highlighted
Explorer
Explorer
100 Views
Registered: ‎04-07-2014

Hi @Nizlas ,

has the patch worked?

In this case you could mark the post as accepted solution.

Regards,

Sebastian

0 Kudos
Highlighted
Observer
Observer
81 Views
Registered: ‎08-26-2020

Hi Sebastian,

 

unfortunately the patch did not solve my problem. Not because your patch did not work, but because of another problem.

 

The spi driver I was using handles all messages in 8 bit packages. Therefore I had to change my settings in my IP to 8 Bit, although I am transmitting 32 bit messages. 

 

Anyway, thanks again for your support.

0 Kudos