Added Unified Target for STM32G4.

This commit is contained in:
mikeller 2021-02-22 22:34:11 +13:00
parent 76b6415d34
commit 03d3d94497
8 changed files with 68 additions and 12 deletions

View File

@ -105,7 +105,7 @@ FEATURE_CUT_LEVEL_SUPPLIED := $(FEATURE_CUT_LEVEL)
FEATURE_CUT_LEVEL =
# The list of targets to build for 'pre-push'
PRE_PUSH_TARGET_LIST ?= STM32F405 STM32F411 STM32F7X2 STM32F745 NUCLEOH743 SITL STM32F4DISCOVERY_DEBUG test-representative
PRE_PUSH_TARGET_LIST ?= $(UNIFIED_TARGETS) NUCLEOH743 SITL STM32F4DISCOVERY_DEBUG test-representative
include $(ROOT)/make/targets.mk

View File

@ -130,13 +130,16 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu
DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DUSE_DMA_RAM -DMAX_MPU_REGIONS=16
# G4X3_TARGETS includes G47{3,4}{RE,CE,CEU}
# G47X_TARGETS includes G47{3,4}{RE,CE,CEU}
ifeq ($(TARGET),$(filter $(TARGET),$(G4X3_TARGETS)))
ifeq ($(TARGET),$(filter $(TARGET),$(G47X_TARGETS)))
DEVICE_FLAGS += -DSTM32G474xx
LD_SCRIPT = $(LINKER_DIR)/stm32_flash_g474.ld
STARTUP_SRC = startup_stm32g474xx.s
MCU_FLASH_SIZE = 512
# Override the OPTIMISE_SPEED compiler setting to save flash space on these 512KB targets.
# Performance is only slightly affected but around 50 kB of flash are saved.
OPTIMISE_SPEED = -O2
else
$(error Unknown MCU for G4 target)
endif

View File

@ -18,7 +18,7 @@ endif
F4_TARGETS := $(F405_TARGETS) $(F411_TARGETS) $(F446_TARGETS)
F7_TARGETS := $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS)
G4_TARGETS := $(G4X3_TARGETS)
G4_TARGETS := $(G47X_TARGETS)
H7_TARGETS := $(H743xI_TARGETS) $(H750xB_TARGETS) $(H7A3xI_TARGETS) $(H7A3xIQ_TARGETS) $(H723xG_TARGETS) $(H725xG_TARGETS)
ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
@ -26,7 +26,7 @@ $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have y
endif
ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS) $(G4_TARGETS) $(H7_TARGETS) $(SITL_TARGETS)),)
$(error Target '$(TARGET)' has not specified a valid STM group, must be one of F1, F3, F405, F411, F446, F7X2RE, F7X5XE, F7X5XG, F7X5XI, F7X6XG, G4X3 or H7X3XI. Have you prepared a valid target.mk?)
$(error Target '$(TARGET)' has not specified a valid STM group, must be one of F1, F3, F405, F411, F446, F7X2RE, F7X5XE, F7X5XG, F7X5XI, F7X6XG, G47X or H7X3XI. Have you prepared a valid target.mk?)
endif
ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))

View File

@ -82,7 +82,8 @@ UNSUPPORTED_TARGETS := \
UNIFIED_TARGETS := STM32F405 \
STM32F411 \
STM32F7X2 \
STM32F745
STM32F745 \
STM32G47X
# Legacy targets are targets that have been replaced by Unified Target configurations
LEGACY_TARGETS := MATEKF405 \

View File

@ -12,10 +12,12 @@
/* Specify the memory areas. */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 4K
FLASH1 (rx) : ORIGIN = 0x08001000, LENGTH = 492K
FLASH_CONFIG (r) : ORIGIN = 0x0807C000, LENGTH = 8K
FLASH_CUSTOM_DEFAULTS (r) : ORIGIN = 0x0807E000, LENGTH = 8K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 10K
FLASH_CUSTOM_DEFAULTS (r) : ORIGIN = 0x08002800, LENGTH = 6K
FLASH_CONFIG (r) : ORIGIN = 0x08004000, LENGTH = 8K
FLASH1 (rx) : ORIGIN = 0x08006000, LENGTH = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? 480K : 488K
FLASH_CUSTOM_DEFAULTS_EXTENDED (r): ORIGIN = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? 0x0807E000 : 0x08080000, LENGTH = DEFINED(USE_CUSTOM_DEFAULTS_EXTENDED) ? 8K : 0K
SYSTEM_MEMORY (r) : ORIGIN = 0x1FFF0000, LENGTH = 64K

