How-to-flash-and-debug-with-JTAG
johnchewyy edited this page 11 months ago

Start TeraTerm

  1. Download Tera Term with this link
  2. Setup Tera Term:

image

image

Connect JTAG According to Table 1 Below

Table 1: JTAG Pin Connection | JTAG Pins | 40-Pin Number | VisionFive2 (JH7110) | |———–|—————|———————-| | JTAG TDO | 40 | GPIO44 | | JTAG TCK | 37 | GPIO60 | | JTAG TDI | 38 | GPIO61 | | JTAG TMS | 35 | GPIO63 | | JTAG TRSTN| 36 | GPIO36 |

Debugger used «Olimex Tiny-H»

Create U-Boot SPL for debugging

  1. Download and unzip «debug_tools.zip» from here
  2. Apply «0001-U-Boot_SPL_debug.patch» patch into U-Boot project

    cd <uboot project folder>
    git apply < 0001-U-Boot_SPL_debug.patch
    
  3. Recompile U-Boot SPL (can refer here)

  4. Flash U-Boot SPL into the boot device of your choice (SD Card, QSPI Flash, or eMMC)

  5. Select the boot device (refer to here)

  6. Power up the board and TeraTerm will display the following message:

image

Connect to VisionFive 2

  1. Download and unzip «debug_tools.zip» from here
  2. Copy JH7110.fd to the same folder as debug_tools > Refer here download or build JH7110.fd
  3. Launch the terminal and run OpenOCD

    ./openocd.exe -f VisionFive2_JTAG.cfg
    

    if you meet error(s) when running the above command. Please check if «ftdi serial» is set correctly

image

  1. Run «riscv64-unknown-elf-gdb.exe»

    target remote: 3333
    set $pc=0x40000000
    c
    

    Refer here for GDB basic commands