Search code examples
debuggingvisual-studio-codegdbembeddedopenocd

Failed to attach: :3333: Operation timed out. (from target-select remote :3333) Issue to debug riscV-WCH device ch32v307 in VsCode 1.68 in Mac Os


I stay trying this: https://nc-pin.com/index.php/category/wch/ch32v-series/ch32v307/ Debugging CH32V307V with Visual Studio Code on macOS

The part more confuse is this: “I saved a workspace of Visual Studio Code into the ch32v307/EVT/EXAM/GPIO/GPIO_Toggle/User directory and added this directory to the workspace also±”

But I can create a lauch.json with workspace(3) and GDB(4)

After I mounted with hdid, mount and export PATH, etc…

But in Final I have issue: Failed to attach: :3333: Operation timed out. (from target-select remote :3333)

Note:

  1. I don't know why but in tutorial not talk about task.json. When I see a message about this on the screen(Because I have "preLaunchTask": "run_openocd" in launch.json) I click on debug anyway

Will I need task.json to resolve my issue?

  1. Is this link I have source codes that I am using and images with issue called images: captura de tela 2022-07-04

https://github.com/neuberfran/ch32v307

How can I solve?

Pls

edited in 06-11-2022. The solution for this issue is use wch-link version 2.3(Not 2.4 upstream today). But so far, it has not been possible to Downgrade from 2.4 to 2.3. Look wehnelt comment in this post:https://www.reddit.com/r/embedded/comments/ut94i3/the_riscv_mcu_ch32v307_is_a_bad_boy/

enter image description here


Solution

  • Due to the need to update in wch-link v2.4 (for Mac OS and Ubuntu), this answer (2022-07-23) comes to complement the tutorial: https://nc-pin.com/index.php/category/wch/ch32v-series/ch32v307/

    1. Open Mac Os terminal

    1.1) https://github.com/neuberfran/openocd (openocd it's working ok)

    1.2) go to /Users/username/csfs/openocd: ./openocd -f wch-riscv.cfg -c init -c halt -c "flash erase_sector wch_riscv 0 last" -c exit

    1. git clone https://github.com/neuberfran/GPIO_Toggle 2.1) go to Finder -> GPIO_Toggle/User -> double click in GPIO_Toggle.code-workspace

    2. in VsCode go to Terminal: export PATH="$HOME/csfs/x-tools/riscv32-unknown-elf/bin:$HOME/csfs/openocd:$PATH"

    note.: You have probably already run: hdid -nomount csfs.sparseimage

    mount -t hfs /dev/diskXs2 csfs

    3.1) mark line 56 in main.c File (debug breakpoint)

    1. Press F5 ...(If a warning screen appears, click Debug Anyway). Next Debug Console will automatically open and debugger will stop at line 56. Click F5 agin (Continue button, up there in VsCode). The Led will blink. Click F6 to stop and F5 to continue.

    2. Remove And Reconnect the USB-C cables from the board. Go to the Mac OS terminal that you open in Step nr.: 1.2. Execute again Step 1.2. Go to Step 4.