mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Merge pull request #1938 from hathach/update-build
Fix build on windows and macos
This commit is contained in:
commit
66da95a0ee
56
.github/workflows/build_win_mac.yml
vendored
Normal file
56
.github/workflows/build_win_mac.yml
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
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:
|
||||||
|
fail-fast: false
|
||||||
|
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: '10.3-2021.10'
|
||||||
|
|
||||||
|
- 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 stm32f4
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: python3 tools/build_family.py stm32f4 stm32f411disco
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
DEPS_SUBMODULES += lib/FreeRTOS-Kernel
|
DEPS_SUBMODULES += lib/FreeRTOS-Kernel
|
||||||
|
|
||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
FREERTOS_SRC = lib/FreeRTOS-Kernel
|
FREERTOS_SRC = lib/FreeRTOS-Kernel
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
DEPS_SUBMODULES += lib/FreeRTOS-Kernel
|
DEPS_SUBMODULES += lib/FreeRTOS-Kernel
|
||||||
|
|
||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
FREERTOS_SRC = lib/FreeRTOS-Kernel
|
FREERTOS_SRC = lib/FreeRTOS-Kernel
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
DEPS_SUBMODULES += lib/lwip
|
DEPS_SUBMODULES += lib/lwip
|
||||||
|
|
||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
# suppress warning caused by lwip
|
# suppress warning caused by lwip
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
ifeq ($(DISABLE_MJPEG),1)
|
ifeq ($(DISABLE_MJPEG),1)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
FATFS_PATH = lib/fatfs/source
|
FATFS_PATH = lib/fatfs/source
|
||||||
|
@ -2,6 +2,35 @@
|
|||||||
# Common make definition for all examples
|
# 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 directory
|
||||||
BUILD := _build/$(BOARD)
|
BUILD := _build/$(BOARD)
|
||||||
|
|
||||||
@ -45,14 +74,10 @@ else
|
|||||||
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
|
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
#-------------- Cross Compiler ------------
|
#-------------- Cross Compiler ------------
|
||||||
# Can be set by board, default to ARM GCC
|
# Can be set by board, default to ARM GCC
|
||||||
CROSS_COMPILE ?= arm-none-eabi-
|
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)
|
ifeq ($(CC),iccarm)
|
||||||
USE_IAR = 1
|
USE_IAR = 1
|
||||||
endif
|
endif
|
||||||
@ -61,29 +86,28 @@ ifdef USE_IAR
|
|||||||
AS = iasmarm
|
AS = iasmarm
|
||||||
LD = ilinkarm
|
LD = ilinkarm
|
||||||
OBJCOPY = ielftool
|
OBJCOPY = ielftool
|
||||||
SIZE = echo "size not available for IAR"
|
SIZE = size
|
||||||
|
|
||||||
else
|
else
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
CXX = $(CROSS_COMPILE)g++
|
CXX = $(CROSS_COMPILE)g++
|
||||||
AS = $(CC) -x assembler-with-cpp
|
AS = $(CC) -x assembler-with-cpp
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
|
||||||
GDB = $(CROSS_COMPILE)gdb
|
GDB = $(CROSS_COMPILE)gdb
|
||||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
SIZE = $(CROSS_COMPILE)size
|
SIZE = $(CROSS_COMPILE)size
|
||||||
endif
|
endif
|
||||||
|
|
||||||
MKDIR = mkdir
|
|
||||||
|
|
||||||
ifeq ($(CMDEXE),1)
|
ifeq ($(CMDEXE),1)
|
||||||
CP = copy
|
CP = copy
|
||||||
RM = del
|
RM = del
|
||||||
|
MKDIR = mkdir
|
||||||
PYTHON = python
|
PYTHON = python
|
||||||
else
|
else
|
||||||
SED = sed
|
|
||||||
CP = cp
|
CP = cp
|
||||||
RM = rm
|
RM = rm
|
||||||
|
MKDIR = mkdir
|
||||||
PYTHON = python3
|
PYTHON = python3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -95,6 +119,9 @@ SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c))
|
|||||||
|
|
||||||
INC += $(TOP)/$(FAMILY_PATH)
|
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 Compiler Flags
|
||||||
GCC_CFLAGS += \
|
GCC_CFLAGS += \
|
||||||
-ggdb \
|
-ggdb \
|
||||||
|
@ -112,7 +112,7 @@ OBJ_DIRS = $(sort $(dir $(OBJ)))
|
|||||||
$(OBJ): | $(OBJ_DIRS)
|
$(OBJ): | $(OBJ_DIRS)
|
||||||
$(OBJ_DIRS):
|
$(OBJ_DIRS):
|
||||||
ifeq ($(CMDEXE),1)
|
ifeq ($(CMDEXE),1)
|
||||||
@$(MKDIR) $(subst /,\,$@)
|
-@$(MKDIR) $(subst /,\,$@)
|
||||||
else
|
else
|
||||||
@$(MKDIR) -p $@
|
@$(MKDIR) -p $@
|
||||||
endif
|
endif
|
||||||
@ -139,7 +139,21 @@ $(BUILD)/obj/%_asm.o: %.S
|
|||||||
@echo AS $(notdir $@)
|
@echo AS $(notdir $@)
|
||||||
@$(AS) $(ASFLAGS) -c -o $@ $<
|
@$(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
|
# GCC based compiler
|
||||||
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
|
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
|
||||||
@echo CREATE $@
|
@echo CREATE $@
|
||||||
@ -153,20 +167,6 @@ $(BUILD)/$(PROJECT).elf: $(OBJ)
|
|||||||
@echo LINK $@
|
@echo LINK $@
|
||||||
@$(LD) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
@$(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
|
endif
|
||||||
|
|
||||||
# UF2 generation, iMXRT need to strip to text only before conversion
|
# UF2 generation, iMXRT need to strip to text only before conversion
|
||||||
@ -265,7 +265,11 @@ debug-bmp: $(BUILD)/$(PROJECT).elf
|
|||||||
|
|
||||||
# Create binary directory
|
# Create binary directory
|
||||||
$(BIN):
|
$(BIN):
|
||||||
|
ifeq ($(CMDEXE),1)
|
||||||
|
@$(MKDIR) $(subst /,\,$@)
|
||||||
|
else
|
||||||
@$(MKDIR) -p $@
|
@$(MKDIR) -p $@
|
||||||
|
endif
|
||||||
|
|
||||||
# Copy binaries .elf, .bin, .hex, .uf2 to BIN for upload
|
# Copy binaries .elf, .bin, .hex, .uf2 to BIN for upload
|
||||||
# due to large size of combined artifacts, only uf2 is uploaded for now
|
# due to large size of combined artifacts, only uf2 is uploaded for now
|
||||||
|
@ -165,7 +165,7 @@ void HardFault_Handler (void)
|
|||||||
* @param line: assert_param error line source number
|
* @param line: assert_param error line source number
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void assert_failed(uint8_t* file, uint32_t line)
|
void assert_failed(const char* file, uint32_t line)
|
||||||
{
|
{
|
||||||
(void) file; (void) line;
|
(void) file; (void) line;
|
||||||
/* USER CODE BEGIN 6 */
|
/* USER CODE BEGIN 6 */
|
||||||
|
@ -24,7 +24,7 @@ GCC_CFLAGS += \
|
|||||||
-nostdlib -nostartfiles \
|
-nostdlib -nostartfiles \
|
||||||
|
|
||||||
# suppress warning caused by vendor mcu driver
|
# 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 Flags
|
||||||
IAR_CFLAGS += --cpu cortex-m0
|
IAR_CFLAGS += --cpu cortex-m0
|
||||||
@ -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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.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_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 += \
|
INC += \
|
||||||
$(TOP)/$(BOARD_PATH) \
|
$(TOP)/$(BOARD_PATH) \
|
||||||
|
@ -303,9 +303,9 @@
|
|||||||
* If expr is true, it returns no value.
|
* If expr is true, it returns no value.
|
||||||
* @retval None
|
* @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 ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void assert_failed(uint8_t* file, uint32_t line);
|
void assert_failed(const char* file, uint32_t line);
|
||||||
#else
|
#else
|
||||||
#define assert_param(expr) ((void)0U)
|
#define assert_param(expr) ((void)0U)
|
||||||
#endif /* USE_FULL_ASSERT */
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
@ -151,7 +151,7 @@ void HardFault_Handler (void)
|
|||||||
* @param line: assert_param error line source number
|
* @param line: assert_param error line source number
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void assert_failed(char *file, uint32_t line)
|
void assert_failed(const char *file, uint32_t line)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 6 */
|
/* USER CODE BEGIN 6 */
|
||||||
/* User can add his own implementation to report the file name and line number,
|
/* User can add his own implementation to report the file name and line number,
|
||||||
|
@ -362,9 +362,9 @@
|
|||||||
* If expr is true, it returns no value.
|
* If expr is true, it returns no value.
|
||||||
* @retval None
|
* @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 ------------------------------------------------------- */
|
/* Exported functions ------------------------------------------------------- */
|
||||||
void assert_failed(uint8_t* file, uint32_t line);
|
void assert_failed(const char* file, uint32_t line);
|
||||||
#else
|
#else
|
||||||
#define assert_param(expr) ((void)0U)
|
#define assert_param(expr) ((void)0U)
|
||||||
#endif /* USE_FULL_ASSERT */
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
@ -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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.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.c \
|
||||||
|
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_dma.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
|
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -52,6 +52,7 @@ SRC_C += \
|
|||||||
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.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_gpio.c \
|
||||||
|
@ -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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.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.c \
|
||||||
|
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart_ex.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
|
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -37,7 +37,7 @@ GCC_CFLAGS += \
|
|||||||
-nostdlib -nostartfiles
|
-nostdlib -nostartfiles
|
||||||
|
|
||||||
# suppress warning caused by vendor mcu driver
|
# 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 Flags
|
||||||
IAR_CFLAGS += --cpu cortex-m7 --fpu VFPv5_D16
|
IAR_CFLAGS += --cpu cortex-m7 --fpu VFPv5_D16
|
||||||
@ -52,10 +52,13 @@ SRC_C += \
|
|||||||
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.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_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 \
|
||||||
|
$(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_pwr_ex.c
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -39,12 +39,14 @@ SRC_C += \
|
|||||||
$(ST_CMSIS)/Source/Templates/system_stm32$(ST_FAMILY)xx.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_cortex.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.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.c \
|
||||||
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.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_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 += \
|
INC += \
|
||||||
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
|
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
include ../../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
INC += \
|
INC += \
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
DEPS_SUBMODULES += lib/lwip
|
DEPS_SUBMODULES += lib/lwip
|
||||||
|
|
||||||
include ../../../../tools/top.mk
|
|
||||||
include ../../make.mk
|
include ../../make.mk
|
||||||
|
|
||||||
# suppress warning caused by lwip
|
# suppress warning caused by lwip
|
||||||
|
@ -2,6 +2,34 @@
|
|||||||
# Common make definition for all examples
|
# 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 directory
|
||||||
BUILD := _build
|
BUILD := _build
|
||||||
PROJECT := $(notdir $(CURDIR))
|
PROJECT := $(notdir $(CURDIR))
|
||||||
@ -42,8 +70,6 @@ SANITIZER_FLAGS ?= -fsanitize=fuzzer \
|
|||||||
CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS)
|
CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS)
|
||||||
|
|
||||||
#-------------- Source files and compiler flags --------------
|
#-------------- Source files and compiler flags --------------
|
||||||
|
|
||||||
|
|
||||||
INC += $(TOP)/test
|
INC += $(TOP)/test
|
||||||
|
|
||||||
# Compiler Flags
|
# Compiler Flags
|
||||||
|
@ -114,9 +114,14 @@ def build_example(example, board, make_option):
|
|||||||
|
|
||||||
|
|
||||||
def build_size(example, board):
|
def build_size(example, board):
|
||||||
elf_file = 'examples/{}/_build/{}/*.elf'.format(example, board)
|
size_cmd = 'make -j -C examples/{} BOARD={} size'.format(example, board)
|
||||||
size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
|
size_output = subprocess.run(size_cmd, shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8").splitlines()
|
||||||
size_list = size_output.split('\n')[1].split('\t')
|
for i, l in enumerate(size_output):
|
||||||
flash_size = int(size_list[0])
|
text_title = 'text data bss dec'
|
||||||
sram_size = int(size_list[1]) + int(size_list[2])
|
if text_title in l:
|
||||||
return (flash_size, sram_size)
|
size_list = size_output[i+1].split('\t')
|
||||||
|
flash_size = int(size_list[0])
|
||||||
|
sram_size = int(size_list[1]) + int(size_list[2])
|
||||||
|
return (flash_size, sram_size)
|
||||||
|
|
||||||
|
return (0, 0)
|
45
tools/top.mk
45
tools/top.mk
@ -1,45 +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
|
|
||||||
|
|
||||||
#$(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 := $(patsubst %/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 := $(shell realpath $(TOP))
|
|
||||||
endif
|
|
||||||
#$(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`)
|
|
||||||
endif
|
|
||||||
#$(info top.mk: Path from top is $(CURRENT_PATH))
|
|
Loading…
x
Reference in New Issue
Block a user