diff --git a/Makefile b/Makefile index 06764ae9af..662752fccd 100644 --- a/Makefile +++ b/Makefile @@ -229,7 +229,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 @@ -240,12 +240,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 \ @@ -255,7 +254,7 @@ CFLAGS += $(ARCH_FLAGS) \ -D'__FORKNAME__="$(FORKNAME)"' \ -D'__TARGET__="$(TARGET)"' \ -D'__REVISION__="$(REVISION)"' \ - -save-temps=obj \ + -pipe \ -MMD -MP \ $(EXTRA_FLAGS) @@ -332,7 +331,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 $< $@ @@ -356,8 +355,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 @@ -370,10 +369,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)` diff --git a/make/mcu/STM32F4.mk b/make/mcu/STM32F4.mk index f94682e6d0..65c81c45ba 100644 --- a/make/mcu/STM32F4.mk +++ b/make/mcu/STM32F4.mk @@ -138,10 +138,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))) diff --git a/make/mcu/STM32F7.mk b/make/mcu/STM32F7.mk index 8d2b22bbbc..b3539ee67f 100644 --- a/make/mcu/STM32F7.mk +++ b/make/mcu/STM32F7.mk @@ -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 diff --git a/make/mcu/STM32G4.mk b/make/mcu/STM32G4.mk index 6317895cdb..510d6088f0 100644 --- a/make/mcu/STM32G4.mk +++ b/make/mcu/STM32G4.mk @@ -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 diff --git a/make/mcu/STM32H7.mk b/make/mcu/STM32H7.mk index 469f22f8fc..5649818ecb 100644 --- a/make/mcu/STM32H7.mk +++ b/make/mcu/STM32H7.mk @@ -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 diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index b0635117c2..c4e7d3d928 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -5242,7 +5242,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); } diff --git a/src/main/common/utils.h b/src/main/common/utils.h index 252d543945..1c773034b5 100644 --- a/src/main/common/utils.h +++ b/src/main/common/utils.h @@ -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 diff --git a/src/main/drivers/dshot_bitbang.c b/src/main/drivers/dshot_bitbang.c index 5059f811ab..49d8a328df 100644 --- a/src/main/drivers/dshot_bitbang.c +++ b/src/main/drivers/dshot_bitbang.c @@ -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; } diff --git a/src/main/drivers/sdio_f4xx.c b/src/main/drivers/sdio_f4xx.c index 0f039a9085..83174bb96f 100644 --- a/src/main/drivers/sdio_f4xx.c +++ b/src/main/drivers/sdio_f4xx.c @@ -1231,7 +1231,7 @@ SD_Error_t SD_GetStatus(void) } else { - ErrorState = SD_CARD_ERROR; + ErrorState = SD_ERROR; } return ErrorState; diff --git a/src/main/drivers/sdio_f7xx.c b/src/main/drivers/sdio_f7xx.c index e6621ef2ec..3dcce967bb 100644 --- a/src/main/drivers/sdio_f7xx.c +++ b/src/main/drivers/sdio_f7xx.c @@ -1216,7 +1216,7 @@ SD_Error_t SD_GetStatus(void) } else { - ErrorState = SD_CARD_ERROR; + ErrorState = SD_ERROR; } return ErrorState; diff --git a/src/main/drivers/serial_uart_hal.c b/src/main/drivers/serial_uart_hal.c index 00f09a5dca..7d3c6c765d 100644 --- a/src/main/drivers/serial_uart_hal.c +++ b/src/main/drivers/serial_uart_hal.c @@ -81,7 +81,7 @@ static void uartConfigurePinSwap(uartPort_t *uartPort) { uartDevice_t *uartDevice = uartFindDevice(uartPort); if (!uartDevice) { - return NULL; + return; } if (uartDevice->pinSwap) { diff --git a/src/main/io/asyncfatfs/asyncfatfs.c b/src/main/io/asyncfatfs/asyncfatfs.c index 13d3760937..50408bd1b9 100644 --- a/src/main/io/asyncfatfs/asyncfatfs.c +++ b/src/main/io/asyncfatfs/asyncfatfs.c @@ -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 diff --git a/src/main/io/displayport_crsf.c b/src/main/io/displayport_crsf.c index 814de585b5..64b60f6b66 100644 --- a/src/main/io/displayport_crsf.c +++ b/src/main/io/displayport_crsf.c @@ -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) { diff --git a/src/main/msc/usbd_storage_sd_spi.c b/src/main/msc/usbd_storage_sd_spi.c index 4addcb5819..694226e392 100644 --- a/src/main/msc/usbd_storage_sd_spi.c +++ b/src/main/msc/usbd_storage_sd_spi.c @@ -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); diff --git a/src/main/startup/system_stm32f4xx.c b/src/main/startup/system_stm32f4xx.c index e29649326f..d036464764 100644 --- a/src/main/startup/system_stm32f4xx.c +++ b/src/main/startup/system_stm32f4xx.c @@ -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. diff --git a/src/main/target/common_pre.h b/src/main/target/common_pre.h index fc3760a761..779ff05945 100644 --- a/src/main/target/common_pre.h +++ b/src/main/target/common_pre.h @@ -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 diff --git a/src/test/Makefile b/src/test/Makefile index 64e23b7e42..da9026525f 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -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)