Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HIL 标记串与环境变量

HIL(hardware-in-the-loop)框架的标记串与环境变量参考。事实取自 hil/hil-smoke.shhil/flash.shhil/pack.shhil/cargo-run-hw.sh

HIL 框架原理见 HIL 测试框架;运行步骤见 运行 HIL 冒烟测试

串口约定

串口用途参数
UART0 = /dev/ttyUSB0板子 UART0(示例输出)115200 8N1
ttyACM0J-Link VCOM

hil-smoke.sh 检查的标记串

hil-smoke.sh 逐例烧录后读 UART,用 grep -qE 匹配下列模式(check <example> <egrep> <desc>):

示例匹配的 egrep 模式描述
uart_helloHello from WS63UART banner(验证 160 MHz 波特基)
timer_irq`timer irq #OK: timer`
gpio_irqgpio irq #GPIO IRQ 投递
reset_demoOK: software reset observedsoftware_reset + reset_reason(第二次启动标记)
spi_loopbackSPI loopback OK阻塞 SPI0(先短接 MOSI↔MISO!)
i2c_scan`scan doneno devices`

blinky(GPIO 翻转无 UART,需 LED/逻辑分析仪)与 semihost_selftest(需 debugger 半主机)在裸 HIL 跳过。总结果:全过打印 HIL SMOKE: PASS,否则 HIL SMOKE: FAILexit 1

各示例标记串(HIL 期望)

示例成功标记串
uart_helloHello from WS63 on QEMU!
timer_irqOK: timer interrupts delivered(或周期性 timer irq #N
gpio_irqOK: custom local IRQ (>=32) delivered(或 gpio irq #N
reset_demoOK: software reset observed
spi_loopbackSPI loopback OK
i2c_scanscan done / no devices acked
blinky无(GPIO0 翻转)
semihost_selftest半主机退出码 0 / console semihost_selftest: PASS(裸 HIL 跳过)

完整 18 例标记串见 示例目录与验证标记串

环境变量

flash.sh

烧录方式选 METHOD=(默认 probe-rs)。

变量默认适用说明
METHODprobe-rsprobe-rs(验证主路径)或 hisiflash(厂商路径)
CHIP_KINDws63共享ws63|bs21,决定默认 app 分区地址
WS63_RS脚本父目录共享ws63-rs 检出根
CHIPWS63probe-rsprobe-rs --chip 目标
PROBE_RS_YAML(必填)probe-rsfork 的芯片描述 YAML(HiSilicon_WS63.yaml
BASE_ADDRESS0x00230000(ws63)/ 0x00090000(bs21)probe-rsapp 分区 flash 地址
PROBE_RSprobe-rsprobe-rsprobe-rs 二进制名
PORT(自动探测)hisiflash串口(导出为 HISIFLASH_PORT
BAUDhisiflash 默认 921600hisiflash烧录波特(HISIFLASH_BAUD
LOADERBOOT(必填)hisiflash厂商 LoaderBoot 二进制(取自 fbb_ws63 产物)
ADDRESS(必填)hisiflash程序写入 flash 偏移(对照分区表确认)
HISIFLASHhisiflashhisiflashhisiflash 二进制名

hil-smoke.sh(在 flash.sh 变量之外另加)

变量默认说明
PORT(必填)板子 UART0(/dev/ttyUSBx
SETTLE4每次烧录后读 UART 的秒数
UART_BAUD115200示例 UART0 波特(8N1)
MONITOR(raw read $PORT打印原始 UART 到 stdout 的命令(覆盖适配器读法)
HISIFLASHhisiflashhisiflash 二进制名

pack.sh

变量默认说明
CHIPws63目标芯片(ws63|bs21),决定 app 分区地址
APP_ADDR(未设)覆盖 app 分区 flash 地址(如 0x230000
FWPKG(未设)非空则同时产出 .fwpkg(厂商 hisiflash 路径)
HISI_FWPKGhisi-fwpkghisi-fwpkg 二进制名
WS63_RS脚本父目录ws63-rs 检出根

默认 app 分区地址:ws63 0x00230000、bs21 0x00090000

cargo-run-hw.sh(cargo runner)

cargo 以 <runner> <built-elf> 调用,脚本把 ELF 打包成 0x300-header 镜像、probe-rs download、复位、(设了 PORT 则)流式 UART0。

变量默认说明
APP_ADDR0x00230000(ws63)app 分区 flash 地址
PROBE_RSprobe-rsprobe-rs 二进制名
PROBE_CHIPWS63probe-rs --chip
PROBE_YAML(空 = 内置 DB)--chip-description-path YAML
HISI_FWPKGhisi-fwpkghisi-fwpkg 二进制名
PORT(无 = 不流式)复位后流式 UART0 的端口
UART_BAUD115200流式 UART 波特
MONITOR10流式 UART 秒数

启用:CARGO_TARGET_RISCV32IMFC_UNKNOWN_NONE_ELF_RUNNER=hil/cargo-run-hw.sh cargo run -p blinky --release(或 just run-hw)。