HPM5301EVKlite windows下上手使用
HPM5301介紹
HPM5301是先輯半導體出的一款300Mhz的riscV芯片,售價7.99,開發板售價39.99,性價比超高
資源獲取
evklite基本不需要原理圖,下載SDK和ENV即可
SDK連接:https://github.com/hpmicro/hpm_sdk
hpm5301還需要打下patch: https://github.com/hpmicro/hpm_sdk/releases/download/v1.3.0/hpm_sdk_v1.3.0_patch-hpm5301evklite.zip
ENV連接:https://github.com/hpmicro/sdk_env
注:國內gitee上也有相同倉庫
環境搭建
windows下,官方的SDK_ENV提供了所有的依賴文件,通過GUI配置即可。
-
解壓HPM_SDK,然后將sdk下的所有文件復制或移動到SDK_ENV下的HPM_SDK中
-
運行START_GNU.EXE
-
選擇board,選擇example

-
generateProject,成功后 open build console,輸入ninja編譯

-
通過openocd下載
下載
CHIP有兩種方式,一種是使用標準的jtag下載調試,另外一種是使用ISP下載。
JTAG
jtag目前可以用jlink,ft232,ft2332,標準的DAP-Link(某閹割jtag協議的WCH-link就別嘗試了)。如果使用jlink的話,需要用jlinkV10以上版本,不然無法通過jlink-gdb-sever進行調試。使用openocd的話,還要注意替換驅動,不然openocd無法識別jlink。
這里使用openocd+gdb的方式進行調試下載。
在hpm_sdk/board/openocd里有所需的cfg,切換到該目錄下,執行openocd -f probes\jlink.cfg -f soc\hpm5300.cfg -f boards\hpm5301evklite.cfg
結果如下:
D:\workspace\git\hpm5301\sdk_env-1.3.0\hpm_sdk\boards\openocd>openocd -f probes\jlink.cfg -f soc\hpm5300.cfg -f boards\hpm5301evklite.cfg
Open On-Chip Debugger 0.11.0+dev-02365-g488108c93 (2023-09-18-18:58)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
srst_only separate srst_gates_jtag srst_open_drain connect_deassert_srst
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V9 compiled May 7 2021 16:26:12
Info : Hardware version: 9.50
Info : VTarget = 3.282 V
Info : clock speed 10000 kHz
Info : JTAG tap: hpm5361.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Info : [hpm5361.cpu0] datacount=4 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x4090112f
[hpm5361.cpu0] Target successfully examined.
Info : starting gdb server for hpm5361.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
然后再open build console,開啟GDB:riscv32-unknown-elf-gdb
D:\workspace\git\hpm5301\sdk_env-1.3.0\toolchains\rv32imac-ilp32-multilib-win\bin\riscv32-unknown-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-w64-mingw32 --target=riscv32-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)
輸入以下指令下載程序并運行
gdb> file output\demo.elf
gdb> target remote localhost:3333
gdb> load
gdb> b main
gdb> c
輸出如下:
(gdb) file output/demo.elf
Reading symbols from output/demo.elf...
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x20017a10 in ?? ()
(gdb) load
Loading section .nor_cfg_option, size 0x10 lma 0x80000400
Loading section .boot_header, size 0x90 lma 0x80001000
Loading section .start, size 0x3e lma 0x80003000
Loading section .vectors, size 0x2a0 lma 0x8000303e
Loading section .text, size 0xa4aa lma 0x800032de
Loading section .data, size 0x1d8 lma 0x8000d788
Start address 0x80003000, load size 43520
Transfer rate: 14 KB/sec, 5440 bytes/write.
(gdb) c
Continuing.
運行效果如圖:

ISP下載
按住boot鍵后按下復位,chip會進入bootloader模式,此時可以通過用戶手冊提供的指令進行下載,或是使用官方提供的HPMpragrammer

進入bootloader模式后,需要通過串口轉USB鏈接TX0/RX0,選擇對應的COM口后,點擊Attach,此時左下角會提示設備連接成功。
20231130_1453 貌似此軟件暫時未適配53xx系列,始終下載失敗。

浙公網安備 33010602011771號