使用环境

<!-- 必须 告知插件运行的环境,帮助开发者定位问题 -->

  • 操作系统版本:win10
  • 操作系统平台(x86/x64): x64
  • VsCode 版本:1.75.1
  • EIDE 插件版本:3.10.11
  • C/C++ 插件版本:
  • 何种编译器(keil_c51/sdcc/armcc5/armgcc/...):
  • 编译器版本(非编译问题可忽略):

描述问题

<!-- 使用简明清晰的语言描述您的问题 -->

在线建立的CH32V103的工程,烧录脚本
#!/bin/bash
firmwareFile=$(echo $1 | sed 's/\/\//g')
./tools/wch_openocd/bin/openocd.exe -f ./tools/wch_openocd/bin/wch-riscv.cfg \
-c init -c halt \
-c "flash erase_sector wch_riscv 0 last" \
-c "program ${firmwareFile}" \
-c "verify_image ${firmwareFile}" \
-c wlink_reset_resume -c exit
点击烧录后提示找不到文件,
** Programming Started **
Error: couldn't open d
embedded:startup.tcl:1162: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1227
at file "embedded:startup.tcl", line 1162

  • 终端进程“cmd.exe /C "bash ./tools/program_flash.sh "d:\EVT\test\test\build\Debug\test.hex""”已终止,退出代码: 1。

屏幕截图

<!--使用一些截图能够更好地展现问题 -->

期望现象

<!--您期望应该产生的,但实际上却没有发生的结果-->

不会bash脚本,用chatgpt生成了一个firmwareFile=$(echo $1 | sed 's/([a-zA-Z])(.*)/\2/g; s/://g' | sed 's/\/\//g')
可以正确烧录了

    daybeen

    第一句是将 '\' 转为 '/' 这样 unix 才能识别,

    我试了下原来的,可以正常替换 '\' 的

      admin 是可以转换,但是前面有盘符d: ,会提示找不到文件,把这个盘符删掉就可以了,firmwareFile=$(echo $1 | sed 's/([a-zA-Z])(.*)/\2/g; s/://g' | sed 's/\/\//g')
      这是ChatGPT生成的命令,不知道有啥其他bug吗,改成这样,我的电脑是可以下载了


      这是文档烧录脚本,不过我看了下,在线仓库里的ch32v103模板里也是我做的这个啊

        stars-under

        最好写成 shell 脚本,这样更容易跨平台

        这样就不用写两份了

        使用 bash 命令去执行

        如果要用 windows bat 脚本,使用 @echo off 去除回显

          admin 过几天去改改.当初cmd脚本也是现学的,对脚本也不怎么了解

            2 years later

            stars-under
            改过的shell脚本 CH32V208 烧录报错:

            Open On-Chip Debugger 0.11.0+dev-02215-gcc0ecfb6d-dirty (2022-09-28-11:32)
            Licensed under GNU GPL v2
            For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
            Info : only one transport option; autoselect 'jtag'
            Ready for Remote Connections
            Error: unknow WCH-LINK

            换成
            openocd -f ./tools/wch_openocd/bin/wch-riscv.cfg \

            还是报错

            stars-under

            • 改过的shell脚本 CH32V208 烧录报错:

            Open On-Chip Debugger 0.11.0+dev-02215-gcc0ecfb6d-dirty (2022-09-28-11:32)
            Licensed under GNU GPL v2
            For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
            Info : only one transport ophttps://discuss.em-ide.com/d/465tion; autoselect 'jtag'
            Ready for Remote Connections
            Error: unknow WCH-LINK

            • 换成 openocd -f ./tools/wch_openocd/bin/wch-riscv.cfg \ 报错 :

            Info : only one transport option; autoselect 'sdi'
            ./tools/wch_openocd/bin/wch-riscv.cfg:3: Error: invalid command name "wlink_set"
            in procedure 'script'
            at file "embedded:startup.tcl", line 26
            at file "./tools/wch_openocd/bin/wch-riscv.cfg", line 3

            • 使用 MounRiver_Studio 下的 wch-riscv.cfg 文件; 修改 firmwareFile=$(echo $1 | sed 's/([a-zA-Z])(.*)/\2/g; s/://g' | sed 's/\/\//g') 还是报错:
              Ready for Remote Connections
              Info : WCH-LinkE mode:RV version 2.14
              Info : wlink_init ok
              Info : clock speed 6000 kHz
              Info : [wch_riscv.cpu.0] datacount=2 progbufsize=8
              Info : [wch_riscv.cpu.0] Examined RISC-V core; found 1 harts
              Info : [wch_riscv.cpu.0] XLEN=32, misa=0x40901105
              [wch_riscv.cpu.0] Target successfully examined.
              Info : starting gdb server for wch_riscv.cpu.0 on 3333
              Info : Listening on port 3333 for gdb connections
              Info : device id = 0x7af6ae20
              Info : flash size = 160kbytes
              Info : ROM 128 kbytes RAM 64 kbytes
              erased sectors 0 through 159 on flash bank 0 in 0.143123s

            wrong # args: should be "program filename ?arg ...?"

              lang30

              不要用 openocd 了(由于他们没有把他们修改版的openocd合并到上游,因此你下载的openocd可能并不支持wch-link设备,另外他们自己的修改版openocd每个版本的兼容性也不一样),容易出问题

              可以尝试用他们自家的新工具 wlink 进行命令行烧录

              https://github.com/ch32-rs/wlink

              Write a Reply...