1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 11:59:58 +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

@ -237,7 +237,7 @@ CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT)
CC_DEFAULT_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
CC_SPEED_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE)
CC_NO_OPTIMISATION :=
CC_NO_OPTIMISATION :=
#
# Added after GCC version update, remove once the warnings have been fixed
@ -248,12 +248,11 @@ CFLAGS += $(ARCH_FLAGS) \
$(addprefix -D,$(OPTIONS)) \
$(addprefix -I,$(INCLUDE_DIRS)) \
$(DEBUG_FLAGS) \
-std=gnu11 \
-Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
-std=gnu17 \
-Wall -Wextra -Werror -Wpedantic -Wunsafe-loop-optimizations -Wdouble-promotion \
-ffunction-sections \
-fdata-sections \
-fno-common \
-pedantic \
$(TEMPORARY_FLAGS) \
$(DEVICE_FLAGS) \
-D_GNU_SOURCE \
@ -263,7 +262,7 @@ CFLAGS += $(ARCH_FLAGS) \
-D'__FORKNAME__="$(FORKNAME)"' \
-D'__TARGET__="$(TARGET)"' \
-D'__REVISION__="$(REVISION)"' \
-save-temps=obj \
-pipe \
-MMD -MP \
$(EXTRA_FLAGS)
@ -340,7 +339,7 @@ ifeq ($(EXST),no)
$(TARGET_BIN): $(TARGET_ELF)
@echo "Creating BIN $(TARGET_BIN)" "$(STDOUT)"
$(V1) $(OBJCOPY) -O binary $< $@
$(TARGET_HEX): $(TARGET_ELF)
@echo "Creating HEX $(TARGET_HEX)" "$(STDOUT)"
$(V1) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
@ -364,8 +363,8 @@ $(TARGET_BIN): $(TARGET_UNPATCHED_BIN)
$(V1) dd if=$(TARGET_UNPATCHED_BIN) of=$(TARGET_BIN) conv=notrunc
@echo "Generating MD5 hash of binary" "$(STDOUT)"
$(V1) openssl dgst -md5 $(TARGET_BIN) > $(TARGET_UNPATCHED_BIN).md5
$(V1) openssl dgst -md5 $(TARGET_BIN) > $(TARGET_UNPATCHED_BIN).md5
@echo "Patching MD5 hash into binary" "$(STDOUT)"
$(V1) cat $(TARGET_UNPATCHED_BIN).md5 | awk '{printf("%08x: %s",(1024*$(FIRMWARE_SIZE))-16,$$2);}' | xxd -r - $(TARGET_BIN)
$(V1) echo $(FIRMWARE_SIZE) | awk '{printf("-s 0x%08x -l 16 -c 16 %s",(1024*$$1)-16,"$(TARGET_BIN)");}' | xargs xxd
@ -378,10 +377,10 @@ $(TARGET_BIN): $(TARGET_UNPATCHED_BIN)
@echo "Extracting HASH section from unpatched EXST elf $(TARGET_ELF)" "$(STDOUT)"
$(OBJCOPY) $(TARGET_ELF) $(TARGET_EXST_ELF).tmp --dump-section .exst_hash=$(TARGET_EXST_HASH_SECTION_FILE) -j .exst_hash
rm $(TARGET_EXST_ELF).tmp
@echo "Patching MD5 hash into HASH section" "$(STDOUT)"
$(V1) cat $(TARGET_UNPATCHED_BIN).md5 | awk '{printf("%08x: %s",64-16,$$2);}' | xxd -r - $(TARGET_EXST_HASH_SECTION_FILE)
# For some currently unknown reason, OBJCOPY, with only input/output files, will generate a file around 2GB for the H730 unless we remove an unused-section
# As a workaround drop the ._user_heap_stack section, which is only used during build to show errors if there's not enough space for the heap/stack.
# The issue can be seen with `readelf -S $(TARGET_EXST_ELF)' vs `readelf -S $(TARGET_ELF)`

View file

@ -148,10 +148,10 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif
#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)))
DEVICE_FLAGS = -DSTM32F411xE
DEVICE_FLAGS = -DSTM32F411xE -finline-limit=20
LD_SCRIPT = $(LINKER_DIR)/stm32_flash_f411.ld
STARTUP_SRC = startup_stm32f411xe.s
else ifeq ($(TARGET),$(filter $(TARGET),$(F405_TARGETS)))

View file

@ -123,7 +123,7 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif
#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
DEVICE_FLAGS = -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER

View file

@ -126,7 +126,7 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif
#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

View file

@ -147,7 +147,7 @@ VPATH := $(VPATH):$(FATFS_DIR)
endif
#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
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++) {
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) {
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
#if __GNUC__ > 6
#define FALLTHROUGH __attribute__ ((fallthrough))
#define FALLTHROUGH ;__attribute__ ((fallthrough))
#else
#define FALLTHROUGH do {} while(0)
#endif

View file

@ -687,7 +687,7 @@ static void bbPostInit()
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) {
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
{
ErrorState = SD_CARD_ERROR;
ErrorState = SD_ERROR;
}
return ErrorState;

View file

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

View file

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

View file

@ -2141,7 +2141,7 @@ afatfsOperationStatus_e afatfs_fseek(afatfsFilePtr_t file, int32_t offset, afatf
break;
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

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) {
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];
crsfScreen.updated |= memcmp(rowStart, s, truncLen);
if (crsfScreen.updated) {

View file

@ -216,7 +216,7 @@ static int8_t STORAGE_Read (uint8_t lun,
{
UNUSED(lun);
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);
}
mscSetActive();
@ -236,7 +236,7 @@ static int8_t STORAGE_Write (uint8_t lun,
{
UNUSED(lun);
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();
}
while (sdcard_poll() == 0);

View file

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

View file

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

View file

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