Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to GD32 RISC-V (gd32vf103cbt6) Sipeed Longan Nano? #75

Open
zoobab opened this issue Dec 23, 2020 · 5 comments
Open

Port to GD32 RISC-V (gd32vf103cbt6) Sipeed Longan Nano? #75

zoobab opened this issue Dec 23, 2020 · 5 comments

Comments

@zoobab
Copy link
Collaborator

zoobab commented Dec 23, 2020

Hi,

Just got a GD32 RISC-V, which is pin to pin compatible with the stm32f103.

How hard would it be to port DirtyJTAG there?

The library unicore-mx does not seem to have support for it...

@jeanthom
Copy link
Collaborator

Taking a look at a WIP patch for libopencm3 (https://github.com/libopencm3/libopencm3/pull/1234/files), it looks like the most significant change lies in NVIC controller, which is much different than ST's.

Does the GD32VF103 have a built-in USB DFU bootloader?

@robertlipe
Copy link

Flyby answer as I was just reading about DirtyJTAG, but I have G32V experience.

Yes, GD32VF103 has a highly integrated USB controller and often ships with a DFU boot loader. (I'll admit I've always gone straight for JTAG, which is sort of how I got here...) Certainly the Longan Nano ships with one: https://longan.sipeed.com/en/get_started/blink.html#usb-dfu-download. OK, That page is talking about PlatformIO, but that's the gateway to DFU. I think that basic recipe (fiddling with buttons) is common to most GD32V eval boards.

I'm a RISC-V guy and not an STM32 dude and never heard of NVIC, but looking at that PR it looks like tomato/tomahto interrupt controllers. The GD32V does have a mode simpler than ECLIC, which was chosen here. If you don't NEED a complicated interrupt nesting scheme CLIC and PLIC are way simpler and match more naturally to other RISC-V processors - you take an exception/interrupt, save some amount of registers, jump through the mtvec register, interrogate mtcause for exception or interrupt sources, handle them, and them mret. SiFive (yet another RISC-V vendor) has a good "Interrupt Cookbook" that explains that all very well. So if that's the part that's giving anyone pause, take the simpler route.

That patch Is bulky, but largely because it's trying really hard to provide the ST103F spellings for things, which seems a pretty reasonable goal for opencm3 as I understand it. A project starting from scratch on GD32VF103 would probably use https://github.com/Nuclei-Software/nuclei-sdk instead.

I haven't gone over it line by line, but that seems a pretty reasonable approach to me. Lots of STF103 projects move to GD32V without drama; lots of RTOSes have done exactly that.

So I'm not volunteering to do the work, but it's probably pretty straight forward and that CL (which still hasn't landed, for reasons not clear) seems like a reasonable start.

Good luck!

@jeanthom
Copy link
Collaborator

Hi Robert, thanks for your advice! In early January @phdussud rewrote all the code that was relying on interrupts to make things a bit quicker, so this should not be a problem anymore.

I started working on STM32F4 support (as getting genuine STM32F1 from Chinese vendors is quite complicated nowadays), which requires extensive Makefile modifications, so I guess we could use that as a starting point to allow compiling DirtyJTAG with on a radically different architecture.

Do you know if the DFU bootloader on the Sipeed dev board is stored in the flash or in ROM?

@robertlipe
Copy link

robertlipe commented Apr 27, 2021 via email

@robertlipe
Copy link

robertlipe commented Apr 27, 2021 via email

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

No branches or pull requests

3 participants