Skip to content

Commit c0719c3

Browse files
Added experimental support for generic GD32F103C inside the STM32 tree
1 parent ec0ec18 commit c0719c3

File tree

24 files changed

+1516
-2
lines changed

24 files changed

+1516
-2
lines changed

STM32F1/boards.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,68 @@ genericSTM32F103Z.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
454454
genericSTM32F103Z.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
455455
genericSTM32F103Z.menu.upload_method.BMPMethod.upload.tool=bmp_upload
456456
genericSTM32F103Z.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
457+
458+
###################### Generic GD32F103C ########################################
459+
460+
genericGD32F103C.name=Generic GD32F103C series
461+
genericGD32F103C.build.variant=generic_GD32f103c
462+
genericGD32F103C.build.vect=VECT_TAB_ADDR=0x8000000
463+
genericGD32F103C.build.core=maple
464+
genericGD32F103C.build.board=GENERIC_GD32F103C
465+
genericGD32F103C.upload.use_1200bps_touch=false
466+
genericGD32F103C.upload.file_type=bin
467+
genericGD32F103C.upload.auto_reset=true
468+
genericGD32F103C.build.cpu_flags=-DMCU_STM32F103CB
469+
genericGD32F103C.build.f_cpu=72000000L
470+
471+
## GD32F103CB -------------------------
472+
genericGD32F103C.menu.device_variant.GD32F103CB=GD32F103CB (20k RAM. 128k Flash)
473+
genericGD32F103C.menu.device_variant.GD32F103CB.build.ldscript=ld/jtag.ld
474+
genericGD32F103C.menu.device_variant.GD32F103CB.upload.maximum_size=131072
475+
genericGD32F103C.menu.device_variant.GD32F103CB.upload.ram.maximum_size=20480
476+
genericGD32F103C.menu.device_variant.GD32F103CB.upload.flash.maximum_size=131072
477+
478+
479+
## GD32F103C8 -------------------------
480+
genericGD32F103C.menu.device_variant.GD32F103C8=GD32F103C8 (20k RAM. 64k Flash)
481+
genericGD32F103C.menu.device_variant.GD32F103C8.build.ldscript=ld/jtag_c8.ld
482+
genericGD32F103C.menu.device_variant.GD32F103C8.upload.maximum_size=65536
483+
genericGD32F103C.menu.device_variant.GD32F103C8.upload.ram.maximum_size=20480
484+
genericGD32F103C.menu.device_variant.GD32F103C8.upload.flash.maximum_size=65536
485+
486+
#---------------------------- UPLOAD METHODS ---------------------------
487+
488+
genericGD32F103C.menu.upload_method.DFUUploadMethod=GD32duino bootloader
489+
490+
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
491+
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
492+
genericGD32F103C.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DGENERIC_BOOTLOADER
493+
genericGD32F103C.menu.upload_method.DFUUploadMethod.build.vect=VECT_TAB_ADDR=0x8002000
494+
genericGD32F103C.menu.upload_method.DFUUploadMethod.build.ldscript=ld/bootloader_20.ld
495+
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
496+
genericGD32F103C.menu.upload_method.DFUUploadMethod.upload.altID=2
497+
498+
genericGD32F103C.menu.upload_method.serialMethod=Serial
499+
genericGD32F103C.menu.upload_method.serialMethod.upload.protocol=maple_serial
500+
genericGD32F103C.menu.upload_method.serialMethod.upload.tool=serial_upload
501+
502+
503+
genericGD32F103C.menu.upload_method.STLinkMethod=STLink
504+
genericGD32F103C.menu.upload_method.STLinkMethod.upload.protocol=STLink
505+
genericGD32F103C.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
506+
genericGD32F103C.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER
507+
508+
509+
genericGD32F103C.menu.upload_method.BMPMethod=BMP (Black Magic Probe)
510+
genericGD32F103C.menu.upload_method.BMPMethod.upload.protocol=gdb_bmp
511+
genericGD32F103C.menu.upload_method.BMPMethod.upload.tool=bmp_upload
512+
genericGD32F103C.menu.upload_method.BMPMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
513+
514+
genericGD32F103C.menu.cpu_speed.speed_120mhz=120Mhz (overdrive)
515+
genericGD32F103C.menu.cpu_speed.speed_120mhz.build.f_cpu=120000000L
516+
517+
genericGD32F103C.menu.cpu_speed.speed_96mhz=96Mhz (Stable)
518+
genericGD32F103C.menu.cpu_speed.speed_96mhz.build.f_cpu=96000000L
519+
520+
genericGD32F103C.menu.cpu_speed.speed_72mhz=72Mhz (compatibility)
521+
genericGD32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L

STM32F1/system/libmaple/stm32f1/include/series/rcc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ must be 48MHz. These bits can’t be reset if the USB clock is enabled.
538538
typedef enum rcc_usb_divider {
539539
RCC_USB_SYSCLK_DIV_1 = 0x1 << 22,
540540
RCC_USB_SYSCLK_DIV_1_5 = 0x0 << 22,
541-
//GD32 only RCC_USB_SYSCLK_DIV_2 = 0x3 << 22,
542-
//GD32 only RCC_USB_SYSCLK_DIV_2_5 = 0x2 << 22,
541+
RCC_USB_SYSCLK_DIV_2 = 0x3 << 22,
542+
RCC_USB_SYSCLK_DIV_2_5 = 0x2 << 22,
543543
} rcc_usb_divider;
544544

