Working with Xilinx's AXI Quad SPI in Linux? Streamline Your Setup with This Simple Fix

Last week, our dev team was knee-deep in a project integrating Xilinx's AXI Quad SPI IP into a Petalinux system. Everything seemed to be in order, but they kept hitting a wall when trying to configure the SPI device. After hours of troubleshooting, and a few dips into linux kernel driver debug features (more on this on future posts!), they finally stumbled upon a simple solution that saved the day!.

If you're experiencing similar frustrations, read on – this post might just be the answer you're looking for."

While integrating Xilinx's AXI Quad SPI IP into a Linux environment (like Petalinux), you might encounter a hiccup where calls to the spidev functions for device configuration mysteriously fail, specially using the soft SPI IP configured with more than the default 8 bits per word. In our case, 16 bits per word transactions.

You've likely double-checked your device tree, verified connections, and scoured forums, but the solution remains elusive. Don't worry, you're not alone!

The fix is surprisingly straightforward. The issue lies in the order of operations when configuring the device. The Xilinx driver registers the device with a bits-per-word value from the device tree, but the initial configuration of the SPI device on Linux doesn't incorporate this information.

The Solution:

  1. Before configuring the device mode, ensure you reconfigure the bits per word using the ioctl function with SPI_IOC_WR_BITS_PER_WORD.
  2. Then, proceed with configuring the device mode as usual.

With this simple adjustment, you'll see your data flowing smoothly through the AXI Quad SPI!

Share this Solution:

If this post helped you, please share it with your colleagues who might also be working with this setup! Feel free to leave a comment if you have any other questions or tips.

#Xilinx #AXIQuadSPI #Linux #Petalinux #EmbeddedSystems #FPGA