GD32F103RGT6 custom board

Boards based on the GigaDevices GD32F103 microcontroller
Flycatcher
Posts: 6
Joined: Fri Jul 28, 2017 5:33 am

GD32F103RGT6 custom board

Post by Flycatcher » Fri Jul 28, 2017 6:24 am

Hello!

I`m hardware designer and i have the GD32F103RG board for one of my projects.

Image

The software for this board was written on Keil by other people.
Howewer, i want to have ability to write some simple programs for testing and to
use this board in my own research and measurement projects. The Arduino IDE with STM32 library
was installed on Linux Mint 17.3 AMD64 and blinking sketch was successfully download to the board using ST-Link/V2.
I had to use STM32F103RE generic board.
So, i have two questions:
1. How exactly i must modify boards.txt to correct use GD32F103RG?
2. How can i determine the quartz frequency ? Serial board have 16 MHz quartz and I want to use 16.55 MHz for measurements.

Somebody help me please!

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: GD32F103RGT6 custom board

Post by RogerClark » Fri Jul 28, 2017 10:57 am

There isnt a lot of difference between the STM32 and GD32 processors

There used to be a separate GD32 core, which was for some small boards which have a 12Mhz crystal, but I removed it ages ago, however you may be able to go back through the github commits and find it.

I recommend you make a new variant based on the STM32F103R and look at the code in the nucleo , specifly these lines

https://github.com/rogerclarkmelbourne/ ... pp#L50-L56

Where a different PLL is set.

I think you will need to use a 6 x multipler to give you 96Mhz as the max freq on the GD32F103 is 108Mhz

Then if you set the f_cpu in the boards.txt to 96000000L (look at the gd32f103 board.txt entry), this should set the correct USB PLL Divider setting (of 2), so that USB will work.


Re: I want to use 16.55 MHz for measurements

The STM32 is not a signal generator, I suspect it will be difficult to make 16.55Mhz from this board, I recommend you by something like a AD9850 board to generate your 16.55Mhz signals

Flycatcher
Posts: 6
Joined: Fri Jul 28, 2017 5:33 am

Re: GD32F103RGT6 custom board

Post by Flycatcher » Fri Jul 28, 2017 3:15 pm

Hi Roger!
Thank you for you attention to my problem.
I modify boards.txt in generic STM32F103R section.

Code: Select all

genericSTM32F103R.menu.device_variant.STM32F103RG=STM32F103RG (96k RAM. 1024k Flash)
genericSTM32F103R.menu.device_variant.STM32F103RG.build.variant=generic_stm32f103r
genericSTM32F103R.menu.device_variant.STM32F103RG.build.cpu_flags=-DMCU_STM32F103RE
genericSTM32F103R.menu.device_variant.STM32F103RG.upload.maximum_size=524288
genericSTM32F103R.menu.device_variant.STM32F103RG.upload.ram.maximum_size=65536
genericSTM32F103R.menu.device_variant.STM32F103RG.upload.flash.maximum_size=524288
genericSTM32F103R.menu.device_variant.STM32F103RG.build.ldscript=ld/stm32f103re.ld

genericSTM32F103R.menu.cpu_speed.speed_96mhz=96Mhz (High)
genericSTM32F103R.menu.cpu_speed.speed_96mhz.build.f_cpu=96000000L

genericSTM32F103R.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
genericSTM32F103R.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L

genericSTM32F103R.menu.cpu_speed.speed_48mhz=48Mhz (Slow)
genericSTM32F103R.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
After that, i got the nice menu entry for my custom board.
Can i set to the correct for 103RG values?
maximum_size=1048576
ram.maximum_size=98304
flash.maximum_size=1048576
Is it correct to use build.cpu_flags=-DMCU_STM32F103RE or it`s necessary to configure DMCU_STM32F103RG?

