HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • GM-3568JHF

    • 1. Introduction

      • GM-3568JHF Introduction
    • 2. Quick Start

      • 01 Environment Construction
      • 02 Compilation Instructions
      • 03 Burning Guide
      • 04 Debugging Tools
      • 05 Software Update
      • 06 View information
      • 07 Test Command
      • 08 Application Compilation
      • 09 Source code acquisition
    • 3. Peripherals and Interfaces

      • USB
      • Display and touch
      • Ethernet
      • WIFI
      • Bluetooth
      • TF-Card
      • Audio
      • Serial Port
      • CAN
      • RTC
    • 4. Application Development

      • 01 UART read and write case
      • 02 Key detection case
      • 03 LED light flashing case
      • 04 MIPI screen detection case
      • 05 Read USB device information example
      • 06 FAN Detection Case
      • 07 FPGA FSPI Communication Case
      • 08 FPGA DMA read and write case
      • 09 GPS debugging case
      • 10 Ethernet Test Cases
      • 11 RS485 reading and writing examples
      • 12 FPGA IIC read and write examples
      • 13 PN532 NFC card reader case
      • 14 TF card reading and writing case
    • 5. QT Development

      • 01 ARM64 cross compiler environment construction
      • 02 QT program added automatic startup service
    • 6. Others

      • 01 Modification of the root directory file system
      • 02 System auto-start service

07 FPGA FSPI Communication Case

1 Case Introduction

This case aims to run the Linux system on the ARM side and perform read and write tests on the FPGA DRAM through the FSPI bus.

2 Communication process between ARM and FPGA

Implementing SPI Master Function on ARM

Open the SPI device node: Open the /dev/spidev4.0 device node.

Configure the FSPI bus: Use the ioctl command to configure the polarity, phase, communication rate, data length and other parameters of the FSPI bus.

Select the transmission mode: You can choose single-line mode, two-line mode or four-line mode. When set to four-line mode, both data transmission and reception will adopt four-line mode. This case only supports four-line mode.

Data transfer: Send data to the FSPI bus and read data from the FSPI bus.

Verify data: Verify the transmitted data and then print out the read/write rate and bit error rate.

Implementing SPI Slave Function on FPGA

Data storage: FPGA saves the data sent by SPI Master to DRAM.

Data read: When the SPI Master initiates a data read request, the FPGA reads data from the DRAM and transmits it to the SPI Master through the FSPI bus.

3 Operation process

Open the terminal and copy the executable program smdt_spi_rw in the bin directory of this case (05-Development Materials\Software Development Materials\linux_demo\smdt_fpga_fspi_demo\bin) to the development board file system (the source code can be viewed in the src path).

#修改 Linux 内核日志的显示级别,内核的日志级别被设置为只显示紧急或更高级别的消息
echo 1 4 1 7 > /proc/sys/kernel/printk

Execute the following command in the terminal to switch to the directory where the smdt_fpga_fspi_demo executable program is located

#切换到 smdt_fpga_fspi_demo 可执行程序所在目录
cd ‘the file's directory’

#查看 smdt_spi_rw 是否在该目录下
ls

If the executable file smdt_spi_rw is in the current directory, modify the permissions of the executable file

#修改文件权限
chmod 777 smdt_spi_rw 

#查询是否修改成功
ls -ld smdt_spi_rw

After confirming that the file modification permission is successful, execute ./smdt_spi_rw -h to view the help information of the program.

#查看帮助信息
./smdt_spi_rw  -h

The execution result is as follows:

FPGA_FSPI_1

Functional testing

Enter the following instructions. On the ARM side, 2048 bytes of random data are written into the FPGA's DRAM via the FSPI bus configured in four-wire mode. The data is then read for verification and the read and write speed of the FSPI bus and the calculated bit error rate are printed out. The execution results are shown in the figure below.

./smdt_spi_rw -d /dev/spidev4.0 -s 150000000 -OH -m 3 -S 2048 -c 1

# The parameters are explained as follows:

# `-d`:Used to specify the device node.

# `-s`:Used to set the frequency of the communication clock, with the unit being hertz (Hz).

# `-O`:Represents clock polarity inversion, i.e., CPOL (Clock Polarity) is set to 1.

# `-H`:Indicates that data is sampled on the second edge at the start of the clock cycle, i.e., CPHA (Clock Phase) is set to 1.

# `-m`:Selects the transmission mode, where 1 represents single-wire mode, 2 represents dual-wire mode, and 3 represents four-wire mode.

# `-S`:Sets the size of the transmitted data, with the unit being bytes (Byte).

# `-c`:Sets the number of times to cyclically transmit data packets.
FPGA_FSPI_2

As can be seen from the above figure, the measured write rate is 5.81 MB/s, the read rate is 10.5 MB/s, and the bit error rate is 0.00%.

Performance Testing

When performing performance testing, the communication clock frequency of the FSPI bus needs to be set to 150MHz. Under this setting, ARM will write 1MB of random data to the FPGA's DRAM through the FSPI bus, then read the data, and repeat this process 100 times. No data verification is performed during the test, and the read and write speed and error rate of the FSPI bus will be output in the end. The execution results are shown in the figure below. This case design reads and writes 2048Byte of random data to the FPGA DRAM at a time, so the bit error rate is high.

./smdt_spi_rw -d /dev/spidev4.0 -s 150000000 -OH -m 3 -S 1048576 -c 100
FPGA_FSPI_3
Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
06 FAN Detection Case
Next
08 FPGA DMA read and write case