From d22dea49762df008bfece3a34061375b75cca5e4 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 19 Mar 2019 19:09:08 +0700 Subject: [PATCH 1/4] update nrfx to 1.6.2 --- README.md | 1 + hw/mcu/nordic/nrfx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18267254..f89719b8 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ TinyUSB is an open-source cross-platform USB Host/Device stack for embedded syst - Human Interface Device (HID): Keyboard, Mouse, Generic - Communication Class (CDC) - Mass Storage Class (MSC) +- Musical Instrument Digital Interface (MIDI) ## Host Stack diff --git a/hw/mcu/nordic/nrfx b/hw/mcu/nordic/nrfx index 67710e47..6f54f689 160000 --- a/hw/mcu/nordic/nrfx +++ b/hw/mcu/nordic/nrfx @@ -1 +1 @@ -Subproject commit 67710e47c7313cc56a15748e485079831ee6a3af +Subproject commit 6f54f689e9555ea18f9aca87caf44a3419e5dd7a From e6612ab82c162dea245dbbcdd2da6a744eca3ac2 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 20 Mar 2019 01:23:49 +0700 Subject: [PATCH 2/4] move -nostdlib (-nostartfiles) into board.mk since nrf5x require the use of std startup. Add verbose mode to makefile --- examples/device/cdc_msc_hid/Makefile | 34 ++++++++++++++++++++++------ hw/bsp/metro_m0_express/board.mk | 3 ++- hw/bsp/metro_m4_express/board.mk | 3 ++- hw/bsp/pca10056/board.mk | 9 ++++++-- hw/bsp/stm32f407g_disc1/board.mk | 3 ++- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/examples/device/cdc_msc_hid/Makefile b/examples/device/cdc_msc_hid/Makefile index 0071301f..86587dd4 100644 --- a/examples/device/cdc_msc_hid/Makefile +++ b/examples/device/cdc_msc_hid/Makefile @@ -12,6 +12,13 @@ else endif endif +# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command +ifeq ("$(V)","2") + QUIET = +else + QUIET = @ +endif + # If the build directory is not given, make it reflect the board name. BUILD ?= build-$(BOARD) @@ -49,11 +56,13 @@ CFLAGS += \ -Wno-deprecated-declarations \ -Wnested-externs \ -Wunreachable-code \ - -Wcast-align \ -Wno-error=lto-type-mismatch \ -ffunction-sections \ -fdata-sections +# This causes lots of warning with nrf5x build due to nrfx code +# CFLAGS += -Wcast-align + #Debugging/Optimization ifeq ($(DEBUG), 1) CFLAGS += -O0 -ggdb @@ -61,8 +70,17 @@ else CFLAGS += -flto -Os endif -CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -DBOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_) -LDFLAGS += $(CFLAGS) -nostartfiles -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs +CFLAGS += $(INC) -Wall -Werror -std=gnu11 -DBOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_) +LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs + +ifeq ("$(V)","1") +$(info CFLAGS $(CFLAGS)) +$(info ) +$(info LDFLAGS $(LDFLAGS)) +$(info ) +$(info ASFLAGS $(ASFLAGS)) +$(info ) +endif LIBS = -lgcc -lc -lm -lnosys @@ -91,6 +109,8 @@ SRC_C += $(LIB_SOURCE) # Assembly files can be name with upper case .S, convert it to .s SRC_S := $(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 OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o)) OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o)) @@ -105,7 +125,7 @@ $(OBJ_DIRS): $(BUILD)/$(BOARD)-firmware.elf: $(OBJ) @echo LINK $@ - $(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group + $(QUIET)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group $(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf @echo CREATE $@ @@ -121,7 +141,7 @@ $(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf vpath %.c . $(TOP) $(BUILD)/obj/%.o: %.c @echo CC $(notdir $@) - @$(CC) $(CFLAGS) -c -MD -o $@ $< + $(QUIET)$(CC) $(CFLAGS) -c -MD -o $@ $< @# The following fixes the dependency file. @# See http://make.paulandlesley.org/autodep.html for details. @# Regex adjusted from the above to play better with Windows paths, etc. @@ -134,13 +154,13 @@ $(BUILD)/obj/%.o: %.c vpath %.s . $(TOP) $(BUILD)/obj/%.o: %.s @echo AS $(notdir $@) - @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< + $(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< # ASM sources upper case .S vpath %.S . $(TOP) $(BUILD)/obj/%.o: %.S @echo AS $(notdir $@) - @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< + $(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< # Flash binary using Jlink ifeq ($(OS),Windows_NT) diff --git a/hw/bsp/metro_m0_express/board.mk b/hw/bsp/metro_m0_express/board.mk index 559d50ad..49b3d575 100644 --- a/hw/bsp/metro_m0_express/board.mk +++ b/hw/bsp/metro_m0_express/board.mk @@ -6,7 +6,8 @@ CFLAGS = \ -mabi=aapcs-linux \ -mcpu=cortex-m0plus \ -msoft-float \ - -mfloat-abi=soft + -mfloat-abi=soft \ + -nostdlib # All source paths should be relative to the top level. LD_FILE = hw/bsp/metro_m0_express/samd21g18a_flash.ld diff --git a/hw/bsp/metro_m4_express/board.mk b/hw/bsp/metro_m4_express/board.mk index b0938c7b..6e324c5a 100644 --- a/hw/bsp/metro_m4_express/board.mk +++ b/hw/bsp/metro_m4_express/board.mk @@ -5,7 +5,8 @@ CFLAGS = \ -mabi=aapcs-linux \ -mcpu=cortex-m4 \ -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 + -mfpu=fpv4-sp-d16 \ + -nostdlib # All source paths should be relative to the top level. LD_FILE = hw/bsp/metro_m4_express/samd51g19a_flash.ld diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index 709b0063..402a295b 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -2,8 +2,6 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_NRF5X \ -DNRF52840_XXAA \ -mthumb \ - -Wno-error=undef \ - -Wno-error=cast-align \ -mabi=aapcs \ -mcpu=cortex-m4 \ -mfloat-abi=hard \ @@ -18,6 +16,9 @@ SRC_C += \ hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \ hw/mcu/nordic/nrfx/mdk/system_nrf52840.c \ +# TODO remove later +SRC_C += src/portable/$(VENDOR)/$(CHIP_FAMILY)/hal_$(CHIP_FAMILY).c + INC += \ -I$(TOP)/hw/cmsis/Include \ -I$(TOP)/hw/mcu/nordic \ @@ -38,3 +39,7 @@ ASFLAGS += -DNRF52840_XXAA VENDOR = nordic CHIP_FAMILY = nrf5x +JLINK_DEVICE = nRF52840_xxAA + +# flash using jlink +flash: flash-jlink diff --git a/hw/bsp/stm32f407g_disc1/board.mk b/hw/bsp/stm32f407g_disc1/board.mk index ddf280c6..d09dc5bc 100644 --- a/hw/bsp/stm32f407g_disc1/board.mk +++ b/hw/bsp/stm32f407g_disc1/board.mk @@ -6,7 +6,8 @@ CFLAGS = \ -mabi=aapcs-linux \ -mcpu=cortex-m4 \ -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 + -mfpu=fpv4-sp-d16 \ + -nostdlib # All source paths should be relative to the top level. LD_FILE = hw/bsp/stm32f407g_disc1/STM32F407VGTx_FLASH.ld From 1a0c4fbb9ba37749f8b51b79937a4baf8b5f9176 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 20 Mar 2019 01:23:59 +0700 Subject: [PATCH 3/4] add pca10056 to travis buidl --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6a9fb454..274d0572 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,4 +20,5 @@ script: - make -j2 -C examples/device/cdc_msc_hid BOARD=metro_m0_express - make -j2 -C examples/device/cdc_msc_hid BOARD=metro_m4_express - make -j2 -C examples/device/cdc_msc_hid BOARD=stm32f407g_disc1 + - make -j2 -C examples/device/cdc_msc_hid BOARD=pca10056 From f2f3f5a7723fc10b2dda84d31d1325c30960816b Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 20 Mar 2019 01:35:52 +0700 Subject: [PATCH 4/4] fix pca10056 build error due to nrfx undef usage --- hw/bsp/metro_m0_express/board.mk | 2 +- hw/bsp/metro_m4_express/board.mk | 4 +++- hw/bsp/pca10056/board.mk | 3 +++ hw/bsp/stm32f407g_disc1/board.mk | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/bsp/metro_m0_express/board.mk b/hw/bsp/metro_m0_express/board.mk index 49b3d575..1844eeec 100644 --- a/hw/bsp/metro_m0_express/board.mk +++ b/hw/bsp/metro_m0_express/board.mk @@ -1,4 +1,4 @@ -CFLAGS = \ +CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_SAMD21 \ -DCONF_DFLL_OVERWRITE_CALIBRATION=0 \ -D__SAMD21G18A__ \ diff --git a/hw/bsp/metro_m4_express/board.mk b/hw/bsp/metro_m4_express/board.mk index 6e324c5a..a560c514 100644 --- a/hw/bsp/metro_m4_express/board.mk +++ b/hw/bsp/metro_m4_express/board.mk @@ -1,4 +1,4 @@ -CFLAGS = \ +CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_SAMD51 \ -D__SAMD51J19A__ \ -mthumb \ @@ -8,6 +8,8 @@ CFLAGS = \ -mfpu=fpv4-sp-d16 \ -nostdlib +CFLAGS += -Wno-error=undef + # All source paths should be relative to the top level. LD_FILE = hw/bsp/metro_m4_express/samd51g19a_flash.ld diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index 402a295b..c60bf8be 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -7,6 +7,9 @@ CFLAGS += \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 +# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49 +CFLAGS += -Wno-error=undef + # All source paths should be relative to the top level. LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld diff --git a/hw/bsp/stm32f407g_disc1/board.mk b/hw/bsp/stm32f407g_disc1/board.mk index d09dc5bc..73d64a6b 100644 --- a/hw/bsp/stm32f407g_disc1/board.mk +++ b/hw/bsp/stm32f407g_disc1/board.mk @@ -1,4 +1,4 @@ -CFLAGS = \ +CFLAGS += \ -DHSE_VALUE=8000000 \ -DCFG_TUSB_MCU=OPT_MCU_STM32F4 \ -DSTM32F407xx \