This board has about 100 pins, including 8 UARTS, but the Arduino variant file for the board so far only addresses a small subset,e.g. only one UART so can serial print, and even Blink LEDs are not setup. I can upload successfully to the board via the WCH-Link dongle but cannot get more than a few of the standard pins to be recognized, using external LED’s. Has anyone successfully extended the variant or other files to recognize more pins, e.g. UART’s, Ethernet and make this board more useful?
Sorry I do not have a clue as to what we are talking about and I am not clairvoyant so I cannot answer your question.
You haven’t really defined the problem yet, and in my experience these projects often fails due to a hardware issue, not the code. The quickest and most reliable way to diagnose it is to post an annotated schematic not a text description.
Please include:
• All connections, including power and ground
• All power sources and how they relate to each device
• Any wire or lead longer than 25 cm (10")
• Links or part numbers for the hardware you’re using, including the processor
With a complete schematic, we can help you far more accurately and avoid guessing.
This is the same topic as one now closed: Ch32V307VCT6 can’t access all pins in Arduino IDE
The problem is the Arduino IDE only identifies a subset of the 100 board pins in the variant.h and .cpp files. Important pins like UARTS are not in these files. Hence I am asking if there are any plans to expose more pins, or whether anyone has created their own local variant and related files, and could get them to work. Its an IDE issue, not wiring, so no diagram is needed, only the above board number. I can give you a further copy of the variant list for CH32V30xx but assume not necessary.
You should probably be asking the author of the board package by raising an issue on their Github page. The repository does not appear to have been updated for several months, so difficult to know what their plans may be.
Sure, more pins or a board definition can be added to the variant file but providing support for those pins is likely to involve rather more than that. You may have to wait for the author to update their repository.
Yes I tried various routes. UARTS not so simple to implement but suspect since so many of these boards out there someone might have attempted. Don’t see recent activity on any site however.
Exactly which board and core are you using?
I don't see any options on IDE for multiple boards with same CH32V30x. Core is Qingke V4F and board this one:
Looks like the original development environment was intended to be MounRiver. Not seen it before so have no knowledge of it.
There has since been made available a CH32 core for the Arduino platform in VsCode/PlatformIO
But the one for the Arduino IDE is here.
@MelMak , you have to add the following link to the JSON file in File->Preferences->Additional Board Manager URLs :
https://github.com/openwch/board_manager_files/raw/main/package_ch32v_index.json
In boards manager (icon on left) if you type CH32 into the search field you then get a board package called CH32 MCU EVT Boards available to install. Once installed, you get a number of boards available in boards manager. Currently the list includes the following categories:
CH32VOOx
CH32X035
CH32V10x
CH32V20x
CH32V30x
The variant file (.../.arduino15/packages/WCH/hardware/ch32v/1.0.4/variants/CH32V30x/PinAF_CH32V30x.h) lists UARTS up to UART8 as well as CAN, ETH and other GPIO pins. I haven't delved into the details.
Have you already added the JSON link and installed the board package?
Yes, installed that preference. That file you identify seems to relate to UART remapping not pin definitions I understand. The specific issue is with the variant file:
variant_CH32V307VCT6.h
Only one UART of 8 is defined there, and only some of the board pins. This was noted in the earlier Forum reference, now closed.
The path/file I was looking at was this:
.../.arduino15/packages/WCH/hardware/ch32v/1.0.4/variants/CH32V30x/PinAF_CH32V30x.h
But you are correct. None of these files define anywhere near 100 pins so you get what comes with the package. As I said earlier, to get into that level of discussion you probably need to liaise with the developer of the board package via their Github page. Only they will know whether they have any plans to further enhance their core software or what the timescales might be.
It's pretty common for chips with "many" serial ports to only support one or two of them - for example, the SAMD21 can support 6 serial ports (but that uses the same hardware as SPI and I2C ports, plus memory...)
In some cases, the software support already exists thanks to the modularity of C++, but the objects don't exist, and if you create them they need to be connected to appropriate pins, somehow.
I actually have a library that aids in adding Serial ports to SAMD (no, it won't help on CH32V chips, but the principle might be similar.
What happens if you just add:
HardwareSerial Serial3(USART3);
to the beginning of your sketch? (It compiles, but I don't have a WCH board to try it out on. You'll need to check the datasheets to see where RX/TX come out (by default) on the chip/board, and the pins may need some additional configuration to "connect" them to the USART, but it should all be possible without needing to modify the core libraries. I think.)
I wasn't aware that the CH32V boards were popular - "blue" and "black" "pills" using the ST32F ARM chips (and clones thereof) have been out for a while, but the RISCV WCH chips are newer, and a lot of people seem to be wary of using a chip whose only source is China.
I went through many steps, adding to variants file using the datasheet etc. Best result I would get it to compile but if have a send to any uart than the serial.print, nothing happens, not even the serial monitor output. Deepseek suggested many things which all failed with no pin responding and then eventually it said to try a Teensy 4.1 with its similar function and better support. My time is more valuable than the extra board cost.
I recall SamD51 has that Sercom thing to config ports, I could get I believe 5 UART’s from a tiny Xiao version, but then no pins are left for anything else. Almost all these chips…ESP etc are from offshore mfg.; the PJRC Teensy is made in Oregon now, but its MCU from elsewhere.
Are you willing to experiment more with the CH32V?
I can poke at the code a bit more and see if there is anything I find "obvious."
(or, like one of my first Arduino Forum Interactions: "Will write code for toys" - arrange for me to receive a board matching yours, and I'll get more serial ports working... (May not be practical if you're outside the US, in today's environment :-( )
Three is trivial on a Xiao SAMD board, since the SPI and I2C Sercoms can "always" be repurposed as UART. Whether you can get any more depends on which pins are broken out; I don't think it's possible.
Almost all these chips…ESP etc are from offshore mfg.; the PJRC Teensy is made in Oregon now, but its MCU from elsewhere.
It's not so much where the chip is physically manufactured, it's the whole supply chain. The Teensy chips are made by NXP; a longtime well known supplier with many distributors. ESP at least is carried by some US distributors (Digikey, etc) (Which is a pretty significant accomplishment, considering that not so long ago the only datasheets you could get were badly translated from Chinese by third parties.) AFAIK, the only way to get WCH chips is via foreign distributors like Alibaba, Aliexpress, LCSC/etc.
You make a lot of good points. Overall it looks like the board has lots of potential, but without WCH support, e.g. nothing on their website in months, no email response, probably not worth pursuing. The latest Teensy looks like a much better option, with support; I will know in a few days. I am not yet a part of the US and this is (was to be) only a small part of my project, so not much time for it unless someone already has a tested solution. I couldn’t even blink the onboard LED’s, and would need lots of UART’s and Ethernet. If you’d like a winter project, the boards and WCH dongle are very inexpensive on Alie:)
Well, WCH mostly supports their own development environment, rather than Arduino. That's true of most semiconductor vendors, at least in the explicit sense.
Microchip doesn't directly support Arduino, nor does TI, NXP, Nordic or Raspberry Pi.
Some vendors have direct support for Arduino: ST and ESP come to mind. I guess WCH's support for Arduino is more a "demo" than a finished product.
Normally, it takes a 3rd party vendor (Arduino, Adafruit, Sparkfun, PJRC) or a significant TEAM of individuals to adequately "support" some processor family - brief efforts by individuals are pretty much doomed to failure, eventually.
(ST is an interesting case. Originally, there was the "Leaf Labs Maple", and they based their core on the ST libraries of the time. But they quickly decided that the ST libraries were bloated, slow, and had potential licensing problems, so they rewrote their core on Bare Metal (not even using the ST #include files.) Roger Clarke expanded that somewhat to work on some of the cheap boards available ("Blue Pill"), but modifying the Bare Metal core to support additional chips was problematic. ST finally took note of the situation and implemented their own core, again based on their own libraries rather than bare metal (there having been significant improvement in the ST libraries and their licensing issues in the intervening years.)
But even Arduino gets accused (rightly) of being unresponsive to user requests...
Is there adequate documentation for the board? Do you know which Port/pin the onboard LEDs are connected to, for example. Some of the cheap boards are very ... sparse ... when it comes to things like schematics...
BTW: I assume that board uses the on-chip 10Mbit Ethernet Phy. If you wanted higher speed, you'd have to use an external Phy that would probably use up some of the same pins used by the UARTs.
Oh, one more thing: spending $35 for a Teensy4.1+Ethernet Jack obviously pays for more "support" than spending $8 for a CH32V board.
Built-in LED pins are identified on the vendor sites, but not in any code like variants, nor seem to respond when add your own. A basic example code showing the pin and functions, like I2C, SPI, UARTS etc like many vendors provide would be useful to encourage general use.
I don’t know the market sizes for various boards, to justify support etc; notice WCH also make a “Blue Pill” clone among other MCU’s.
Some of the WCH Core code looks like they implemented it originally on one of the much smaller chips (there was significant excitement over the $0.10 CH32V003 chips, for instance), and the same basic variant was copied to other chips without adding additional pins or features,
I've ordered a board to play with. I'm pretty sure I can get LED_BUILTIN working, and probably multiple UARTS, but I doubt that I have the patience to deal with the Ethernet.
Good luck with the board, mine supposedly has the 2 LED builtin pins on PA15 and PB4 as per vendor site.
I've been looking at the WCH core source code.
The Serial port code is pretty awful (even for what there is of it.) No interrupts.
(This is relatively common for "first draft" implementations; several official Arduino boards have also started like this. But it does mean that a sketch trying to use multiple serial ports is not likely to work very well.)
(I don't see an interrupt-driven UART implementation in the non-Arduino WCH libraries, either.)
