From 47bc269b50eb0fab9ac2f708cecdce2e2df601d9 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 21 Nov 2022 11:12:10 +0700 Subject: fix build with rp2040 and rx65 --- examples/make.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index 47520d660..73a39a8fe 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -113,7 +113,8 @@ CFLAGS += \ # Debugging/Optimization ifeq ($(DEBUG), 1) - CFLAGS += -Og + CFLAGS += -O0 + NO_LTO = 1 else CFLAGS += $(CFLAGS_OPTIMIZED) endif -- cgit v1.3.1 From 3fee8b402e3efefc341a0c1ce0474deb748858b2 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 17 Jan 2023 16:20:04 +0700 Subject: update makefile to support iar build starting with stm32f070 --- examples/make.mk | 37 +++++-- examples/rules.mk | 120 ++++++++++++++++------- hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk | 6 +- hw/bsp/stm32f0/family.c | 2 +- hw/bsp/stm32f0/family.mk | 17 +++- 5 files changed, 133 insertions(+), 49 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index 73a39a8fe..dd7a5cf4e 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -49,14 +49,31 @@ endif #-------------- Cross Compiler ------------ # Can be set by board, default to ARM GCC CROSS_COMPILE ?= arm-none-eabi- + # Allow for -Os to be changed by board makefiles in case -Os is not allowed CFLAGS_OPTIMIZED ?= -Os -CC = $(CROSS_COMPILE)gcc -CXX = $(CROSS_COMPILE)g++ -GDB = $(CROSS_COMPILE)gdb -OBJCOPY = $(CROSS_COMPILE)objcopy -SIZE = $(CROSS_COMPILE)size +ifeq ($(CC),iccarm) +USE_IAR = 1 +endif + +ifdef USE_IAR + AS = iasmarm + LD = ilinkarm + OBJCOPY = ielftool + SIZE = echo "size not available for IAR" + +else + CC = $(CROSS_COMPILE)gcc + CXX = $(CROSS_COMPILE)g++ + AS = $(CC) -x assembler-with-cpp + LD = $(CC) + + GDB = $(CROSS_COMPILE)gdb + OBJCOPY = $(CROSS_COMPILE)objcopy + SIZE = $(CROSS_COMPILE)size +endif + MKDIR = mkdir ifeq ($(CMDEXE),1) @@ -78,8 +95,8 @@ SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c)) INC += $(TOP)/$(FAMILY_PATH) -# Compiler Flags -CFLAGS += \ +# GCC Compiler Flags +GCC_CFLAGS += \ -ggdb \ -fdata-sections \ -ffunction-sections \ @@ -110,13 +127,13 @@ CFLAGS += \ # conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion # -Wconversion - + # Debugging/Optimization ifeq ($(DEBUG), 1) - CFLAGS += -O0 + GCC_CFLAGS += -O0 NO_LTO = 1 else - CFLAGS += $(CFLAGS_OPTIMIZED) + GCC_CFLAGS += $(CFLAGS_OPTIMIZED) endif # Log level is mapped to TUSB DEBUG option diff --git a/examples/rules.mk b/examples/rules.mk index c3134056a..2c4df85ba 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -46,39 +46,57 @@ INC += $(TOP)/src CFLAGS += $(addprefix -I,$(INC)) +ifdef USE_IAR + +IAR_CFLAGS += $(CFLAGS) -e --debug +IAR_LDFLAGS += --config $(TOP)/$(IAR_LD_FILE) + +else + +CFLAGS += $(GCC_CFLAGS) + # LTO makes it difficult to analyze map file for optimizing size purpose # We will run this option in ci ifeq ($(NO_LTO),1) CFLAGS := $(filter-out -flto,$(CFLAGS)) endif -ifneq ($(LD_FILE),) -LDFLAGS_LD_FILE ?= -Wl,-T,$(TOP)/$(LD_FILE) +LDFLAGS += $(CFLAGS) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections + +ifdef LD_FILE +LDFLAGS += -Wl,-T,$(TOP)/$(LD_FILE) endif -LDFLAGS += $(CFLAGS) $(LDFLAGS_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections ifneq ($(SKIP_NANOLIB), 1) LDFLAGS += -specs=nosys.specs -specs=nano.specs endif ASFLAGS += $(CFLAGS) +endif + +# Verbose mode +ifeq ("$(V)","1") +$(info CFLAGS $(CFLAGS) ) $(info ) +$(info LDFLAGS $(LDFLAGS)) $(info ) +$(info ASFLAGS $(ASFLAGS)) $(info ) +endif + # Assembly files can be name with upper case .S, convert it to .s SRC_S := $(SRC_S:.S=.s) +IAR_SRC_S := $(IAR_SRC_S:.S=.s) # Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966 # assembly file should be placed first in linking order # '_asm' suffix is added to object of assembly file +ifdef USE_IAR +OBJ += $(addprefix $(BUILD)/obj/, $(IAR_SRC_S:.s=_asm.o)) +else OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=_asm.o)) -OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o)) - -# Verbose mode -ifeq ("$(V)","1") -$(info CFLAGS $(CFLAGS) ) $(info ) -$(info LDFLAGS $(LDFLAGS)) $(info ) -$(info ASFLAGS $(ASFLAGS)) $(info ) endif +OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o)) + # --------------------------------------- # Rules # --------------------------------------- @@ -96,9 +114,15 @@ else @$(MKDIR) -p $@ endif -$(BUILD)/$(PROJECT).elf: $(OBJ) - @echo LINK $@ - @$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group +# We set vpath to point to the top of the tree so that the source files +# can be located. By following this scheme, it allows a single build rule +# to be used to compile all .c files. +vpath %.c . $(TOP) +vpath %.s . $(TOP) +vpath %.S . $(TOP) + +ifndef USE_IAR +# GCC based compiler $(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @@ -108,42 +132,73 @@ $(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @$(OBJCOPY) -O ihex $^ $@ -# UF2 generation, iMXRT need to strip to text only before conversion -ifeq ($(FAMILY),imxrt) -$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).elf - @echo CREATE $@ - @$(OBJCOPY) -O ihex -R .flash_config -R .ivt $^ $(BUILD)/$(PROJECT)-textonly.hex - $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $(BUILD)/$(PROJECT)-textonly.hex +$(BUILD)/$(PROJECT).elf: $(OBJ) + @echo LINK $@ + @$(LD) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group + +$(BUILD)/obj/%.o: %.c + @echo CC $(notdir $@) + @$(CC) $(CFLAGS) -c -MD -o $@ $< + +# ASM sources lower case .s +$(BUILD)/obj/%_asm.o: %.s + @echo AS $(notdir $@) + @$(AS) $(ASFLAGS) -c -o $@ $< + +# ASM sources upper case .S +$(BUILD)/obj/%_asm.o: %.S + @echo AS $(notdir $@) + @$(AS) $(ASFLAGS) -c -o $@ $< + else -$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex + +# IAR Compiler + +$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf @echo CREATE $@ - $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $^ -endif + @$(OBJCOPY) --bin $^ $@ -copy-artifact: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex $(BUILD)/$(PROJECT).uf2 +$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf + @echo CREATE $@ + @$(OBJCOPY) --ihex $^ $@ + +$(BUILD)/$(PROJECT).elf: $(OBJ) + @echo LINK $@ + @$(LD) $(IAR_LDFLAGS) $^ -o $@ -# We set vpath to point to the top of the tree so that the source files -# can be located. By following this scheme, it allows a single build rule -# to be used to compile all .c files. -vpath %.c . $(TOP) $(BUILD)/obj/%.o: %.c @echo CC $(notdir $@) - @$(CC) $(CFLAGS) -c -MD -o $@ $< + @$(CC) $(IAR_CFLAGS) -c -o $@ $< # ASM sources lower case .s -vpath %.s . $(TOP) $(BUILD)/obj/%_asm.o: %.s @echo AS $(notdir $@) - @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< + @$(AS) $(IAR_ASFLAGS) -c -o $@ $< # ASM sources upper case .S -vpath %.S . $(TOP) $(BUILD)/obj/%_asm.o: %.S @echo AS $(notdir $@) - @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< + @$(AS) $(IAR_ASFLAGS) -c -o $@ $< endif +# UF2 generation, iMXRT need to strip to text only before conversion +ifeq ($(FAMILY),imxrt) +$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).elf + @echo CREATE $@ + @$(OBJCOPY) -O ihex -R .flash_config -R .ivt $^ $(BUILD)/$(PROJECT)-textonly.hex + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $(BUILD)/$(PROJECT)-textonly.hex +else +$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex + @echo CREATE $@ + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $^ +endif + +copy-artifact: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex $(BUILD)/$(PROJECT).uf2 + +endif +# ---------------- GNU Make End ----------------------- + .PHONY: clean clean: ifeq ($(CMDEXE),1) @@ -151,7 +206,6 @@ ifeq ($(CMDEXE),1) else $(RM) -rf $(BUILD) endif -# ---------------- GNU Make End ----------------------- # get depenecies .PHONY: get-deps diff --git a/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk b/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk index 7c0ee40b6..242b5a034 100644 --- a/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk +++ b/hw/bsp/stm32f0/boards/stm32f070rbnucleo/board.mk @@ -1,11 +1,13 @@ CFLAGS += -DSTM32F070xB -DCFG_EXAMPLE_VIDEO_READONLY +SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f070xb.s LD_FILE = $(BOARD_PATH)/stm32F070rbtx_flash.ld -SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f070xb.s +IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f070xb.s +IAR_LD_FILE = $(ST_CMSIS)/Source/Templates/iar/linker/stm32f070xb_flash.icf # For flash-jlink target JLINK_DEVICE = stm32f070rb # flash target using on-board stlink -flash: flash-stlink +flash: flash-stlink \ No newline at end of file diff --git a/hw/bsp/stm32f0/family.c b/hw/bsp/stm32f0/family.c index 8de3147e2..806c4af51 100644 --- a/hw/bsp/stm32f0/family.c +++ b/hw/bsp/stm32f0/family.c @@ -153,7 +153,7 @@ uint32_t board_millis(void) void HardFault_Handler (void) { - asm("bkpt"); + __asm("BKPT #0\n"); } #ifdef USE_FULL_ASSERT diff --git a/hw/bsp/stm32f0/family.mk b/hw/bsp/stm32f0/family.mk index 39831e154..a81ab426f 100644 --- a/hw/bsp/stm32f0/family.mk +++ b/hw/bsp/stm32f0/family.mk @@ -8,17 +8,28 @@ ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ + -DCFG_EXAMPLE_MSC_READONLY \ + -DCFG_TUSB_MCU=OPT_MCU_STM32F0 + +# -------------- +# GCC Flags +# -------------- +GCC_CFLAGS += \ -flto \ -mthumb \ -mabi=aapcs \ -mcpu=cortex-m0 \ -mfloat-abi=soft \ -nostdlib -nostartfiles \ - -DCFG_EXAMPLE_MSC_READONLY \ - -DCFG_TUSB_MCU=OPT_MCU_STM32F0 # suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual +GCC_CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual + +# -------------- +# IAR Flags +# -------------- +IAR_CFLAGS += --cpu cortex-m0 +IAR_ASFLAGS += --cpu cortex-m0 SRC_C += \ src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \ -- cgit v1.3.1 From b4ef98cbdcac8a6bec4caee05920afc37a745149 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 5 Mar 2023 10:57:16 +0700 Subject: fix ci build on windows --- examples/make.mk | 4 ++-- tools/top.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index dd7a5cf4e..5b364baf7 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -74,16 +74,16 @@ else SIZE = $(CROSS_COMPILE)size endif -MKDIR = mkdir - ifeq ($(CMDEXE),1) CP = copy RM = del PYTHON = python + MKDIR = cmd /e /c mkdir else SED = sed CP = cp RM = rm + MKDIR = mkdir PYTHON = python3 endif diff --git a/tools/top.mk b/tools/top.mk index 2800f9571..d2388201a 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -25,7 +25,7 @@ endif THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) # strip off /tools/top.mk to get for example ../../.. -TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE)) +TOP := $(subst /tools/top.mk,,$(THIS_MAKEFILE)) $(info top.mk: Initial TOP=$(TOP)) # Set TOP to an absolute path, for example /tinyUSB (from ../../..) -- cgit v1.3.1 From 8a493485e802673a877e43a53c7181a9668c7d51 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 5 Mar 2023 13:39:38 +0700 Subject: more ci test --- .github/workflows/build_win_mac.yml | 2 +- examples/make.mk | 3 +-- examples/rules.mk | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'examples/make.mk') diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index c2e961f23..6d4f8ff80 100644 --- a/.github/workflows/build_win_mac.yml +++ b/.github/workflows/build_win_mac.yml @@ -44,7 +44,7 @@ jobs: - name: Install ARM GCC uses: carlosperate/arm-none-eabi-gcc-action@v1 with: - release: '12.2.Rel1' + release: '10.3-2021.10' - name: Checkout TinyUSB uses: actions/checkout@v3 diff --git a/examples/make.mk b/examples/make.mk index 5b364baf7..8a0b6db6b 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -77,10 +77,9 @@ endif ifeq ($(CMDEXE),1) CP = copy RM = del + MKDIR = mkdir PYTHON = python - MKDIR = cmd /e /c mkdir else - SED = sed CP = cp RM = rm MKDIR = mkdir diff --git a/examples/rules.mk b/examples/rules.mk index dcef934ab..06bc593ba 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -265,7 +265,11 @@ debug-bmp: $(BUILD)/$(PROJECT).elf # Create binary directory $(BIN): +ifeq ($(CMDEXE),1) + @$(MKDIR) $(subst /,\,$@) +else @$(MKDIR) -p $@ +endif # Copy binaries .elf, .bin, .hex, .uf2 to BIN for upload # due to large size of combined artifacts, only uf2 is uploaded for now -- cgit v1.3.1 From 956d1c9c4e6c26e1c7de70c1c2e01a5380dd3dfe Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 10:33:04 +0700 Subject: update size to fix macos ci --- examples/make.mk | 2 +- tools/build_utils.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index 8a0b6db6b..e02d226b6 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -61,7 +61,7 @@ ifdef USE_IAR AS = iasmarm LD = ilinkarm OBJCOPY = ielftool - SIZE = echo "size not available for IAR" + SIZE = size else CC = $(CROSS_COMPILE)gcc diff --git a/tools/build_utils.py b/tools/build_utils.py index ad1daf8c7..0dbfd3356 100644 --- a/tools/build_utils.py +++ b/tools/build_utils.py @@ -114,9 +114,15 @@ def build_example(example, board, make_option): def build_size(example, board): - elf_file = 'examples/{}/_build/{}/*.elf'.format(example, board) - size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8") - size_list = size_output.split('\n')[1].split('\t') + size_cmd = 'make -j -C examples/{} BOARD={} size'.format(example, board) + size_output = subprocess.run(size_cmd, shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8").splitlines() + for i, l in enumerate(size_output): + text_title = 'text data bss dec' + if text_title in l: + size_list = size_output[i+1].split('\t') + break + flash_size = int(size_list[0]) sram_size = int(size_list[1]) + int(size_list[2]) return (flash_size, sram_size) + -- cgit v1.3.1 From e62d1a03acfa2a3b8afa0568690fdcad5495c260 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 13:25:56 +0700 Subject: integrate top.mk into make.mk --- examples/device/audio_4_channel_mic/Makefile | 1 - examples/device/audio_test/Makefile | 1 - examples/device/audio_test_multi_rate/Makefile | 1 - examples/device/board_test/Makefile | 1 - examples/device/cdc_dual_ports/Makefile | 1 - examples/device/cdc_msc/Makefile | 1 - examples/device/cdc_msc_freertos/Makefile | 1 - examples/device/dfu/Makefile | 1 - examples/device/dfu_runtime/Makefile | 1 - examples/device/dynamic_configuration/Makefile | 1 - examples/device/hid_boot_interface/Makefile | 1 - examples/device/hid_composite/Makefile | 1 - examples/device/hid_composite_freertos/Makefile | 1 - examples/device/hid_generic_inout/Makefile | 1 - examples/device/hid_multiple_interface/Makefile | 1 - examples/device/midi_test/Makefile | 1 - examples/device/msc_dual_lun/Makefile | 1 - examples/device/net_lwip_webserver/Makefile | 1 - examples/device/uac2_headset/Makefile | 1 - examples/device/usbtmc/Makefile | 1 - examples/device/video_capture/Makefile | 1 - examples/device/webusb_serial/Makefile | 1 - examples/dual/host_hid_to_device_cdc/Makefile | 1 - examples/host/bare_api/Makefile | 1 - examples/host/cdc_msc_hid/Makefile | 1 - examples/host/hid_controller/Makefile | 1 - examples/host/msc_file_explorer/Makefile | 1 - examples/make.mk | 110 +++++++++++++++--------- test/fuzz/device/cdc/Makefile | 1 - test/fuzz/device/msc/Makefile | 1 - test/fuzz/device/net/Makefile | 1 - test/fuzz/make.mk | 30 ++++++- tools/top.mk | 29 ------- 33 files changed, 97 insertions(+), 102 deletions(-) delete mode 100644 tools/top.mk (limited to 'examples/make.mk') diff --git a/examples/device/audio_4_channel_mic/Makefile b/examples/device/audio_4_channel_mic/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/audio_4_channel_mic/Makefile +++ b/examples/device/audio_4_channel_mic/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/audio_test/Makefile b/examples/device/audio_test/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/audio_test/Makefile +++ b/examples/device/audio_test/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/audio_test_multi_rate/Makefile b/examples/device/audio_test_multi_rate/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/audio_test_multi_rate/Makefile +++ b/examples/device/audio_test_multi_rate/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/board_test/Makefile b/examples/device/board_test/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/board_test/Makefile +++ b/examples/device/board_test/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/cdc_dual_ports/Makefile b/examples/device/cdc_dual_ports/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/cdc_dual_ports/Makefile +++ b/examples/device/cdc_dual_ports/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/cdc_msc/Makefile b/examples/device/cdc_msc/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/cdc_msc/Makefile +++ b/examples/device/cdc_msc/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/cdc_msc_freertos/Makefile b/examples/device/cdc_msc_freertos/Makefile index 4ee816880..e2bbc2268 100644 --- a/examples/device/cdc_msc_freertos/Makefile +++ b/examples/device/cdc_msc_freertos/Makefile @@ -1,6 +1,5 @@ DEPS_SUBMODULES += lib/FreeRTOS-Kernel -include ../../../tools/top.mk include ../../make.mk FREERTOS_SRC = lib/FreeRTOS-Kernel diff --git a/examples/device/dfu/Makefile b/examples/device/dfu/Makefile index 5148ed55a..b3f2cc588 100644 --- a/examples/device/dfu/Makefile +++ b/examples/device/dfu/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/dfu_runtime/Makefile b/examples/device/dfu_runtime/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/dfu_runtime/Makefile +++ b/examples/device/dfu_runtime/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/dynamic_configuration/Makefile b/examples/device/dynamic_configuration/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/dynamic_configuration/Makefile +++ b/examples/device/dynamic_configuration/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/hid_boot_interface/Makefile b/examples/device/hid_boot_interface/Makefile index c6a9c5b21..d58a539e8 100644 --- a/examples/device/hid_boot_interface/Makefile +++ b/examples/device/hid_boot_interface/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/hid_composite/Makefile b/examples/device/hid_composite/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/hid_composite/Makefile +++ b/examples/device/hid_composite/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/hid_composite_freertos/Makefile b/examples/device/hid_composite_freertos/Makefile index a354a90b6..099a43893 100644 --- a/examples/device/hid_composite_freertos/Makefile +++ b/examples/device/hid_composite_freertos/Makefile @@ -1,6 +1,5 @@ DEPS_SUBMODULES += lib/FreeRTOS-Kernel -include ../../../tools/top.mk include ../../make.mk FREERTOS_SRC = lib/FreeRTOS-Kernel diff --git a/examples/device/hid_generic_inout/Makefile b/examples/device/hid_generic_inout/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/hid_generic_inout/Makefile +++ b/examples/device/hid_generic_inout/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/hid_multiple_interface/Makefile b/examples/device/hid_multiple_interface/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/hid_multiple_interface/Makefile +++ b/examples/device/hid_multiple_interface/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/midi_test/Makefile b/examples/device/midi_test/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/midi_test/Makefile +++ b/examples/device/midi_test/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/msc_dual_lun/Makefile b/examples/device/msc_dual_lun/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/msc_dual_lun/Makefile +++ b/examples/device/msc_dual_lun/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/net_lwip_webserver/Makefile b/examples/device/net_lwip_webserver/Makefile index 55bd820bd..bc2914b36 100644 --- a/examples/device/net_lwip_webserver/Makefile +++ b/examples/device/net_lwip_webserver/Makefile @@ -1,6 +1,5 @@ DEPS_SUBMODULES += lib/lwip -include ../../../tools/top.mk include ../../make.mk # suppress warning caused by lwip diff --git a/examples/device/uac2_headset/Makefile b/examples/device/uac2_headset/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/uac2_headset/Makefile +++ b/examples/device/uac2_headset/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/usbtmc/Makefile b/examples/device/usbtmc/Makefile index 69b633fea..da088ea6b 100644 --- a/examples/device/usbtmc/Makefile +++ b/examples/device/usbtmc/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/device/video_capture/Makefile b/examples/device/video_capture/Makefile index fda66bcc1..90d174c32 100644 --- a/examples/device/video_capture/Makefile +++ b/examples/device/video_capture/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk ifeq ($(DISABLE_MJPEG),1) diff --git a/examples/device/webusb_serial/Makefile b/examples/device/webusb_serial/Makefile index 5a455078e..2a3d854fb 100644 --- a/examples/device/webusb_serial/Makefile +++ b/examples/device/webusb_serial/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/dual/host_hid_to_device_cdc/Makefile b/examples/dual/host_hid_to_device_cdc/Makefile index 3fe9b0888..95c88e7e8 100644 --- a/examples/dual/host_hid_to_device_cdc/Makefile +++ b/examples/dual/host_hid_to_device_cdc/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/host/bare_api/Makefile b/examples/host/bare_api/Makefile index 84555a889..058307c40 100644 --- a/examples/host/bare_api/Makefile +++ b/examples/host/bare_api/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/host/cdc_msc_hid/Makefile b/examples/host/cdc_msc_hid/Makefile index 9adccfa3a..7c16b39d3 100644 --- a/examples/host/cdc_msc_hid/Makefile +++ b/examples/host/cdc_msc_hid/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/host/hid_controller/Makefile b/examples/host/hid_controller/Makefile index e7fbd741f..cda2977bc 100644 --- a/examples/host/hid_controller/Makefile +++ b/examples/host/hid_controller/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk INC += \ diff --git a/examples/host/msc_file_explorer/Makefile b/examples/host/msc_file_explorer/Makefile index de2f9c01c..1fda72b18 100644 --- a/examples/host/msc_file_explorer/Makefile +++ b/examples/host/msc_file_explorer/Makefile @@ -1,4 +1,3 @@ -include ../../../tools/top.mk include ../../make.mk FATFS_PATH = lib/fatfs/source diff --git a/examples/make.mk b/examples/make.mk index e02d226b6..d91263db9 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -2,6 +2,72 @@ # Common make definition for all examples # --------------------------------------- +#-------------- TOP and CURRENT_PATH ------------ + +# Set TOP to be the path to get from the current directory (where make was +# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns +# the name of this makefile relative to where make was invoked. +THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) + +# strip off /tools/top.mk to get for example ../../.. +# and Set TOP to an absolute path +TOP = $(abspath $(subst make.mk,..,$(THIS_MAKEFILE))) + +# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos +CURRENT_PATH = $(subst $(TOP)/,,$(abspath .)) + +# Detect whether shell style is windows or not +# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069 +ifeq '$(findstring ;,$(PATH))' ';' +# PATH contains semicolon - so we're definitely on Windows. +CMDEXE := 1 + +# makefile shell commands should use syntax for DOS CMD, not unix sh +# Unfortunately, SHELL may point to sh or bash, which can't accept DOS syntax. +# We can't just use sh, because while sh and/or bash shell may be available, +# many Windows environments won't have utilities like realpath used below, so... +# Force DOS command shell on Windows. +SHELL := cmd.exe +endif + +#-------------- Cross Compiler ------------ +# Can be set by board, default to ARM GCC +CROSS_COMPILE ?= arm-none-eabi- + +ifeq ($(CC),iccarm) +USE_IAR = 1 +endif + +ifdef USE_IAR + AS = iasmarm + LD = ilinkarm + OBJCOPY = ielftool + SIZE = size + +else + CC = $(CROSS_COMPILE)gcc + CXX = $(CROSS_COMPILE)g++ + AS = $(CC) -x assembler-with-cpp + LD = $(CC) + + GDB = $(CROSS_COMPILE)gdb + OBJCOPY = $(CROSS_COMPILE)objcopy + SIZE = $(CROSS_COMPILE)size +endif + +ifeq ($(CMDEXE),1) + CP = copy + RM = del + MKDIR = mkdir + PYTHON = python +else + CP = cp + RM = rm + MKDIR = mkdir + PYTHON = python3 +endif + + # Build directory BUILD := _build/$(BOARD) @@ -45,47 +111,6 @@ else SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) endif - -#-------------- Cross Compiler ------------ -# Can be set by board, default to ARM GCC -CROSS_COMPILE ?= arm-none-eabi- - -# Allow for -Os to be changed by board makefiles in case -Os is not allowed -CFLAGS_OPTIMIZED ?= -Os - -ifeq ($(CC),iccarm) -USE_IAR = 1 -endif - -ifdef USE_IAR - AS = iasmarm - LD = ilinkarm - OBJCOPY = ielftool - SIZE = size - -else - CC = $(CROSS_COMPILE)gcc - CXX = $(CROSS_COMPILE)g++ - AS = $(CC) -x assembler-with-cpp - LD = $(CC) - - GDB = $(CROSS_COMPILE)gdb - OBJCOPY = $(CROSS_COMPILE)objcopy - SIZE = $(CROSS_COMPILE)size -endif - -ifeq ($(CMDEXE),1) - CP = copy - RM = del - MKDIR = mkdir - PYTHON = python -else - CP = cp - RM = rm - MKDIR = mkdir - PYTHON = python3 -endif - #-------------- Source files and compiler flags -------------- # Include all source C in family & board folder @@ -94,6 +119,9 @@ SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c)) INC += $(TOP)/$(FAMILY_PATH) +# Allow for -Os to be changed by board makefiles in case -Os is not allowed +CFLAGS_OPTIMIZED ?= -Os + # GCC Compiler Flags GCC_CFLAGS += \ -ggdb \ diff --git a/test/fuzz/device/cdc/Makefile b/test/fuzz/device/cdc/Makefile index ee51936b5..7071df057 100644 --- a/test/fuzz/device/cdc/Makefile +++ b/test/fuzz/device/cdc/Makefile @@ -1,4 +1,3 @@ -include ../../../../tools/top.mk include ../../make.mk INC += \ diff --git a/test/fuzz/device/msc/Makefile b/test/fuzz/device/msc/Makefile index ee51936b5..7071df057 100644 --- a/test/fuzz/device/msc/Makefile +++ b/test/fuzz/device/msc/Makefile @@ -1,4 +1,3 @@ -include ../../../../tools/top.mk include ../../make.mk INC += \ diff --git a/test/fuzz/device/net/Makefile b/test/fuzz/device/net/Makefile index 22241fcdc..4e99604ad 100644 --- a/test/fuzz/device/net/Makefile +++ b/test/fuzz/device/net/Makefile @@ -1,6 +1,5 @@ DEPS_SUBMODULES += lib/lwip -include ../../../../tools/top.mk include ../../make.mk # suppress warning caused by lwip diff --git a/test/fuzz/make.mk b/test/fuzz/make.mk index e7c5518e7..934819665 100644 --- a/test/fuzz/make.mk +++ b/test/fuzz/make.mk @@ -2,6 +2,34 @@ # Common make definition for all examples # --------------------------------------- +#-------------- TOP and CURRENT_PATH ------------ + +# Set TOP to be the path to get from the current directory (where make was +# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns +# the name of this makefile relative to where make was invoked. +THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) + +# strip off /tools/top.mk to get for example ../../.. +# and Set TOP to an absolute path +TOP = $(abspath $(subst make.mk,../..,$(THIS_MAKEFILE))) + +# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos +CURRENT_PATH = $(subst $(TOP)/,,$(abspath .)) + +# Detect whether shell style is windows or not +# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069 +ifeq '$(findstring ;,$(PATH))' ';' +# PATH contains semicolon - so we're definitely on Windows. +CMDEXE := 1 + +# makefile shell commands should use syntax for DOS CMD, not unix sh +# Unfortunately, SHELL may point to sh or bash, which can't accept DOS syntax. +# We can't just use sh, because while sh and/or bash shell may be available, +# many Windows environments won't have utilities like realpath used below, so... +# Force DOS command shell on Windows. +SHELL := cmd.exe +endif + # Build directory BUILD := _build PROJECT := $(notdir $(CURDIR)) @@ -42,8 +70,6 @@ SANITIZER_FLAGS ?= -fsanitize=fuzzer \ CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS) #-------------- Source files and compiler flags -------------- - - INC += $(TOP)/test # Compiler Flags diff --git a/tools/top.mk b/tools/top.mk deleted file mode 100644 index fdae6337c..000000000 --- a/tools/top.mk +++ /dev/null @@ -1,29 +0,0 @@ -ifneq ($(lastword a b),b) -$(error This Makefile requires make 3.81 or newer) -endif - -# Detect whether shell style is windows or not -# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069 -ifeq '$(findstring ;,$(PATH))' ';' -# PATH contains semicolon - so we're definitely on Windows. -CMDEXE := 1 - -# makefile shell commands should use syntax for DOS CMD, not unix sh -# Unfortunately, SHELL may point to sh or bash, which can't accept DOS syntax. -# We can't just use sh, because while sh and/or bash shell may be available, -# many Windows environments won't have utilities like realpath used below, so... -# Force DOS command shell on Windows. -SHELL := cmd.exe -endif - -# Set TOP to be the path to get from the current directory (where make was -# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns -# the name of this makefile relative to where make was invoked. -THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) - -# strip off /tools/top.mk to get for example ../../.. -# and Set TOP to an absolute path -TOP = $(abspath $(subst /tools/top.mk,,$(THIS_MAKEFILE))) - -# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos -CURRENT_PATH = $(subst $(TOP)/,,$(abspath .)) -- cgit v1.3.1 From 02478c57e51fcb82c53530a03ca4cca296645f1c Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 14:31:18 +0700 Subject: more ci fix --- examples/make.mk | 74 ++++++++++++++++++++++++------------------------ hw/bsp/stm32h7/family.mk | 2 +- 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index d91263db9..0a07da21c 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -30,43 +30,6 @@ CMDEXE := 1 SHELL := cmd.exe endif -#-------------- Cross Compiler ------------ -# Can be set by board, default to ARM GCC -CROSS_COMPILE ?= arm-none-eabi- - -ifeq ($(CC),iccarm) -USE_IAR = 1 -endif - -ifdef USE_IAR - AS = iasmarm - LD = ilinkarm - OBJCOPY = ielftool - SIZE = size - -else - CC = $(CROSS_COMPILE)gcc - CXX = $(CROSS_COMPILE)g++ - AS = $(CC) -x assembler-with-cpp - LD = $(CC) - - GDB = $(CROSS_COMPILE)gdb - OBJCOPY = $(CROSS_COMPILE)objcopy - SIZE = $(CROSS_COMPILE)size -endif - -ifeq ($(CMDEXE),1) - CP = copy - RM = del - MKDIR = mkdir - PYTHON = python -else - CP = cp - RM = rm - MKDIR = mkdir - PYTHON = python3 -endif - # Build directory BUILD := _build/$(BOARD) @@ -111,6 +74,43 @@ else SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) endif +#-------------- Cross Compiler ------------ +# Can be set by board, default to ARM GCC +CROSS_COMPILE ?= arm-none-eabi- + +ifeq ($(CC),iccarm) +USE_IAR = 1 +endif + +ifdef USE_IAR + AS = iasmarm + LD = ilinkarm + OBJCOPY = ielftool + SIZE = size + +else + CC = $(CROSS_COMPILE)gcc + CXX = $(CROSS_COMPILE)g++ + AS = $(CC) -x assembler-with-cpp + LD = $(CC) + + GDB = $(CROSS_COMPILE)gdb + OBJCOPY = $(CROSS_COMPILE)objcopy + SIZE = $(CROSS_COMPILE)size +endif + +ifeq ($(CMDEXE),1) + CP = copy + RM = del + MKDIR = mkdir + PYTHON = python +else + CP = cp + RM = rm + MKDIR = mkdir + PYTHON = python3 +endif + #-------------- Source files and compiler flags -------------- # Include all source C in family & board folder diff --git a/hw/bsp/stm32h7/family.mk b/hw/bsp/stm32h7/family.mk index e1b2cd40e..9989b17a8 100644 --- a/hw/bsp/stm32h7/family.mk +++ b/hw/bsp/stm32h7/family.mk @@ -37,7 +37,7 @@ GCC_CFLAGS += \ -nostdlib -nostartfiles # suppress warning caused by vendor mcu driver -GCC_CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align +GCC_CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=cast-align -Wno-error=unused-parameter # IAR Flags IAR_CFLAGS += --cpu cortex-m7 --fpu VFPv5_D16 -- cgit v1.3.1