Author Topic: WCH $0.10 USD RISC-V MCU  (Read 42962 times)

0 Members and 1 Guest are viewing this topic.

Offline martinribelotta

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ar
  • A camel is a horse designed by a committee
    • Martin Ribelotta design services
Re: WCH $0.10 USD RISC-V MCU
« Reply #200 on: February 21, 2023, 03:52:13 pm »
Now, Patrick just posted the 1-wire protocol of debug:
https://github.com/openwch/ch32v003/blob/main/RISC-V%20QingKeV2%20Microprocessor%20Debug%20Manual.pdf

I hope that this protocol be the same for ch32v307 and familly but addapting the transport to 2-wire interface (Man I need a weekend free to put a logic analyzer over CK and DIO lines on my ch32v307 board)
 

Offline gmb42

  • Frequent Contributor
  • **
  • Posts: 294
  • Country: gb
Re: WCH $0.10 USD RISC-V MCU
« Reply #201 on: February 22, 2023, 11:01:16 am »
A tiny $1.50 WCH dev board from Muse labs, the nanoCH32V003. See https://linuxgizmos.com/the-nanoch32v003-is-a-risc-v-dev-board-available-for-1-50/
 

Offline elecdonia

  • Frequent Contributor
  • **
  • Posts: 399
  • Country: us
Re: WCH $0.10 USD RISC-V MCU
« Reply #202 on: February 22, 2023, 08:03:37 pm »
I think it's fascinating that Chinese vendors seem to have started targeting American "hobbyists" - cheap development boards, free development environments, documentation in English (even if it's not very good documentation), chips for sale in retail quantities, etc...   I'm guessing it's due to the success of Espressif.  But it's certainly fun times!
I think of myself as more of a “frugal independent developer” than “hobbyist.”

I retired after a 20+ year full-time hardware/software design engineer position (at one company!). These days I still have plenty of projects but a much more limited budget compared to when my employer was willing to purchase (most) of the development supplies I requested.

I continue to support Arduino.cc, Raspberry Pi, adafruit, Sparkfun, and Teensy by frequently purchasing items directly from them. Without them we wouldn’t have either the hardware or the tools to make cost-effective embedded systems.

But I also find it irresistible to sample the enormous smorgasboard of Chinese clones, modules, boards, and tools. It costs almost nothing to try them out. Some items are junk. Others are quite well made and stable over time.
I’m learning to be a leading-edge designer of trailing-edge technology.
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1486
  • Country: gb
Re: WCH $0.10 USD RISC-V MCU
« Reply #203 on: February 22, 2023, 08:58:44 pm »
Don't you just love it when there are inconsistencies between what a manufacturer's documentation says and what code in their HAL/SPL/etc actually does? ;D

There are a couple of such inconsistencies I've noticed in the CH32V003 Reference Manual (as of latest available, v1.3).

First is to do with the RCC clock configuration register CFGR0. According to the Reference Manual, bits 10:8 are "reserved" and bits 15:11 are for ADCPRE (ADC clock source divider). But wait! The library headers give bits 10:8 as for PPRE1 (APB1 clock source divider), bits 13:11 as PPRE2 (APB2 clock source divider), and only bits 15:14 for ADCPRE.

Did they decide to throw out the ability to run APB1 and APB2 at speeds different than the main AHB clock in order to have a greater range of dividers for the ADC? It may be that the docs are correct, because the separate header file for the RCC peripheral defines its own set of values for the ADC prescaler field that match the docs, and they forgot to update the main header file (it seems to be a pattern that peripheral-specific header files define their own register constants, in duplication of the main header). Who to believe?

The second instance is with the I2C peripheral. The manual documents that bits 14:10 of the OAR1 register are "reserved", but yet the I2C_AcknowledgedAddress_7bit constant in the I2C header file has the value 0x4000, which has bit 14 set, and this constant is always written to the register by the I2C_Init function.

So what is this bit? It rang a bell in my memory, that I had seen something like this before. Lo and behold, the I2C peripheral of the STM8 has in its OARH register an ADDCONF bit 14 which is documented as "This bit must set by software (must always be written as '1')". Hmmmmm... Are WCH using the exact same I2C peripheral? Everything else seems to also be highly similar to that of the ST chip. Did they buy the same third-party implementation? Or did they clone it so well, they included the flaws too? :-DD
« Last Edit: February 23, 2023, 02:02:54 pm by HwAoRrDk »
 
The following users thanked this post: karpouzi9

Offline josuah

  • Regular Contributor
  • *
  • Posts: 119
  • Country: fr
    • josuah.net
Re: WCH $0.10 USD RISC-V MCU
« Reply #204 on: February 26, 2023, 09:32:08 am »
so, the ATTiny8 is done for, right? end of an era  :-\

It will be when the power consumption will also match:

In standby, 25°, with the low speed oscillator running (for waking-up periodically and trigger an ADC readout for instance):

Not everything has lower than 1 uA battery consumption as requirement though.
 
The following users thanked this post: karpouzi9

Offline tim_

  • Regular Contributor
  • *
  • Posts: 239
  • Country: de
Re: WCH $0.10 USD RISC-V MCU
« Reply #205 on: February 26, 2023, 05:45:07 pm »
VDDmin is also much lower for the ATtinies.
 
