summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-24 22:11:08 +0700
committerhathach <[email protected]>2024-04-24 22:11:08 +0700
commiteab42d90d42234997ea55c01b1a510c9bb6434aa (patch)
tree361c1a6e6a4a7dd199fc006d2f3dd7fa36b9837d
parenta7bf0e3e7f7799c28e370826710810033c117744 (diff)
update clang make build for stm32: f0 f1 f2 f3 f4 f7 h7 g0 g4 l0 l4 samd21 samd51 nrf
-rw-r--r--examples/build_system/make/toolchain/gcc_rules.mk1
-rw-r--r--hw/bsp/nrf/family.mk21
-rw-r--r--hw/bsp/samd21/family.mk2
-rw-r--r--hw/bsp/samd51/family.mk7
-rw-r--r--hw/bsp/stm32f0/family.mk5
-rw-r--r--hw/bsp/stm32f1/family.mk5
-rw-r--r--hw/bsp/stm32f2/family.mk5
-rw-r--r--hw/bsp/stm32f3/family.mk5
-rw-r--r--hw/bsp/stm32f4/family.mk5
-rw-r--r--hw/bsp/stm32f7/family.mk5
-rw-r--r--hw/bsp/stm32g0/family.mk5
-rw-r--r--hw/bsp/stm32g4/family.mk5
-rw-r--r--hw/bsp/stm32h5/family.mk10
-rw-r--r--hw/bsp/stm32h7/family.mk9
-rw-r--r--hw/bsp/stm32l0/family.mk15
-rw-r--r--hw/bsp/stm32l4/family.mk11
-rw-r--r--hw/bsp/stm32u5/boards/stm32u575eval/board.mk2
-rw-r--r--hw/bsp/stm32u5/boards/stm32u575nucleo/board.mk2
-rw-r--r--hw/bsp/stm32u5/family.mk17
-rw-r--r--tools/build_make.py10
20 files changed, 95 insertions, 52 deletions
diff --git a/examples/build_system/make/toolchain/gcc_rules.mk b/examples/build_system/make/toolchain/gcc_rules.mk
index 3cd87db64..fc5225503 100644
--- a/examples/build_system/make/toolchain/gcc_rules.mk
+++ b/examples/build_system/make/toolchain/gcc_rules.mk
@@ -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)
diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk
index 29802dc37..b3c05e6db 100644
--- a/hw/bsp/nrf/family.mk
+++ b/hw/bsp/nrf/family.mk
@@ -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) \
diff --git a/hw/bsp/samd21/family.mk b/hw/bsp/samd21/family.mk
index 309df58fe..aabcff4a2 100644
--- a/hw/bsp/samd21/family.mk
+++ b/hw/bsp/samd21/family.mk
@@ -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 +=
diff --git a/hw/bsp/samd51/family.mk b/hw/bsp/samd51/family.mk
index 94ca68705..7b90efad0 100644
--- a/hw/bsp/samd51/family.mk
+++ b/hw/bsp/samd51/family.mk
@@ -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/
diff --git a/hw/bsp/stm32f0/family.mk b/hw/bsp/stm32f0/family.mk
index 537df4d7b..431709de0 100644
--- a/hw/bsp/stm32f0/family.mk
+++ b/hw/bsp/stm32f0/family.mk
@@ -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.
diff --git a/hw/bsp/stm32f1/family.mk b/hw/bsp/stm32f1/family.mk
index 8a5625551..03fbf4010 100644
--- a/hw/bsp/stm32f1/family.mk
+++ b/hw/bsp/stm32f1/family.mk
@@ -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.
diff --git a/hw/bsp/stm32f2/family.mk b/hw/bsp/stm32f2/family.mk
index c6ef1ec1d..7e71f6eed 100644
--- a/hw/bsp/stm32f2/family.mk
+++ b/hw/bsp/stm32f2/family.mk
@@ -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 \
diff --git a/hw/bsp/stm32f3/family.mk b/hw/bsp/stm32f3/family.mk
index be8271d96..4fe3aa99d 100644
--- a/hw/bsp/stm32f3/family.mk
+++ b/hw/bsp/stm32f3/family.mk
@@ -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 \
diff --git a/hw/bsp/stm32f4/family.mk b/hw/bsp/stm32f4/family.mk
index ecbbff417..523a1cb04 100644
--- a/hw/bsp/stm32f4/family.mk
+++ b/hw/bsp/stm32f4/family.mk
@@ -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
diff --git a/hw/bsp/stm32f7/family.mk b/hw/bsp/stm32f7/family.mk
index 1cdf23c6b..cc21bd64e 100644
--- a/hw/bsp/stm32f7/family.mk
+++ b/hw/bsp/stm32f7/family.mk
@@ -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
diff --git a/hw/bsp/stm32g0/family.mk b/hw/bsp/stm32g0/family.mk
index fb382b56a..95b8e537d 100644
--- a/hw/bsp/stm32g0/family.mk
+++ b/hw/bsp/stm32g0/family.mk
@@ -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
diff --git a/hw/bsp/stm32g4/family.mk b/hw/bsp/stm32g4/family.mk
index 95cd84dbd..0abd73532 100644
--- a/hw/bsp/stm32g4/family.mk
+++ b/hw/bsp/stm32g4/family.mk
@@ -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
diff --git a/hw/bsp/stm32h5/family.mk b/hw/bsp/stm32h5/family.mk
index 270b1c465..792edb2bb 100644
--- a/hw/bsp/stm32h5/family.mk
+++ b/hw/bsp/stm32h5/family.mk
@@ -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
diff --git a/hw/bsp/stm32h7/family.mk b/hw/bsp/stm32h7/family.mk
index 0777bb9c2..40df190db 100644
--- a/hw/bsp/stm32h7/family.mk
+++ b/hw/bsp/stm32h7/family.mk
@@ -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
diff --git a/hw/bsp/stm32l0/family.mk b/hw/bsp/stm32l0/family.mk
index a811e1823..fe7561fc2 100644
--- a/hw/bsp/stm32l0/family.mk
+++ b/hw/bsp/stm32l0/family.mk
@@ -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 \
diff --git a/hw/bsp/stm32l4/family.mk b/hw/bsp/stm32l4/family.mk
index 956f82263..411436cf6 100644
--- a/hw/bsp/stm32l4/family.mk
+++ b/hw/bsp/stm32l4/family.mk
@@ -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
diff --git a/hw/bsp/stm32u5/boards/stm32u575eval/board.mk b/hw/bsp/stm32u5/boards/stm32u575eval/board.mk
index 37d59023f..922d67f83 100644
--- a/hw/bsp/stm32u5/boards/stm32u575eval/board.mk
+++ b/hw/bsp/stm32u5/boards/stm32u575eval/board.mk
@@ -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
diff --git a/hw/bsp/stm32u5/boards/stm32u575nucleo/board.mk b/hw/bsp/stm32u5/boards/stm32u575nucleo/board.mk
index f07157801..1dd157a68 100644
--- a/hw/bsp/stm32u5/boards/stm32u575nucleo/board.mk
+++ b/hw/bsp/stm32u5/boards/stm32u575nucleo/board.mk
@@ -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
diff --git a/hw/bsp/stm32u5/family.mk b/hw/bsp/stm32u5/family.mk
index 2144ef37b..be5809340 100644
--- a/hw/bsp/stm32u5/family.mk
+++ b/hw/bsp/stm32u5/family.mk
@@ -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 \
diff --git a/tools/build_make.py b/tools/build_make.py
index f79a452e4..240fc8d64 100644
--- a/tools/build_make.py
+++ b/tools/build_make.py
@@ -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))]