545545

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/******************************************************************************
2+
* The MIT License
3+
*
4+
* Copyright (c) 2011 LeafLabs, LLC.
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without
9+
* restriction, including without limitation the rights to use, copy,
10+
* modify, merge, publish, distribute, sublicense, and/or sell copies
11+
* of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be
15+
* included in all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*****************************************************************************/
26+
27+
/**
28+
* &file wirish/boards/maple_mini/board.cpp
29+
* &author Marti Bolivar <mbolivar&leaflabs.com>
30+
* &brief Maple Mini board file.
31+
*/
32+
33+
#include <board/board.h>
34+
35+
#include <libmaple/gpio.h>
36+
#include <libmaple/timer.h>
37+
38+
/* Roger Clark. Added next to includes for changes to Serial */
39+
#include <libmaple/usart.h>
40+
#include <HardwareSerial.h>
41+
42+
#include <wirish_debug.h>
43+
#include <wirish_types.h>
44+
45+
/* Since we want the Serial Wire/JTAG pins as GPIOs, disable both SW
46+
* and JTAG debug support, unless configured otherwise. */
47+
void boardInit(void) {
48+
#ifndef CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
49+
disableDebugPorts();
50+
#endif
51+
}
52+
53+
// Note. See the enum of pin names in board.h
54+
55+
extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {
56+
57+
58+
{&gpioa, &timer2, &adc1, 0, 1, 0}, /* PA0 */
59+
{&gpioa, &timer2, &adc1, 1, 2, 1}, /* PA1 */
60+
{&gpioa, &timer2, &adc1, 2, 3, 2}, /* PA2 */
61+
{&gpioa, &timer2, &adc1, 3, 4, 3}, /* PA3 */
62+
{&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */
63+
{&gpioa, NULL, &adc1, 5, 0, 5}, /* PA5 */
64+
{&gpioa, &timer3, &adc1, 6, 1, 6}, /* PA6 */
65+
{&gpioa, &timer3, &adc1, 7, 2, 7}, /* PA7 */
66+
{&gpioa, &timer1, NULL, 8, 1, ADCx}, /* PA8 */
67+
{&gpioa, &timer1, NULL, 9, 2, ADCx}, /* PA9 */
68+
{&gpioa, &timer1, NULL, 10, 3, ADCx}, /* PA10 */
69+
{&gpioa, &timer1, NULL, 11, 4, ADCx}, /* PA11 */
70+
{&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */
71+
{&gpioa, NULL, NULL, 13, 0, ADCx}, /* PA13 */
72+
{&gpioa, NULL, NULL, 14, 0, ADCx}, /* PA14 */
73+
{&gpioa, NULL, NULL, 15, 0, ADCx}, /* PA15 */
74+
75+
{&gpiob, &timer3, &adc1, 0, 3, 8}, /* PB0 */
76+
{&gpiob, &timer3, &adc1, 1, 4, 9}, /* PB1 */
77+
{&gpiob, NULL, NULL, 2, 0, ADCx}, /* PB2 */
78+
{&gpiob, NULL, NULL, 3, 0, ADCx}, /* PB3 */
79+
{&gpiob, NULL, NULL, 4, 0, ADCx}, /* PB4 */
80+
{&gpiob, NULL, NULL, 5, 0, ADCx}, /* PB5 */
81+
{&gpiob, &timer4, NULL, 6, 1, ADCx}, /* PB6 */
82+
{&gpiob, &timer4, NULL, 7, 2, ADCx}, /* PB7 */
83+
{&gpiob, &timer4, NULL, 8, 3, ADCx}, /* PB8 */
84+
{&gpiob, &timer4, NULL, 9, 4, ADCx}, /* PB9 */
85+
{&gpiob, NULL, NULL, 10, 0, ADCx}, /* PB10 */
86+
{&gpiob, NULL, NULL, 11, 0, ADCx}, /* PB11 */
87+
{&gpiob, NULL, NULL, 12, 0, ADCx}, /* PB12 */
88+
{&gpiob, NULL, NULL, 13, 0, ADCx}, /* PB13 */
89+
{&gpiob, NULL, NULL, 14, 0, ADCx}, /* PB14 */
90+
{&gpiob, NULL, NULL, 15, 0, ADCx}, /* PB15 */
91+
92+
{&gpioc, NULL, NULL, 13, 0, ADCx}, /* PC13 */
93+
{&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 */
94+
{&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 */
95+
96+
97+
98+
};
99+
100+
extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {
101+
PB0, PA7, PA6, PA3, PA2, PA1, PA0, PB7, PB6, PA10, PA9, PA8
102+
};
103+
104+
extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
105+
PB0, PA7, PA6 , PA5 , PA4 , PA3 , PA2 , PA1 , PA0
106+
};
107+
108+
// Note. These defines are not really used by generic boards. They are for Maple Serial USB
109+
#define USB_DP PA12
110+
#define USB_DM PA11
111+
112+
// NOte. These definitions are not really used for generic boards, they only relate to boards modified to behave like Maple boards
113+
extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
114+
USB_DP, USB_DM
115+
};
116+
117+
118+
/*
119+
* Roger Clark
120+
*
121+
* 2015/05/28
122+
*
123+
* Moved definitions for Hardware Serial devices from HardwareSerial.cpp so that each board can define which Arduino "Serial" instance
124+
* Maps to which hardware serial port on the microprocessor
125+
*/
126+
127+
#ifdef SERIAL_USB
128+
DEFINE_HWSERIAL(Serial1, 1);
129+
130+
DEFINE_HWSERIAL(Serial2, 2);
131+
132+
DEFINE_HWSERIAL(Serial3, 3);
133+
#else
134+
DEFINE_HWSERIAL(Serial, 1);
135+
136+
DEFINE_HWSERIAL(Serial1, 2);
137+
138+
DEFINE_HWSERIAL(Serial2, 3);
139+
#endif
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/******************************************************************************
2+
* The MIT License
3+
*
4+
* Copyright (c) 2011 LeafLabs, LLC.
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without
9+
* restriction, including without limitation the rights to use, copy,
10+
* modify, merge, publish, distribute, sublicense, and/or sell copies
11+
* of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be
15+
* included in all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*****************************************************************************/
26+
27+
/**
28+
* @file wirish/boards/maple_mini/include/board/board.h
29+
* @author Marti Bolivar <[email protected]>
30+
* @brief Maple Mini board header.
31+
*
32+
* See wirish/boards/maple/include/board/board.h for more information
33+
* on these definitions.
34+
*/
35+
36+
#ifndef _BOARD_GENERIC_STM32F103C_H_
37+
#define _BOARD_GENERIC_STM32F103C_H_
38+
39+
#define CYCLES_PER_MICROSECOND 72
40+
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
41+
42+
#define BOARD_NR_USARTS 3
43+
#define BOARD_USART1_TX_PIN PA9
44+
#define BOARD_USART1_RX_PIN PA10
45+
#define BOARD_USART2_TX_PIN PA2
46+
#define BOARD_USART2_RX_PIN PA3
47+
#define BOARD_USART3_TX_PIN PB10
48+
#define BOARD_USART3_RX_PIN PB11
49+
50+
#define BOARD_NR_SPI 2
51+
#define BOARD_SPI1_NSS_PIN PA4
52+
#define BOARD_SPI1_MOSI_PIN PA7
53+
#define BOARD_SPI1_MISO_PIN PA6
54+
#define BOARD_SPI1_SCK_PIN PA5
55+
56+
#define BOARD_SPI2_NSS_PIN PB12
57+
#define BOARD_SPI2_MOSI_PIN PB15
58+
#define BOARD_SPI2_MISO_PIN PB14
59+
#define BOARD_SPI2_SCK_PIN PB13
60+
61+
#define BOARD_NR_GPIO_PINS 35
62+
#define BOARD_NR_PWM_PINS 12
63+
#define BOARD_NR_ADC_PINS 9
64+
#define BOARD_NR_USED_PINS 4
65+
66+
67+
#define BOARD_JTMS_SWDIO_PIN 22
68+
#define BOARD_JTCK_SWCLK_PIN 21
69+
#define BOARD_JTDI_PIN 20
70+
#define BOARD_JTDO_PIN 19
71+
#define BOARD_NJTRST_PIN 18
72+
73+
#define BOARD_USB_DISC_DEV GPIOB
74+
#define BOARD_USB_DISC_BIT 10
75+
76+
// Note this needs to match with the PIN_MAP array in board.cpp
77+
enum {
78+
PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13,PA14,PA15,
79+
PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13,PB14,PB15,
80+
PC13, PC14,PC15
81+
};
82+
83+
#endif
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* libmaple linker script for "Flash" builds.
3+
*
4+
* A Flash build puts .text (and .rodata) in Flash, and
5+
* .data/.bss/heap (of course) in SRAM, but offsets the sections by
6+
* enough space to store the Maple bootloader, which lives in low
7+
* Flash and uses low memory.
8+
*/
9+
10+
/*
11+
* This pulls in the appropriate MEMORY declaration from the right
12+
* subdirectory of stm32/mem/ (the environment must call ld with the
13+
* right include directory flags to make this happen). Boards can also
14+
* use this file to use any of libmaple's memory-related hooks (like
15+
* where the heap should live).
16+
*/
17+
MEMORY
18+
{
19+
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
20+
rom (rx) : ORIGIN = 0x08002000, LENGTH = 120K
21+
}
22+
23+
/* Provide memory region aliases for common.inc */
24+
REGION_ALIAS("REGION_TEXT", rom);
25+
REGION_ALIAS("REGION_DATA", ram);
26+
REGION_ALIAS("REGION_BSS", ram);
27+
REGION_ALIAS("REGION_RODATA", rom);
28+
29+
/* Let common.inc handle the real work. */
30+
INCLUDE common.inc

0 commit comments

Comments
 (0)