update clang make build for stm32: f0 f1 f2 f3 f4 f7 h7 g0 g4 l0 l4 samd21 samd51 nrf

This commit is contained in:
hathach 2024-04-24 22:11:08 +07:00
parent a7bf0e3e7f
commit eab42d90d4
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52
20 changed files with 95 additions and 52 deletions

View File

@ -22,6 +22,7 @@ CFLAGS := $(filter-out $(CFLAGS_SKIP),$(CFLAGS))
endif
ifeq ($(TOOLCHAIN),clang)
CFLAGS += $(CFLAGS_CLANG)
LDFLAGS += $(CFLAGS) $(LDFLAGS_CLANG)
else
LDFLAGS += $(CFLAGS) $(LDFLAGS_GCC)

View File

@ -8,25 +8,31 @@ include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= cortex-m4
CFLAGS += \
-flto \
-DCFG_TUSB_MCU=OPT_MCU_NRF5X \
-DCONFIG_GPIO_AS_PINRESET
-DCONFIG_GPIO_AS_PINRESET \
-D__STARTUP_CLEAR_BSS
#CFLAGS += -nostdlib
#CFLAGS += -D__START=main
# suppress warning caused by vendor mcu driver
CFLAGS += \
CFLAGS_GCC += \
-flto \
-Wno-error=undef \
-Wno-error=unused-parameter \
-Wno-error=unused-variable \
-Wno-error=cast-align \
-Wno-error=cast-qual \
-Wno-error=redundant-decls
-Wno-error=redundant-decls \
LDFLAGS += \
-specs=nosys.specs -specs=nano.specs \
LDFLAGS_GCC += \
-nostartfiles \
--specs=nosys.specs --specs=nano.specs \
-L$(TOP)/${NRFX_DIR}/mdk
LDFLAGS_CLANG += \
-L$(TOP)/${NRFX_DIR}/mdk \
SRC_C += \
src/portable/nordic/nrf5x/dcd_nrf5x.c \
${NRFX_DIR}/helpers/nrfx_flag32_allocator.c \
@ -34,7 +40,8 @@ SRC_C += \
${NRFX_DIR}/drivers/src/nrfx_power.c \
${NRFX_DIR}/drivers/src/nrfx_spim.c \
${NRFX_DIR}/drivers/src/nrfx_uarte.c \
${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c
${NRFX_DIR}/mdk/system_$(MCU_VARIANT).c \
${NRFX_DIR}/soc/nrfx_atomic.c
INC += \
$(TOP)/$(BOARD_PATH) \

View File

@ -17,7 +17,7 @@ CFLAGS_SKIP += -Wcast-qual
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
-specs=nosys.specs -specs=nano.specs \
--specs=nosys.specs --specs=nano.specs \
LDFLAGS_CLANG +=

View File

@ -6,13 +6,14 @@ CPU_CORE ?= cortex-m4
CFLAGS += \
-flto \
-nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_SAMD51
# SAM driver is flooded with -Wcast-qual which slow down complication significantly
CFLAGS_SKIP += -Wcast-qual
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/microchip/samd/dcd_samd.c \
@ -33,7 +34,7 @@ INC += \
$(TOP)/hw/mcu/microchip/samd51/hal/utils/include \
$(TOP)/hw/mcu/microchip/samd51/hpl/port \
$(TOP)/hw/mcu/microchip/samd51/hri \
$(TOP)/hw/mcu/microchip/samd51/CMSIS/Include
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -18,12 +18,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles \
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=unused-parameter -Wno-error=cast-align
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# ------------------------
# All source paths should be relative to the top level.

View File

@ -16,12 +16,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles \
# mcu driver cause following warnings
CFLAGS_GCC += -Wno-error=cast-align
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
-specs=nosys.specs -specs=nano.specs
# ------------------------
# All source paths should be relative to the top level.

View File

@ -16,12 +16,13 @@ CFLAGS += \
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles \
# mcu driver cause following warnings
CFLAGS_GCC += -Wno-error=sign-compare
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \

View File

@ -13,13 +13,14 @@ CPU_CORE ?= cortex-m4
CFLAGS += \
-flto \
-nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
# mcu driver cause following warnings
CFLAGS += -Wno-error=unused-parameter
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \

View File

@ -20,12 +20,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=cast-align
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include

View File

@ -30,12 +30,13 @@ endif
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles
# mcu driver cause following warnings
CFLAGS_GCC += -Wno-error=cast-align
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include

View File

@ -16,12 +16,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=cast-align
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include

View File

@ -15,12 +15,13 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles \
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=cast-align
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include

View File

@ -16,7 +16,6 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles \
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += \
@ -24,7 +23,12 @@ CFLAGS_GCC += \
-Wno-error=undef \
-Wno-error=unused-parameter \
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
CFLAGS_CLANG += \
-Wno-error=parentheses-equality
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include
@ -56,7 +60,7 @@ SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_$(MCU_VARIANT).s
# Linker
LD_FILE_IAR = $(ST_CMSIS)/Source/Templates/iar/linker/$(MCU_VARIANT)_flash.icf
LD_FILE_GCC = $(ST_CMSIS)/Source/Templates/gcc/linker/$(MCU_VARIANT_UPPER)_FLASH.ld
LD_FILE_GCC = $(FAMILY_PATH)/linker/$(MCU_VARIANT_UPPER)_FLASH.ld
# flash target using on-board stlink
flash: flash-stlink

View File

@ -30,12 +30,15 @@ endif
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=maybe-uninitialized -Wno-error=cast-align -Wno-error=unused-parameter
CFLAGS_GCC += \
-Wno-error=cast-align \
-Wno-error=unused-parameter \
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include

View File

@ -12,19 +12,26 @@ CPU_CORE ?= cortex-m0plus
CFLAGS += \
-flto \
-nostdlib -nostartfiles \
-DCFG_EXAMPLE_MSC_READONLY \
-DCFG_EXAMPLE_VIDEO_READONLY \
-DCFG_TUSB_MCU=OPT_MCU_STM32L0
# mcu driver cause following warnings
CFLAGS += \
CFLAGS_GCC += \
-Wno-error=unused-parameter \
-Wno-error=redundant-decls \
-Wno-error=cast-align \
-Wno-error=maybe-uninitialized
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
ifeq ($(TOOLCHAIN),gcc)
CFLAGS_GCC += -Wno-error=maybe-uninitialized
endif
CFLAGS_CLANG += \
-Wno-error=parentheses-equality
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \

View File

@ -16,12 +16,15 @@ CFLAGS += \
# GCC Flags
CFLAGS_GCC += \
-flto \
-nostdlib -nostartfiles
-Wno-error=cast-align \
# suppress warning caused by vendor mcu driver
CFLAGS_GCC += -Wno-error=maybe-uninitialized -Wno-error=cast-align
ifeq ($(TOOLCHAIN),gcc)
CFLAGS_GCC += -Wno-error=maybe-uninitialized
endif
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
# -----------------
# Sources & Include

View File

@ -2,7 +2,7 @@ CFLAGS += \
-DSTM32U575xx \
# All source paths should be relative to the top level.
LD_FILE = ${ST_CMSIS}/Source/Templates/gcc/linker/STM32U575xx_FLASH.ld
LD_FILE = ${FAMILY_PATH}/linker/STM32U575xx_FLASH.ld
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32u575xx.s

View File

@ -2,7 +2,7 @@ CFLAGS += \
-DSTM32U575xx \
# All source paths should be relative to the top level.
LD_FILE = ${ST_CMSIS}/Source/Templates/gcc/linker/STM32U575xx_FLASH.ld
LD_FILE = ${FAMILY_PATH}/linker/STM32U575xx_FLASH.ld
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32u575xx.s

View File

@ -8,14 +8,23 @@ include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= cortex-m33
CFLAGS += \
-flto \
-nostdlib -nostartfiles \
-DCFG_TUSB_MCU=OPT_MCU_STM32U5
# suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align -Wno-error=undef -Wno-error=unused-parameter
CFLAGS_GCC += \
-flto \
-Wno-error=cast-align \
-Wno-error=undef \
-Wno-error=unused-parameter \
-Wno-error=type-limits \
LDFLAGS_GCC += -specs=nosys.specs -specs=nano.specs
ifeq ($(TOOLCHAIN),gcc)
CFLAGS_GCC += -Wno-error=maybe-uninitialized
endif
LDFLAGS_GCC += \
-nostdlib -nostartfiles \
--specs=nosys.specs --specs=nano.specs
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \

View File

@ -11,7 +11,6 @@ SKIPPED = "\033[33mskipped\033[0m"
build_separator = '-' * 106
make_iar_option = 'TOOLCHAIN=iar'
def filter_with_input(mylist):
if len(sys.argv) > 1:
@ -36,9 +35,10 @@ def build_family(example, family, make_option):
if __name__ == '__main__':
# IAR CC
if make_iar_option not in sys.argv:
make_iar_option = ''
make_option = ''
for a in sys.argv:
if 'TOOLCHAIN=' in sys.argv:
make_option += ' ' + a
# If examples are not specified in arguments, build all
all_examples = []
@ -67,7 +67,7 @@ if __name__ == '__main__':
for example in all_examples:
print(build_separator)
for family in all_families:
fret = build_family(example, family, make_iar_option)
fret = build_family(example, family, make_option)
if len(fret) == len(total_result):
total_result = [total_result[i] + fret[i] for i in range(len(fret))]