View File

@ -94,7 +94,7 @@
#define USE_UART5
#define USE_UART6
#define SERIAL_PORT_COUNT (UNIFIED_SERIAL_PORT_COUNT + 6)
#define SERIAL_PORT_COUNT (UNIFIED_SERIAL_PORT_COUNT + 6)
#define USE_SPI_DEVICE_1
#define USE_SPI_DEVICE_2
@ -139,6 +139,42 @@
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
#define TARGET_IO_PORTF 0xffff
#elif defined(STM32G47X)
#define TARGET_BOARD_IDENTIFIER "SG47"
#define USBD_PRODUCT_STRING "Betaflight STM32G47x"
#define USE_I2C_DEVICE_1
#define USE_I2C_DEVICE_2
#define USE_I2C_DEVICE_3
#define USE_I2C_DEVICE_4
#define USE_UART1
#define USE_UART2
#define USE_UART3
#define USE_UART4
#define USE_UART5
#define USE_UART9
#define SERIAL_PORT_COUNT (UNIFIED_SERIAL_PORT_COUNT + 6)
#define USE_SPI_DEVICE_1
#define USE_SPI_DEVICE_2
#define USE_SPI_DEVICE_3
#define USE_SPI_DEVICE_4
#define TARGET_IO_PORTA 0xffff
#define TARGET_IO_PORTB 0xffff
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD 0xffff
#define TARGET_IO_PORTE 0xffff
#define TARGET_IO_PORTF 0xffff
#elif !defined(UNIT_TEST)
#error "No resources defined for this Unified Target."
#endif
// Treat the target as unified, and expect manufacturer id / board name
@ -190,9 +226,12 @@
#define USE_BARO_DPS310
#define USE_BARO_SPI_DPS310
#if !defined(STM32G4)
// G4 support needs fixing
#define USE_SDCARD
#define USE_SDCARD_SPI
#define USE_SDCARD_SDIO
#endif
#define USE_FLASHFS
#define USE_FLASH_TOOLS
@ -207,11 +246,14 @@
#define USE_VTX_RTC6705
#define USE_VTX_RTC6705_SOFTSPI
#if !defined(STM32G4)
// To make it fit RAM
#define USE_TRANSPONDER
#define USE_RANGEFINDER
#define USE_RANGEFINDER_HCSR04
#define USE_RANGEFINDER_TF
#endif
#define USE_SPI
#define SPI_FULL_RECONFIGURABILITY

View File

@ -9,12 +9,17 @@ else
ifeq ($(TARGET), STM32F7X2)
F7X2RE_TARGETS += $(TARGET)
else
ifeq ($(TARGET), STM32G47X)
G47X_TARGETS += $(TARGET)
else # STM32F745
F7X5XG_TARGETS += $(TARGET)
endif
endif
endif
endif
ifeq ($(TARGET), $(filter $(TARGET), STM32F405 STM32F745))
# Use a full block (16 kB) of flash for custom defaults - with 1 MB flash we have more than we know how to use anyway
@ -22,8 +27,11 @@ ifeq ($(TARGET), $(filter $(TARGET), STM32F405 STM32F745))
CUSTOM_DEFAULTS_EXTENDED = yes
endif
ifeq ($(TARGET), STM32G47X)
FEATURES += VCP ONBOARDFLASH
else
FEATURES += VCP SDCARD_SPI SDCARD_SDIO ONBOARDFLASH
endif
TARGET_SRC = \
$(addprefix drivers/accgyro/,$(notdir $(wildcard $(SRC_DIR)/drivers/accgyro/*.c))) \