From 09d1dcf6b3e7b28ee4bb5b302fef370da2710135 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 4 Sep 2019 14:58:32 +0200 Subject: [PATCH] boards: Split off 128KiB version of bl*pill - Created new `bluepill-128kib` as 128KiB version of the `bluepill` - Created new `blackpill-128kib` as 128KiB version of the `blackpill` - Updated `openocd.cfg` to allow flashing 128KiB of ROM --- boards/blackpill-128kib/Makefile | 5 + boards/blackpill-128kib/Makefile.dep | 1 + boards/blackpill-128kib/Makefile.features | 1 + boards/blackpill-128kib/Makefile.include | 8 + boards/blackpill-128kib/doc.txt | 9 + boards/blackpill-128kib/include/board.h | 52 ++++++ boards/blackpill/Makefile | 2 +- boards/blackpill/Makefile.dep | 5 +- boards/blackpill/Makefile.features | 2 +- boards/blackpill/Makefile.include | 10 +- boards/blackpill/board.c | 35 ---- boards/blackpill/dist/openocd.cfg | 1 - boards/blackpill/doc.txt | 9 + boards/blackpill/include/board.h | 42 +---- boards/blackpill/include/gpio_params.h | 49 ------ boards/bluepill-128kib/Makefile | 5 + boards/bluepill-128kib/Makefile.dep | 1 + boards/bluepill-128kib/Makefile.features | 1 + boards/bluepill-128kib/Makefile.include | 8 + boards/bluepill-128kib/doc.txt | 9 + boards/bluepill-128kib/include/board.h | 45 +++++ boards/bluepill/Makefile | 2 +- boards/bluepill/Makefile.dep | 5 +- boards/bluepill/Makefile.features | 2 +- boards/bluepill/Makefile.include | 10 +- boards/bluepill/dist/openocd.cfg | 1 - boards/bluepill/doc.txt | 153 +---------------- boards/bluepill/include/board.h | 33 +--- .../{stm32f103c8 => blxxxpill}/Makefile | 2 +- boards/common/blxxxpill/Makefile.dep | 3 + .../Makefile.features | 0 .../Makefile.include | 11 +- boards/{bluepill => common/blxxxpill}/board.c | 0 .../common/blxxxpill/dist/openocd-128kib.cfg | 22 +++ .../dist/openocd.cfg | 0 boards/common/blxxxpill/doc.txt | 161 ++++++++++++++++++ .../common/blxxxpill/include/board_common.h | 75 ++++++++ .../blxxxpill}/include/gpio_params.h | 2 +- .../include/periph_conf.h | 6 +- boards/common/stm32f103c8/Makefile.dep | 0 40 files changed, 454 insertions(+), 334 deletions(-) create mode 100644 boards/blackpill-128kib/Makefile create mode 100644 boards/blackpill-128kib/Makefile.dep create mode 100644 boards/blackpill-128kib/Makefile.features create mode 100644 boards/blackpill-128kib/Makefile.include create mode 100644 boards/blackpill-128kib/doc.txt create mode 100644 boards/blackpill-128kib/include/board.h delete mode 100644 boards/blackpill/board.c delete mode 120000 boards/blackpill/dist/openocd.cfg create mode 100644 boards/blackpill/doc.txt delete mode 100644 boards/blackpill/include/gpio_params.h create mode 100644 boards/bluepill-128kib/Makefile create mode 100644 boards/bluepill-128kib/Makefile.dep create mode 100644 boards/bluepill-128kib/Makefile.features create mode 100644 boards/bluepill-128kib/Makefile.include create mode 100644 boards/bluepill-128kib/doc.txt create mode 100644 boards/bluepill-128kib/include/board.h delete mode 120000 boards/bluepill/dist/openocd.cfg rename boards/common/{stm32f103c8 => blxxxpill}/Makefile (50%) create mode 100644 boards/common/blxxxpill/Makefile.dep rename boards/common/{stm32f103c8 => blxxxpill}/Makefile.features (100%) rename boards/common/{stm32f103c8 => blxxxpill}/Makefile.include (83%) rename boards/{bluepill => common/blxxxpill}/board.c (100%) create mode 100644 boards/common/blxxxpill/dist/openocd-128kib.cfg rename boards/common/{stm32f103c8 => blxxxpill}/dist/openocd.cfg (100%) create mode 100644 boards/common/blxxxpill/doc.txt create mode 100644 boards/common/blxxxpill/include/board_common.h rename boards/{bluepill => common/blxxxpill}/include/gpio_params.h (95%) rename boards/common/{stm32f103c8 => blxxxpill}/include/periph_conf.h (96%) delete mode 100644 boards/common/stm32f103c8/Makefile.dep diff --git a/boards/blackpill-128kib/Makefile b/boards/blackpill-128kib/Makefile new file mode 100644 index 0000000000..e5fe6ee130 --- /dev/null +++ b/boards/blackpill-128kib/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/blxxxpill + +include $(RIOTBASE)/Makefile.base diff --git a/boards/blackpill-128kib/Makefile.dep b/boards/blackpill-128kib/Makefile.dep new file mode 100644 index 0000000000..a3e195bcc2 --- /dev/null +++ b/boards/blackpill-128kib/Makefile.dep @@ -0,0 +1 @@ +include $(RIOTBOARD)/common/blxxxpill/Makefile.dep diff --git a/boards/blackpill-128kib/Makefile.features b/boards/blackpill-128kib/Makefile.features new file mode 100644 index 0000000000..94ebe23fab --- /dev/null +++ b/boards/blackpill-128kib/Makefile.features @@ -0,0 +1 @@ +include $(RIOTBOARD)/common/blxxxpill/Makefile.features diff --git a/boards/blackpill-128kib/Makefile.include b/boards/blackpill-128kib/Makefile.include new file mode 100644 index 0000000000..7b80db87b4 --- /dev/null +++ b/boards/blackpill-128kib/Makefile.include @@ -0,0 +1,8 @@ +## the cpu to build for +export CPU = stm32f1 +export CPU_MODEL = stm32f103cb +export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd-128kib.cfg + +USEMODULE += boards_common_blxxxpill + +include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/blackpill-128kib/doc.txt b/boards/blackpill-128kib/doc.txt new file mode 100644 index 0000000000..a2397c086c --- /dev/null +++ b/boards/blackpill-128kib/doc.txt @@ -0,0 +1,9 @@ +/** +@defgroup boards_blackpill_128kib Blackpill board (128KiB flash hack version) +@ingroup boards +@brief Support for the stm32f103c8 based blackpill board. + +Refer to the common documentation of the bluepill and blackpill board in +@ref boards_common_blxxxpill instead. + + */ diff --git a/boards/blackpill-128kib/include/board.h b/boards/blackpill-128kib/include/board.h new file mode 100644 index 0000000000..317bd31818 --- /dev/null +++ b/boards/blackpill-128kib/include/board.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2015 TriaGnoSys GmbH + * 2017 Alexander Kurth, Sören Tempel, Tristan Bruns + * 2018 Otto-von-Guericke-Universität Magdeburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_blackpill_128kib + * @brief Support for the stm32f103c8 based Black pill. + * + * @{ + * + * @file + * @brief Peripheral MCU configuration for the Black Pill board + * + * @author Víctor Ariño + * @author Sören Tempel + * @author Tristan Bruns + * @author Alexander Kurth + * @author Marian Buschsieweke + */ + +#ifndef BOARD_H +#define BOARD_H + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Macros for controlling the on-board LED. + * @{ + */ +#define LED0_PORT GPIOB /**< GPIO-Port the LED is connected to */ +#define LED0_PORTNUM PORT_B /**< GPIO Port number the LED is connected to */ +#define LED0_PINNUM (12) /**< Pin number the LED is connected to */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +/* Beware: This include must come *after* LED0 paramters have been defined */ +#include "board_common.h" + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/blackpill/Makefile b/boards/blackpill/Makefile index 7d218baad8..e5fe6ee130 100644 --- a/boards/blackpill/Makefile +++ b/boards/blackpill/Makefile @@ -1,5 +1,5 @@ MODULE = board -DIRS = $(RIOTBOARD)/common/stm32f103c8 +DIRS = $(RIOTBOARD)/common/blxxxpill include $(RIOTBASE)/Makefile.base diff --git a/boards/blackpill/Makefile.dep b/boards/blackpill/Makefile.dep index 587675d912..a3e195bcc2 100644 --- a/boards/blackpill/Makefile.dep +++ b/boards/blackpill/Makefile.dep @@ -1,4 +1 @@ -ifneq (,$(filter saul_default,$(USEMODULE))) - USEMODULE += saul_gpio -endif -include $(RIOTBOARD)/common/stm32f103c8/Makefile.dep +include $(RIOTBOARD)/common/blxxxpill/Makefile.dep diff --git a/boards/blackpill/Makefile.features b/boards/blackpill/Makefile.features index b8adee88b3..94ebe23fab 100644 --- a/boards/blackpill/Makefile.features +++ b/boards/blackpill/Makefile.features @@ -1 +1 @@ -include $(RIOTBOARD)/common/stm32f103c8/Makefile.features +include $(RIOTBOARD)/common/blxxxpill/Makefile.features diff --git a/boards/blackpill/Makefile.include b/boards/blackpill/Makefile.include index 60e5ff25b5..0278f0c650 100644 --- a/boards/blackpill/Makefile.include +++ b/boards/blackpill/Makefile.include @@ -1,2 +1,8 @@ -USEMODULE += boards_common_stm32f103c8 -include $(RIOTBOARD)/common/stm32f103c8/Makefile.include +## the cpu to build for +export CPU = stm32f1 +export CPU_MODEL = stm32f103c8 +export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd.cfg + +USEMODULE += boards_common_blxxxpill + +include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/blackpill/board.c b/boards/blackpill/board.c deleted file mode 100644 index 585feb6fab..0000000000 --- a/boards/blackpill/board.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2015 TriaGnoSys GmbH - * 2017 Alexander Kurth, Sören Tempel, Tristan Bruns - * 2018 Otto-von-Guericke-Universität Magdeburg - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup boards_blackpill - * @{ - * - * @file - * @brief Board specific implementations for the Black Pill - * Board - * - * @author Víctor Ariño - * @author Sören Tempel - * @author Tristan Bruns - * @author Alexander Kurth - * @author Marian Buschsieweke - * - * @} - */ - -#include "board.h" -#include "periph/gpio.h" - -void board_init(void) -{ - cpu_init(); - gpio_init(LED0_PIN, GPIO_OUT); -} diff --git a/boards/blackpill/dist/openocd.cfg b/boards/blackpill/dist/openocd.cfg deleted file mode 120000 index c5149f81f5..0000000000 --- a/boards/blackpill/dist/openocd.cfg +++ /dev/null @@ -1 +0,0 @@ -../../common/stm32f103c8/dist/openocd.cfg \ No newline at end of file diff --git a/boards/blackpill/doc.txt b/boards/blackpill/doc.txt new file mode 100644 index 0000000000..ef5ca24429 --- /dev/null +++ b/boards/blackpill/doc.txt @@ -0,0 +1,9 @@ +/** +@defgroup boards_blackpill Blackpill board +@ingroup boards +@brief Support for the stm32f103c8 based blackpill board. + +Refer to the common documentation of the bluepill and blackpill board in +@ref boards_common_blxxxpill instead. + + */ diff --git a/boards/blackpill/include/board.h b/boards/blackpill/include/board.h index 97d6b92651..d817b91f55 100644 --- a/boards/blackpill/include/board.h +++ b/boards/blackpill/include/board.h @@ -9,17 +9,9 @@ */ /** - * @defgroup boards_blackpill Black pill - * @ingroup boards + * @ingroup boards_blackpill * @brief Support for the stm32f103c8 based Black pill. * - * This board can be bought very cheaply on sides like eBay or - * AliExpress. Although the MCU nominally has 64 KiB ROM, most of them - * have 128 KiB ROM. This board is almost identical to the bluepill board, - * except for the pin layout and the on board LED is connected to PB12 instead - * of PC13. For more information see: - * http://wiki.stm32duino.com/index.php?title=Black_Pill - * * @{ * * @file @@ -35,6 +27,7 @@ #ifndef BOARD_H #define BOARD_H + #ifdef __cplusplus extern "C" { #endif @@ -43,36 +36,17 @@ extern "C" { * @name Macros for controlling the on-board LED. * @{ */ -#define LED0_PORT GPIOB -#define LED0_PIN GPIO_PIN(PORT_B, 12) -#define LED0_MASK (1 << 12) - -#define LED0_ON (LED0_PORT->BSRR = (LED0_MASK << 16)) -#define LED0_OFF (LED0_PORT->BSRR = LED0_MASK) -#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK) -/** @} */ - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - -/** - * @brief Use the 2nd UART for STDIO on this board - */ -#define STDIO_UART_DEV UART_DEV(1) - -/** - * @name xtimer configuration - * @{ - */ -#define XTIMER_WIDTH (16) -#define XTIMER_BACKOFF (19) +#define LED0_PORT GPIOB /**< GPIO-Port the LED is connected to */ +#define LED0_PORTNUM PORT_B /**< GPIO Port number the LED is connected to */ +#define LED0_PINNUM (12) /**< Pin number the LED is connected to */ /** @} */ #ifdef __cplusplus } #endif +/* Beware: This include must come *after* LED0 paramters have been defined */ +#include "board_common.h" + #endif /* BOARD_H */ /** @} */ diff --git a/boards/blackpill/include/gpio_params.h b/boards/blackpill/include/gpio_params.h deleted file mode 100644 index 77ea94ba66..0000000000 --- a/boards/blackpill/include/gpio_params.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2017 HAW Hamburg - * 2018 Otto-von-Guericke-Universität Magdeburg - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup boards_blackpill - * @{ - * - * @file - * @brief Board specific configuration of direct mapped GPIOs - * - * @author Sebastian Meiling - * @author Marian Buschsieweke - */ - -#ifndef GPIO_PARAMS_H -#define GPIO_PARAMS_H - -#include "board.h" -#include "saul/periph.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief GPIO pin configuration - */ -static const saul_gpio_params_t saul_gpio_params[] = -{ - { - .name = "LED", - .pin = LED0_PIN, - .mode = GPIO_OUT, - .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) - }, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* GPIO_PARAMS_H */ -/** @} */ diff --git a/boards/bluepill-128kib/Makefile b/boards/bluepill-128kib/Makefile new file mode 100644 index 0000000000..e5fe6ee130 --- /dev/null +++ b/boards/bluepill-128kib/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/blxxxpill + +include $(RIOTBASE)/Makefile.base diff --git a/boards/bluepill-128kib/Makefile.dep b/boards/bluepill-128kib/Makefile.dep new file mode 100644 index 0000000000..a3e195bcc2 --- /dev/null +++ b/boards/bluepill-128kib/Makefile.dep @@ -0,0 +1 @@ +include $(RIOTBOARD)/common/blxxxpill/Makefile.dep diff --git a/boards/bluepill-128kib/Makefile.features b/boards/bluepill-128kib/Makefile.features new file mode 100644 index 0000000000..94ebe23fab --- /dev/null +++ b/boards/bluepill-128kib/Makefile.features @@ -0,0 +1 @@ +include $(RIOTBOARD)/common/blxxxpill/Makefile.features diff --git a/boards/bluepill-128kib/Makefile.include b/boards/bluepill-128kib/Makefile.include new file mode 100644 index 0000000000..7b80db87b4 --- /dev/null +++ b/boards/bluepill-128kib/Makefile.include @@ -0,0 +1,8 @@ +## the cpu to build for +export CPU = stm32f1 +export CPU_MODEL = stm32f103cb +export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd-128kib.cfg + +USEMODULE += boards_common_blxxxpill + +include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/bluepill-128kib/doc.txt b/boards/bluepill-128kib/doc.txt new file mode 100644 index 0000000000..661f108800 --- /dev/null +++ b/boards/bluepill-128kib/doc.txt @@ -0,0 +1,9 @@ +/** +@defgroup boards_bluepill_128kib Bluepill board (128KiB flash hack version) +@ingroup boards +@brief Support for the stm32f103c8 based bluepill board. + +Refer to the common documentation of the bluepill and blackpill board in +@ref boards_common_blxxxpill instead. + + */ diff --git a/boards/bluepill-128kib/include/board.h b/boards/bluepill-128kib/include/board.h new file mode 100644 index 0000000000..4a88d49ea6 --- /dev/null +++ b/boards/bluepill-128kib/include/board.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2015 TriaGnoSys GmbH + * 2017 Alexander Kurth, Sören Tempel, Tristan Bruns + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_bluepill_128kib + * + * This board can be bought very cheaply on sides like eBay or + * AliExpress. Although the MCU nominally has 64 KiB ROM, most of them + * have 128 KiB ROM. For more information see: + * http://wiki.stm32duino.com/index.php?title=Blue_Pill + * + * @{ + * + * @file + * @brief Peripheral MCU configuration for the bluepill board + * + * @author Víctor Ariño + * @author Sören Tempel + * @author Tristan Bruns + * @author Alexander Kurth + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "board_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Board common contains all required info */ + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/bluepill/Makefile b/boards/bluepill/Makefile index 7d218baad8..e5fe6ee130 100644 --- a/boards/bluepill/Makefile +++ b/boards/bluepill/Makefile @@ -1,5 +1,5 @@ MODULE = board -DIRS = $(RIOTBOARD)/common/stm32f103c8 +DIRS = $(RIOTBOARD)/common/blxxxpill include $(RIOTBASE)/Makefile.base diff --git a/boards/bluepill/Makefile.dep b/boards/bluepill/Makefile.dep index 587675d912..a3e195bcc2 100644 --- a/boards/bluepill/Makefile.dep +++ b/boards/bluepill/Makefile.dep @@ -1,4 +1 @@ -ifneq (,$(filter saul_default,$(USEMODULE))) - USEMODULE += saul_gpio -endif -include $(RIOTBOARD)/common/stm32f103c8/Makefile.dep +include $(RIOTBOARD)/common/blxxxpill/Makefile.dep diff --git a/boards/bluepill/Makefile.features b/boards/bluepill/Makefile.features index b8adee88b3..94ebe23fab 100644 --- a/boards/bluepill/Makefile.features +++ b/boards/bluepill/Makefile.features @@ -1 +1 @@ -include $(RIOTBOARD)/common/stm32f103c8/Makefile.features +include $(RIOTBOARD)/common/blxxxpill/Makefile.features diff --git a/boards/bluepill/Makefile.include b/boards/bluepill/Makefile.include index 60e5ff25b5..0278f0c650 100644 --- a/boards/bluepill/Makefile.include +++ b/boards/bluepill/Makefile.include @@ -1,2 +1,8 @@ -USEMODULE += boards_common_stm32f103c8 -include $(RIOTBOARD)/common/stm32f103c8/Makefile.include +## the cpu to build for +export CPU = stm32f1 +export CPU_MODEL = stm32f103c8 +export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/blxxxpill/dist/openocd.cfg + +USEMODULE += boards_common_blxxxpill + +include $(RIOTBOARD)/common/blxxxpill/Makefile.include diff --git a/boards/bluepill/dist/openocd.cfg b/boards/bluepill/dist/openocd.cfg deleted file mode 120000 index c5149f81f5..0000000000 --- a/boards/bluepill/dist/openocd.cfg +++ /dev/null @@ -1 +0,0 @@ -../../common/stm32f103c8/dist/openocd.cfg \ No newline at end of file diff --git a/boards/bluepill/doc.txt b/boards/bluepill/doc.txt index 7266c006e2..ac920dc782 100644 --- a/boards/bluepill/doc.txt +++ b/boards/bluepill/doc.txt @@ -3,156 +3,7 @@ @ingroup boards @brief Support for the stm32f103c8 based bluepill board. -## Overview +Refer to the common documentation of the bluepill and blackpill board in +@ref boards_common_blxxxpill instead. -The bluepill is an STM32F103 based board which can be bought for around -2€ on sides like AliExpress, eBay and others. Although the STM32F130C8 -MCU nominally has 64 KB flash, most [actually have 128 KB -flash][Flashsize]. - - -## Hardware - -![bluepill](https://camo.githubusercontent.com/8df2fb54f87527bdd57fe007352d72c1f377d08f/687474703a2f2f77696b692e73746d33326475696e6f2e636f6d2f696d616765732f7468756d622f312f31392f53544d33325f426c75655f50696c6c5f746f702e6a70672f38303070782d53544d33325f426c75655f50696c6c5f746f702e6a7067) - -### MCU - -| MCU | STM32F103C8 | -|:----------|:-----------------------| -| Family | ARM Cortex-M3 | -| Vendor | STMicroelectronics | -| RAM | 20 KB | -| Flash | 64 KB / 128 KB | -| Frequency | up to 72 MHz | -| Timer | 3x 16-Bit | -| ADC | 2x 12-bit, 10 channels | -| UART | 3 | -| SPI | 2 | -| I2C | 2 | -| CAN | 1 | -| Vcc | 2.0 to 3.6 V | -| Datasheet | [Datasheet][Datasheet] | - - -## Implementation Status - -| ID | Supported | -|:----- |:--------- | -| GPIO | yes | -| PWM | yes | -| UART | yes | -| ADC | yes | -| I2C | no | -| SPI | yes | -| USB | no | -| Timer | yes | -| CAN | no | - - -## Flashing - -To program and debug the board you need a SWD capable debugger. The -easiest way is using [OpenOCD][OpenOCD]. By default RIOT uses the hardware -reset signal and connects to the chip under reset for flashing. This is -required to reliably connect to the device even when the MCU is in a low power -mode. Therefore not only SWDIO and SWCLK, but also the RST pin of your -debugger need to be connected to the board. Once the device is connected to -the debugger and OpenOCD is installed, you can flash the device with: - - $ make BOARD=bluepill flash - -### Additional Flash - -To make use of the entire 128 KB flash, compile your application with: - - $ make STM32F103C8_FLASH_HACK=1 BOARD=bluepill - -This sets the `CPU_MODEL` make variable to `stm32f103cb`, the default -value is `stm32f103c8`. These two CPU models basically only have one -major difference, the latter has 128 KB flash while the former has 64 -KB. You may also set `STM32F103C8_FLASH_HACK` as environment variable. - -If you want to flash a binary compiled this way you either need to -figure out how to adjust the OpenOCD configuration to make it use 128 KB -flash or use this [stlink fork][caboStlink] which has a -[patch][caboPatch] to make use of the entire 128 KB flash using: - - $ C8T6HACK=1 st-flash write /dev/sgX $pathToHexFile 0x8000000 - - -## Connecting via Serial - -The default UART port used is UART2, which uses pins A2 (TX) and A3 (RX). -To use it, configure your UART to operate at a baudrate of 115200/8N1. - -## Using PWM - -PWM is available at pins A8 to A11. - -## Known Issues - -### USB connector - -The Micro-USB port is sometimes not soldered properly. Also, it is -usually equipped with an incorrect resistor. [This can be fixed multiple -ways][USB]. - -### Flashing fails - -Please check whether the debugger is properly connected, including the hardware -reset signal pin. - -| Pin on Debugger | Pin on Blue Pill | -|:------------------ |:---------------- | -| SWDIO | DIO | -| SWCLK | DCLK | -| NRST | R | -| GND | GND | -| VDD (3.3V) (*) | 3.3 | -| Target VCC (**) | 3.3 | - -- (*) Most debuggers have a 3.3V supply voltage to power the board. You can - alternatively power the board using the TTL-Adapter or via Micro-USB. -- (**) Some debuggers monitor the voltage of the target MCU. Their target VCC - pin needs to be connected to one of the 3.3V pins of the boards. - -Most very cheap SWD debuggers (especially those imported for about 2€ from far -east) do not have a Target VCC pin; they will still work just fine. On these -cheap debuggers the pin to send the reset signal to the board is often either -not present or defunct. You can work around this by pressing the reset button -when OpenOCD wants to connect to the Blue Pill. Hit the reset button again after -flashing in order to boot the newly flashed image. - -## Where to buy - -The board is sold under different names. On some sites it is called -`bluepill` or `blue pill`. On others you might find it by searching for -`stm32f103c8` or `stm32f103c8t6`. - -Try [eBay][eBay] or [AliExpress][AliExpress]. - - -## Further reading - -* http://wiki.stm32duino.com/index.php?title=Blue_Pill -* http://wiki.stm32duino.com/index.php?title=Maple_Mini#Clones -* http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit- -arm-cortex-mcus/stm32-mainstream-mcus/stm32f1-series/stm32f103/stm32f103c8.html - -[Datasheet]: http://www.st.com/content/ccc/resource/technical/document/datash -eet/33/d4/6f/1d/df/0b/4c/6d/CD00161566.pdf/files/CD00161566.pdf/jcr:content/tran -slations/en.CD00161566.pdf -[Flashsize]: -http://wiki.stm32duino.com/index.php?title=Blue_Pill#128_KB_flash_on_C8_version -[eBay]: https://www.ebay.com/sch/i.html?_nkw=stm32f103c8 -[AliExpress]: https://www.aliexpress.com/wholesale?SearchText=STM32F103C8T6 -[OpenOCD]: https://github.com/RIOT-OS/RIOT/wiki/OpenOCD -[USB]: -http://wiki.stm32duino.com/index.php?title=Blue_Pill#Hardware_installation -[imgTop]: -http://wiki.stm32duino.com/images/thumb/1/19/STM32_Blue_Pill_top.jpg/800px- -STM32_Blue_Pill_top.jpg -[caboStlink]: https://github.com/cabo/stlink -[caboPatch]: -https://github.com/cabo/stlink/commit/e2ff1710ca6caeb55b5b99f7bd8a29181ccf533d */ diff --git a/boards/bluepill/include/board.h b/boards/bluepill/include/board.h index 626d1e6eca..e0cdb07720 100644 --- a/boards/bluepill/include/board.h +++ b/boards/bluepill/include/board.h @@ -29,41 +29,12 @@ #ifndef BOARD_H #define BOARD_H +#include "board_common.h" + #ifdef __cplusplus extern "C" { #endif -/** - * @name Macros for controlling the on-board LED. - * @{ - */ -#define LED0_PORT GPIOC -#define LED0_PIN GPIO_PIN(PORT_C, 13) -#define LED0_MASK (1 << 13) - -#define LED0_ON (LED0_PORT->BSRR = (LED0_MASK << 16)) -#define LED0_OFF (LED0_PORT->BSRR = LED0_MASK) -#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK) -/** @} */ - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - -/** - * @brief Use the 2nd UART for STDIO on this board - */ -#define STDIO_UART_DEV UART_DEV(1) - -/** - * @name xtimer configuration - * @{ - */ -#define XTIMER_WIDTH (16) -#define XTIMER_BACKOFF (19) -/** @} */ - #ifdef __cplusplus } #endif diff --git a/boards/common/stm32f103c8/Makefile b/boards/common/blxxxpill/Makefile similarity index 50% rename from boards/common/stm32f103c8/Makefile rename to boards/common/blxxxpill/Makefile index 43083909ed..ede738cd00 100644 --- a/boards/common/stm32f103c8/Makefile +++ b/boards/common/blxxxpill/Makefile @@ -1,3 +1,3 @@ -MODULE = boards_common_stm32f103c8 +MODULE = boards_common_blxxxpill include $(RIOTBASE)/Makefile.base diff --git a/boards/common/blxxxpill/Makefile.dep b/boards/common/blxxxpill/Makefile.dep new file mode 100644 index 0000000000..5472bf8b8d --- /dev/null +++ b/boards/common/blxxxpill/Makefile.dep @@ -0,0 +1,3 @@ +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif diff --git a/boards/common/stm32f103c8/Makefile.features b/boards/common/blxxxpill/Makefile.features similarity index 100% rename from boards/common/stm32f103c8/Makefile.features rename to boards/common/blxxxpill/Makefile.features diff --git a/boards/common/stm32f103c8/Makefile.include b/boards/common/blxxxpill/Makefile.include similarity index 83% rename from boards/common/stm32f103c8/Makefile.include rename to boards/common/blxxxpill/Makefile.include index 9862d252c8..cd49a07cb2 100644 --- a/boards/common/stm32f103c8/Makefile.include +++ b/boards/common/blxxxpill/Makefile.include @@ -1,13 +1,4 @@ -## the cpu to build for -export CPU = stm32f1 -STM32F103C8_FLASH_HACK ?= 0 -ifneq ($(STM32F103C8_FLASH_HACK),0) - export CPU_MODEL = stm32f103cb -else - export CPU_MODEL = stm32f103c8 -endif - -INCLUDES += -I$(RIOTBOARD)/common/stm32f103c8/include +INCLUDES += -I$(RIOTBOARD)/common/blxxxpill/include # define the default port depending on the host OS PORT_LINUX ?= /dev/ttyUSB0 diff --git a/boards/bluepill/board.c b/boards/common/blxxxpill/board.c similarity index 100% rename from boards/bluepill/board.c rename to boards/common/blxxxpill/board.c diff --git a/boards/common/blxxxpill/dist/openocd-128kib.cfg b/boards/common/blxxxpill/dist/openocd-128kib.cfg new file mode 100644 index 0000000000..ccaf60b777 --- /dev/null +++ b/boards/common/blxxxpill/dist/openocd-128kib.cfg @@ -0,0 +1,22 @@ +set CHIPNAME STM32F103C8Tx + +# Enable debug when in low power modes +set ENABLE_LOW_POWER 1 + +# Stop Watchdog counters when halt +set STOP_WATCHDOG 1 + +# STlink Debug clock frequency +set CLOCK_FREQ 4000 + +# use hardware reset, connect under reset +# connect_assert_srst needed if low power mode application running (WFI...) +reset_config srst_only srst_nogate connect_assert_srst +set CONNECT_UNDER_RESET 1 + +# brutally overwriting detected flash size with 128KiB (OpenOCD > 0.10.0) +set FLASH_SIZE 0x20000 + +source [find target/stm32f1x.cfg] + +$_TARGETNAME configure -rtos auto diff --git a/boards/common/stm32f103c8/dist/openocd.cfg b/boards/common/blxxxpill/dist/openocd.cfg similarity index 100% rename from boards/common/stm32f103c8/dist/openocd.cfg rename to boards/common/blxxxpill/dist/openocd.cfg diff --git a/boards/common/blxxxpill/doc.txt b/boards/common/blxxxpill/doc.txt new file mode 100644 index 0000000000..b7e888a231 --- /dev/null +++ b/boards/common/blxxxpill/doc.txt @@ -0,0 +1,161 @@ +/** +@defgroup boards_common_blxxxpill Common code for bluepill and blackpill +@ingroup boards_common +@brief Support for cheap stm32f103c8 based boards such as bluepill and blackpill. + +## Overview + +The bluepill and the blackpill are STM32F103 based board which can be bought for +around 2€ on sides like AliExpress, eBay and others. Although the STM32F130C8 +MCU nominally has 64 KiB flash, most [actually have 128 KiB flash][Flashsize]. + +There are also versions that only report to have 32 KiB, but actually have +64 KiB. + + +## Hardware + +![bluepill](https://camo.githubusercontent.com/8df2fb54f87527bdd57fe007352d72c1f377d08f/687474703a2f2f77696b692e73746d33326475696e6f2e636f6d2f696d616765732f7468756d622f312f31392f53544d33325f426c75655f50696c6c5f746f702e6a70672f38303070782d53544d33325f426c75655f50696c6c5f746f702e6a7067) + +### MCU + +| MCU | STM32F103C8 | +|:----------|:--------------------------| +| Family | ARM Cortex-M3 | +| Vendor | STMicroelectronics | +| RAM | 20 KiB | +| Flash | 32 KiB/ 64 KiB / 128 KiB | +| Frequency | up to 72 MHz | +| Timer | 3x 16-Bit | +| ADC | 2x 12-bit, 10 channels | +| UART | 3 | +| SPI | 2 | +| I2C | 2 | +| CAN | 1 | +| Vcc | 2.0 to 3.6 V | +| Datasheet | [Datasheet][Datasheet] | + + +## Implementation Status + +| ID | Supported | +|:----- |:--------- | +| GPIO | yes | +| PWM | yes | +| UART | yes | +| ADC | yes | +| I2C | yes | +| SPI | yes | +| USB | no | +| Timer | yes | +| CAN | no | + + +## Flashing + +To program and debug the board you need a SWD capable debugger. The +easiest way is using [OpenOCD][OpenOCD]. By default RIOT uses the hardware +reset signal and connects to the chip under reset for flashing. This is +required to reliably connect to the device even when the MCU is in a low power +mode. Therefore not only SWDIO and SWCLK, but also the RST pin of your +debugger need to be connected to the board. Once the device is connected to +the debugger and OpenOCD is installed, you can flash the device with: + + $ make BOARD=bluepill flash + +Or for the blackpill with: + + $ make BOARD=blackpill flash + +### Additional Flash + +To make use of the entire 128 KiB flash, compile and flash your application +with: + + $ make BOARD=bluepill-128kib flash + +Or for the blackpill with: + + $ make BOARD=blackpill-128kib flash + +This sets the `CPU_MODEL` make variable to `stm32f103cb`, the default +value is `stm32f103c8`. These two CPU models basically only have one +major difference, the former has 128 KiB flash while the latter has 64 +KiB. + +Flashing for the 128KiB version currently (as of September 2019) requires the +development version of OpenOCD. + +## Connecting via Serial + +The default UART port used is UART2, which uses pins A2 (TX) and A3 (RX). +To use it, configure your UART to operate at a baudrate of 115200/8N1. + +## Using PWM + +PWM is available at pins A8 to A11. + +## Known Issues + +### USB connector + +The Micro-USB port is sometimes not soldered properly. Also, it is +usually equipped with an incorrect resistor. [This can be fixed multiple +ways][USB]. + +### Flashing fails + +Please check whether the debugger is properly connected, including the hardware +reset signal pin. + +| Pin on Debugger | Pin on Blue Pill | +|:------------------ |:---------------- | +| SWDIO | DIO | +| SWCLK | DCLK | +| NRST | R | +| GND | GND | +| VDD (3.3V) (*) | 3.3 | +| Target VCC (**) | 3.3 | + +- (*) Most debuggers have a 3.3V supply voltage to power the board. You can + alternatively power the board using the TTL-Adapter or via Micro-USB. +- (**) Some debuggers monitor the voltage of the target MCU. Their target VCC + pin needs to be connected to one of the 3.3V pins of the boards. + +Most very cheap SWD debuggers (especially those imported for about 2€ from far +east) do not have a Target VCC pin; they will still work just fine. On these +cheap debuggers the pin to send the reset signal to the board is often either +not present or defunct. You can work around this by pressing the reset button +when OpenOCD wants to connect to the Blue Pill. Hit the reset button again after +flashing in order to boot the newly flashed image. + +## Where to buy + +The board is sold under different names. On some sites it is called +`bluepill` or `blue pill`. On others you might find it by searching for +`stm32f103c8` or `stm32f103c8t6`. + +Try [eBay][eBay] or [AliExpress][AliExpress]. + + +## Further reading + +* http://wiki.stm32duino.com/index.php?title=Blue_Pill +* http://wiki.stm32duino.com/index.php?title=Maple_Mini#Clones +* http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit- +arm-cortex-mcus/stm32-mainstream-mcus/stm32f1-series/stm32f103/stm32f103c8.html + +[Datasheet]: http://www.st.com/content/ccc/resource/technical/document/datash +eet/33/d4/6f/1d/df/0b/4c/6d/CD00161566.pdf/files/CD00161566.pdf/jcr:content/tran +slations/en.CD00161566.pdf +[Flashsize]: +http://wiki.stm32duino.com/index.php?title=Blue_Pill#128_KB_flash_on_C8_version +[eBay]: https://www.ebay.com/sch/i.html?_nkw=stm32f103c8 +[AliExpress]: https://www.aliexpress.com/wholesale?SearchText=STM32F103C8T6 +[OpenOCD]: https://github.com/RIOT-OS/RIOT/wiki/OpenOCD +[USB]: +http://wiki.stm32duino.com/index.php?title=Blue_Pill#Hardware_installation +[imgTop]: +http://wiki.stm32duino.com/images/thumb/1/19/STM32_Blue_Pill_top.jpg/800px- +STM32_Blue_Pill_top.jpg + */ diff --git a/boards/common/blxxxpill/include/board_common.h b/boards/common/blxxxpill/include/board_common.h new file mode 100644 index 0000000000..a405eadd8c --- /dev/null +++ b/boards/common/blxxxpill/include/board_common.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 TriaGnoSys GmbH + * 2017 Alexander Kurth, Sören Tempel, Tristan Bruns + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_common_blxxxpill + * + * @{ + * + * @file + * @brief Peripheral MCU configuration for the bluepill/blackpill board + * + * @author Víctor Ariño + * @author Sören Tempel + * @author Tristan Bruns + * @author Alexander Kurth + */ + +#ifndef BOARD_COMMON_H +#define BOARD_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Macros for controlling the on-board LED. + * @{ + */ +#ifndef LED0_PORT +#define LED0_PORT GPIOC /**< GPIO-Port the LED is connected to */ +#endif +#ifndef LED0_PORTNUM +#define LED0_PORTNUM PORT_C /**< GPIO Port number the LED is connected to */ +#endif +#ifndef LED0_PINNUM +#define LED0_PINNUM (13) /**< Pin number the LED is connected to */ +#endif +#define LED0_PIN GPIO_PIN(LED0_PORTNUM, LED0_PINNUM) /**< GPIO-Pin the LED is connected to */ +#define LED0_MASK (1 << LED0_PINNUM) + +#define LED0_ON (LED0_PORT->BSRR = (LED0_MASK << 16)) /**< Turn LED0 on */ +#define LED0_OFF (LED0_PORT->BSRR = LED0_MASK) /**< Turn LED0 off */ +#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK) /**< Toggle LED0 */ +/** @} */ + +/** + * @brief Initialize board specific hardware, including clock, LEDs and std-IO + */ +void board_init(void); + +/** + * @brief Use the 2nd UART for STDIO on this board + */ +#define STDIO_UART_DEV UART_DEV(1) + +/** + * @name xtimer configuration + * @{ + */ +#define XTIMER_WIDTH (16) +#define XTIMER_BACKOFF (19) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_COMMON_H */ +/** @} */ diff --git a/boards/bluepill/include/gpio_params.h b/boards/common/blxxxpill/include/gpio_params.h similarity index 95% rename from boards/bluepill/include/gpio_params.h rename to boards/common/blxxxpill/include/gpio_params.h index a9f8b46172..913060746d 100644 --- a/boards/bluepill/include/gpio_params.h +++ b/boards/common/blxxxpill/include/gpio_params.h @@ -7,7 +7,7 @@ */ /** - * @ingroup boards_bluepill + * @ingroup boards_common_blxxxpill * @{ * * @file diff --git a/boards/common/stm32f103c8/include/periph_conf.h b/boards/common/blxxxpill/include/periph_conf.h similarity index 96% rename from boards/common/stm32f103c8/include/periph_conf.h rename to boards/common/blxxxpill/include/periph_conf.h index 862402526a..143b69a82a 100644 --- a/boards/common/stm32f103c8/include/periph_conf.h +++ b/boards/common/blxxxpill/include/periph_conf.h @@ -8,13 +8,11 @@ */ /** - * @defgroup boards_common_stm32f103c8 STM32F103C8 based boards common - * @ingroup boards_common - * @brief Shared files and configuration for STM32F103C8 based boards + * @ingroup boards_common_blxxxpill * @{ * * @file - * @brief Peripheral MCU configuration for the bluepill board + * @brief Peripheral MCU configuration for the bluepill/blackpill boards * * @author Víctor Ariño * @author Sören Tempel diff --git a/boards/common/stm32f103c8/Makefile.dep b/boards/common/stm32f103c8/Makefile.dep deleted file mode 100644 index e69de29bb2..0000000000