So, i try to modify boards_setup.cpp and read the STM32F103 reference manual. Actually, i can get 48 and 96 MHz cloks with 16 MHz HSE oscillator, but i can`t have 72 MHz (it`s no 4.5 prescaler value) and i have no USB with 96 MHz cloks (USB have no divide by 2, only 1 and 1.5).
After that, i think the best way is to divide HSE cloks by 2. It`s possible if set PLLXTPRE bit in register RCC_CFGR.
Can you advise me the way to do that?

And, of course, i didn`t try to use 103RG as a DDS or PLL circuit. I have 16.583 MHz quartz to use with 103RG for synchronize measurements and try to preserve UART functionality :) .

Good luck!

Ollie
Posts: 197
Joined: Thu Feb 25, 2016 7:27 pm

Re: GD32F103RGT6 custom board

Post by Ollie » Sat Jul 29, 2017 3:54 pm

Flycatcher,

I wish you good luck and success with your development. Based on my own experience, I have observed that it is easiest and most productive to stay in the main stream. Every time you deviate from the main stream, there is a huge cost, which is not always immediately evident. In that sense, there have to be some major benefits to do that, such as cost savings, performance gain, or technical feasibility. I am not convinced that your choice of GD over ST and using a non-standard crystal are wise choices.

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: GD32F103RGT6 custom board

Post by RogerClark » Sat Jul 29, 2017 9:53 pm

USB is unlikely to work with a 16.55mhz crystal as the USB clock freq has to be quit close to 48mhz.

I think you may be able to get the UART to work, but you would need to play with the various numbers used in the UART timing setup.

I personally gave up using my GD32F103C8 boards, because I had issues with SPI not working with the ILI9341 display, and I did not have time to spend hours debugging the differences in the SPI operations.
(I did some basic tests with SPI can I could clock data in and out, but the display would not work, so I presumed it was some timing issue)

GD32 boards initially looked like they would become popular because we expected GD to undercut the price of STM32 and they have much higher code execution speed because they have zero wait state program memory.

However, none of the Chinese board producers seem to have thought that the GD32 was a viable or cheaper alternative to the STM32 and GD32 boards now tend to be hard to get hold of and are more epensive than STM32 boards.

Flycatcher
Posts: 6
Joined: Fri Jul 28, 2017 5:33 am

Re: GD32F103RGT6 custom board

Post by Flycatcher » Sun Jul 30, 2017 6:26 am

Ollie wrote:
Sat Jul 29, 2017 3:54 pm
Flycatcher,
I wish you good luck and success with your development. Based on my own experience, I have observed that it is easiest and most productive to stay in the main stream. Every time you deviate from the main stream, there is a huge cost, which is not always immediately evident. In that sense, there have to be some major benefits to do that, such as cost savings, performance gain, or technical feasibility. I am not convinced that your choice of GD over ST and using a non-standard crystal are wise choices.
Hi Ollie!

Thank you for benevolent words!
I agree about the cost of non-mainstream decisions, but i have my own reasons.
First - this board (it`s my hardware design) is in serial production and i want to have ability to test and fixing it by myself, without programmers time spending. Also, it`s cose to use this boards for my own purposes like home automation or measurements in the shack.
Second - about GD. Here, in Russia, it`s easy to buy it and it`s really cheap. Another reason is sanctions. We have a problems with supply of IC from US, EU and Japan time to time. In some cases we must prove non-military appointment of the project. Inside Russia the IC with some crypto engine (DES,AES, etc.) must have special certificate. It`s additional time and money expences. I have few boards with the partlist variant with STM32F205 for testing.

Bye!

Flycatcher
Posts: 6
Joined: Fri Jul 28, 2017 5:33 am

Re: GD32F103RGT6 custom board

Post by Flycatcher » Sun Jul 30, 2017 6:51 am

RogerClark wrote:
Sat Jul 29, 2017 9:53 pm
USB is unlikely to work with a 16.55mhz crystal as the USB clock freq has to be quit close to 48mhz.
I think you may be able to get the UART to work, but you would need to play with the various numbers used in the UART timing setup.
Hello, Roger!
Thanks a lot for your help!
As i read, the GD micros have a divide by two prescaler on USB instead ST. Files was corrected and i have 48 and 96 MHz with USB. "Hello World!" was reseaved by built-in Arduino IDE terminal. 16.55 or 16.583 MHz in not for USB i guess. Just for UART. I had my first professional hardware project in 1997. It was an ISA UART with 16 channel multiplexer for industrial purpose.....
RogerClark wrote:
Sat Jul 29, 2017 9:53 pm
However, none of the Chinese board producers seem to have thought that the GD32 was a viable or cheaper alternative to the STM32 and GD32 boards now tend to be hard to get hold of and are more epensive than STM32 boards.
It`s a difference between us - you speak about boards, i - about IC. :)

