1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 03:50:02 +03:00

Support for GCC10 and some compilation tuning

This commit is contained in:
Štěpán Dalecký 2021-10-19 19:45:49 +02:00
parent 81a3c53b1c
commit 4cf54f9ddc
17 changed files with 27 additions and 29 deletions

View file

@ -248,12 +248,11 @@ CFLAGS += $(ARCH_FLAGS) \
$(addprefix -D,$(OPTIONS)) \ $(addprefix -D,$(OPTIONS)) \
$(addprefix -I,$(INCLUDE_DIRS)) \ $(addprefix -I,$(INCLUDE_DIRS)) \
$(DEBUG_FLAGS) \ $(DEBUG_FLAGS) \
-std=gnu11 \ -std=gnu17 \
-Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \ -Wall -Wextra -Werror -Wpedantic -Wunsafe-loop-optimizations -Wdouble-promotion \
-ffunction-sections \ -ffunction-sections \
-fdata-sections \ -fdata-sections \
-fno-common \ -fno-common \
-pedantic \
$(TEMPORARY_FLAGS) \ $(TEMPORARY_FLAGS) \
$(DEVICE_FLAGS) \ $(DEVICE_FLAGS) \
-D_GNU_SOURCE \ -D_GNU_SOURCE \
@ -263,7 +262,7 @@ CFLAGS += $(ARCH_FLAGS) \
-D'__FORKNAME__="$(FORKNAME)"' \ -D'__FORKNAME__="$(FORKNAME)"' \
-D'__TARGET__="$(TARGET)"' \ -D'__TARGET__="$(TARGET)"' \
-D'__REVISION__="$(REVISION)"' \ -D'__REVISION__="$(REVISION)"' \
-save-temps=obj \ -pipe \
-MMD -MP \ -MMD -MP \
$(EXTRA_FLAGS) $(EXTRA_FLAGS)

View file

@ -148,10 +148,10 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif endif
#Flags #Flags
ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
ifeq ($(TARGET),$(filter $(TARGET),$(F411_TARGETS))) ifeq ($(TARGET),$(filter $(TARGET),$(F411_TARGETS)))
DEVICE_FLAGS = -DSTM32F411xE DEVICE_FLAGS = -DSTM32F411xE -finline-limit=20
LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld
STARTUP_SRC = startup_stm32f411xe.s STARTUP_SRC = startup_stm32f411xe.s
else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS))) else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS)))

View file

@ -123,7 +123,7 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif endif
#Flags #Flags
ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant -Wdouble-promotion ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant
# Flags that are used in the STM32 libraries # Flags that are used in the STM32 libraries
DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER

View file

@ -126,7 +126,7 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif endif
#Flags #Flags
ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -Wdouble-promotion ARCH_FLAGS = -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DUSE_DMA_RAM -DMAX_MPU_REGIONS=16 DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -DUSE_DMA_RAM -DMAX_MPU_REGIONS=16

View file

@ -147,7 +147,7 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif endif
#Flags #Flags
ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant -Wdouble-promotion ARCH_FLAGS = -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fsingle-precision-constant
# Flags that are used in the STM32 libraries # Flags that are used in the STM32 libraries
DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER

View file

@ -5244,7 +5244,7 @@ static void printResource(dumpFlags_t dumpMask, const char *headingStr)
for (int index = 0; index < RESOURCE_VALUE_MAX_INDEX(resourceTable[i].maxIndex); index++) { for (int index = 0; index < RESOURCE_VALUE_MAX_INDEX(resourceTable[i].maxIndex); index++) {
const ioTag_t ioTag = *(ioTag_t *)((const uint8_t *)currentConfig + resourceTable[i].stride * index + resourceTable[i].offset); const ioTag_t ioTag = *(ioTag_t *)((const uint8_t *)currentConfig + resourceTable[i].stride * index + resourceTable[i].offset);
ioTag_t ioTagDefault = NULL; ioTag_t ioTagDefault = 0;
if (defaultConfig) { if (defaultConfig) {
ioTagDefault = *(ioTag_t *)((const uint8_t *)defaultConfig + resourceTable[i].stride * index + resourceTable[i].offset); ioTagDefault = *(ioTag_t *)((const uint8_t *)defaultConfig + resourceTable[i].stride * index + resourceTable[i].offset);
} }

View file

@ -114,7 +114,7 @@ void * memcpy_fn ( void * destination, const void * source, size_t num ) asm("me
#endif #endif
#if __GNUC__ > 6 #if __GNUC__ > 6
#define FALLTHROUGH __attribute__ ((fallthrough)) #define FALLTHROUGH ;__attribute__ ((fallthrough))
#else #else
#define FALLTHROUGH do {} while(0) #define FALLTHROUGH do {} while(0)
#endif #endif

View file

@ -687,7 +687,7 @@ static void bbPostInit()
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) { for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) {
if (!bbMotorConfig(bbMotors[motorIndex].io, motorIndex, motorPwmProtocol, bbMotors[motorIndex].output)) { if (!bbMotorConfig(bbMotors[motorIndex].io, motorIndex, motorPwmProtocol, bbMotors[motorIndex].output)) {
return NULL; return;
} }

View file

@ -1231,7 +1231,7 @@ SD_Error_t SD_GetStatus(void)
} }
else else
{ {
ErrorState = SD_CARD_ERROR; ErrorState = SD_ERROR;
} }
return ErrorState; return ErrorState;

View file

@ -1216,7 +1216,7 @@ SD_Error_t SD_GetStatus(void)
} }
else else
{ {
ErrorState = SD_CARD_ERROR; ErrorState = SD_ERROR;
} }
return ErrorState; return ErrorState;

