meta-nuclei的编译和使用¶
本章介绍如何编译、烧录芯来镜像的例子。 具体内容如下:
1.构建镜像¶
2.烧录镜像¶
2.1 烧录引导程序¶
板卡可以正常启动无需下载
预安装gdb、openocd等工具。
请参考 devtools
openocd -f openocd.cfg
riscv-nuclei-elf-gdb freeloader.elf
(gdb) target remote :3333
(gdb) monitor reset halt
(gdb) load freeloader.elf
Loading section .text, size 0xa41e8 lma 0x20000000
Loading section .interp, size 0x21 lma 0x200a41e8
Loading section .note.gnu.build-id, size 0x24 lma 0x200a420c
Loading section .dynsym, size 0x18 lma 0x200a4230
Loading section .dynstr, size 0xb lma 0x200a4248
Loading section .hash, size 0x10 lma 0x200a4258
Loading section .dynamic, size 0x100 lma 0x200a4268
Loading section .got, size 0x8 lma 0x200a4368
Start address 0x0000000020000000, load size 672616
Transfer rate: 24 KB/sec, 13726 bytes/write.
(gdb) q
openocd.cfg 具体内容参考 2.3 配置文件
2.2 制作SD卡¶
/dev/sdX 更改为SD卡实际设备文件
xzcat core-image-full-cmdline-nuclei.wic.xz | \
sudo dd of=/dev/sdX bs=512K iflag=fullblock oflag=direct conv=fsync status=progress
2.3 配置文件¶
adapter_khz 1000
interface ftdi
ftdi_vid_pid 0x0403 0x6010
ftdi_oscan1_mode off
## bindto 0.0.0.0 can be used to cover all available interfaces.
## Uncomment bindto line to enable remote machine debug
bindto 0.0.0.0
## If ftdi_device_desc not specified, the device description is ignored during device selection.
## So if you want to specify a dedicated FTDI device, you can select following device description:
## "Dual RS232-HS" is for HummingBird Debugger V1
## "USB <-> JTAG-DEBUGGER" is for HummingBird Debugger V2
## Uncomment one which match your device description
# ftdi_device_desc "Dual RS232-HS"
# ftdi_device_desc "USB <-> JTAG-DEBUGGER"
transport select jtag
ftdi_layout_init 0x0008 0x001b
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020
ftdi_layout_signal TCK -data 0x0001
ftdi_layout_signal TDI -data 0x0002
ftdi_layout_signal TDO -input 0x0004
ftdi_layout_signal TMS -data 0x0008
ftdi_layout_signal JTAG_SEL -data 0x0100 -oe 0x0100
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
# Please use Nuclei OpenOCD >= 2022.01 release version
flash bank $_FLASHNAME nuspi 0x20000000 0 0 0 $_TARGETNAME
# Set the ILM space also as flash, to make sure it can be add breakpoint with hardware trigger
#flash bank onboard_ilm nuspi 0x80000000 0 0 0 $_TARGETNAME
# Expose Nuclei self-defined CSRS
# See https://github.com/riscv/riscv-gnu-toolchain/issues/319#issuecomment-358397306
# Then user can view the csr register value in gdb using: info reg csr775 for CSR MTVT(0x307)
riscv expose_csrs 416-496,770-800,835-850,1227-1231,1483-1486,1984-2032,2064-2070,2370-2380,2490-2500,4032-4040
init
if {[ info exists pulse_srst]} {
ftdi_set_signal nSRST 0
ftdi_set_signal nSRST z
}
halt
# We must turn on this because otherwise the IDE version debug cannot download the program into flash
flash protect 0 0 last off