Good luck!

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: GD32F103RGT6 custom board

Post by RogerClark » Sun Jul 30, 2017 7:18 am

@Flycatcher

Interesting about GD pricing in Russia, and also not being able to get STM32.
I get all my STM32's from China, but I normally only buy boards e.g. BluePill and rarely just STM32F103C8 MCU IC's

Cost of the BluePill is often cheaper than I can make a board, even buying components from AliExpress.


I know one other forum member "Greg" who runs a manufacturing company in the USA was in discussions with GD about building boards (in the USA), using GD, but he has not posted for ages, so I don't think he made any boards.

GD does have some interesting features like the 2 extra USB PLL prescaler settings (2x and 2.5x ) and also runs much faster than STM32
But it also has some disadvantages, e.g. GD32F103C8 only has 64k flash, but STM32F103C8 seems to always have 128k flash even though its only supposed to have 64k

There are similar things on other STM32F1 series processors, the F101 is not supposed to have USB but it seems to have the same core silicon as the F103 and hence has USB !
So many Chinese companies use the F101 for STLink dongles, as its cheaper than the F103.

Anyway.

Good luck with your project

Flycatcher
Posts: 6
Joined: Fri Jul 28, 2017 5:33 am

Re: GD32F103RGT6 custom board

Post by Flycatcher » Sun Jul 30, 2017 7:20 pm

RogerClark wrote:
Sun Jul 30, 2017 7:18 am
Interesting about GD pricing in Russia, and also not being able to get STM32.
I get all my STM32's from China, but I normally only buy boards e.g. BluePill and rarely just STM32F103C8 MCU IC's
Hello Roger!
The exchange rate today is 59.52 russian roubles for 1 US dollar.
Price of GD32F103RGT6 is 260.11 - it`s close to 4.37 USD (1 MB Flash, 96 KB Ram). This price is for one IC, if you want to buy few hungreds, the price will be lower. Half year ago the price was ~ 3.5 USD at 4000 pcs.
Price of GD32F103C8T6 is 63.58 - approx. 1.07 USD (64 KB Flash, 8 KB Ram) for 1 pcs.
About not able to get - It`s possible to buy few parts for prototyping, but the problem is to get big volume for serial production.
RogerClark wrote:
Sun Jul 30, 2017 7:18 am
I know one other forum member "Greg" who runs a manufacturing company in the USA was in discussions with GD about building boards (in the USA), using GD, but he has not posted for ages, so I don't think he made any boards.
I can design the boar if it`s necessary. And organize manufacturing in Russia or China. What reason to produce it directly in the USA?

Good luck!

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: GD32F103RGT6 custom board

Post by Pito » Sun Jul 30, 2017 8:04 pm

I've configured 50x50mm 10pcs pcb boards, similar params to iTead's cheapest offering, 15-20days, by Rezonit.ru and the price exclusive shipping costs is $78 (4700rub).
Is there a cheaper producer in Russia?
Pukao Hats Cleaning Services Ltd.

Post Reply