Preparation

Before configuring the 40-pin header, you need to prepare for the following.

Hardware Preparation

Table 1. Hardware Preparation
Type M/O* Item Notes
General M VisionFive 2 Board or VisionFive 2 Lite Board -
General M
  • 32 GB (or more) micro-SD card
  • Micro-SD card reader
  • Computer (Windows/Mac OS/Linux)
  • USB to serial converter (3.3 V I/O)
  • Ethernet cable
  • Power adapter (5 V / 3 A)
  • USB Type-C Cable
These items are used for flashing Debian OS into a Micro-SD card.
GPIO O An oscilloscope The oscilloscope is used to verify the GPIO voltage.
I2C O
  • Sense Hat (B)
  • Dupont Line
-
SPI O
  • ADXL345 Module
  • Dupont Line
-
PWM O An oscilloscope The oscilloscope is used to measure the corresponding pin and check the PWM period and duty cycle.
SPI LCD O
  • 2.4inch LCD Module
  • Dupont Line
-
UART O
  • GNSS HAT
  • Dupont Line

This is a GNSS HAT based on MAX-7Q, which supports positioning systems including GPS, GLONASS, QZSS, and SBAS. It features accurate and fast positioning with minor drifting, low power consumption, outstanding ability for anti-spoofing and anti-jamming, and so on. For detailed specifications, refer to MAX-7Q GNSS HAT.

Software Preparation

Before configuring the 40-pin header, the Debian OS needs to be flashed into the Micro-SD card, and the DTB files need to be compiled and replaced.

Table 2. Software Preparation
Item Details
GitHub Repository
Note: Make sure you have switched to the corresponding branch.
Flash OS to a Micro-SD card See Flash OS to a Micro-SD Card.
Generate DTB
To compile the device tree sources (.dtsi files) into device tree blobs (.dtb files) using the device tree compiler (DTC), execute the following command under the root directory of Linux:
make <Configuration_File> ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv dtbs
Note:
  • <Configuration_File>: Both starfive_jh7110_defconfig and starfive_visionfive2_defconfig are applicable.

  • To install the crossbuild-essential-riscv64 package, execute the following command:
    sudo apt-get install crossbuild-essential-riscv64
Replace DTB

You can directly replace the DTB file or add a startup item.

Prerequisite: You already generated the DTB file.

To directly replace the DTB file:
  1. Insert the micro-SD card to the PC with Ubuntu system, and execute the following command to check the SD card partition:
    sudo fdisk -l
    Example output:
    Device      Start     End Sectors  Size Type
    /dev/sdc1    4096    8191    4096    2M unknown
    /dev/sdc2    8192   16383    8192    4M unknown
    /dev/sdc3   16384  221183  204800  100M EFI System
    /dev/sdc4  221184 4503518 4282335    2G Linux filesyste
    In this output, the /dev/sdc3 partition is the SD card partition.
  2. Mount the SD card partition under the mnt file patch by executing the following:
    sudo mount /dev/sdc3 /mnt
  3. Under the Linux root directory, execute the following:
    sudo cp arch/riscv/boot/dts/starfive/<DTB_File> /mnt/dtbs/starfive
  4. Enter the /mnt directory and modify the configuration file (uEnv.txt)by executing the following:
    cd /mnt
    sudo vim uEnv.txt
    fdtfile=starfive/<DTB_File>
  5. Unmount the /mnt directory.
    sudo umount /mnt
  6. Remove the micro-SD card from PC and insert it into VisionFive 2. Power on VisionFive 2.

To replace the DTB file by adding a startup item:
  1. Perform 1 to 3

    .
  2. Open extlinux.conf by executing the following:
    sudo vim /mnt/extlinux/extlinux.conf
  3. Add the following lines, save the file, and exit:
    label l1
    	menu label Debian GNU/Linux bookworm/sid 5.15.0-starfive (customized)
    	linux /vmlinuz-5.15.0-starfive
    	initrd /initrd.img-5.15.0-starfive
    	fdt /dtbs/starfive/<DTB_File>
    	append  root=/dev/mmcblk1p4 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 /vmlinuz-5.15.0-starfive
    	initrd /initrd.img-5.15.0-starfive
    	fdt /dtbs/starfive/<DTB_File>
    	append  root=/dev/mmcblk1p4 rw console=tty0 console=ttyS0,115200 earlycon rootwait stmmaceth=chain_mode:1 selinux=0 single
  4. Remove the micro-SD card from PC and insert it into VisionFive 2. Power on VisionFive 2.

    You can see the custom menu item, for example, Debian GNU/Linux bookworm/sid 5.15.0-starfive (customized), in the U-Boot startup menu. Select this item.