From e92583ffd73d5307b918be2e4c7e39b978a804ed Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Mar 2023 15:37:17 +0700 Subject: [PATCH 01/16] try adding build for windows and macos --- .github/workflows/build_win_mac.yml | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/build_win_mac.yml diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml new file mode 100644 index 000000000..f41457617 --- /dev/null +++ b/.github/workflows/build_win_mac.yml @@ -0,0 +1,55 @@ +name: Build Windows/MacOS + +on: + push: + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/build_win_mac.yml' + pull_request: + branches: [ master ] + paths: + - 'src/**' + - 'examples/**' + - 'lib/**' + - 'hw/**' + - '.github/workflows/build_win_mac.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + # --------------------------------------- + # Build ARM family + # --------------------------------------- + build-arm: + strategy: + matrix: + os: [windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install ARM GCC + uses: carlosperate/arm-none-eabi-gcc-action@v1 + with: + release: '11.2-2022.02' + + - name: Checkout TinyUSB + uses: actions/checkout@v3 + + - name: Checkout common submodules in lib + run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip + + - name: Get Dependencies + run: python3 tools/get_dependencies.py stm32f0 + + - name: Build + run: python3 tools/build_family.py stm32f0 From 9a8a9359e40c93c187743a469f3d984dbf2f6413 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Mar 2023 15:55:34 +0700 Subject: [PATCH 02/16] use make abspath intead of shell realpath --- .github/workflows/build_win_mac.yml | 1 + tools/top.mk | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index f41457617..5ff7fa6f8 100644 --- a/.github/workflows/build_win_mac.yml +++ b/.github/workflows/build_win_mac.yml @@ -27,6 +27,7 @@ jobs: # --------------------------------------- build-arm: strategy: + fail-fast: false matrix: os: [windows-latest, macos-latest] runs-on: ${{ matrix.os }} diff --git a/tools/top.mk b/tools/top.mk index af8d698f5..2800f9571 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -26,20 +26,21 @@ THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) # strip off /tools/top.mk to get for example ../../.. TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE)) -#$(info top.mk: Initial TOP=$(TOP)) +$(info top.mk: Initial TOP=$(TOP)) # Set TOP to an absolute path, for example /tinyUSB (from ../../..) ifeq ($(CMDEXE),1) TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi)) else -TOP := $(shell realpath $(TOP)) +TOP := $(abspath $(TOP)) endif -#$(info top.mk: Top directory is $(TOP)) + +$(info top.mk: Top directory is $(TOP)) # Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos ifeq ($(CMDEXE),1) CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%))) else -CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`) +CURRENT_PATH = $(subst $(TOP)/,,$(abspath .)) endif -#$(info top.mk: Path from top is $(CURRENT_PATH)) +$(info top.mk: CURRENT_PATH = $(CURRENT_PATH)) From 70895358481255d5349461f99dc1f536aafec6ce Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Mar 2023 16:13:12 +0700 Subject: [PATCH 03/16] clean up f0 warnings --- hw/bsp/stm32f0/family.c | 2 +- hw/bsp/stm32f0/family.mk | 2 +- hw/bsp/stm32f0/stm32f0xx_hal_conf.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/bsp/stm32f0/family.c b/hw/bsp/stm32f0/family.c index a7e914128..0765f361d 100644 --- a/hw/bsp/stm32f0/family.c +++ b/hw/bsp/stm32f0/family.c @@ -165,7 +165,7 @@ void HardFault_Handler (void) * @param line: assert_param error line source number * @retval None */ -void assert_failed(uint8_t* file, uint32_t line) +void assert_failed(const char* file, uint32_t line) { (void) file; (void) line; /* USER CODE BEGIN 6 */ diff --git a/hw/bsp/stm32f0/family.mk b/hw/bsp/stm32f0/family.mk index 2983af49e..a065e9221 100644 --- a/hw/bsp/stm32f0/family.mk +++ b/hw/bsp/stm32f0/family.mk @@ -24,7 +24,7 @@ GCC_CFLAGS += \ -nostdlib -nostartfiles \ # suppress warning caused by vendor mcu driver -GCC_CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align -Wno-error=cast-qual +GCC_CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align # IAR Flags IAR_CFLAGS += --cpu cortex-m0 diff --git a/hw/bsp/stm32f0/stm32f0xx_hal_conf.h b/hw/bsp/stm32f0/stm32f0xx_hal_conf.h index cfa66b366..0bf053e13 100644 --- a/hw/bsp/stm32f0/stm32f0xx_hal_conf.h +++ b/hw/bsp/stm32f0/stm32f0xx_hal_conf.h @@ -303,9 +303,9 @@ * If expr is true, it returns no value. * @retval None */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) + #define assert_param(expr) ((expr) ? (void)0U : assert_failed(__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); + void assert_failed(const char* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ From 363fcc5b6816c98c0e3e951f17a108c35fbd86da Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 3 Mar 2023 16:24:33 +0700 Subject: [PATCH 04/16] only build 1 board on windows/macos --- .github/workflows/build_win_mac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index 5ff7fa6f8..c3aaa316a 100644 --- a/.github/workflows/build_win_mac.yml +++ b/.github/workflows/build_win_mac.yml @@ -53,4 +53,4 @@ jobs: run: python3 tools/get_dependencies.py stm32f0 - name: Build - run: python3 tools/build_family.py stm32f0 + run: python3 tools/build_family.py stm32f0 stm32f072disco From a99ee1b1a238b3edc6f2511543ffed2a3a1b657e Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 4 Mar 2023 20:08:10 +0700 Subject: [PATCH 05/16] bump up gcc, test macos uname --- .github/workflows/build_win_mac.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index c3aaa316a..c2e961f23 100644 --- a/.github/workflows/build_win_mac.yml +++ b/.github/workflows/build_win_mac.yml @@ -38,10 +38,13 @@ jobs: with: python-version: '3.x' + - if: matrix.os == 'macos-latest' + run: uname -a + - name: Install ARM GCC uses: carlosperate/arm-none-eabi-gcc-action@v1 with: - release: '11.2-2022.02' + release: '12.2.Rel1' - name: Checkout TinyUSB uses: actions/checkout@v3 From b4ef98cbdcac8a6bec4caee05920afc37a745149 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 5 Mar 2023 10:57:16 +0700 Subject: [PATCH 06/16] fix ci build on windows --- examples/make.mk | 4 ++-- tools/top.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 ../../..) From 8a493485e802673a877e43a53c7181a9668c7d51 Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 5 Mar 2023 13:39:38 +0700 Subject: [PATCH 07/16] 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(-) 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 From 9824981ee80f38791ec8de2d26ab928a382e852f Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 5 Mar 2023 15:35:02 +0700 Subject: [PATCH 08/16] ignore mkdir in windows ci --- .github/workflows/build_win_mac.yml | 2 +- examples/rules.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index 6d4f8ff80..46aa4a784 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: '10.3-2021.10' + release: '11.2-2022.02' - name: Checkout TinyUSB uses: actions/checkout@v3 diff --git a/examples/rules.mk b/examples/rules.mk index 06bc593ba..76be50b9c 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -112,7 +112,7 @@ OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) $(OBJ_DIRS): ifeq ($(CMDEXE),1) - @$(MKDIR) $(subst /,\,$@) + -@$(MKDIR) $(subst /,\,$@) else @$(MKDIR) -p $@ endif From 0a1a61bb6c921d033fc8bce0718b56e2d334323b Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 5 Mar 2023 15:42:05 +0700 Subject: [PATCH 09/16] try gcc 12.2 with macos --- .github/workflows/build_win_mac.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index 46aa4a784..a4b0ad220 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: '11.2-2022.02' + release: '12.2.Rel1' - name: Checkout TinyUSB uses: actions/checkout@v3 @@ -53,7 +53,7 @@ jobs: run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip - name: Get Dependencies - run: python3 tools/get_dependencies.py stm32f0 + run: python3 tools/get_dependencies.py stm32f4 - name: Build - run: python3 tools/build_family.py stm32f0 stm32f072disco + run: python3 tools/build_family.py stm32f4 stm32f411disco From 956d1c9c4e6c26e1c7de70c1c2e01a5380dd3dfe Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 10:33:04 +0700 Subject: [PATCH 10/16] update size to fix macos ci --- examples/make.mk | 2 +- tools/build_utils.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) 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) + From 5c537c25f00dad43c4839ba1bffe7d9cd03cc87f Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 11:16:21 +0700 Subject: [PATCH 11/16] change gcc to 10.3 due to freeRTOS warning --- .github/workflows/build_win_mac.yml | 2 +- hw/bsp/stm32f1/family.c | 2 +- hw/bsp/stm32f1/stm32f1xx_hal_conf.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index a4b0ad220..4b899cfb6 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/hw/bsp/stm32f1/family.c b/hw/bsp/stm32f1/family.c index 246d496c8..61b40badd 100644 --- a/hw/bsp/stm32f1/family.c +++ b/hw/bsp/stm32f1/family.c @@ -151,7 +151,7 @@ void HardFault_Handler (void) * @param line: assert_param error line source number * @retval None */ -void assert_failed(char *file, uint32_t line) +void assert_failed(const char *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, diff --git a/hw/bsp/stm32f1/stm32f1xx_hal_conf.h b/hw/bsp/stm32f1/stm32f1xx_hal_conf.h index a4a3f3086..5243e5bca 100644 --- a/hw/bsp/stm32f1/stm32f1xx_hal_conf.h +++ b/hw/bsp/stm32f1/stm32f1xx_hal_conf.h @@ -362,9 +362,9 @@ * If expr is true, it returns no value. * @retval None */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) + #define assert_param(expr) ((expr) ? (void)0U : assert_failed(__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); + void assert_failed(const char* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ From 9930863b412cc4e6b762a1a5aa300d94f2ea0518 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 12:45:47 +0700 Subject: [PATCH 12/16] fix iar ci --- examples/rules.mk | 30 +++++++++++++++--------------- hw/bsp/stm32f0/family.mk | 4 +++- hw/bsp/stm32f4/family.mk | 1 + hw/bsp/stm32f7/family.mk | 1 + hw/bsp/stm32g4/family.mk | 1 + hw/bsp/stm32h7/family.mk | 3 +++ hw/bsp/stm32l4/family.mk | 4 +++- tools/build_utils.py | 9 ++++----- 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/examples/rules.mk b/examples/rules.mk index 76be50b9c..3254112cf 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -139,7 +139,21 @@ $(BUILD)/obj/%_asm.o: %.S @echo AS $(notdir $@) @$(AS) $(ASFLAGS) -c -o $@ $< -ifndef USE_IAR +ifdef USE_IAR +# IAR Compiler +$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf + @echo CREATE $@ + @$(OBJCOPY) --silent --bin $^ $@ + +$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf + @echo CREATE $@ + @$(OBJCOPY) --silent --ihex $^ $@ + +$(BUILD)/$(PROJECT).elf: $(OBJ) + @echo LINK $@ + @$(LD) -o $@ $(IAR_LDFLAGS) $^ + +else # GCC based compiler $(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @@ -153,20 +167,6 @@ $(BUILD)/$(PROJECT).elf: $(OBJ) @echo LINK $@ @$(LD) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group -else - -# IAR Compiler -$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf - @echo CREATE $@ - @$(OBJCOPY) --silent --bin $^ $@ - -$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf - @echo CREATE $@ - @$(OBJCOPY) --silent --ihex $^ $@ - -$(BUILD)/$(PROJECT).elf: $(OBJ) - @echo LINK $@ - @$(LD) -o $@ $(IAR_LDFLAGS) $^ endif # UF2 generation, iMXRT need to strip to text only before conversion diff --git a/hw/bsp/stm32f0/family.mk b/hw/bsp/stm32f0/family.mk index a065e9221..1ae2aa5fc 100644 --- a/hw/bsp/stm32f0/family.mk +++ b/hw/bsp/stm32f0/family.mk @@ -42,7 +42,9 @@ SRC_C += \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \ - $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_dma.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart_ex.c INC += \ $(TOP)/$(BOARD_PATH) \ diff --git a/hw/bsp/stm32f4/family.mk b/hw/bsp/stm32f4/family.mk index e8352bad7..860955729 100644 --- a/hw/bsp/stm32f4/family.mk +++ b/hw/bsp/stm32f4/family.mk @@ -42,6 +42,7 @@ SRC_C += \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_dma.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c INC += \ diff --git a/hw/bsp/stm32f7/family.mk b/hw/bsp/stm32f7/family.mk index 781b8bb18..a54e43780 100644 --- a/hw/bsp/stm32f7/family.mk +++ b/hw/bsp/stm32f7/family.mk @@ -52,6 +52,7 @@ SRC_C += \ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_dma.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \ diff --git a/hw/bsp/stm32g4/family.mk b/hw/bsp/stm32g4/family.mk index 79defac56..ad9babf3f 100644 --- a/hw/bsp/stm32g4/family.mk +++ b/hw/bsp/stm32g4/family.mk @@ -43,6 +43,7 @@ SRC_C += \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c INC += \ diff --git a/hw/bsp/stm32h7/family.mk b/hw/bsp/stm32h7/family.mk index 834347b4b..e1b2cd40e 100644 --- a/hw/bsp/stm32h7/family.mk +++ b/hw/bsp/stm32h7/family.mk @@ -52,10 +52,13 @@ SRC_C += \ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_dma.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart_ex.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c INC += \ diff --git a/hw/bsp/stm32l4/family.mk b/hw/bsp/stm32l4/family.mk index 4fab7dc0d..84aa357e9 100644 --- a/hw/bsp/stm32l4/family.mk +++ b/hw/bsp/stm32l4/family.mk @@ -39,12 +39,14 @@ SRC_C += \ $(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_dma.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c \ $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \ - $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c \ + $(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart_ex.c INC += \ $(TOP)/lib/CMSIS_5/CMSIS/Core/Include \ diff --git a/tools/build_utils.py b/tools/build_utils.py index 0dbfd3356..a24cea7bb 100644 --- a/tools/build_utils.py +++ b/tools/build_utils.py @@ -120,9 +120,8 @@ def build_size(example, board): 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) + flash_size = int(size_list[0]) + sram_size = int(size_list[1]) + int(size_list[2]) + return (flash_size, sram_size) + return (0, 0) \ No newline at end of file From b6404d143ed218ad13dce62bd16b9a21de3bba79 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 13:03:55 +0700 Subject: [PATCH 13/16] clean up top --- tools/top.mk | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tools/top.mk b/tools/top.mk index d2388201a..fdae6337c 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -16,31 +16,14 @@ CMDEXE := 1 SHELL := cmd.exe endif -#$(info top.mk: SHELL=$(SHELL)) -#$(info top.mk: CMDEXE=$(CMDEXE)) - # 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 ../../.. -TOP := $(subst /tools/top.mk,,$(THIS_MAKEFILE)) -$(info top.mk: Initial TOP=$(TOP)) - -# Set TOP to an absolute path, for example /tinyUSB (from ../../..) -ifeq ($(CMDEXE),1) -TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi)) -else -TOP := $(abspath $(TOP)) -endif - -$(info top.mk: Top directory is $(TOP)) +# 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 -ifeq ($(CMDEXE),1) -CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%))) -else CURRENT_PATH = $(subst $(TOP)/,,$(abspath .)) -endif -$(info top.mk: CURRENT_PATH = $(CURRENT_PATH)) From e62d1a03acfa2a3b8afa0568690fdcad5495c260 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 13:25:56 +0700 Subject: [PATCH 14/16] integrate top.mk into make.mk --- examples/device/audio_4_channel_mic/Makefile | 1 - examples/device/audio_test/Makefile | 1 - .../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 - .../device/dynamic_configuration/Makefile | 1 - examples/device/hid_boot_interface/Makefile | 1 - examples/device/hid_composite/Makefile | 1 - .../device/hid_composite_freertos/Makefile | 1 - examples/device/hid_generic_inout/Makefile | 1 - .../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 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 .)) From 02478c57e51fcb82c53530a03ca4cca296645f1c Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 14:31:18 +0700 Subject: [PATCH 15/16] more ci fix --- examples/make.mk | 74 ++++++++++++++++++++-------------------- hw/bsp/stm32h7/family.mk | 2 +- 2 files changed, 38 insertions(+), 38 deletions(-) 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 From ec8c292bbebdbaebe39abef6e88c6a0fbb1f2be7 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 14:37:40 +0700 Subject: [PATCH 16/16] clean up --- .github/workflows/build_win_mac.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml index 4b899cfb6..bad9f3162 100644 --- a/.github/workflows/build_win_mac.yml +++ b/.github/workflows/build_win_mac.yml @@ -38,9 +38,6 @@ jobs: with: python-version: '3.x' - - if: matrix.os == 'macos-latest' - run: uname -a - - name: Install ARM GCC uses: carlosperate/arm-none-eabi-gcc-action@v1 with: