Skip to content

Conversation

@hathach
Copy link
Contributor

@hathach hathach commented Aug 21, 2024

Add support for Adafruit qtpy ch32v203g, which is the main reason for my effort (on behalf of Adafruit) for porting tinyusb to ch32v core as well as recent PRs. Boards is tested with neoixel, i2c, spi, uart2 all working well, for more info. Hopefully @ladyada would make more of ch32v hardware if that gain popular enough (and she could manage the time).

Note:

  • the board enable full 224 KB of flash, and enable enahnce read mode with pre_init()
  • comparing to stm32, ch32v usbd controller has a few race conditions (especially with windows) that I have put quite a bit of effort (like a week of work or more) to fix. I am glad it finally working more reliably.

What menu looks like after merged.
image

@ladyada
Copy link

ladyada commented Aug 21, 2024

thanks @hathach !

@maxint-rd
Copy link
Contributor

Hello @hathach, for my CH32V003 project I needed to enable the Watchdog and also wanted to use sleep. When looking for some Arduino standard I found that the Adafruit_SleepyDog library provided the broadest universal support. A moment ago I published a fork of Adafruit_SleepyDog that supports the CH32V003.

Other than perhaps some cleanup I think this version could already be useful for testing by other people. Unfortunately I don't have any other CH32 chips, so I couldn't add support for those. I did see in the core code that other chips use different EXTI_Line registers for implementing sleep(), but have no hardware to test that. Did you already have a look at supporting sleep for the CH32V203?

@ladyada
Copy link

ladyada commented Aug 26, 2024

we have no plans to add more library supports at this time so PRs are welcome! please submit a PR and you can tag @hathach to get a review for that library

@maxint-rd
Copy link
Contributor

Hello @ladyada - thanks for the swift reply. When I have time I will do some cleanup and submit that PR.
And before I forget: a big THANKS to Adafruit for making all those libraries to support a large community of makers, including myself.

@hathach
Copy link
Contributor Author

hathach commented Sep 5, 2024

@TianpeiLee sorry to bother your, would you please review this since we already launch the product for a few weeks. We could contribute to maintain support for our boards should there is any issue with it.

@TianpeiLee
Copy link
Collaborator

Hello, sorry for not processing it in time

@TianpeiLee
Copy link
Collaborator

@hathach
image

What does 224KB mean?

@TianpeiLee
Copy link
Collaborator

@hathach https://www.adafruit.com/product/5996 I already got it from here ,thank you !

@TianpeiLee TianpeiLee merged commit 4fb8a3f into openwch:main Sep 10, 2024

extern "C" {

void pre_init(void) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable enhanced read mode

@hathach
Copy link
Contributor Author

hathach commented Sep 10, 2024

@TianpeiLee thank you for merging the PR.

What does 224KB mean?

For your question, all v203 always has 224KB of flash, however, only 32K/64K is zero-wait state i.e fast flash. The rest is considered as slow flash, which requires to enable Flash Enhanced Read mode for stability, which we implemented in pre_init() for qtpy variant (check diff comment above). In our testing, it can run with application exeeding normal 32KB without any issues. I guess it will slow down a bit but not really notable with most arduino user.

Note: openocd only flash 32Kb due to its algorithm, to flash the whole elf up to full 224KB we need to either use wchisp (bootrom) and/or wchlink

from datasheet
image

from manual
image

Ref: article https://cpldcpu.wordpress.com/2024/05/01/decapsulating-the-ch32v203-reveals-a-separate-flash-die/

PS: Let me know if these make sense to you, or if you need any more clarification

@TianpeiLee
Copy link
Collaborator

thank you for your explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants