aappleby / picorvd

GDB-compatible RISC-V Debugger for CH32V003 that runs on a Raspberry Pi Pico
MIT License
173 stars 11 forks source link

Documentation clarifications re: pull up resistor #1

Closed prosper00 closed 1 year ago

prosper00 commented 1 year ago

I just came across your project today - wow, this is excellent work!! I got a pile of ch32v003 chips in the mail yesterday, but I'd ordered the wrong debugger, and your project gets me up and going.

Couple observations:

  1. The pullup resistor - it's important that the pullup is as close the ch32v as possible. I'd thought to connect it on the rpi side, but when using a 40cm wire between the two boards, it doesn't work. [also note that wch recommends a 10k value instead of 1k].
  2. In order to build successfully, example/build.sh needs to be run first, and then ./build.sh - Console.cpp depends on example/bin/blink.h, which doesn't exist until blink is built.
aappleby commented 1 year ago

I've had the pull-up resistor in a couple different positions and it hasn't mattered much, but the wire from the Pico to the CH32 is only ~15 cm. It definitely has to be 1kohm, 10k would not pull the bus up nearly fast enough to support normal-speed mode.

Someone else mentioned the blink.h thing, I need to fix that today :/

aappleby commented 1 year ago

(the official wch-link dongle also uses 1k)

prosper00 commented 1 year ago

Yeah, you can disregard what I said regarding the pull up resistor. There's something else going on here that I need to troubleshoot. I can get the blink example to flash, but the mcu often fails to start up. I have to disconnect/reconnect the power several times to get the LED to start blinking. Same for flashing it in the first place - sometimes it fails or times out, but after a few power cycles, it works. So far, I can't find a pattern. Have tried two chips so far with identical results. Tried different decoupling caps, tried a cap on nRST, tried different power supplies, different wires - all with the same results. I'll keep poking away at it here, but it's certainly not anything to do with the pull up resistor.

prosper00 commented 1 year ago

I've narrowed down my ch32v startup problems to something in the included example blinkie. Perhaps there's an issue in the default interrupt vectors or the clocks somewhere. In any case, when I compile and burn a fresh example from the ch32v003fun repo (this one: https://github.com/cnlohr/ch32v003fun/tree/master/examples/systick_irq_millis ) - the chip starts up fine every time. But when I burn 'blink' from this repo, the mcu generally fails to start up until I bounce the power a few times.

Also, I've noticed that 'wipe_chip' from the console doesn't seem to do anything other than halt the mcu. Issuing a 'resume' (or a hardware reset or power cycle) after an (apparently successful) 'wipe' resumes the program as if nothing had happened.