/rv003usb

CH32V003 RISC-V Pure Software USB Controller

Primary LanguageCMIT LicenseMIT

Using USB on the CH32V003

Ever wanted a 10 cent USB-capable processor? Well, look no further. RV003USB allows you to, in firmware connect a 10 cent RISC-V to a computer with USB. It is fundamentally just a pin-change interrupt routine that runs in assembly, and some C code to handle higher level functionality.

It's small!

The bootloader version of the tool can create a HID device, enumerate and allow execution of code on-device in 1,920 bytes of code.

It's simple!

The core assembly code is only 2 functions, an interrupt and code to send.

It's adaptable!

The core assembly code is standardized, but the C code, to handle different functionality with hid feature requests, control setup events, interrupt endpoints (send and receive) are all done in a C file that changes per your needs.

It's built on ch32v003fun

ch32v003fun is a minimal development SDK of sorts for the CH32V003, allowing for maximum flexability without needing lots of code surrounding a HAL.

It's still in alpha.

This project is not ready for prime time, though it is sort of in an early alpha phase. Proof of concept works, we are on track for proper releases soon. Maybe you can help out!

✅ Able to go on-bus and receive USB frames
✅ Compute CRC in-line while receiving data
✅ Bit Stuffing (Works, tested)
✅ Sending USB Frames
✅ High Level USB Stack in C
✅ Make USB timing more precise.
✅ Use SE0 1ms ticks to tune HSItrim
✅ Rework sending code to send tokens/data separately.
✅ Fix CRC Code
✅ Make minichlink able to use bootloader.
✅ Optimize high-level stack.
✅ Fit in bootloader (NOTE: Need to tighten more)
✅ Do basic retiming, at least in preamble to improve timing.
✅ Use HID custom messages.
✅ Improve sync sled. I.e. coarse and fine sledding.
✅ Abort on non-8-bit-aligned-frames.
🔳 Make more demos
🔳 API For self-flashing + printf from bootloader
🔳 Improve timing on send, for CRC bits. Currently we are off by about 6 cycles total.
❕ Use hardware CRC to save space/time (Investigate)
❕ Further optimize Send/Receive PHY code. (Please help)
⚠️ Enable improved retiming (Requires a few more cycles) (Please help!)
⚠️ Arduino support (someone else will have to take this on)