View file

@ -81,7 +81,7 @@ static void uartConfigurePinSwap(uartPort_t *uartPort)
{ {
uartDevice_t *uartDevice = uartFindDevice(uartPort); uartDevice_t *uartDevice = uartFindDevice(uartPort);
if (!uartDevice) { if (!uartDevice) {
return NULL; return;
} }
if (uartDevice->pinSwap) { if (uartDevice->pinSwap) {

View file

@ -2141,7 +2141,7 @@ afatfsOperationStatus_e afatfs_fseek(afatfsFilePtr_t file, int32_t offset, afatf
break; break;
case AFATFS_SEEK_SET: case AFATFS_SEEK_SET:
FALLTHROUGH; break;
} }
// Now we have a SEEK_SET with a positive offset. Begin by seeking to the start of the file // Now we have a SEEK_SET with a positive offset. Begin by seeking to the start of the file

View file

@ -85,7 +85,7 @@ static int crsfWriteString(displayPort_t *displayPort, uint8_t col, uint8_t row,
if (row >= crsfScreen.rows || col >= crsfScreen.cols) { if (row >= crsfScreen.rows || col >= crsfScreen.cols) {
return 0; return 0;
} }
const size_t truncLen = MIN((int)strlen(s), crsfScreen.cols-col); // truncate at colCount const size_t truncLen = MIN(strlen(s), (size_t)(crsfScreen.cols - col)); // truncate at colCount
char *rowStart = &crsfScreen.buffer[row * crsfScreen.cols + col]; char *rowStart = &crsfScreen.buffer[row * crsfScreen.cols + col];
crsfScreen.updated |= memcmp(rowStart, s, truncLen); crsfScreen.updated |= memcmp(rowStart, s, truncLen);
if (crsfScreen.updated) { if (crsfScreen.updated) {

View file

@ -216,7 +216,7 @@ static int8_t STORAGE_Read (uint8_t lun,
{ {
UNUSED(lun); UNUSED(lun);
for (int i = 0; i < blk_len; i++) { for (int i = 0; i < blk_len; i++) {
while (sdcard_readBlock(blk_addr + i, buf + (512 * i), NULL, NULL) == 0); while (sdcard_readBlock(blk_addr + i, buf + (512 * i), NULL, 0) == 0);
while (sdcard_poll() == 0); while (sdcard_poll() == 0);
} }
mscSetActive(); mscSetActive();
@ -236,7 +236,7 @@ static int8_t STORAGE_Write (uint8_t lun,
{ {
UNUSED(lun); UNUSED(lun);
for (int i = 0; i < blk_len; i++) { for (int i = 0; i < blk_len; i++) {
while (sdcard_writeBlock(blk_addr + i, buf + (i * 512), NULL, NULL) != SDCARD_OPERATION_IN_PROGRESS) { while (sdcard_writeBlock(blk_addr + i, buf + (i * 512), NULL, 0) != SDCARD_OPERATION_IN_PROGRESS) {
sdcard_poll(); sdcard_poll();
} }
while (sdcard_poll() == 0); while (sdcard_poll() == 0);

View file

@ -812,8 +812,6 @@ void SetSysClock(void)
/* Wait till the main PLL is used as system clock source */ /* Wait till the main PLL is used as system clock source */
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL); while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
{
}
#if defined(STM32F446xx) #if defined(STM32F446xx)
// Always use PLLSAI to derive USB 48MHz clock. // Always use PLLSAI to derive USB 48MHz clock.

View file

@ -57,7 +57,7 @@
#ifdef STM32F7 #ifdef STM32F7
#define USE_ITCM_RAM #define USE_ITCM_RAM
#define ITCM_RAM_OPTIMISATION "-O2" #define ITCM_RAM_OPTIMISATION "-O2", "-freorder-blocks-algorithm=simple"
#define USE_FAST_DATA #define USE_FAST_DATA
#define USE_DSHOT #define USE_DSHOT
#define USE_DSHOT_BITBANG #define USE_DSHOT_BITBANG

View file

@ -499,7 +499,8 @@ COMMON_FLAGS = \
-isystem $(GTEST_DIR)/inc \ -isystem $(GTEST_DIR)/inc \
-MMD -MP \ -MMD -MP \
-Wno-c99-extensions \ -Wno-c99-extensions \
-Wno-reorder -Wno-reorder \
-pipe
CC_VERSION = $(shell $(CC) -dumpversion) CC_VERSION = $(shell $(CC) -dumpversion)
CXX_VERSION = $(shell $(CXX) -dumpversion) CXX_VERSION = $(shell $(CXX) -dumpversion)