Skip to content

Commit 4f61d96

Browse files
committed
Add a new target for the GigaDevice variant of the BluePill Plus.
WeAct ships two variants of this board, one with an STM32F103 and another with a GD32F303 series chip. The two boards are otherwise identical. The GD32F303 series is pin-compatible and register compatible with the STM32F103, but features a cortex M4, more ram, and more flash. In this case, the chip included has 48k of RAM and 256k of flash. The biggest difference is that flash pages are 2k and not 1k. While it's a little bit gross to be compiling code targeting the Cortex M3 on an ST chip and using it on an M4 made by somebody else, this was exactly the use case envisioned by GigaDevice. I've tested this bootloader on actual hardware and additionally validated that WebDFU works from https://devanlai.github.io/webdfu/dfu-util/ to it. The LED does *not* light up in the bootloader and I haven't dug into that, although the pin definition is correctly targeting PB2.
1 parent 087b7c7 commit 4f61d96

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2016, Devan Lai
3+
*
4+
* Permission to use, copy, modify, and/or distribute this software
5+
* for any purpose with or without fee is hereby granted, provided
6+
* that the above copyright notice and this permission notice
7+
* appear in all copies.
8+
*
9+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10+
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11+
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12+
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
13+
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15+
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17+
*/
18+
19+
#ifndef CONFIG_H_INCLUDED
20+
#define CONFIG_H_INCLUDED
21+
22+
#ifndef APP_BASE_ADDRESS
23+
#define APP_BASE_ADDRESS (0x08000000 + BOOTLOADER_OFFSET)
24+
#endif
25+
#ifndef FLASH_SIZE_OVERRIDE
26+
#define FLASH_SIZE_OVERRIDE 0x20000
27+
#endif
28+
#ifndef FLASH_PAGE_SIZE
29+
#define FLASH_PAGE_SIZE 2048
30+
#endif
31+
#ifndef DFU_UPLOAD_AVAILABLE
32+
#define DFU_UPLOAD_AVAILABLE 1
33+
#endif
34+
#ifndef DFU_DOWNLOAD_AVAILABLE
35+
#define DFU_DOWNLOAD_AVAILABLE 1
36+
#endif
37+
38+
#ifndef HAVE_LED
39+
#define HAVE_LED 1
40+
#endif
41+
#ifndef LED_OPEN_DRAIN
42+
#define LED_OPEN_DRAIN 0
43+
#endif
44+
#ifndef LED_GPIO_PORT
45+
#define LED_GPIO_PORT GPIOB
46+
#endif
47+
#ifndef LED_GPIO_PIN
48+
#define LED_GPIO_PIN GPIO2
49+
#endif
50+
51+
#ifndef HAVE_BUTTON
52+
#define HAVE_BUTTON 1
53+
#endif
54+
#ifndef BUTTON_ACTIVE_HIGH
55+
#define BUTTON_ACTIVE_HIGH 1
56+
#endif
57+
#ifndef BUTTON_GPIO_PORT
58+
#define BUTTON_GPIO_PORT GPIOA
59+
#endif
60+
#ifndef BUTTON_GPIO_PIN
61+
#define BUTTON_GPIO_PIN GPIO0
62+
#endif
63+
#ifndef BUTTON_USES_PULL
64+
#define BUTTON_USES_PULL 1
65+
#endif
66+
#ifndef BUTTON_SAMPLE_DELAY_CYCLES
67+
#define BUTTON_SAMPLE_DELAY_CYCLES 1440000
68+
#endif
69+
70+
#ifndef HAVE_USB_PULLUP_CONTROL
71+
#define HAVE_USB_PULLUP_CONTROL 0
72+
#endif
73+
74+
#ifndef USES_GPIOA
75+
#define USES_GPIOA 1
76+
#endif
77+
#ifndef USES_GPIOB
78+
#define USES_GPIOB 1
79+
#endif
80+
81+
#endif

src/targets.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ ifeq ($(TARGET),BLUEPILLPLUSSTM32_HIGH_128)
119119
ARCH = STM32F1
120120
DEFS += -DBOOTLOADER_HIGH
121121
endif
122+
ifeq ($(TARGET),BLUEPILLPLUSGD32)
123+
TARGET_COMMON_DIR := ./stm32f103
124+
TARGET_SPEC_DIR := ./stm32f103/bluepillplus-gd32
125+
LDSCRIPT := ./stm32f103/stm32f103x8.ld
126+
ARCH = STM32F1
127+
endif
122128
ifeq ($(TARGET),STM32L1_GENERIC)
123129
TARGET_COMMON_DIR := ./stm32l1
124130
TARGET_SPEC_DIR := ./stm32l1/generic

0 commit comments

Comments
 (0)