Community-PIO-CH32V / platform-ch32v

PlatformIO platform for CH32V RISC-V chips (CH32V003, CH32V103, CH32V20x, CH32V30x, CH32X035) and CH56x, CH57x, CH58x, CH59x
Apache License 2.0
203 stars 34 forks source link

minichlink debug support #28

Open maxgerhardt opened 1 year ago

maxgerhardt commented 1 year ago

With https://github.com/Community-PIO-CH32V/platform-ch32v/commit/d451c465657bf796c1f6b57f0f0b710ab09e6d4c, we can now upload via minichlink. We can also start minichlink's GDB server and connect to it, however, the step into and step over controls in VSCode are broken because minichlink just hangs on the GDB step command. Thus, we depend on https://github.com/cnlohr/ch32v003fun/issues/158.

Other oddities like not supporting load were worked-around with the preload load mode in PlatformIO.

It's also an open question on how to do a reset as GDB command.

tmolteno commented 1 year ago

With the most recent version I am getting errors on trying to upload (I had been using the using Link-E) On debian linux.

Executing task: platformio run --target upload --environment genericCH32V305RBT6 --upload-port /dev/ttyACM0 

Processing 
genericCH32V305RBT6 (board: genericCH32V305RBT6; platform: ch32v; framework: noneos-sdk)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing git+https://github.com/Community-PIO-CH32V/tool-minichlink.git#master
git version 2.39.2
Cloning into '/home/tim/.platformio/.cache/tmp/pkg-installing-s34sw55g'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream origin
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', 'master', 'https://github.com/Community-PIO-CH32V/tool-minichlink.git', '/home/tim/.platformio/.cache/tmp/pkg-installing-s34sw55g']

 *  The terminal process "platformio 'run', '--target', 'upload', '--environment', 'genericCH32V305RBT6', '--upload-port', '/dev/ttyACM0'" terminated with exit code: 1.

Seems a bit random when this is happening... Choosing "Run without debugging" seems to still upload. Hitting the upload button causes this error.

tmolteno commented 1 year ago

I think the problem is that the branch is called "main". Modifying this in the line in the .platformio directory,

platforms/ch32v/platform.json:      "version": "https://github.com/Community-PIO-CH32V/tool-minichlink.git#master",

to

platforms/ch32v/platform.json:      "version": "https://github.com/Community-PIO-CH32V/tool-minichlink.git#main",

Allows the upload to proceed further. Uploading now works.

maxgerhardt commented 1 year ago

Thanks for the info, I'll investigate this later.

maxgerhardt commented 1 year ago

Might already be fixed with 131d250034d057222b27b8b75cb557290e333845, can you reinstall the platform cleanly?

rm -rf ~/.platformio/platforms/ch32v
rm -rf ~/.platformio/packages/tool-minichlink

And, this is not documented yet, but you need to have libusb installed with I think brew on Mac so that the program can startup at all.

tmolteno commented 1 year ago

Seems to work now. Thanks