prosper00 / CH32V305-DAPLink-HS

CH32V305 DAPLink - USB2.0 High Speed DAPLink firmware for the WCH-LinkE
11 stars 2 forks source link

[Feature request] support for V307 #1

Open lyusupov opened 1 month ago

lyusupov commented 1 month ago

Is there any chance to add support for V307 as well ?

https://www.cnx-software.com/2022/07/14/yd-ch32v307vct6-risc-v-mcu-board-comes-with-ethernet-and-plenty-of-i-os/ https://github.com/yym36100/RISC-V_CH32V307VCT6

prosper00 commented 1 month ago

I don't have a 307.... but I suspect it should work.

lyusupov commented 1 month ago

Thank you for your reply!

but I suspect it should work

Could you, please, deploy HEX and BIN binaries for V307, similar to that you already did for the V305 ?

prosper00 commented 1 month ago

it looks like the 305 and 307 are binary compatible. The source code doesn't differentiate between the two, and they share a common startup file and macro.

`

define CH32V30x_D8C / CH32V307x-CH32V305x /

`

So, you should be able to flash the same binary to a 307 device and as long as you have it wired up to the same GPIO pins (https://www.wch.cn/downloads/WCH-LinkSCH_PDF.html) - I don't see why it wouldn't work. The actual pin numbers will likely be different, but the port/pins used are the same. If needed, you can change them in User/DAP_config.h.

For example, // SWD IO RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = PIN_CLK | PIN_DIO; the SWDIO pin is therefore using Port A and PIN_CLK is defined as pin 14 - so, PA14.

Also don't forget that you need a 12MHZ crystal on PD0/PD1

lyusupov commented 1 month ago

Uploading of CH32V305_DAP.bin by WCHISPStudio via USB into V307 devkit gives no effect.

V307 uses different clock source routing.

V305

image

V307

image
prosper00 commented 1 month ago

CH32V307_DAP.zip

Give this a try.... the code assumes a 12MHz crystal, and you've got an 8MHz one. I updated the HSE_VALUE to 8000000. Having it connected to the OSC_IN / OSC_OUT pins is correct.

lyusupov commented 1 month ago

Give this a try...

Still no positive effect. I've tried both of USB ports available - no any HS DAP device comes up.

This V307 code works Ok - https://github.com/nielh/hs-link
However it does not provide USB CDC interface.

prosper00 commented 1 month ago

I'm out of ideas, then. The startup code and MCU libraries are the same for both projects.

Maybe someday I'll order a 307, and hack around some more.