From bcf9718f9a0278fd4c5e6332183ed995e7a527bf Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 15 May 2019 22:51:49 +0700 Subject: [PATCH 1/2] clean up --- src/tusb_option.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/tusb_option.h b/src/tusb_option.h index 0f87ce663..694191406 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -131,33 +131,32 @@ #endif #ifndef CFG_TUSB_MEM_ALIGN -#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) #endif #ifndef CFG_TUSB_OS -#define CFG_TUSB_OS OPT_OS_NONE +#define CFG_TUSB_OS OPT_OS_NONE #endif //-------------------------------------------------------------------- // DEVICE OPTIONS //-------------------------------------------------------------------- -#if TUSB_OPT_DEVICE_ENABLED - #ifndef CFG_TUD_ENDOINT0_SIZE - #define CFG_TUD_ENDOINT0_SIZE 64 - #endif +#ifndef CFG_TUD_ENDOINT0_SIZE + #define CFG_TUD_ENDOINT0_SIZE 64 +#endif - #ifndef CFG_TUD_CTRL_BUFSIZE - #define CFG_TUD_CTRL_BUFSIZE 256 - #endif +#ifndef CFG_TUD_CDC + #define CFG_TUD_CDC 0 +#endif - #ifndef CFG_TUD_CDC - #define CFG_TUD_CDC 0 - #endif +#ifndef CFG_TUD_MSC + #define CFG_TUD_MSC 0 +#endif - #ifndef CFG_TUD_MSC - #define CFG_TUD_MSC 0 - #endif +#ifndef CFG_TUD_HID + #define CFG_TUD_HID 0 +#endif #ifndef CFG_TUD_MIDI #define CFG_TUD_MIDI 0 @@ -167,7 +166,6 @@ #define CFG_TUD_CUSTOM_CLASS 0 #endif -#endif // TUSB_OPT_DEVICE_ENABLED //-------------------------------------------------------------------- // HOST OPTIONS From 6861b670fc0cf3e3c9e7c438c1f0a1410bfc6c8f Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 20 May 2019 12:35:33 +0700 Subject: [PATCH 2/2] add uf2 target for uf2 bootloader board: metro m0/m4 feather nrf52840 --- .gitmodules | 3 ++ examples/make.mk | 1 + examples/rules.mk | 7 ++++ hw/bsp/feather_nrf52840_express/board.mk | 5 ++- .../nrf52840_s140_v6.ld | 38 +++++++++++++++++++ tools/uf2 | 1 + 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld create mode 160000 tools/uf2 diff --git a/.gitmodules b/.gitmodules index 8ee905376..2b3082756 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "hw/mcu/nxp/lpcopen"] path = hw/mcu/nxp/lpcopen url = https://github.com/hathach/lpcopen.git +[submodule "tools/uf2"] + path = tools/uf2 + url = https://github.com/microsoft/uf2.git diff --git a/examples/make.mk b/examples/make.mk index 444b22310..b71c75280 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -12,6 +12,7 @@ MKDIR = mkdir SED = sed CP = cp RM = rm +PYTHON ?= python # Select the board to build for. ifeq ($(BOARD),) diff --git a/examples/rules.mk b/examples/rules.mk index c4b4471de..213d9a5a1 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -43,6 +43,8 @@ endif .DEFAULT_GOAL := all all: $(BUILD)/$(BOARD)-firmware.bin size +uf2: $(BUILD)/$(BOARD)-firmware.uf2 + OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) $(OBJ_DIRS): @@ -60,6 +62,11 @@ $(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf @echo CREATE $@ @$(OBJCOPY) -O ihex $^ $@ +UF2_FAMILY ?= 0x00 +$(BUILD)/$(BOARD)-firmware.uf2: $(BUILD)/$(BOARD)-firmware.hex + @echo CREATE $@ + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY) -c -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. diff --git a/hw/bsp/feather_nrf52840_express/board.mk b/hw/bsp/feather_nrf52840_express/board.mk index 7462cf62b..427e06e2e 100644 --- a/hw/bsp/feather_nrf52840_express/board.mk +++ b/hw/bsp/feather_nrf52840_express/board.mk @@ -12,7 +12,7 @@ CFLAGS += \ CFLAGS += -Wno-error=undef # All source paths should be relative to the top level. -LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld +LD_FILE = hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk @@ -47,5 +47,8 @@ FREERTOS_PORT = ARM_CM4F JLINK_DEVICE = nRF52840_xxAA JLINK_IF = swd +# For uf2 conversion +UF2_FAMILY = 0xADA52840 + # flash using jlink flash: flash-jlink diff --git a/hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld b/hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld new file mode 100644 index 000000000..5314a4e93 --- /dev/null +++ b/hw/bsp/feather_nrf52840_express/nrf52840_s140_v6.ld @@ -0,0 +1,38 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xED000 - 0x26000 + + /* SRAM required by S132 depend on + * - Attribute Table Size + * - Vendor UUID count + * - Max ATT MTU + * - Concurrent connection peripheral + central + secure links + * - Event Len, HVN queue, Write CMD queue + */ + RAM (rwx) : ORIGIN = 0x20003400, LENGTH = 0x20040000 - 0x20003400 +} + +SECTIONS +{ + . = ALIGN(4); + .svc_data : + { + PROVIDE(__start_svc_data = .); + KEEP(*(.svc_data)) + PROVIDE(__stop_svc_data = .); + } > RAM + + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM +} INSERT AFTER .data; + +INCLUDE "nrf52_common.ld" diff --git a/tools/uf2 b/tools/uf2 new file mode 160000 index 000000000..196154077 --- /dev/null +++ b/tools/uf2 @@ -0,0 +1 @@ +Subproject commit 19615407727073e36d81bf239c52108ba92e7660