Merge pull request #15190 from benpicco/boards/wefun-f401cc

boards/common/weact-f4x1cx: create common WeAct boards
This commit is contained in:
Alexandre Abadie 2020-12-01 12:03:38 +01:00 committed by GitHub
commit b0b19203a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 323 additions and 92 deletions

View File

@ -0,0 +1,19 @@
# Copyright (c) 2020 Benjamin Valentin
#
# 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.
#
config BOARD_COMMON_WEACT_F41XCX
bool
# Put defined MCU peripherals here (in alphabetical order)
select HAS_PERIPH_ADC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_RTC
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_PERIPH_USBDEV
select HAS_HIGHLEVEL_STDIO

View File

@ -0,0 +1,3 @@
MODULE = boards_common_weact-f4x1cx
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,15 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
include $(RIOTBOARD)/common/makefiles/stdio_cdc_acm.dep.mk
ifneq (,$(filter stdio_cdc_acm,$(USEMODULE)))
# The Mask-ROM bootloader provides USB-DFU capability
FEATURES_REQUIRED += bootloader_stm32
USEMODULE += usb_board_reset
endif
ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_spi_nor
endif

View File

@ -0,0 +1,14 @@
CPU = stm32
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev
# Various other features (if any)
FEATURES_PROVIDED += highlevel_stdio

View File

@ -0,0 +1,15 @@
INCLUDES += -I$(RIOTBOARD)/common/stm32/include
INCLUDES += -I$(RIOTBOARD)/common/weact-f4x1cx/include
# default to flashing over USB
PROGRAMMER ?= dfu-util
DFU_USB_ID ?= 0483:df11
DFU_FLAGS ?= -a 0 -s 0x08000000:leave
ROM_OFFSET ?= 0x0
# CDC ACM is available faster on STM32
TERM_DELAY ?= 1
# Setup of programmer and serial is shared between STM32 based boards
include $(RIOTMAKE)/boards/stm32.inc.mk
include $(RIOTMAKE)/tools/usb_board_reset.mk

View File

