StarFive VisionFive 2 User Manual

40-pin gpio header
Hide thumbs Also See for VisionFive 2:
Table of Contents

Advertisement

Quick Links

VisionFive 2    40-Pin GPIO Header User 
Guide
Version: 1.1
Date: 2022/12/27
Doc ID: VisionFive2-UGEN-001

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the VisionFive 2 and is the answer not in the manual?

Questions and answers

Summary of Contents for StarFive VisionFive 2

  • Page 1 VisionFive 2    40-Pin GPIO Header User  Guide Version: 1.1 Date: 2022/12/27 Doc ID: VisionFive2-UGEN-001...
  • Page 2 StarFive does not assume any liability rising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation indirect, incidental, special, exemplary, or consequential damages.
  • Page 3 Preface About this guide and technical support information. About this document This document is intended to: • introduce the 40-pin header. • provide instructions to configure and debug GPIO, I2C, SPI, PWM, and UART. • provide peripheral examples to use the 40-pin GPIO header. Revision History Table ...
  • Page 4: Table Of Contents

    8.2.2. Debugging UART Send and Receive Functions...................... 29 9. Peripheral Examples................................33 9.1. Sense Hat (B) Example..............................33 9.1.1. Hardware Setup..............................33 9.1.2. Running Example with Sense Hat (B)........................34 9.2. 2.4inch LCD Module Example............................35 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 5 Contents 9.2.1. Hardware Setup..............................35 9.2.2. Executing Example..............................37 © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 6: List Of Tables

    Table 7-1 PWM and Pin Name Mapping............................25 Table 8-1 UART and DEV Mapping..............................28 Table 9-1 Connect Sense Hat (B) to the 40-Pin Header........................33 Table 9-2 Connect 2.4inch LCD with 40-pin Header........................35 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 7: List Of Figures

    Figure 9-1 Connect Sense Hat (B) to the 40-Pin Header.........................33 Figure 9-2 Connect Sense Hat (B) to the 40-Pin Header.........................34 Figure 9-3 Connect 2.4inch LCD with 40-Pin Header........................36 Figure 9-5 Example Output................................37 © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 8: Overview

    1. Overview The 40-pin header allows VisionFive 2 single board computers to interface with a variety of external components, which enables developers to create their projects. This document is intended to: • introduce the 40-pin header as described in this chapter.
  • Page 9: Gpio Pinout

    • The dts column shows the name of the node in the DTSI file (jh7110-visionfive-v2.dtsi). You can find the associated node by simply searching the name. • The Sys column shows the pin number used when exporting the GPIO pin under the /sys/class/gpio. © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 10: Preparation

    Table    3-1 Hardware Preparation Type Item Notes General VisionFive 2 single board computer General These items are used for flashing Debian OS into • 32 GB (or more) micro-SD card a micro-SD card. • micro-SD card reader • Computer (Windows/macOS/Linux) •...
  • Page 11: Preparing Software

    Two methods are provided to flash images. One is for Mac/Linux, the other is for Windows. For detailed instructions on flashing Debian OS to a Micro-SD card, refer to Flashing OS to a Micro-SD Card section in VisionFive 2 Single Board Computer Quick Start Guide.
  • Page 12: Replacing Dtb

    /media/<UserName>/root/usr/lib/linux-image-5.15.0-starfive/starfive/ 3.2.4.2. Method 2: Adding Startup Item To replace dtb file by adding a startup item, perform the following: 1. Execute the following commands under the root directory of Linux: sudo cp arch/riscv/boot/dts/starfive/<DTB_File> <Mount_Direcotry>/ root/usr/lib/linux-image-<Kernel_Version>/starfive/ Tip: ◦ <DTB_File>: Different boards use different dtb files: ▪...
  • Page 13 /boot/vmlinuz-<Kernel_Version> initrd /boot/initrd.img-<Kernel_Version> fdt /usr/lib/linux-image-<Kernel_Version>/starfive/<DTB_File> append root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 label l1r menu label Debian GNU/Linux bookworm/sid 5.15.0-starfive (customized)(rescue target) linux /boot/vmlinuz-<Kernel_Version> initrd /boot/initrd.img-<Kernel_Version> fdt /usr/lib/linux-image-<Kernel_Version>/starfive/uart_test.dtb append root=/dev/mmcblk1p3 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 single Tip: ◦...
  • Page 14 | 3 - Preparation 5. When you see the U-Boot startup item, select the menu item set in the previous step, for example, Debian GNU/Linux  bookworm/sid 5 . 15 . 0-starfive (customized). Tip: Multiple startup items can be added according to the actual number of DTB files.
  • Page 15: Gpio Operations

    7. Connect the 3.3V Power  pin with the GPIO44, and check the voltage level of GPIO44: cat value 8. Connect the GND  pin with the GPIO44, and check the voltage level of GPIO44: cat value © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 16: I2C Operations

    Table    5-1 Connect Sense Hat (B) to the 40-Pin Header 40-Pin GPIO Header Sense HAT (B) Pin Number Pin Name 3.3V Power GPIO58 (I2C SDA) GPIO57 (I2C SCL) Figure    5-1 Connect Sense Hat (B) to the 40-Pin GPIO Header Sense Hat (B) 5V Power 3.3V Power 5V Power GPIO58 (I2C SDA) GPIO57 (I2C SCL) GPIO5 (UART TX) GPIO55 GPIO6 (UART RX) GPIO38 GPIO42 GPIO43 GPIO21 GPIO20 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 17: Configuring Dts File

    | 5 - I2C Operations 5.1.2. Configuring dts File 7 channels of I2C bus are supported: i2c0 to i2c6. The DTSI file, jh7110-visionfive-v2.dtsi, is under /linux/arch/riscv/boot/dts/starfive. The following is the default setting. You can configure the unoccupied GPIOs as required. Figure    5-2 Example File Content Note: The I2C GPIO pin number is the number indicated in the Pin Name.
  • Page 18: Figure 5-4 Example Output

    : I2C device address. 0x5c ◦ : Memory address. 0x11 ◦ : The content to be written in the register. 0x10 5. Execute the following to read all register values: i2cdump -y 0 0x5c www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 19: Figure 5-6 Example Output

    | 5 - I2C Operations Tip: ◦ : I2C bus number ◦ : I2C device address 0x5c Result: Figure    5-6 Example Output © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 20: Spi Operations

    6. SPI Operations This chapter describes how to configure and debug SPI GPIO. 6.1. Configuring SPI GPIO The DTSI file, jh7110-visionfive-v2.dtsi, is under /linux/arch/riscv/boot/dts/starfive. 7 channels of SPI bus are supported: spi0 to spi6. 6.1.1. Modify Pins The configured SPI GPIO number is the number indicated in the Pin Name. For more details about the GPIO Pin Name, see the GPIO Pinout (on page 9) in this document.
  • Page 21: Loopback Test

    3. Execute the following command under the test tool directory: make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv Result: The output file is spidev_test in the same directory. 4. Upload spidev_test to VisionFive 2, and change the execution permission by executing the following: chmod +x spidev_test 5. Confirm the SPI device. ls /dev/spidev* Result: Figure ...
  • Page 22: Testing Spi With Adxl345 Module

    Figure    6-4 Example Output In this figure, the TX  and RX  output are the same, which indicates the test is successful. 6.2.2. Testing SPI with ADXL345 Module Perform the following steps to test SPI with the ADXL345 module: www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 23: Figure 6-5 Connect Adxl345 Module To The Header

    3. Execute the following command under the test tool directory: make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv Result: The output file is spidev_test in the same directory. 4. Upload spidev_test to VisionFive 2, and change the execution permission by executing the following: © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 24: Figure 6-6 Example Output

    ./spidev_test -H -O -D /dev/spidev1.0 -v -p \\x9e\\x00 9. Execute the following to write: ./spidev_test -H -O -D /dev/spidev1.0 -v -p \\x1e\\xaa 10. Execute the following to read the verification: ./spidev_test -H -O -D /dev/spidev1.0 -v -p \\x9e\\x00 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 25: Pwm Operations

    7. PWM Operations This chapter describes how to configure and debug PWM GPIO: 7.1. Configuring PWM GPIO The DTSI file, jh7110-visionfive-v2.dtsi, is under /linux/arch/riscv/boot/dts/starfive. 8 channels of PWM are supported at the most. 7.1.1. Modify Pin The following figure shows the example file content to modify the pin: Figure ...
  • Page 26 4. Use an oscilloscope to measure the corresponding pin and check the PWM period and duty cycle. Note: A duty cycle is the fraction of one period in which a signal or system is active. www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 27: Uart Operations

    This chapter describes how to configure and debug UART GPIO: 8.1. Configuring UART GPIO The DTSI file, jh7110-visionfive-v2.dtsi, is under /linux/arch/riscv/boot/dts/starfive. 6 channels of UART are supported at the most. The configured UART GPIO number is the number contained in the Pin Name. For more details about the GPIO Pin Name, see GPIO Pinout (on page 9) in this document.
  • Page 28: Debugging Uart Gpio

    Figure    8-3 Example Configuration 8.1.1.1. UART and DEV Mapping The following table describes the UART and DEV mapping: Table    8-1 UART and DEV Mapping UART UART1 /dev/ttyS1 UART2 /dev/ttyS2 8.2. Debugging UART GPIO 8.2.1. Hardware Setup To set up the hardware, perform the following steps: www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 29: Debugging Uart Send And Receive Functions

    | 8 - UART Operations 1. Connect the jumper wires from the USB-to-Serial Converter to the 40-Pin GPIO header of the VisionFive 2 as follows. Figure    8-4 Connect the Converter to the Header 5V Power 3.3V Power 5V Power GPIO58 (I2C SDA) GPIO57 (I2C SCL) GPIO5 (UART TX) GPIO55 GPIO6 (UART RX) GPIO38 GPIO42 GPIO43 GPIO54...
  • Page 30: Figure 8-7 Example Output

    | 8 - UART Operations 3. Start VisionFive 2 minicom by typing the following command on the PC: minicom -o -D /dev/ttyS1 Figure    8-7 Example Output 4. Configure Ubuntu minicom by typing the following: sudo minicom -s 5. Select Serial port setup, and configure minicom as follows: Figure ...
  • Page 31: Figure 8-10 Example Command And Output

    Note: Serial Device can be detected by command on Ubuntu dmesg | grep tty Figure    8-10 Example Command and Output 6. Start Ubuntu minicom, you can see as follows: Figure    8-11 Example Output Test UART Send: © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 32: Figure 8-12 Test Uart Send

    | 8 - UART Operations 7. To test UART send function, you can input characters, such as , on the VisionFive 2 minicom. Then you will hello ubuntu see the character are outputted on the Ubuntu minicom as the following: Figure ...
  • Page 33: Peripheral Examples

    The following table and figure describe how to connect Sense HAT to the 40-pin header: Table    9-1 Connect Sense Hat (B) to the 40-Pin Header Sense HAT (B) Pin Number Figure    9-1 Connect Sense Hat (B) to the 40-Pin Header Sense Hat (B) 5V Power 3.3V Power 5V Power GPIO58 (I2C SDA) GPIO57 (I2C SCL) GPIO5 (UART TX) GPIO55 GPIO6 (UART RX) GPIO38 GPIO42 GPIO43 GPIO21 GPIO20 © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 34: Running Example With Sense Hat (B)

    +x shtc3 5. Execute the following command to run: ./shtc3 Result: The following output indicates the execution is successful: root@starfive:~# ./shtc3 SHTC3 Sensor Test Program ... Fopen : /dev/i2c-0 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 35: Inch Lcd Module Example

    The official examples are required to be modified for this demo. 9.2.1. Hardware Setup The following table and figure describe how to connect the 2.4inch LCD module with the 40-pin header: Table    9-2 Connect 2.4inch LCD with 40-pin Header 2.4inch LCD Module Pin Number © 2018-2022 StarFive Technology www.starfivetech.com All rights reserved...
  • Page 36: Figure 9-3 Connect 2.4Inch Lcd With 40-Pin Header

    5V Power 3.3V Power 5V Power GPIO58 (I2C SDA) GPIO57 (I2C SCL) GPIO5 (UART TX) GPIO55 GPIO6 (UART RX) GPIO38 GPIO42 GPIO43 GPIO54 GPIO47 GPIO51 3.3V Power GPIO52 (SPI MOSI) GPIO50 GPIO53 (SPI MISO) GPIO49 (SPI CE0) GPIO48 (SPI SCLK) GPIO56 GPIO40 GPIO45 GPIO37 GPIO46 (PWM0) GPIO39 GPIO59 (PWM1) GPIO36 GPIO63 GPIO61 GPIO60 GPIO44 www.starfivetech.com © 2018-2022 StarFive Technology All rights reserved...
  • Page 37: Figure 9-5 Example Output

    2. Execute the following command to copy the code to the board. For example, VisionFive 2. tar -xvf LCD_Demo.tar.gz cd visionfive2/ ./main 2.4 Result: The following two figures will be displayed in turn. One is the photo of VisionFive 2, the other is the official example figure. Figure    9-5 Example Output © 2018-2022 StarFive Technology www.starfivetech.com...

Table of Contents