Closed 0x0fe closed 5 months ago
For what it's worth, I really appreciate the effort WCH made to provide an Arduino core. The CH32v003 and it's family is a nice addition to the Arduino environment and delivers great value for money. I encourage WCH to dedicate some more attention to making this core more Arduino compatible, by implementing more of the features Arduino users are familiar with. The current list of issues shows that users are willing to help with improvements, but it seems that core developers have insufficient time available to respond.
Adding support for USB would be nice. Charles Lohr has shown that it certainly is possible: https://github.com/cnlohr/rv003usb Next to a compact bootloader for uploading code, he also demonstrates the use as HID device such as a gamepad.
@maxint-rd
The Lohr implementation is bitbanged and cannot serve as a basis forCH32X035 and other MCU featuring an USB PHY. and i highly doubt WCH will bother to implement bit banged USB stack on CH32V003 serie.
Lohr implementation could be used as is on CH32V003, but the USB stack has to be added to the core to perform the reset from CDC.
Okay, Thank you for this informative reply. Good to know. (I really hope WCH keeps supporting this Arduino core and give developers a bit more time to participate in discussions)
All chips with a bootloader support serial port and USB downloads, but for CH32V103, etc., the level of the boot pin needs to be switched to remap the startup address of the program, which requires auxiliary hardware on the board. The great thing about using WCH-LINKE is that you only need a few wires to achieve these functions, and it provides a serial port
All chips with a bootloader support serial port and USB downloads, but for CH32V103, etc., the level of the boot pin needs to be switched to remap the startup address of the program, which requires auxiliary hardware on the board. The great thing about using WCH-LINKE is that you only need a few wires to achieve these functions, and it provides a serial port
Generally what can be done by a boot pin can also be done by setting a register, i would be surprized if it was not possible to set this register and reset to the booatloader, without needing to set the boot pin. This would allow a seamless reset-upload without external hardware / circuit.
What the LINKE does could be done cirectly by the USB port 'CDC and DFU), this is the case on most SoC with USB support. Besides, you could not expect the end-user of a commercial product to require a LINKE to perform a firmware update.
For example, the boot mapping of the STM32 series of microcontrollers we are familiar with is also controlled through pins, which is relatively common among MCUs. Usually mass production burning tools are used to perform programming operations in mass production. User program upgrades may be through IAP, because each solution provider may have its own firmware upgrade platform, or upgrade verification process and protocol.
So, in arduino the "traditional" firmware upload method is via UART / CDC (when the MCU provides native USB).
On older WCH MCUs, such as CH5xx, the rom bootloader does support this, i assume it is also supported on newer MCUs such as CH32X035. To be convenient upload should be automatic (no user action on tact switch). If done via UART, no problem, we can use the control lines of the USB-UART bridge to toggle reset and BOOT, on CDC it should be done the baudrate change cdc command, using an odd/unused value such as 4800. When the host sets baudrate to 4800 the USB stack writes a persistant flag (usually in RTC memory) and resets the MCU, after reset the bootloader see the flag and stay in upload mode rather than jumping to the user application, waiting for datas.
I have done that some years ago on various STM32 for a client project and it was not particularly hard to implement, is there a plan to add this mechanism to the WCH core? It would be valuable.