@ -7,11 +7,11 @@
*/
/**
* @ingroup boards_weact-f411ce
* @ingroup boards_common_weact-f4x1cx
* @{
*
* @file
* @brief Board initialization code for the WeAct-F411CE board.
* @brief Board initialization code for the WeAct-F4x1Cx board.
*
* @author Benjamin Valentin <benpicco@googlemail.com>
*
@ -21,24 +21,24 @@
#include "board.h"
#include "cpu.h"
#include "mtd.h"
#include "timex.h"
#include "mtd_spi_nor.h"
#include "periph/gpio.h"
#include "timex.h"
#ifdef MODULE_MTD
/* AT25SF041 */
static const mtd_spi_nor_params_t _weact_nor_params = {
.opcode = &mtd_spi_nor_opcode_default,
.wait_chip_erase = 4800LU * US_PER_MS,
.wait_32k_erase = 300LU * US_PER_MS,
.wait_chip_erase = 4800LU * US_PER_MS,
.wait_32k_erase = 300LU * US_PER_MS,
.wait_sector_erase = 70LU * US_PER_MS,
.wait_chip_wake_up = 1LU * US_PER_MS,
.clk = WEACT_411CE_NOR_SPI_CLK,
.flag = WEACT_411CE_NOR_FLAGS,
.spi = WEACT_411CE_NOR_SPI_DEV,
.mode = WEACT_411CE_NOR_SPI_MODE,
.cs = WEACT_411CE_NOR_SPI_CS,
.wp = GPIO_UNDEF,
.clk = WEACT_4X1CX_NOR_SPI_CLK,
.flag = WEACT_4X1CX_NOR_FLAGS,
.spi = WEACT_4X1CX_NOR_SPI_DEV,
.mode = WEACT_4X1CX_NOR_SPI_MODE,
.cs = WEACT_4X1CX_NOR_SPI_CS,
.wp = GPIO_UNDEF,
.hold = GPIO_UNDEF,
.addr_width = 3,
};
@ -46,8 +46,8 @@ static const mtd_spi_nor_params_t _weact_nor_params = {
static mtd_spi_nor_t weact_nor_dev = {
.base = {
.driver = &mtd_spi_nor_driver,
.page_size = WEACT_411CE_NOR_PAGE_SIZE,
.pages_per_sector = WEACT_411CE_NOR_PAGES_PER_SECTOR,
.page_size = WEACT_4X1CX_NOR_PAGE_SIZE,
.pages_per_sector = WEACT_4X1CX_NOR_PAGES_PER_SECTOR,
},
.params = &_weact_nor_params,
};

View File

@ -0,0 +1,6 @@
/**
@defgroup boards_common_weact-f4x1cx WeAct-F4x1Cx common code
@ingroup boards_common
@brief Support for cheap stm32f401/stm32f411 based boards by WeAct.
*/

View File

@ -7,9 +7,9 @@
*/
/**
* @ingroup boards_weact-f411ce
* @ingroup boards_common_weact-f4x1cx
*
* @brief Support for the WeAct-F411CE Board
* @brief Support for the WeAct-F4x1Cx Board
* @{
*
* @file
@ -29,22 +29,13 @@ extern "C" {
#include "periph_cpu.h"
/**
* @name Xtimer configuration
* @name xtimer configuration
* @{
*/
#define XTIMER_BACKOFF (8)
#define XTIMER_OVERHEAD (6)
/** @} */
/**
* @brief Product & Vendor ID taken from example firmware
* that the board was shipped with.
* @{
*/
#define INTERNAL_PERIPHERAL_VID (0x0483)
#define INTERNAL_PERIPHERAL_PID (0x5740)
/** @} */
/**
* @name LED pin definition and handlers
* @{
@ -67,19 +58,19 @@ extern "C" {
/** @} */
/**
* @name WeAct-F411CE NOR flash hardware configuration
* @name WeAct-F4X1CX NOR flash hardware configuration
*
* The pad for the NOR Flash (U3) is not populated.
* You have to solder a serial flash yourself and adjust the parameters.
* @{
*/
#define WEACT_411CE_NOR_PAGE_SIZE (256)
#define WEACT_411CE_NOR_PAGES_PER_SECTOR (16)
#define WEACT_411CE_NOR_FLAGS (SPI_NOR_F_SECT_4K | SPI_NOR_F_SECT_32K)
#define WEACT_411CE_NOR_SPI_DEV SPI_DEV(0)
#define WEACT_411CE_NOR_SPI_CLK SPI_CLK_10MHZ
#define WEACT_411CE_NOR_SPI_CS GPIO_PIN(PORT_A, 4)
#define WEACT_411CE_NOR_SPI_MODE SPI_MODE_0
#define WEACT_4X1CX_NOR_PAGE_SIZE (256)
#define WEACT_4X1CX_NOR_PAGES_PER_SECTOR (16)
#define WEACT_4X1CX_NOR_FLAGS (SPI_NOR_F_SECT_4K | SPI_NOR_F_SECT_32K)
#define WEACT_4X1CX_NOR_SPI_DEV SPI_DEV(0)
#define WEACT_4X1CX_NOR_SPI_CLK SPI_CLK_10MHZ
#define WEACT_4X1CX_NOR_SPI_CS GPIO_PIN(PORT_A, 4)
#define WEACT_4X1CX_NOR_SPI_MODE SPI_MODE_0
/** @} */
/**

View File

@ -7,7 +7,7 @@
*/
/**
* @ingroup boards_weact-f411ce
* @ingroup boards_common_weact-f4x1cx
* @{
*
* @file

View File

@ -7,11 +7,11 @@
*/
/**
* @ingroup boards_weact-f411ce
* @ingroup boards_common_weact-f4x1cx
* @{
*
* @file
* @brief Peripheral MCU configuration for the WeAct-F411CE Board
* @brief Peripheral MCU configuration for the WeAct-F4X1CX Board
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author José Ignacio Alamos <jialamos@uc.cl>
@ -35,7 +35,6 @@
/* The HSE provides a 25MHz clock */
#define CLOCK_HSE MHZ(25)
#include "periph_cpu.h"
#include "clk_conf.h"
#include "cfg_i2c1_pb8_pb9.h"
#include "cfg_timer_tim5.h"
@ -170,7 +169,7 @@ static const spi_conf_t spi_config[] = {
* @name ADC configuration
*
* Note that we do not configure all ADC channels,
* and not in the STM32F411 order.
* and not in the STM32F4x1 order.
* Feel free to add more if needed.
*
* @{

View File

@ -0,0 +1,17 @@
# Copyright (c) 2020 Benjamin Valentin
#
# 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.
#
config BOARD
default "weact-f401cc" if BOARD_WEACT_F401CC
config BOARD_WEACT_F401CC
bool
default y
select BOARD_COMMON_WEACT_F41XCX
select CPU_MODEL_STM32F401CC
source "$(RIOTBOARD)/common/weact-f4x1cx/Kconfig"

View File

@ -0,0 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/weact-f4x1cx
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,3 @@
USEMODULE += boards_common_weact-f4x1cx
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.dep

View File

@ -0,0 +1,3 @@
CPU_MODEL = stm32f401cc
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.features

View File

@ -0,0 +1 @@
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.include

View File

@ -0,0 +1,70 @@
/**
@defgroup boards_weact-f401cc WeAct-F401CC board
@ingroup boards
@brief Support for the WeAct-F401CC Board
## Overview
WeAct-F401CC is a board with the same form-factor as the blue/blackpill,
but with an STM32F401CCU6 and a USB-C connector.
It is available on sites like AliExpress for less than 3€.
## Hardware
![WeAct-F401CC](https://user-images.githubusercontent.com/1301112/69389644-eb5fb080-0ccc-11ea-8002-67d3db851250.png)
### MCU
| MCU | STM32F401CCU6 |
|:---------------- |:--------------------- |
| Family | ARM Cortex-M4F |
| Vendor | ST Microelectronics |
| RAM | 64KiB |
| Flash | 256KiB |
| Frequency | up to 84MHz |
| FPU | yes |
| Timers | 8 (2x watchdog, 1 SysTick, 6x 16-bit) |
| ADCs | 1x 12-bit |
| UARTs | 3 |
| SPIs | 4 |
| I2Cs | 3 |
| RTC | 1 |
| Vcc | 2.0V - 3.6V |
| Datasheet | [Datasheet](https://www.st.com/resource/en/datasheet/stm32f401cc.pdf) |
| Reference Manual | [Reference Manual](https://www.st.com/content/ccc/resource/technical/document/reference_manual/9b/53/39/1c/f7/01/4a/79/DM00119316.pdf/files/DM00119316.pdf/jcr:content/translations/en.DM00119316.pdf) |
## Flashing the device
The device comes with a bootloader that allows flashing via `dfu-util`.
If RIOT is already running on the board, you can upload your RIOT-firmware by typing
```
make BOARD=weact-f401cc flash
```
RIOT will make sure to enter the bootloader automatically.
If RIOT crashed or you have the plain board with the stock firmware, you have to enter
the bootloader manually.
There are two buttons on the board labeled `BOOT0` and `NRST`.
- Hold down `BOOT0`
- Shortly press `NRST` to reset the CPU while keeping `BOOT0` held down
The board will now show up as `0483:df11` - `STM32 BOOTLOADER` and will accept
firmware using the DFU protocol.
*Note:* You need to have write permissions to the device.
On Linux you could add yourself to the `plugdev` group and store the following as `/etc/udev/rules.d/99-weact-f401cc.rules`:
```
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", GROUP="plugdev", MODE="660"
```
## UART
stdio is provided through USB CDC ACM so the board can be used
without any extra hardware, save for a USB-C cable.
*/

View File

@ -0,0 +1,17 @@
# Copyright (c) 2020 Benjamin Valentin
#
# 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.
#
config BOARD
default "weact-f401ce" if BOARD_WEACT_F401CE
config BOARD_WEACT_F401CE
bool
default y
select BOARD_COMMON_WEACT_F41XCX
select CPU_MODEL_STM32F401CE
source "$(RIOTBOARD)/common/weact-f4x1cx/Kconfig"

View File

@ -0,0 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/weact-f4x1cx
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1,3 @@
USEMODULE += boards_common_weact-f4x1cx
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.dep

View File

@ -0,0 +1,3 @@
CPU_MODEL = stm32f401ce
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.features

View File

@ -0,0 +1,5 @@
# Product & Vendor ID taken from example firmware that the board was shipped with.
CFLAGS += -DINTERNAL_PERIPHERAL_VID=0x0483
CFLAGS += -DINTERNAL_PERIPHERAL_PID=0x572a
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.include

View File

@ -0,0 +1,70 @@
/**
@defgroup boards_weact-f401ce WeAct-F401CE board
@ingroup boards
@brief Support for the WeAct-F401CE Board
## Overview
WeAct-F401CE is a board with the same form-factor as the blue/blackpill,
but with an STM32F401CEU6 and a USB-C connector.
It is available on sites like AliExpress for less than 3€.
## Hardware
![WeAct-F401CE](https://user-images.githubusercontent.com/1301112/69389644-eb5fb080-0ccc-11ea-8002-67d3db851250.png)
### MCU
| MCU | STM32F401CEU6 |
|:---------------- |:--------------------- |
| Family | ARM Cortex-M4F |
| Vendor | ST Microelectronics |
| RAM | 96KiB |
| Flash | 512KiB |
| Frequency | up to 84MHz |
| FPU | yes |
| Timers | 8 (2x watchdog, 1 SysTick, 6x 16-bit, 2x 32-bit) |
| ADCs | 1x 12-bit |
| UARTs | 3 |
| SPIs | 4 |
| I2Cs | 3 |
| RTC | 1 |
| Vcc | 2.0V - 3.6V |
| Datasheet | [Datasheet](https://www.st.com/resource/en/datasheet/stm32f401ce.pdf) |
| Reference Manual | [Reference Manual](https://www.st.com/content/ccc/resource/technical/document/reference_manual/9b/53/39/1c/f7/01/4a/79/DM00119316.pdf/files/DM00119316.pdf/jcr:content/translations/en.DM00119316.pdf) |
## Flashing the device
The device comes with a bootloader that allows flashing via `dfu-util`.
If RIOT is already running on the board, you can upload your RIOT-firmware by typing
```
make BOARD=weact-f401ce flash
```
RIOT will make sure to enter the bootloader automatically.
If RIOT crashed or you have the plain board with the stock firmware, you have to enter
the bootloader manually.
There are two buttons on the board labeled `BOOT0` and `NRST`.
- Hold down `BOOT0`
- Shortly press `NRST` to reset the CPU while keeping `BOOT0` held down
The board will now show up as `0483:df11` - `STM32 BOOTLOADER` and will accept
firmware using the DFU protocol.
*Note:* You need to have write permissions to the device.
On Linux you could add yourself to the `plugdev` group and store the following as `/etc/udev/rules.d/99-weact-f401ce.rules`:
```
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", GROUP="plugdev", MODE="660"
```
## UART
stdio is provided through USB CDC ACM so the board can be used
without any extra hardware, save for a USB-C cable.
*/

View File

@ -1,4 +1,4 @@
# Copyright (c) 2020 Inria
# Copyright (c) 2020 Benjamin Valentin
#
# 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
@ -11,17 +11,7 @@ config BOARD
config BOARD_WEACT_F411CE
bool
default y
select BOARD_COMMON_WEACT_F41XCX
select CPU_MODEL_STM32F411CE
# Put defined MCU peripherals here (in alphabetical order)
select HAS_PERIPH_ADC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_RTC
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_PERIPH_USBDEV
# Put other features for this board (in alphabetical order)
select HAS_HIGHLEVEL_STDIO
source "$(RIOTBOARD)/common/weact-f4x1cx/Kconfig"

View File

@ -1,3 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/weact-f4x1cx
include $(RIOTBASE)/Makefile.base

View File

@ -1,15 +1,3 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
USEMODULE += boards_common_weact-f4x1cx
include $(RIOTBOARD)/common/makefiles/stdio_cdc_acm.dep.mk
ifneq (,$(filter stdio_cdc_acm,$(USEMODULE)))
# The Mask-ROM bootloader provides USB-DFU capability
FEATURES_REQUIRED += bootloader_stm32
USEMODULE += usb_board_reset
endif
ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_spi_nor
endif
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.dep

View File

@ -1,14 +1,3 @@
CPU = stm32
CPU_MODEL = stm32f411ce
# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev
FEATURES_PROVIDED += highlevel_stdio
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.features

View File

@ -1,14 +1,5 @@
INCLUDES += -I$(RIOTBOARD)/common/stm32/include
# Product & Vendor ID taken from example firmware that the board was shipped with.
CFLAGS += -DINTERNAL_PERIPHERAL_VID=0x0483
CFLAGS += -DINTERNAL_PERIPHERAL_PID=0x5740
# default to flashing over USB
PROGRAMMER ?= dfu-util
DFU_USB_ID ?= 0483:df11
DFU_FLAGS ?= -a 0 -s 0x08000000:leave
ROM_OFFSET ?= 0x0
# CDC ACM is available faster on STM32
TERM_DELAY ?= 1
# Setup of programmer and serial is shared between STM32 based boards
include $(RIOTMAKE)/boards/stm32.inc.mk
include $(RIOTMAKE)/tools/usb_board_reset.mk
include $(RIOTBOARD)/common/weact-f4x1cx/Makefile.include

View File

@ -33,14 +33,20 @@ extern "C" {
* @name Clock PLL settings (84MHz)
* @{
*/
/* The following parameters configure a 84MHz system clock with HSE (8MHz or
16MHz) or HSI (16MHz) as PLL input clock */
/* The following parameters configure a 84MHz system clock with HSE (8MHz, 16MHz
or 25MHz) or HSI (16MHz) as PLL input clock */
#ifndef CONFIG_CLOCK_PLL_M
#if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CLOCK_HSE == MHZ(25))
#define CONFIG_CLOCK_PLL_M (25)
#else
#define CONFIG_CLOCK_PLL_M (4)
#endif
#endif
#ifndef CONFIG_CLOCK_PLL_N
#if IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CLOCK_HSE == MHZ(8))
#define CONFIG_CLOCK_PLL_N (168)
#elif IS_ACTIVE(CONFIG_BOARD_HAS_HSE) && (CLOCK_HSE == MHZ(25))
#define CONFIG_CLOCK_PLL_N (336)
#else
#define CONFIG_CLOCK_PLL_N (84)
#endif

View File

@ -108,6 +108,7 @@ BOARD_INSUFFICIENT_MEMORY := \
teensy31 \
telosb \
waspmote-pro \
weact-f401cc \
yarm \
yunjia-nrf51822 \
z1 \