The following users thanked this post: karpouzi9

Offline MT

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: aq
Re: WCH $0.10 USD RISC-V MCU
« Reply #206 on: March 10, 2023, 12:05:48 am »
CH32V203 manual.

In the Standby mode, the contents of 32KB of SRAM can be kept (depending on the planning and configuration before going to bed), and the contents of the backup registers are kept. :)
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14504
  • Country: fr
Re: WCH $0.10 USD RISC-V MCU
« Reply #207 on: March 10, 2023, 12:12:02 am »
CH32V203 manual.

In the Standby mode, the contents of 32KB of SRAM can be kept (depending on the planning and configuration before going to bed),

Good night! ;D
 

Offline Sacodepatatas

  • Regular Contributor
  • *
  • Posts: 82
  • Country: es
Re: WCH $0.10 USD RISC-V MCU
« Reply #208 on: March 10, 2023, 01:29:40 am »
Also CH32V203 Datasheet...
 

Offline 1276-2449-1-ND

  • Regular Contributor
  • *
  • Posts: 63
  • Country: ca
Re: WCH $0.10 USD RISC-V MCU
« Reply #209 on: April 18, 2023, 09:44:58 pm »

... and configuration before going to bed), and the contents of ... :)


If you put your ear to it when shutting down you can hear it beep and buzz a little lullaby.  :-DD
 

Online jnk0le

  • Contributor
  • Posts: 42
  • Country: pl
Re: WCH $0.10 USD RISC-V MCU
« Reply #210 on: May 06, 2023, 01:24:10 pm »
FYI

With a bit cursed github workflow, I've got someones GPL-lettered openocd fork to build windows binaries.

https://github.com/jnk0le/openocd-wch/releases/tag/29042023

v003 confirmed to work and open eclipse debug session.
No idea about the rest as I don't own those and cfg scripting is cursed similarly to code quality (even compared to extracts from MRS).

EDIT: it turns out that it requires proprietary drivers to work (enumerate as WCH-LinkRV instead of WCH-Link). Zadig WinUSB doesn't work.
« Last Edit: May 13, 2023, 01:37:48 pm by jnk0le »
 

Online jnk0le

  • Contributor
  • Posts: 42
  • Country: pl
Re: WCH $0.10 USD RISC-V MCU
« Reply #211 on: May 06, 2023, 06:19:49 pm »
some notes after briefly debugging this thing:

- debugger cannot step over `ebreak` instructions (single step as well as "continue" option). However eclipse breakpoints do work. Probably something with openocd code.

- MIE csr register is non functional

- `mie` bit can be written (high) by csr instructions only when it's written together with `mpie` (must write 0x88 instead of 0x08).
Debugger can however write `mie` bit without touching `mpie`

- after a hard reset (remove power, short vcc to gnd), sometimes the `mpop` and `mppop` are set in `mstatus` register

- 0x744 in `ra` after hard reset (anyone else?)
« Last Edit: May 06, 2023, 07:49:33 pm by jnk0le »
 

Online jnk0le

  • Contributor
  • Posts: 42
  • Country: pl
Re: WCH $0.10 USD RISC-V MCU
« Reply #212 on: May 07, 2023, 01:41:35 pm »
Finally got the startup code a bit more optimized than the vendor one.
https://github.com/jnk0le/simple-crt/tree/master/ch32v003

while(1) is 208 bytes with static initializers (194 without), and blinky (volatile delay)  is 286 bytes.

ED: now it's 202, 188, and 280 bytes
« Last Edit: May 12, 2023, 11:27:13 pm by jnk0le »
 

Offline HwAoRrDk

  • Super Contributor
  • ***
  • Posts: 1486
  • Country: gb
Re: WCH $0.10 USD RISC-V MCU
« Reply #213 on: May 07, 2023, 07:18:56 pm »
- MIE csr register is non functional

That's because it doesn't have an MIE register (nor MIP). The list of supported CSR registers can be found in the WCH QingKeV2 CPU manual.

Interrupt enable/disable/status are controlled by the proprietary PFIC peripheral using the PFIC_* registers (I say 'proprietary', but it's basically a clone of the STM32F103's NVIC).
 
The following users thanked this post: SiliconWizard

Online jnk0le

  • Contributor
  • Posts: 42
  • Country: pl
Re: WCH $0.10 USD RISC-V MCU
« Reply #214 on: May 07, 2023, 08:36:09 pm »

Interrupt enable/disable/status are controlled by the proprietary PFIC peripheral using the PFIC_* registers (I say 'proprietary', but it's basically a clone of the STM32F103's NVIC).

Those are per interrupt ones somewhat redundant to the core `mie` in `mstatus`, and the ones inside peripherals.
« Last Edit: May 07, 2023, 08:38:25 pm by jnk0le »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: WCH $0.10 USD RISC-V MCU
« Reply #215 on: May 08, 2023, 12:21:00 am »
Quote
a clone of the STM32F103's NVIC
Is the STM's NVIC anything different that the ARM Cortex-M3 NVIC?

 

Offline GromBeestje

  • Frequent Contributor
  • **
  • Posts: 280
  • Country: nl
Re: WCH $0.10 USD RISC-V MCU
« Reply #216 on: May 08, 2023, 05:35:59 am »
It is standard Cortex M
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf