From 4130c50b011f0156fed77d2b3428e2ade8b80013 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 28 Nov 2020 00:16:28 +0700 Subject: grouping nrf boards --- examples/make.mk | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index 6743044fd..ec536d2cb 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -2,15 +2,6 @@ # Common make definition for all examples # --------------------------------------- -#-------------- Select the board to build for. ------------ -BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))) - -ifeq ($(filter $(BOARD),$(BOARD_LIST)),) - $(info You must provide a BOARD parameter with 'BOARD=', supported boards are:) - $(foreach b,$(BOARD_LIST),$(info - $(b))) - $(error Invalid BOARD specified) -endif - # Handy check parameter function check_defined = \ $(strip $(foreach 1,$1, \ @@ -19,11 +10,28 @@ __check_defined = \ $(if $(value $1),, \ $(error Undefined make flag: $1$(if $2, ($2)))) +#-------------- Select the board to build for. ------------ +#BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))) +#ifeq ($(filter $(BOARD),$(BOARD_LIST)),) +# $(info You must provide a BOARD parameter with 'BOARD=', supported boards are:) +# $(foreach b,$(BOARD_LIST),$(info - $(b))) +# $(error Invalid BOARD specified) +#endif + +BOARD_PATH = $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD))) +ifeq ($(BOARD_PATH),) + $(error Invalid BOARD specified) +endif + +FAMILY = $(word 3, $(subst /, ,$(BOARD_PATH))) +FAMILY_PATH = hw/bsp/$(FAMILY) + # Build directory BUILD = _build/build-$(BOARD) -# Board specific define -include $(TOP)/hw/bsp/$(BOARD)/board.mk +# Include Family and Board specific defs +include $(TOP)/$(FAMILY_PATH)/family.mk +-include $(TOP)/$(BOARD_PATH)/board.mk #-------------- Cross Compiler ------------ # Can be set by board, default to ARM GCC @@ -40,9 +48,10 @@ RM = rm #-------------- Source files and compiler flags -------------- -# Include all source C in board folder +# Include all source C in family & board folder SRC_C += hw/bsp/board.c -SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c)) +SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) +SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c)) # Compiler Flags CFLAGS += \ -- cgit v1.3.1 From 658194ccc4e71f867534c4e2cb99baff2937801c Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 28 Nov 2020 00:45:44 +0700 Subject: group more nrf boards --- examples/make.mk | 2 +- hw/bsp/circuitplayground_bluefruit/board.mk | 62 ------ .../circuitplayground_bluefruit.c | 200 ------------------ .../nrf52840_s140_v6.ld | 38 ---- hw/bsp/itsybitsy_nrf52840/board.mk | 63 ------ hw/bsp/itsybitsy_nrf52840/itsybitsy_nrf52840.c | 225 --------------------- hw/bsp/itsybitsy_nrf52840/nrf52840_s140_v6.ld | 38 ---- hw/bsp/nrf/boards/adafruit_clue/board.h | 11 +- .../boards/circuitplayground_bluefruit/board.mk | 2 + .../nrf52840_s140_v6.ld | 38 ++++ hw/bsp/nrf/boards/feather_nrf52840_express/board.h | 1 + hw/bsp/nrf/boards/feather_nrf52840_sense/board.h | 1 + hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h | 52 +++++ hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk | 2 + .../boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld | 38 ++++ hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h | 52 +++++ hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk | 12 ++ .../nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld | 13 ++ hw/bsp/nrf/family.c | 3 +- hw/bsp/nrf/family.mk | 2 +- hw/bsp/nrf52840_mdk_dongle/board.mk | 61 ------ hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c | 198 ------------------ hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld | 13 -- 23 files changed, 220 insertions(+), 907 deletions(-) delete mode 100644 hw/bsp/circuitplayground_bluefruit/board.mk delete mode 100644 hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c delete mode 100755 hw/bsp/circuitplayground_bluefruit/nrf52840_s140_v6.ld delete mode 100644 hw/bsp/itsybitsy_nrf52840/board.mk delete mode 100644 hw/bsp/itsybitsy_nrf52840/itsybitsy_nrf52840.c delete mode 100644 hw/bsp/itsybitsy_nrf52840/nrf52840_s140_v6.ld create mode 100644 hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk create mode 100755 hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld create mode 100644 hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h create mode 100644 hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk create mode 100644 hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld create mode 100644 hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h create mode 100644 hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk create mode 100644 hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld delete mode 100644 hw/bsp/nrf52840_mdk_dongle/board.mk delete mode 100644 hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c delete mode 100644 hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index ec536d2cb..62a01f2da 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -30,8 +30,8 @@ FAMILY_PATH = hw/bsp/$(FAMILY) BUILD = _build/build-$(BOARD) # Include Family and Board specific defs -include $(TOP)/$(FAMILY_PATH)/family.mk -include $(TOP)/$(BOARD_PATH)/board.mk +include $(TOP)/$(FAMILY_PATH)/family.mk #-------------- Cross Compiler ------------ # Can be set by board, default to ARM GCC diff --git a/hw/bsp/circuitplayground_bluefruit/board.mk b/hw/bsp/circuitplayground_bluefruit/board.mk deleted file mode 100644 index d5f7c7cd4..000000000 --- a/hw/bsp/circuitplayground_bluefruit/board.mk +++ /dev/null @@ -1,62 +0,0 @@ -CFLAGS += \ - -flto \ - -mthumb \ - -mabi=aapcs \ - -mcpu=cortex-m4 \ - -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 \ - -DCFG_TUSB_MCU=OPT_MCU_NRF5X \ - -DNRF52840_XXAA \ - -DCONFIG_GPIO_AS_PINRESET - -# suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align - -# due to tusb_hal_nrf_power_event -GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) -CFLAGS += -Wno-error=cast-function-type -endif - -# All source paths should be relative to the top level. -LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld - -LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk - -SRC_C += \ - hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \ - hw/mcu/nordic/nrfx/mdk/system_nrf52840.c \ - -INC += \ - $(TOP)/lib/CMSIS_4/CMSIS/Include \ - $(TOP)/hw/mcu/nordic \ - $(TOP)/hw/mcu/nordic/nrfx \ - $(TOP)/hw/mcu/nordic/nrfx/mdk \ - $(TOP)/hw/mcu/nordic/nrfx/hal \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/include \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/src \ - -SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52840.S - -ASFLAGS += -D__HEAP_SIZE=0 - -# For TinyUSB port source -VENDOR = nordic -CHIP_FAMILY = nrf5x - -# For freeRTOS port source -FREERTOS_PORT = ARM_CM4F - -# For flash-jlink target -JLINK_DEVICE = nRF52840_xxAA - -# For uf2 conversion -UF2_FAMILY = 0xADA52840 - -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex - adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ - -# flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip - @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) - adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c b/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c deleted file mode 100644 index 9638b3cc8..000000000 --- a/hw/bsp/circuitplayground_bluefruit/circuitplayground_bluefruit.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "bsp/board.h" - -#include "nrfx.h" -#include "nrfx/hal/nrf_gpio.h" -#include "nrfx/drivers/include/nrfx_power.h" - -#ifdef SOFTDEVICE_PRESENT -#include "nrf_sdm.h" -#include "nrf_soc.h" -#endif - -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USBD_IRQHandler(void) -{ - tud_int_handler(0); -} - -/*------------------------------------------------------------------*/ -/* MACRO TYPEDEF CONSTANT ENUM - *------------------------------------------------------------------*/ -#define _PINNUM(port, pin) ((port)*32 + (pin)) - -#define LED_PIN _PINNUM(1, 14) -#define LED_STATE_ON 1 - -#define BUTTON_PIN _PINNUM(1, 15) - -// tinyusb function that handles power event (detected, ready, removed) -// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. -extern void tusb_hal_nrf_power_event(uint32_t event); - -void board_init(void) -{ - // Config clock source: XTAL or RC in sdk_config.h - NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); - NRF_CLOCK->TASKS_LFCLKSTART = 1UL; - - // LED - nrf_gpio_cfg_output(LED_PIN); - board_led_write(false); - - // Button - nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLDOWN); - -#if CFG_TUSB_OS == OPT_OS_NONE - // 1ms tick timer - SysTick_Config(SystemCoreClock/1000); -#endif - -#if TUSB_OPT_DEVICE_ENABLED - // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice - // 2 is highest for application - NVIC_SetPriority(USBD_IRQn, 2); - - - // USB power may already be ready at this time -> no event generated - // We need to invoke the handler based on the status initially - uint32_t usb_reg; - -#ifdef SOFTDEVICE_PRESENT - uint8_t sd_en = false; - sd_softdevice_is_enabled(&sd_en); - - if ( sd_en ) { - sd_power_usbdetected_enable(true); - sd_power_usbpwrrdy_enable(true); - sd_power_usbremoved_enable(true); - - sd_power_usbregstatus_get(&usb_reg); - }else -#endif - { - // Power module init - const nrfx_power_config_t pwr_cfg = { 0 }; - nrfx_power_init(&pwr_cfg); - - // Register tusb function as USB power handler - const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event }; - nrfx_power_usbevt_init(&config); - - nrfx_power_usbevt_enable(); - - usb_reg = NRF_POWER->USBREGSTATUS; - } - - if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED); - if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY); -#endif -} - -//--------------------------------------------------------------------+ -// Board porting API -//--------------------------------------------------------------------+ - -void board_led_write(bool state) -{ - nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON)); -} - -uint32_t board_button_read(void) -{ - // button is active HIGH - return nrf_gpio_pin_read(BUTTON_PIN); -} - -int board_uart_read(uint8_t* buf, int len) -{ - (void) buf; (void) len; - return 0; -} - -int board_uart_write(void const * buf, int len) -{ - (void) buf; (void) len; - return 0; -} - -#if CFG_TUSB_OS == OPT_OS_NONE -volatile uint32_t system_ticks = 0; -void SysTick_Handler (void) -{ - system_ticks++; -} - -uint32_t board_millis(void) -{ - return system_ticks; -} -#endif - -#ifdef SOFTDEVICE_PRESENT -// process SOC event from SD -uint32_t proc_soc(void) -{ - uint32_t soc_evt; - uint32_t err = sd_evt_get(&soc_evt); - - if (NRF_SUCCESS == err) - { - /*------------- usb power event handler -------------*/ - int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED: - (soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY : - (soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1; - - if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt); - } - - return err; -} - -uint32_t proc_ble(void) -{ - // do nothing with ble - return NRF_ERROR_NOT_FOUND; -} - -void SD_EVT_IRQHandler(void) -{ - // process BLE and SOC until there is no more events - while( (NRF_ERROR_NOT_FOUND != proc_ble()) || (NRF_ERROR_NOT_FOUND != proc_soc()) ) - { - - } -} - -void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) -{ - (void) id; - (void) pc; - (void) info; -} -#endif diff --git a/hw/bsp/circuitplayground_bluefruit/nrf52840_s140_v6.ld b/hw/bsp/circuitplayground_bluefruit/nrf52840_s140_v6.ld deleted file mode 100755 index 5314a4e93..000000000 --- a/hw/bsp/circuitplayground_bluefruit/nrf52840_s140_v6.ld +++ /dev/null @@ -1,38 +0,0 @@ -/* 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/hw/bsp/itsybitsy_nrf52840/board.mk b/hw/bsp/itsybitsy_nrf52840/board.mk deleted file mode 100644 index 6cc972835..000000000 --- a/hw/bsp/itsybitsy_nrf52840/board.mk +++ /dev/null @@ -1,63 +0,0 @@ -CFLAGS += \ - -flto \ - -mthumb \ - -mabi=aapcs \ - -mcpu=cortex-m4 \ - -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 \ - -DCFG_TUSB_MCU=OPT_MCU_NRF5X \ - -DNRF52840_XXAA \ - -DCONFIG_GPIO_AS_PINRESET - -# suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align - -# due to tusb_hal_nrf_power_event -GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) -CFLAGS += -Wno-error=cast-function-type -endif - -# All source paths should be relative to the top level. -LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld - -LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk - -SRC_C += \ - hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \ - hw/mcu/nordic/nrfx/drivers/src/nrfx_uarte.c \ - hw/mcu/nordic/nrfx/mdk/system_nrf52840.c - -INC += \ - $(TOP)/lib/CMSIS_4/CMSIS/Include \ - $(TOP)/hw/mcu/nordic \ - $(TOP)/hw/mcu/nordic/nrfx \ - $(TOP)/hw/mcu/nordic/nrfx/mdk \ - $(TOP)/hw/mcu/nordic/nrfx/hal \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/include \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/src \ - -SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52840.S - -ASFLAGS += -D__HEAP_SIZE=0 - -# For TinyUSB port source -VENDOR = nordic -CHIP_FAMILY = nrf5x - -# For freeRTOS port source -FREERTOS_PORT = ARM_CM4F - -# For flash-jlink target -JLINK_DEVICE = nRF52840_xxAA - -# For uf2 conversion -UF2_FAMILY = 0xADA52840 - -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex - adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ - -# flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip - @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) - adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/itsybitsy_nrf52840/itsybitsy_nrf52840.c b/hw/bsp/itsybitsy_nrf52840/itsybitsy_nrf52840.c deleted file mode 100644 index e9e5a3876..000000000 --- a/hw/bsp/itsybitsy_nrf52840/itsybitsy_nrf52840.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "bsp/board.h" - -#include "nrfx.h" -#include "nrfx/hal/nrf_gpio.h" -#include "nrfx/drivers/include/nrfx_power.h" -#include "nrfx/drivers/include/nrfx_uarte.h" - -#ifdef SOFTDEVICE_PRESENT -#include "nrf_sdm.h" -#include "nrf_soc.h" -#endif - -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USBD_IRQHandler(void) -{ - tud_int_handler(0); -} - -/*------------------------------------------------------------------*/ -/* MACRO TYPEDEF CONSTANT ENUM - *------------------------------------------------------------------*/ -#define _PINNUM(port, pin) ((port)*32 + (pin)) - -#define LED_PIN _PINNUM(0, 6) -#define LED_STATE_ON 1 - -#define BUTTON_PIN _PINNUM(0, 29) - -#define UART_RX_PIN 25 -#define UART_TX_PIN 24 - -static nrfx_uarte_t _uart_id = NRFX_UARTE_INSTANCE(0); - -// tinyusb function that handles power event (detected, ready, removed) -// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. -extern void tusb_hal_nrf_power_event(uint32_t event); - -void board_init(void) -{ - // stop LF clock just in case we jump from application without reset - NRF_CLOCK->TASKS_LFCLKSTOP = 1UL; - - // Config clock source: XTAL or RC in sdk_config.h - NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); - NRF_CLOCK->TASKS_LFCLKSTART = 1UL; - - // LED - nrf_gpio_cfg_output(LED_PIN); - board_led_write(false); - - // Button - nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP); - - // 1ms tick timer - SysTick_Config(SystemCoreClock/1000); - - // UART - nrfx_uarte_config_t uart_cfg = - { - .pseltxd = UART_TX_PIN, - .pselrxd = UART_RX_PIN, - .pselcts = NRF_UARTE_PSEL_DISCONNECTED, - .pselrts = NRF_UARTE_PSEL_DISCONNECTED, - .p_context = NULL, - .baudrate = NRF_UARTE_BAUDRATE_115200, // CFG_BOARD_UART_BAUDRATE - .interrupt_priority = 7, - .hal_cfg = { - .hwfc = NRF_UARTE_HWFC_DISABLED, - .parity = NRF_UARTE_PARITY_EXCLUDED, - } - }; - - nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler); - - //------------- USB -------------// -#if TUSB_OPT_DEVICE_ENABLED - // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice - // 2 is highest for application - NVIC_SetPriority(USBD_IRQn, 2); - - // USB power may already be ready at this time -> no event generated - // We need to invoke the handler based on the status initially - uint32_t usb_reg; - -#ifdef SOFTDEVICE_PRESENT - uint8_t sd_en = false; - sd_softdevice_is_enabled(&sd_en); - - if ( sd_en ) { - sd_power_usbdetected_enable(true); - sd_power_usbpwrrdy_enable(true); - sd_power_usbremoved_enable(true); - - sd_power_usbregstatus_get(&usb_reg); - }else -#endif - { - // Power module init - const nrfx_power_config_t pwr_cfg = { 0 }; - nrfx_power_init(&pwr_cfg); - - // Register tusb function as USB power handler - const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event }; - nrfx_power_usbevt_init(&config); - - nrfx_power_usbevt_enable(); - - usb_reg = NRF_POWER->USBREGSTATUS; - } - - if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED); - if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY); -#endif -} - -//--------------------------------------------------------------------+ -// Board porting API -//--------------------------------------------------------------------+ - -void board_led_write(bool state) -{ - nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON)); -} - -uint32_t board_button_read(void) -{ - // button is active LOW - return (nrf_gpio_pin_read(BUTTON_PIN) ? 0 : 1); -} - -int board_uart_read(uint8_t* buf, int len) -{ - (void) buf; (void) len; - return 0; -// return NRFX_SUCCESS == nrfx_uart_rx(&_uart_id, buf, (size_t) len) ? len : 0; -} - -int board_uart_write(void const * buf, int len) -{ - return (NRFX_SUCCESS == nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len)) ? len : 0; -} - -#if CFG_TUSB_OS == OPT_OS_NONE -volatile uint32_t system_ticks = 0; -void SysTick_Handler (void) -{ - system_ticks++; -} - -uint32_t board_millis(void) -{ - return system_ticks; -} -#endif - -#ifdef SOFTDEVICE_PRESENT -// process SOC event from SD -uint32_t proc_soc(void) -{ - uint32_t soc_evt; - uint32_t err = sd_evt_get(&soc_evt); - - if (NRF_SUCCESS == err) - { - /*------------- usb power event handler -------------*/ - int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED: - (soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY : - (soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1; - - if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt); - } - - return err; -} - -uint32_t proc_ble(void) -{ - // do nothing with ble - return NRF_ERROR_NOT_FOUND; -} - -void SD_EVT_IRQHandler(void) -{ - // process BLE and SOC until there is no more events - while( (NRF_ERROR_NOT_FOUND != proc_ble()) || (NRF_ERROR_NOT_FOUND != proc_soc()) ) - { - - } -} - -void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) -{ - (void) id; - (void) pc; - (void) info; -} -#endif diff --git a/hw/bsp/itsybitsy_nrf52840/nrf52840_s140_v6.ld b/hw/bsp/itsybitsy_nrf52840/nrf52840_s140_v6.ld deleted file mode 100644 index 5314a4e93..000000000 --- a/hw/bsp/itsybitsy_nrf52840/nrf52840_s140_v6.ld +++ /dev/null @@ -1,38 +0,0 @@ -/* 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/hw/bsp/nrf/boards/adafruit_clue/board.h b/hw/bsp/nrf/boards/adafruit_clue/board.h index 2bd8d37e2..2c58e8fe8 100644 --- a/hw/bsp/nrf/boards/adafruit_clue/board.h +++ b/hw/bsp/nrf/boards/adafruit_clue/board.h @@ -34,15 +34,16 @@ #define _PINNUM(port, pin) ((port)*32 + (pin)) // LED -#define LED_PIN _PINNUM(1, 1) -#define LED_STATE_ON 1 +#define LED_PIN _PINNUM(1, 1) +#define LED_STATE_ON 1 // Button -#define BUTTON_PIN _PINNUM(1, 02) +#define BUTTON_PIN _PINNUM(1, 02) +#define BUTTON_STATE_ACTIVE 0 // UART -#define UART_RX_PIN 4 -#define UART_TX_PIN 5 +#define UART_RX_PIN 4 +#define UART_TX_PIN 5 #ifdef __cplusplus } diff --git a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk new file mode 100644 index 000000000..3b1c20f5f --- /dev/null +++ b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk @@ -0,0 +1,2 @@ +# flash using adafruit-nrfutil dfu +flash: flash-adafruit-nrfutil diff --git a/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld b/hw/bsp/nrf/boards/circuitplayground_bluefruit/nrf52840_s140_v6.ld new file mode 100755 index 000000000..5314a4e93 --- /dev/null +++ b/hw/bsp/nrf/boards/circuitplayground_bluefruit/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/hw/bsp/nrf/boards/feather_nrf52840_express/board.h b/hw/bsp/nrf/boards/feather_nrf52840_express/board.h index 64cfcbc3c..3208a948a 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_express/board.h +++ b/hw/bsp/nrf/boards/feather_nrf52840_express/board.h @@ -39,6 +39,7 @@ // Button #define BUTTON_PIN _PINNUM(1, 02) +#define BUTTON_STATE_ACTIVE 0 // UART #define UART_RX_PIN 24 diff --git a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h index 91b2c5127..ece6e34cb 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h +++ b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.h @@ -39,6 +39,7 @@ // Button #define BUTTON_PIN _PINNUM(1, 02) +#define BUTTON_STATE_ACTIVE 0 // UART #define UART_RX_PIN 24 diff --git a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h new file mode 100644 index 000000000..132173a80 --- /dev/null +++ b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.h @@ -0,0 +1,52 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef BOARD_H_ +#define BOARD_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define _PINNUM(port, pin) ((port)*32 + (pin)) + +// LED +#define LED_PIN _PINNUM(0, 6) +#define LED_STATE_ON 1 + +// Button +#define BUTTON_PIN _PINNUM(0, 29) +#define BUTTON_STATE_ACTIVE 0 + +// UART +#define UART_RX_PIN 25 +#define UART_TX_PIN 24 + +#ifdef __cplusplus + } +#endif + +#endif /* BOARD_H_ */ diff --git a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk new file mode 100644 index 000000000..3b1c20f5f --- /dev/null +++ b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk @@ -0,0 +1,2 @@ +# flash using adafruit-nrfutil dfu +flash: flash-adafruit-nrfutil diff --git a/hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld b/hw/bsp/nrf/boards/itsybitsy_nrf52840/nrf52840_s140_v6.ld new file mode 100644 index 000000000..5314a4e93 --- /dev/null +++ b/hw/bsp/nrf/boards/itsybitsy_nrf52840/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/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h new file mode 100644 index 000000000..01dd1f24f --- /dev/null +++ b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.h @@ -0,0 +1,52 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef BOARD_H_ +#define BOARD_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define _PINNUM(port, pin) ((port)*32 + (pin)) + +// LED +#define LED_PIN _PINNUM(0, 23) +#define LED_STATE_ON 0 + +// Button +#define BUTTON_PIN _PINNUM(0, 18) +#define BUTTON_STATE_ACTIVE 0 + +// UART +#define UART_RX_PIN 2 +#define UART_TX_PIN 3 + +#ifdef __cplusplus + } +#endif + +#endif /* BOARD_H_ */ diff --git a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk new file mode 100644 index 000000000..cf79dd884 --- /dev/null +++ b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk @@ -0,0 +1,12 @@ +LD_FILE ?= hw/bsp/nrf/boards/$(BOARD)/$(BOARD).ld + +# flash using Nordic nrfutil (pip3 install nrfutil) +# make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash +NRFUTIL = nrfutil + +$(BUILD)/$(BOARD)-firmware-nrfutil.zip: $(BUILD)/$(BOARD)-firmware.hex + $(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@ + +flash: $(BUILD)/$(BOARD)-firmware-nrfutil.zip + @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) + $(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200 \ No newline at end of file diff --git a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld new file mode 100644 index 000000000..78eddc9c3 --- /dev/null +++ b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld @@ -0,0 +1,13 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xE0000-0x1000 + RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8 +} + + +INCLUDE "nrf_common.ld" diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c index 076a21b1c..bd16eedc6 100644 --- a/hw/bsp/nrf/family.c +++ b/hw/bsp/nrf/family.c @@ -145,8 +145,7 @@ void board_led_write(bool state) uint32_t board_button_read(void) { - // button is active LOW - return (nrf_gpio_pin_read(BUTTON_PIN) ? 0 : 1); + return BUTTON_STATE_ACTIVE == nrf_gpio_pin_read(BUTTON_PIN); } int board_uart_read(uint8_t* buf, int len) diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk index a8d06afec..edd764487 100644 --- a/hw/bsp/nrf/family.mk +++ b/hw/bsp/nrf/family.mk @@ -19,7 +19,7 @@ CFLAGS += -Wno-error=cast-function-type endif # All source paths should be relative to the top level. -LD_FILE = hw/bsp/nrf/boards/$(BOARD)/nrf52840_s140_v6.ld +LD_FILE ?= hw/bsp/nrf/boards/$(BOARD)/nrf52840_s140_v6.ld LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk diff --git a/hw/bsp/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf52840_mdk_dongle/board.mk deleted file mode 100644 index 8ce8929b8..000000000 --- a/hw/bsp/nrf52840_mdk_dongle/board.mk +++ /dev/null @@ -1,61 +0,0 @@ -CFLAGS += \ - -flto \ - -mthumb \ - -mabi=aapcs \ - -mcpu=cortex-m4 \ - -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 \ - -DNRF52840_XXAA \ - -DCFG_TUSB_MCU=OPT_MCU_NRF5X - -# suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align - -# due to tusb_hal_nrf_power_event -GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) -CFLAGS += -Wno-error=cast-function-type -endif - -# All source paths should be relative to the top level. -LD_FILE = hw/bsp/$(BOARD)/$(BOARD).ld - -LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk - -SRC_C += \ - hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \ - hw/mcu/nordic/nrfx/mdk/system_nrf52840.c \ - -INC += \ - $(TOP)/lib/CMSIS_4/CMSIS/Include \ - $(TOP)/hw/mcu/nordic \ - $(TOP)/hw/mcu/nordic/nrfx \ - $(TOP)/hw/mcu/nordic/nrfx/mdk \ - $(TOP)/hw/mcu/nordic/nrfx/hal \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/include \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/src \ - -SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52840.S - -ASFLAGS += -D__HEAP_SIZE=0 - -# For TinyUSB port source -VENDOR = nordic -CHIP_FAMILY = nrf5x - -# For freeRTOS port source -FREERTOS_PORT = ARM_CM4F - -# For flash-jlink target -JLINK_DEVICE = nRF52840_xxAA - -# flash using Nordic nrfutil (pip2 install nrfutil) -# make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash -NRFUTIL = nrfutil - -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex - $(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@ - -flash: $(BUILD)/$(BOARD)-firmware.zip - @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) - $(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200 diff --git a/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c b/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c deleted file mode 100644 index 870a290dd..000000000 --- a/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "bsp/board.h" - -#include "nrfx.h" -#include "nrfx/hal/nrf_gpio.h" -#include "nrfx/drivers/include/nrfx_power.h" - -#ifdef SOFTDEVICE_PRESENT -#include "nrf_sdm.h" -#include "nrf_soc.h" -#endif - -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USBD_IRQHandler(void) -{ - tud_int_handler(0); -} - -/*------------------------------------------------------------------*/ -/* MACRO TYPEDEF CONSTANT ENUM - *------------------------------------------------------------------*/ -#define LED_PIN 23 -#define LED_STATE_ON 0 - -// Button 1 -#define BUTTON_PIN 18 -#define BUTTON_STATE_ACTIVE 0 - -// tinyusb function that handles power event (detected, ready, removed) -// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. -extern void tusb_hal_nrf_power_event(uint32_t event); - -void board_init(void) -{ - // Config clock source: XTAL or RC in sdk_config.h - NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); - NRF_CLOCK->TASKS_LFCLKSTART = 1UL; - - // LED - nrf_gpio_cfg_output(LED_PIN); - board_led_write(false); - - // Button - nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP); - -#if CFG_TUSB_OS == OPT_OS_NONE - // 1ms tick timer - SysTick_Config(SystemCoreClock/1000); -#endif - -#if TUSB_OPT_DEVICE_ENABLED - // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice - // 2 is highest for application - NVIC_SetPriority(USBD_IRQn, 2); - - // USB power may already be ready at this time -> no event generated - // We need to invoke the handler based on the status initially - uint32_t usb_reg; - -#ifdef SOFTDEVICE_PRESENT - uint8_t sd_en = false; - sd_softdevice_is_enabled(&sd_en); - - if ( sd_en ) { - sd_power_usbdetected_enable(true); - sd_power_usbpwrrdy_enable(true); - sd_power_usbremoved_enable(true); - - sd_power_usbregstatus_get(&usb_reg); - }else -#endif - { - // Power module init - const nrfx_power_config_t pwr_cfg = { 0 }; - nrfx_power_init(&pwr_cfg); - - // Register tusb function as USB power handler - const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event }; - nrfx_power_usbevt_init(&config); - - nrfx_power_usbevt_enable(); - - usb_reg = NRF_POWER->USBREGSTATUS; - } - - if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED); - if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY); -#endif -} - -//--------------------------------------------------------------------+ -// Board porting API -//--------------------------------------------------------------------+ - -void board_led_write(bool state) -{ - nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON)); -} - -uint32_t board_button_read(void) -{ - return BUTTON_STATE_ACTIVE == nrf_gpio_pin_read(BUTTON_PIN); -} - -int board_uart_read(uint8_t* buf, int len) -{ - (void) buf; (void) len; - return 0; -} - -int board_uart_write(void const * buf, int len) -{ - (void) buf; (void) len; - return 0; -} - -#if CFG_TUSB_OS == OPT_OS_NONE -volatile uint32_t system_ticks = 0; -void SysTick_Handler (void) -{ - system_ticks++; -} - -uint32_t board_millis(void) -{ - return system_ticks; -} -#endif - -#ifdef SOFTDEVICE_PRESENT -// process SOC event from SD -uint32_t proc_soc(void) -{ - uint32_t soc_evt; - uint32_t err = sd_evt_get(&soc_evt); - - if (NRF_SUCCESS == err) - { - /*------------- usb power event handler -------------*/ - int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED: - (soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY : - (soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1; - - if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt); - } - - return err; -} - -uint32_t proc_ble(void) -{ - // do nothing with ble - return NRF_ERROR_NOT_FOUND; -} - -void SD_EVT_IRQHandler(void) -{ - // process BLE and SOC until there is no more events - while( (NRF_ERROR_NOT_FOUND != proc_ble()) || (NRF_ERROR_NOT_FOUND != proc_soc()) ) - { - - } -} - -void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) -{ - (void) id; - (void) pc; - (void) info; -} -#endif diff --git a/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld b/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld deleted file mode 100644 index 78eddc9c3..000000000 --- a/hw/bsp/nrf52840_mdk_dongle/nrf52840_mdk_dongle.ld +++ /dev/null @@ -1,13 +0,0 @@ -/* Linker script to configure memory regions. */ - -SEARCH_DIR(.) -GROUP(-lgcc -lc -lnosys) - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xE0000-0x1000 - RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x3fff8 -} - - -INCLUDE "nrf_common.ld" -- cgit v1.3.1 From 630692d81b8cfdb459a28dad632cbe13ad031492 Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 28 Nov 2020 10:48:44 +0700 Subject: move all nrf boards into its family group --- examples/make.mk | 1 - hw/bsp/nrf/boards/adafruit_clue/board.mk | 5 +- .../boards/circuitplayground_bluefruit/board.mk | 5 +- .../nrf/boards/feather_nrf52840_express/board.mk | 5 +- hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk | 5 +- hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk | 5 +- hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk | 5 +- hw/bsp/nrf/boards/pca10056/board.mk | 3 + hw/bsp/nrf/boards/pca10059/board.mk | 3 + hw/bsp/nrf/boards/pca10100/board.mk | 7 + hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk | 3 + hw/bsp/nrf/family.c | 7 +- hw/bsp/nrf/family.mk | 9 +- hw/bsp/pca10100/board.mk | 55 ----- hw/bsp/pca10100/pca10100.c | 229 --------------------- 15 files changed, 49 insertions(+), 298 deletions(-) create mode 100644 hw/bsp/nrf/boards/pca10100/board.mk delete mode 100644 hw/bsp/pca10100/board.mk delete mode 100644 hw/bsp/pca10100/pca10100.c (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index 62a01f2da..d19dd7f09 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -30,7 +30,6 @@ FAMILY_PATH = hw/bsp/$(FAMILY) BUILD = _build/build-$(BOARD) # Include Family and Board specific defs --include $(TOP)/$(BOARD_PATH)/board.mk include $(TOP)/$(FAMILY_PATH)/family.mk #-------------- Cross Compiler ------------ diff --git a/hw/bsp/nrf/boards/adafruit_clue/board.mk b/hw/bsp/nrf/boards/adafruit_clue/board.mk index 40278bc65..d8530dc74 100644 --- a/hw/bsp/nrf/boards/adafruit_clue/board.mk +++ b/hw/bsp/nrf/boards/adafruit_clue/board.mk @@ -1,7 +1,10 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + $(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash-adafruit-nrfutil: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(BOARD)-firmware.zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk index 40278bc65..d8530dc74 100644 --- a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk @@ -1,7 +1,10 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + $(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash-adafruit-nrfutil: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(BOARD)-firmware.zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk b/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk index 40278bc65..d8530dc74 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk +++ b/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk @@ -1,7 +1,10 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + $(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash-adafruit-nrfutil: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(BOARD)-firmware.zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk index 40278bc65..d8530dc74 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk +++ b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk @@ -1,7 +1,10 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + $(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash-adafruit-nrfutil: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(BOARD)-firmware.zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk index 40278bc65..d8530dc74 100644 --- a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk +++ b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk @@ -1,7 +1,10 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + $(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash-adafruit-nrfutil: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(BOARD)-firmware.zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk index d9312ed05..a184fa892 100644 --- a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk +++ b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk @@ -1,4 +1,7 @@ -LD_FILE ?= $(BOARD_PATH)/$(BOARD).ld +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + +LD_FILE = $(BOARD_PATH)/$(BOARD).ld # flash using Nordic nrfutil (pip3 install nrfutil) # make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash diff --git a/hw/bsp/nrf/boards/pca10056/board.mk b/hw/bsp/nrf/boards/pca10056/board.mk index b1d02591b..be2ed3314 100644 --- a/hw/bsp/nrf/boards/pca10056/board.mk +++ b/hw/bsp/nrf/boards/pca10056/board.mk @@ -1,3 +1,6 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld # flash using jlink diff --git a/hw/bsp/nrf/boards/pca10059/board.mk b/hw/bsp/nrf/boards/pca10059/board.mk index 9f0171066..25609f2fa 100644 --- a/hw/bsp/nrf/boards/pca10059/board.mk +++ b/hw/bsp/nrf/boards/pca10059/board.mk @@ -1,3 +1,6 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + LD_FILE = $(BOARD_PATH)/$(BOARD).ld # flash using Nordic nrfutil (pip2 install nrfutil) diff --git a/hw/bsp/nrf/boards/pca10100/board.mk b/hw/bsp/nrf/boards/pca10100/board.mk new file mode 100644 index 000000000..5fba269b7 --- /dev/null +++ b/hw/bsp/nrf/boards/pca10100/board.mk @@ -0,0 +1,7 @@ +MCU_VARIANT = nrf52833 +CFLAGS += -DNRF52833_XXAA + +LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52833_xxaa.ld + +# flash using jlink +flash: flash-jlink diff --git a/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk b/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk index b1d02591b..be2ed3314 100644 --- a/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk +++ b/hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.mk @@ -1,3 +1,6 @@ +MCU_VARIANT = nrf52840 +CFLAGS += -DNRF52840_XXAA + LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld # flash using jlink diff --git a/hw/bsp/nrf/family.c b/hw/bsp/nrf/family.c index bd16eedc6..48f560a6f 100644 --- a/hw/bsp/nrf/family.c +++ b/hw/bsp/nrf/family.c @@ -61,8 +61,8 @@ void board_init(void) // stop LF clock just in case we jump from application without reset NRF_CLOCK->TASKS_LFCLKSTOP = 1UL; - // Config clock source: XTAL or RC in sdk_config.h - NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); + // Use Internal OSC to compatible with all boards + NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC; NRF_CLOCK->TASKS_LFCLKSTART = 1UL; // LED @@ -121,7 +121,8 @@ void board_init(void) nrfx_power_init(&pwr_cfg); // Register tusb function as USB power handler - const nrfx_power_usbevt_config_t config = { .handler = (nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event }; + // cause cast-function-type warning + const nrfx_power_usbevt_config_t config = { .handler = ((nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event) }; nrfx_power_usbevt_init(&config); nrfx_power_usbevt_enable(); diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk index f07e1157d..479b24d95 100644 --- a/hw/bsp/nrf/family.mk +++ b/hw/bsp/nrf/family.mk @@ -1,3 +1,5 @@ +include $(TOP)/$(BOARD_PATH)/board.mk + CFLAGS += \ -flto \ -mthumb \ @@ -6,7 +8,6 @@ CFLAGS += \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 \ -DCFG_TUSB_MCU=OPT_MCU_NRF5X \ - -DNRF52840_XXAA \ -DCONFIG_GPIO_AS_PINRESET # suppress warning caused by vendor mcu driver @@ -26,7 +27,7 @@ LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk SRC_C += \ hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \ hw/mcu/nordic/nrfx/drivers/src/nrfx_uarte.c \ - hw/mcu/nordic/nrfx/mdk/system_nrf52840.c + hw/mcu/nordic/nrfx/mdk/system_$(MCU_VARIANT).c INC += \ $(TOP)/$(BOARD_PATH) \ @@ -38,7 +39,7 @@ INC += \ $(TOP)/hw/mcu/nordic/nrfx/drivers/include \ $(TOP)/hw/mcu/nordic/nrfx/drivers/src \ -SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52840.S +SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_$(MCU_VARIANT).S ASFLAGS += -D__HEAP_SIZE=0 @@ -50,7 +51,7 @@ CHIP_FAMILY = nrf5x FREERTOS_PORT = ARM_CM4F # For flash-jlink target -JLINK_DEVICE = nRF52840_xxAA +JLINK_DEVICE = $(MCU_VARIANT)_xxaa # For uf2 conversion UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/pca10100/board.mk b/hw/bsp/pca10100/board.mk deleted file mode 100644 index 4b5be082e..000000000 --- a/hw/bsp/pca10100/board.mk +++ /dev/null @@ -1,55 +0,0 @@ -CFLAGS += \ - -flto \ - -mthumb \ - -mabi=aapcs \ - -mcpu=cortex-m4 \ - -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 \ - -DNRF52833_XXAA \ - -DCONFIG_GPIO_AS_PINRESET \ - -DCFG_TUSB_MCU=OPT_MCU_NRF5X - -# suppress warning caused by vendor mcu driver -CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align - -# due to tusb_hal_nrf_power_event -GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) -CFLAGS += -Wno-error=cast-function-type -endif - -# All source paths should be relative to the top level. -LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52833_xxaa.ld - -LDFLAGS += -L$(TOP)/hw/mcu/nordic/nrfx/mdk - -SRC_C += \ - hw/mcu/nordic/nrfx/drivers/src/nrfx_power.c \ - hw/mcu/nordic/nrfx/drivers/src/nrfx_uarte.c \ - hw/mcu/nordic/nrfx/mdk/system_nrf52833.c \ - -INC += \ - $(TOP)/lib/CMSIS_4/CMSIS/Include \ - $(TOP)/hw/mcu/nordic \ - $(TOP)/hw/mcu/nordic/nrfx \ - $(TOP)/hw/mcu/nordic/nrfx/mdk \ - $(TOP)/hw/mcu/nordic/nrfx/hal \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/include \ - $(TOP)/hw/mcu/nordic/nrfx/drivers/src \ - -SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52833.S - -ASFLAGS += -D__HEAP_SIZE=0 - -# For TinyUSB port source -VENDOR = nordic -CHIP_FAMILY = nrf5x - -# For freeRTOS port source -FREERTOS_PORT = ARM_CM4F - -# For flash-jlink target -JLINK_DEVICE = nRF52833_XXAA - -# flash using jlink -flash: flash-jlink diff --git a/hw/bsp/pca10100/pca10100.c b/hw/bsp/pca10100/pca10100.c deleted file mode 100644 index 30df50124..000000000 --- a/hw/bsp/pca10100/pca10100.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "bsp/board.h" - -#include "nrfx.h" -#include "nrfx/hal/nrf_gpio.h" -#include "nrfx/drivers/include/nrfx_power.h" -#include "nrfx/drivers/include/nrfx_uarte.h" - -#ifdef SOFTDEVICE_PRESENT -#include "nrf_sdm.h" -#include "nrf_soc.h" -#endif - -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USBD_IRQHandler(void) -{ - tud_int_handler(0); -} - -/*------------------------------------------------------------------*/ -/* MACRO TYPEDEF CONSTANT ENUM - *------------------------------------------------------------------*/ -#define LED_PIN 13 -#define LED_STATE_ON 0 - -#define BUTTON_PIN 11 -#define BUTTON_STATE_ACTIVE 0 - -#define UART_RX_PIN 8 -#define UART_TX_PIN 6 - -static nrfx_uarte_t _uart_id = NRFX_UARTE_INSTANCE(0); -//static void uart_handler(nrfx_uart_event_t const * p_event, void* p_context); - -// tinyusb function that handles power event (detected, ready, removed) -// We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. -extern void tusb_hal_nrf_power_event(uint32_t event); - -void board_init(void) -{ - // stop LF clock just in case we jump from application without reset - NRF_CLOCK->TASKS_LFCLKSTOP = 1UL; - - // Use Internal OSC to compatible with all boards - NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC; - NRF_CLOCK->TASKS_LFCLKSTART = 1UL; - - // LED - nrf_gpio_cfg_output(LED_PIN); - board_led_write(false); - - // Button - nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP); - - // 1ms tick timer - SysTick_Config(SystemCoreClock/1000); - - // UART - nrfx_uarte_config_t uart_cfg = - { - .pseltxd = UART_TX_PIN, - .pselrxd = UART_RX_PIN, - .pselcts = NRF_UARTE_PSEL_DISCONNECTED, - .pselrts = NRF_UARTE_PSEL_DISCONNECTED, - .p_context = NULL, - .baudrate = NRF_UARTE_BAUDRATE_115200, // CFG_BOARD_UART_BAUDRATE - .interrupt_priority = 7, - .hal_cfg = { - .hwfc = NRF_UARTE_HWFC_DISABLED, - .parity = NRF_UARTE_PARITY_EXCLUDED, - } - }; - - nrfx_uarte_init(&_uart_id, &uart_cfg, NULL); //uart_handler); - -#if TUSB_OPT_DEVICE_ENABLED - // Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice - // 2 is highest for application - NVIC_SetPriority(USBD_IRQn, 2); - - // USB power may already be ready at this time -> no event generated - // We need to invoke the handler based on the status initially - uint32_t usb_reg; - -#ifdef SOFTDEVICE_PRESENT - uint8_t sd_en = false; - sd_softdevice_is_enabled(&sd_en); - - if ( sd_en ) { - sd_power_usbdetected_enable(true); - sd_power_usbpwrrdy_enable(true); - sd_power_usbremoved_enable(true); - - sd_power_usbregstatus_get(&usb_reg); - }else -#endif - { - // Power module init - const nrfx_power_config_t pwr_cfg = { 0 }; - nrfx_power_init(&pwr_cfg); - - // Register tusb function as USB power handler - // cause cast-function-type warning - const nrfx_power_usbevt_config_t config = { .handler = ((nrfx_power_usb_event_handler_t) tusb_hal_nrf_power_event) }; - nrfx_power_usbevt_init(&config); - - nrfx_power_usbevt_enable(); - - usb_reg = NRF_POWER->USBREGSTATUS; - } - - if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_DETECTED); - if ( usb_reg & POWER_USBREGSTATUS_OUTPUTRDY_Msk ) tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY); -#endif -} - -//--------------------------------------------------------------------+ -// Board porting API -//--------------------------------------------------------------------+ - -void board_led_write(bool state) -{ - nrf_gpio_pin_write(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON)); -} - -uint32_t board_button_read(void) -{ - return BUTTON_STATE_ACTIVE == nrf_gpio_pin_read(BUTTON_PIN); -} - -//static void uart_handler(nrfx_uart_event_t const * p_event, void* p_context) -//{ -// -//} - -int board_uart_read(uint8_t* buf, int len) -{ - (void) buf; (void) len; - return 0; -// return NRFX_SUCCESS == nrfx_uart_rx(&_uart_id, buf, (size_t) len) ? len : 0; -} - -int board_uart_write(void const * buf, int len) -{ - return (NRFX_SUCCESS == nrfx_uarte_tx(&_uart_id, (uint8_t const*) buf, (size_t) len)) ? len : 0; -} - -#if CFG_TUSB_OS == OPT_OS_NONE -volatile uint32_t system_ticks = 0; -void SysTick_Handler (void) -{ - system_ticks++; -} - -uint32_t board_millis(void) -{ - return system_ticks; -} -#endif - -#ifdef SOFTDEVICE_PRESENT -// process SOC event from SD -uint32_t proc_soc(void) -{ - uint32_t soc_evt; - uint32_t err = sd_evt_get(&soc_evt); - - if (NRF_SUCCESS == err) - { - /*------------- usb power event handler -------------*/ - int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED: - (soc_evt == NRF_EVT_POWER_USB_POWER_READY) ? NRFX_POWER_USB_EVT_READY : - (soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1; - - if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt); - } - - return err; -} - -uint32_t proc_ble(void) -{ - // do nothing with ble - return NRF_ERROR_NOT_FOUND; -} - -void SD_EVT_IRQHandler(void) -{ - // process BLE and SOC until there is no more events - while( (NRF_ERROR_NOT_FOUND != proc_ble()) || (NRF_ERROR_NOT_FOUND != proc_soc()) ) - { - - } -} - -void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info) -{ - (void) id; - (void) pc; - (void) info; -} -#endif -- cgit v1.3.1 From 8c5c46454fdcc43faf04d8c3dd41434f7fd0122e Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 13 Jan 2021 12:56:33 +0700 Subject: also build boards without family --- examples/make.mk | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index d19dd7f09..60e5f2c06 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -2,6 +2,9 @@ # Common make definition for all examples # --------------------------------------- +# Build directory +BUILD = _build/build-$(BOARD) + # Handy check parameter function check_defined = \ $(strip $(foreach 1,$1, \ @@ -18,19 +21,29 @@ __check_defined = \ # $(error Invalid BOARD specified) #endif -BOARD_PATH = $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD))) +# Board without family +BOARD_PATH := $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD))) +FAMILY := + +# Board within family ifeq ($(BOARD_PATH),) - $(error Invalid BOARD specified) + BOARD_PATH := $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD))) + FAMILY := $(word 3, $(subst /, ,$(BOARD_PATH))) + FAMILY_PATH = hw/bsp/$(FAMILY) endif -FAMILY = $(word 3, $(subst /, ,$(BOARD_PATH))) -FAMILY_PATH = hw/bsp/$(FAMILY) +ifeq ($(BOARD_PATH),) + $(error Invalid BOARD specified) +endif -# Build directory -BUILD = _build/build-$(BOARD) +ifeq ($(FAMILY),) + include $(TOP)/hw/bsp/$(BOARD)/board.mk +else + # Include Family and Board specific defs + include $(TOP)/$(FAMILY_PATH)/family.mk -# Include Family and Board specific defs -include $(TOP)/$(FAMILY_PATH)/family.mk + SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) +endif #-------------- Cross Compiler ------------ # Can be set by board, default to ARM GCC @@ -49,7 +62,6 @@ RM = rm # Include all source C in family & board folder SRC_C += hw/bsp/board.c -SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c)) # Compiler Flags -- cgit v1.3.1 From b6e9c42b0217124aaf47e1d65e4eac39c3d3d681 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 22 Jan 2021 14:58:32 +0700 Subject: update cmake build to work with esp32s2 and rp2040 --- examples/device/board_test/CMakeLists.txt | 13 +-- examples/make.mk | 2 +- examples/rules.mk | 28 ++++-- hw/bsp/esp32s2/family.cmake | 6 ++ hw/bsp/esp32s2/family.mk | 2 - hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c | 99 ---------------------- .../raspberry_pi_pico/board_raspberry_pi_pico.c | 99 ++++++++++++++++++++++ hw/bsp/rp2040/family.cmake | 3 + hw/bsp/rp2040/family_extra.cmake | 1 + 9 files changed, 137 insertions(+), 116 deletions(-) create mode 100644 hw/bsp/esp32s2/family.cmake delete mode 100644 hw/bsp/esp32s2/family.mk delete mode 100644 hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c create mode 100644 hw/bsp/rp2040/boards/raspberry_pi_pico/board_raspberry_pi_pico.c create mode 100644 hw/bsp/rp2040/family.cmake create mode 100644 hw/bsp/rp2040/family_extra.cmake (limited to 'examples/make.mk') diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index c09ffe215..ee0d7ef58 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,15 +1,16 @@ -# The following five lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) -# Add example src and bsp directories -set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s2/boards" "${TOP}/hw/bsp/esp32s2/components") +# Check for -DFAMILY= +if(NOT DEFINED FAMILY) + message(FATAL_ERROR "Invalid FAMILY specified") +endif() -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(SUPPORTED_TARGETS esp32s2) +include(${TOP}/hw/bsp/${FAMILY}/family.cmake) project(board_test) + +include(${TOP}/hw/bsp/${FAMILY}/family_extra.cmake OPTIONAL) diff --git a/examples/make.mk b/examples/make.mk index bf3b36a62..da0f60d2f 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -40,7 +40,7 @@ ifeq ($(FAMILY),) include $(TOP)/hw/bsp/$(BOARD)/board.mk else # Include Family and Board specific defs - include $(TOP)/$(FAMILY_PATH)/family.mk + -include $(TOP)/$(FAMILY_PATH)/family.mk SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) endif diff --git a/examples/rules.mk b/examples/rules.mk index fb1fe76c2..b61af1d55 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -2,34 +2,46 @@ # Common make rules for all examples # --------------------------------------- -ifeq ($(CROSS_COMPILE),xtensa-esp32s2-elf-) +ifeq ($(FAMILY),esp32s2) # Espressif IDF use CMake build system, this add wrapper target to call idf.py .PHONY: all clean flash .DEFAULT_GOAL := all all: - idf.py -B$(BUILD) -DBOARD=$(BOARD) build + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) build build: all clean: - idf.py -B$(BUILD) -DBOARD=$(BOARD) clean + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) clean + +fullclean: + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) fullclean flash: - idf.py -B$(BUILD) -DBOARD=$(BOARD) flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) flash bootloader-flash: - idf.py -B$(BUILD) -DBOARD=$(BOARD) bootloader-flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) bootloader-flash app-flash: - idf.py -B$(BUILD) -DBOARD=$(BOARD) app-flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) app-flash erase: - idf.py -B$(BUILD) -DBOARD=$(BOARD) erase_flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) erase_flash monitor: - idf.py -B$(BUILD) -DBOARD=$(BOARD) monitor + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) monitor + +else ifeq ($(FAMILY),rp2040) + +all: + [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DPICO_BUILD_DOCS=0 + $(MAKE) -C $(BUILD) + +clean: + $(RM) -rf $(BUILD) else # GNU Make build system diff --git a/hw/bsp/esp32s2/family.cmake b/hw/bsp/esp32s2/family.cmake new file mode 100644 index 000000000..c19221b14 --- /dev/null +++ b/hw/bsp/esp32s2/family.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.5) + +# Add example src and bsp directories +set(EXTRA_COMPONENT_DIRS "src" "${TOP}/hw/bsp/esp32s2/boards" "${TOP}/hw/bsp/esp32s2/components") +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +set(SUPPORTED_TARGETS esp32s2) diff --git a/hw/bsp/esp32s2/family.mk b/hw/bsp/esp32s2/family.mk deleted file mode 100644 index 167ef6226..000000000 --- a/hw/bsp/esp32s2/family.mk +++ /dev/null @@ -1,2 +0,0 @@ -# Cross Compiler for ESP32 -CROSS_COMPILE = xtensa-esp32s2-elf- diff --git a/hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c b/hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c deleted file mode 100644 index efdb54733..000000000 --- a/hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "pico/stdlib.h" -#include "../board.h" - -#ifndef LED_PIN -#define LED_PIN PICO_DEFAULT_LED_PIN -#endif - -void board_init(void) -{ - setup_default_uart(); - gpio_init(LED_PIN); - gpio_set_dir(LED_PIN, 1); - - // Button - - // todo probably set up device mode? - -#if TUSB_OPT_HOST_ENABLED - // set portfunc to host !!! -#endif -} - -////--------------------------------------------------------------------+ -//// USB Interrupt Handler -////--------------------------------------------------------------------+ -//void USB_IRQHandler(void) -//{ -//#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST -// tuh_isr(0); -//#endif -// -//#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE -// tud_int_handler(0); -//#endif -//} - -//--------------------------------------------------------------------+ -// Board porting API -//--------------------------------------------------------------------+ - -void board_led_write(bool state) -{ - gpio_put(LED_PIN, state); -} - -uint32_t board_button_read(void) -{ - return 0; -} - -int board_uart_read(uint8_t* buf, int len) -{ - for(int i=0;i Date: Mon, 25 Jan 2021 23:40:52 +0700 Subject: rename build output --- examples/make.mk | 10 +++++++++- tools/build_board.py | 4 ++-- tools/build_esp32s2.py | 4 ++-- tools/build_family.py | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index da0f60d2f..556b0c41a 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -3,7 +3,7 @@ # --------------------------------------- # Build directory -BUILD = _build/build-$(BOARD) +BUILD = _build/$(BOARD) # Handy check parameter function check_defined = \ @@ -13,6 +13,12 @@ __check_defined = \ $(if $(value $1),, \ $(error Undefined make flag: $1$(if $2, ($2)))) +# TODO Check if submodule haven't checkout yet +fetch_submodule_if_empty = \ + ifeq ($(wildcard $(TOP)/$1/*),) \ + $(info $(shell git -C $(TOP) submodule update --init)) \ + endif + #-------------- Select the board to build for. ------------ #BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))) #ifeq ($(filter $(BOARD),$(BOARD_LIST)),) @@ -45,6 +51,8 @@ else SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) endif +#TODO $(call fetch_submodule_if_empty,lib/sct_neopixel) + #-------------- Cross Compiler ------------ # Can be set by board, default to ARM GCC CROSS_COMPILE ?= arm-none-eabi- diff --git a/tools/build_board.py b/tools/build_board.py index 464ee68cf..9397c754f 100644 --- a/tools/build_board.py +++ b/tools/build_board.py @@ -74,8 +74,8 @@ def build_board(example, board): print(build_result.stdout.decode("utf-8")) def build_size(example, board): - #elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board) - elf_file = 'examples/{}/_build/build-{}/*.elf'.format(example, board) + #elf_file = 'examples/device/{}/_build/{}/{}-firmware.elf'.format(example, board, 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') flash_size = int(size_list[0]) diff --git a/tools/build_esp32s2.py b/tools/build_esp32s2.py index 9823e8c53..6580b6562 100644 --- a/tools/build_esp32s2.py +++ b/tools/build_esp32s2.py @@ -72,8 +72,8 @@ def build_board(example, board): print(build_result.stdout.decode("utf-8")) def build_size(example, board): - #elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board) - elf_file = 'examples/device/{}/_build/build-{}/*.elf'.format(example, board) + #elf_file = 'examples/device/{}/_build/{}/{}-firmware.elf'.format(example, board, board) + elf_file = 'examples/device/{}/_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') flash_size = int(size_list[0]) diff --git a/tools/build_family.py b/tools/build_family.py index ae1bf078d..4ef7201ed 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -85,8 +85,8 @@ def build_board(example, board): print(build_result.stdout.decode("utf-8")) def build_size(example, board): - #elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board) - elf_file = 'examples/{}/_build/build-{}/*.elf'.format(example, board) + #elf_file = 'examples/device/{}/_build/{}/{}-firmware.elf'.format(example, board, 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') flash_size = int(size_list[0]) -- cgit v1.3.1 From 4a0f5cbd6332a9ae76dc2eea293024fab2c81885 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 26 Jan 2021 12:46:24 +0700 Subject: change output filename to BOARD-Directory --- examples/device/audio_test/CMakeLists.txt | 3 ++- examples/device/board_test/CMakeLists.txt | 1 + examples/device/cdc_dual_ports/CMakeLists.txt | 1 + examples/device/cdc_msc/CMakeLists.txt | 1 + examples/device/cdc_msc_freertos/CMakeLists.txt | 14 ++++++------- examples/device/dfu_rt/CMakeLists.txt | 1 + .../device/dynamic_configuration/CMakeLists.txt | 1 + examples/device/hid_composite/CMakeLists.txt | 1 + .../device/hid_composite_freertos/CMakeLists.txt | 14 ++++++------- examples/device/hid_generic_inout/CMakeLists.txt | 1 + .../device/hid_multiple_interface/CMakeLists.txt | 1 + examples/device/midi_test/CMakeLists.txt | 1 + examples/device/msc_dual_lun/CMakeLists.txt | 1 + examples/device/net_lwip_webserver/CMakeLists.txt | 1 + examples/device/uac2_headset/CMakeLists.txt | 1 + examples/device/usbtmc/CMakeLists.txt | 1 + examples/device/webusb_serial/CMakeLists.txt | 1 + examples/make.mk | 1 + examples/rules.mk | 23 ++++++++++++---------- hw/bsp/da14695_dk_usb/board.mk | 4 ++-- hw/bsp/da1469x_dk_pro/board.mk | 4 ++-- hw/bsp/double_m33_express/board.mk | 2 +- hw/bsp/fomu/board.mk | 4 ++-- hw/bsp/imxrt/boards/teensy_40/board.mk | 2 +- hw/bsp/lpcxpresso11u37/board.mk | 2 +- hw/bsp/lpcxpresso11u68/board.mk | 2 +- hw/bsp/lpcxpresso51u68/board.mk | 2 +- hw/bsp/lpcxpresso54114/board.mk | 2 +- hw/bsp/lpcxpresso55s69/board.mk | 2 +- hw/bsp/mbed1768/board.mk | 2 +- hw/bsp/msp_exp430f5529lp/board.mk | 4 ++-- hw/bsp/nrf/boards/adafruit_clue/board.mk | 4 ++-- hw/bsp/nrf/boards/arduino_nano33_ble/board.mk | 2 +- .../boards/circuitplayground_bluefruit/board.mk | 4 ++-- .../nrf/boards/feather_nrf52840_express/board.mk | 4 ++-- hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk | 4 ++-- hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk | 4 ++-- hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk | 4 ++-- hw/bsp/nrf/boards/pca10059/board.mk | 4 ++-- hw/bsp/nutiny_nuc121s/board.mk | 2 +- hw/bsp/nutiny_nuc125s/board.mk | 2 +- hw/bsp/nutiny_nuc126v/board.mk | 2 +- hw/bsp/nutiny_sdk_nuc120/board.mk | 2 +- hw/bsp/nutiny_sdk_nuc505/board.mk | 2 +- hw/bsp/samd11_xplained/board.mk | 2 +- hw/bsp/samd21/boards/luna/board.mk | 2 +- hw/bsp/samd21/family.mk | 2 +- hw/bsp/samd51/family.mk | 2 +- hw/bsp/same70_xplained/board.mk | 2 +- hw/bsp/samg55xplained/board.mk | 2 +- hw/bsp/spresense/board.mk | 8 ++++---- hw/bsp/stm32f103bluepill/board.mk | 2 +- hw/bsp/stm32f4/boards/feather_stm32f405/board.mk | 2 +- hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk | 2 +- hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk | 2 +- hw/bsp/stm32l0538disco/board.mk | 2 +- hw/bsp/stm32l476disco/board.mk | 2 +- 57 files changed, 96 insertions(+), 77 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/device/audio_test/CMakeLists.txt b/examples/device/audio_test/CMakeLists.txt index 99ee77bd3..645d57157 100644 --- a/examples/device/audio_test/CMakeLists.txt +++ b/examples/device/audio_test/CMakeLists.txt @@ -1,5 +1,6 @@ -# use directory name for project id +# use BOARD-Directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/board_test/CMakeLists.txt b/examples/device/board_test/CMakeLists.txt index 68577ba73..573f026f3 100644 --- a/examples/device/board_test/CMakeLists.txt +++ b/examples/device/board_test/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/cdc_dual_ports/CMakeLists.txt b/examples/device/cdc_dual_ports/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/cdc_dual_ports/CMakeLists.txt +++ b/examples/device/cdc_dual_ports/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/cdc_msc/CMakeLists.txt b/examples/device/cdc_msc/CMakeLists.txt index 7f5d5a998..5f4d9ba4e 100644 --- a/examples/device/cdc_msc/CMakeLists.txt +++ b/examples/device/cdc_msc/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/cdc_msc_freertos/CMakeLists.txt b/examples/device/cdc_msc_freertos/CMakeLists.txt index 2e55d8c47..dabb4bc80 100644 --- a/examples/device/cdc_msc_freertos/CMakeLists.txt +++ b/examples/device/cdc_msc_freertos/CMakeLists.txt @@ -1,18 +1,18 @@ cmake_minimum_required(VERSION 3.5) -# use directory name for project id +# use BOARD-Directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -project(cdc_msc_freertos) diff --git a/examples/device/dfu_rt/CMakeLists.txt b/examples/device/dfu_rt/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/dfu_rt/CMakeLists.txt +++ b/examples/device/dfu_rt/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/dynamic_configuration/CMakeLists.txt b/examples/device/dynamic_configuration/CMakeLists.txt index f26465729..a759e56e8 100644 --- a/examples/device/dynamic_configuration/CMakeLists.txt +++ b/examples/device/dynamic_configuration/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/hid_composite/CMakeLists.txt b/examples/device/hid_composite/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/hid_composite/CMakeLists.txt +++ b/examples/device/hid_composite/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/hid_composite_freertos/CMakeLists.txt b/examples/device/hid_composite_freertos/CMakeLists.txt index c4777f122..dabb4bc80 100644 --- a/examples/device/hid_composite_freertos/CMakeLists.txt +++ b/examples/device/hid_composite_freertos/CMakeLists.txt @@ -1,18 +1,18 @@ cmake_minimum_required(VERSION 3.5) -# use directory name for project id +# use BOARD-Directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") get_filename_component(TOP "${TOP}" REALPATH) # Check for -DFAMILY= -if(NOT DEFINED FAMILY) +if(FAMILY STREQUAL "esp32s2") + include(${TOP}/hw/bsp/${FAMILY}/family.cmake) + project(${PROJECT}) + +else() message(FATAL_ERROR "Invalid FAMILY specified") endif() - -include(${TOP}/hw/bsp/${FAMILY}/family.cmake) -project(${PROJECT}) - -project(hid_composite_freertos) diff --git a/examples/device/hid_generic_inout/CMakeLists.txt b/examples/device/hid_generic_inout/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/hid_generic_inout/CMakeLists.txt +++ b/examples/device/hid_generic_inout/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/hid_multiple_interface/CMakeLists.txt b/examples/device/hid_multiple_interface/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/hid_multiple_interface/CMakeLists.txt +++ b/examples/device/hid_multiple_interface/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/midi_test/CMakeLists.txt b/examples/device/midi_test/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/midi_test/CMakeLists.txt +++ b/examples/device/midi_test/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/msc_dual_lun/CMakeLists.txt b/examples/device/msc_dual_lun/CMakeLists.txt index 084565400..f0e050f9c 100644 --- a/examples/device/msc_dual_lun/CMakeLists.txt +++ b/examples/device/msc_dual_lun/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/net_lwip_webserver/CMakeLists.txt b/examples/device/net_lwip_webserver/CMakeLists.txt index 695dd7c59..ec4996086 100644 --- a/examples/device/net_lwip_webserver/CMakeLists.txt +++ b/examples/device/net_lwip_webserver/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/uac2_headset/CMakeLists.txt b/examples/device/uac2_headset/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/uac2_headset/CMakeLists.txt +++ b/examples/device/uac2_headset/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/usbtmc/CMakeLists.txt b/examples/device/usbtmc/CMakeLists.txt index 03bb04389..686e8dc2d 100644 --- a/examples/device/usbtmc/CMakeLists.txt +++ b/examples/device/usbtmc/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/device/webusb_serial/CMakeLists.txt b/examples/device/webusb_serial/CMakeLists.txt index 99ee77bd3..c358eddab 100644 --- a/examples/device/webusb_serial/CMakeLists.txt +++ b/examples/device/webusb_serial/CMakeLists.txt @@ -1,5 +1,6 @@ # use directory name for project id get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME) +set(PROJECT ${BOARD}-${PROJECT}) # TOP is absolute path to root directory of TinyUSB git repo set(TOP "../../..") diff --git a/examples/make.mk b/examples/make.mk index 556b0c41a..329efa774 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -4,6 +4,7 @@ # Build directory BUILD = _build/$(BOARD) +PROJECT = $(BOARD)-$(notdir $(CURDIR)) # Handy check parameter function check_defined = \ diff --git a/examples/rules.mk b/examples/rules.mk index ab0373bac..12ec35043 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -43,6 +43,9 @@ all: clean: $(RM) -rf $(BUILD) +#copy-artifact: +# @$(CP) + else # GNU Make build system @@ -100,9 +103,9 @@ endif # Set all as default goal .DEFAULT_GOAL := all -all: $(BUILD)/$(BOARD)-firmware.bin $(BUILD)/$(BOARD)-firmware.hex size +all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size -uf2: $(BUILD)/$(BOARD)-firmware.uf2 +uf2: $(BUILD)/$(PROJECT).uf2 OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) @@ -113,20 +116,20 @@ else @$(MKDIR) -p $@ endif -$(BUILD)/$(BOARD)-firmware.elf: $(OBJ) +$(BUILD)/$(PROJECT).elf: $(OBJ) @echo LINK $@ @$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group -$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf +$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @$(OBJCOPY) -O binary $^ $@ -$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf +$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @$(OBJCOPY) -O ihex $^ $@ UF2_FAMILY ?= 0x00 -$(BUILD)/$(BOARD)-firmware.uf2: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex @echo CREATE $@ $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY) -c -o $@ $^ @@ -150,7 +153,7 @@ $(BUILD)/obj/%.o: %.S @echo AS $(notdir $@) @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< -size: $(BUILD)/$(BOARD)-firmware.elf +size: $(BUILD)/$(PROJECT).elf -@echo '' @$(SIZE) $< -@echo '' @@ -178,7 +181,7 @@ endif JLINK_IF ?= swd # Flash using jlink -flash-jlink: $(BUILD)/$(BOARD)-firmware.hex +flash-jlink: $(BUILD)/$(PROJECT).hex @echo halt > $(BUILD)/$(BOARD).jlink @echo r > $(BUILD)/$(BOARD).jlink @echo loadfile $^ >> $(BUILD)/$(BOARD).jlink @@ -188,11 +191,11 @@ flash-jlink: $(BUILD)/$(BOARD)-firmware.hex $(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink # flash STM32 MCU using stlink with STM32 Cube Programmer CLI -flash-stlink: $(BUILD)/$(BOARD)-firmware.elf +flash-stlink: $(BUILD)/$(PROJECT).elf STM32_Programmer_CLI --connect port=swd --write $< --go # flash with pyocd -flash-pyocd: $(BUILD)/$(BOARD)-firmware.hex +flash-pyocd: $(BUILD)/$(PROJECT).hex pyocd flash -t $(PYOCD_TARGET) $< pyocd reset -t $(PYOCD_TARGET) diff --git a/hw/bsp/da14695_dk_usb/board.mk b/hw/bsp/da14695_dk_usb/board.mk index b097262dc..2e76012d2 100644 --- a/hw/bsp/da14695_dk_usb/board.mk +++ b/hw/bsp/da14695_dk_usb/board.mk @@ -42,10 +42,10 @@ JLINK_DEVICE = DA14695 # flash using jlink but with some twists flash: flash-dialog -flash-dialog: $(BUILD)/$(BOARD)-firmware.bin +flash-dialog: $(BUILD)/$(PROJECT).bin @echo '#define SW_VERSION "v_1.0.0.1"' >$(BUILD)/version.h @echo '#define SW_VERSION_DATE "'`date +"%Y-%m-%d %H:%M"`'"' >>$(BUILD)/version.h - mkimage da1469x $(BUILD)/$(BOARD)-firmware.bin $(BUILD)/version.h $^.img + mkimage da1469x $(BUILD)/$(PROJECT).bin $(BUILD)/version.h $^.img cp $(TOP)/hw/bsp/$(BOARD)/product_header.dump $(BUILD)/$(BOARD)-image.bin cat $^.img >> $(BUILD)/$(BOARD)-image.bin @echo r > $(BUILD)/$(BOARD).jlink diff --git a/hw/bsp/da1469x_dk_pro/board.mk b/hw/bsp/da1469x_dk_pro/board.mk index 16bd6de6b..52064e63c 100644 --- a/hw/bsp/da1469x_dk_pro/board.mk +++ b/hw/bsp/da1469x_dk_pro/board.mk @@ -42,10 +42,10 @@ JLINK_DEVICE = DA14699 # flash using jlink but with some twists flash: flash-dialog -flash-dialog: $(BUILD)/$(BOARD)-firmware.bin +flash-dialog: $(BUILD)/$(PROJECT).bin @echo '#define SW_VERSION "v_1.0.0.1"' >$(BUILD)/version.h @echo '#define SW_VERSION_DATE "'`date +"%Y-%m-%d %H:%M"`'"' >>$(BUILD)/version.h - mkimage da1469x $(BUILD)/$(BOARD)-firmware.bin $(BUILD)/version.h $^.img + mkimage da1469x $(BUILD)/$(PROJECT).bin $(BUILD)/version.h $^.img cp $(TOP)/hw/bsp/$(BOARD)/product_header.dump $(BUILD)/$(BOARD)-image.bin cat $^.img >> $(BUILD)/$(BOARD)-image.bin @echo r > $(BUILD)/$(BOARD).jlink diff --git a/hw/bsp/double_m33_express/board.mk b/hw/bsp/double_m33_express/board.mk index c3401e5b2..5757aa5cd 100644 --- a/hw/bsp/double_m33_express/board.mk +++ b/hw/bsp/double_m33_express/board.mk @@ -51,5 +51,5 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure JLINK_DEVICE = LPC55S69 # flash using pyocd -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t LPC55S69 $< diff --git a/hw/bsp/fomu/board.mk b/hw/bsp/fomu/board.mk index 70fb66975..f31dfec2a 100644 --- a/hw/bsp/fomu/board.mk +++ b/hw/bsp/fomu/board.mk @@ -27,9 +27,9 @@ CHIP_FAMILY = eptri FREERTOS_PORT = RISC-V # flash using dfu-util -$(BUILD)/$(BOARD)-firmware.dfu: $(BUILD)/$(BOARD)-firmware.bin +$(BUILD)/$(PROJECT).dfu: $(BUILD)/$(PROJECT).bin @echo "Create $@" python $(TOP)/hw/bsp/$(BOARD)/dfu.py -b $^ -D 0x1209:0x5bf0 $@ -flash: $(BUILD)/$(BOARD)-firmware.dfu +flash: $(BUILD)/$(PROJECT).dfu dfu-util -D $^ diff --git a/hw/bsp/imxrt/boards/teensy_40/board.mk b/hw/bsp/imxrt/boards/teensy_40/board.mk index 02f77193f..0ad5ea5c0 100644 --- a/hw/bsp/imxrt/boards/teensy_40/board.mk +++ b/hw/bsp/imxrt/boards/teensy_40/board.mk @@ -6,5 +6,5 @@ JLINK_DEVICE = MIMXRT1062xxx6A # flash by using teensy_loader_cli https://github.com/PaulStoffregen/teensy_loader_cli # Make sure it is in your PATH -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex teensy_loader_cli --mcu=imxrt1062 -v -w $< diff --git a/hw/bsp/lpcxpresso11u37/board.mk b/hw/bsp/lpcxpresso11u37/board.mk index d34125ac7..441e5215d 100644 --- a/hw/bsp/lpcxpresso11u37/board.mk +++ b/hw/bsp/lpcxpresso11u37/board.mk @@ -42,5 +42,5 @@ FREERTOS_PORT = ARM_CM0 JLINK_DEVICE = LPC11U37/401 # flash using pyocd -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t lpc11u37 $< diff --git a/hw/bsp/lpcxpresso11u68/board.mk b/hw/bsp/lpcxpresso11u68/board.mk index 67124ab90..53d809cfc 100644 --- a/hw/bsp/lpcxpresso11u68/board.mk +++ b/hw/bsp/lpcxpresso11u68/board.mk @@ -39,5 +39,5 @@ FREERTOS_PORT = ARM_CM0 JLINK_DEVICE = LPC11U68 # flash using pyocd -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t lpc11u68 $< diff --git a/hw/bsp/lpcxpresso51u68/board.mk b/hw/bsp/lpcxpresso51u68/board.mk index cb36b3409..e5ff8242d 100644 --- a/hw/bsp/lpcxpresso51u68/board.mk +++ b/hw/bsp/lpcxpresso51u68/board.mk @@ -43,5 +43,5 @@ FREERTOS_PORT = ARM_CM0 JLINK_DEVICE = LPC51U68 # flash using pyocd (51u68 is not supported yet) -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t LPC51U68 $< diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpcxpresso54114/board.mk index cc0f6cd43..88f2bc734 100644 --- a/hw/bsp/lpcxpresso54114/board.mk +++ b/hw/bsp/lpcxpresso54114/board.mk @@ -45,5 +45,5 @@ FREERTOS_PORT = ARM_CM4F JLINK_DEVICE = LPC54114J256_M4 # flash using pyocd -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t LPC54114 $< diff --git a/hw/bsp/lpcxpresso55s69/board.mk b/hw/bsp/lpcxpresso55s69/board.mk index f98144cc5..646ca2833 100644 --- a/hw/bsp/lpcxpresso55s69/board.mk +++ b/hw/bsp/lpcxpresso55s69/board.mk @@ -45,5 +45,5 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure JLINK_DEVICE = LPC55S69 # flash using pyocd -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t LPC55S69 $< diff --git a/hw/bsp/mbed1768/board.mk b/hw/bsp/mbed1768/board.mk index 54a8357cc..1b09a7f7a 100644 --- a/hw/bsp/mbed1768/board.mk +++ b/hw/bsp/mbed1768/board.mk @@ -41,6 +41,6 @@ FREERTOS_PORT = ARM_CM3 JLINK_DEVICE = LPC1768 # flash using pyocd -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex pyocd flash -t lpc1768 $< diff --git a/hw/bsp/msp_exp430f5529lp/board.mk b/hw/bsp/msp_exp430f5529lp/board.mk index 8e857eb66..9fe8da274 100644 --- a/hw/bsp/msp_exp430f5529lp/board.mk +++ b/hw/bsp/msp_exp430f5529lp/board.mk @@ -28,9 +28,9 @@ endif # flash target using TI MSP430-Flasher # http://www.ti.com/tool/MSP430-FLASHER # Please add its installation dir to PATH -flash: $(BUILD)/$(BOARD)-firmware.hex +flash: $(BUILD)/$(PROJECT).hex MSP430Flasher -w $< -z [VCC] # flash target using mspdebug. -flash-mspdebug: $(BUILD)/$(BOARD)-firmware.elf +flash-mspdebug: $(BUILD)/$(PROJECT).elf $(MSPDEBUG) tilib "prog $<" --allow-fw-update diff --git a/hw/bsp/nrf/boards/adafruit_clue/board.mk b/hw/bsp/nrf/boards/adafruit_clue/board.mk index d8530dc74..f31899eb7 100644 --- a/hw/bsp/nrf/boards/adafruit_clue/board.mk +++ b/hw/bsp/nrf/boards/adafruit_clue/board.mk @@ -1,10 +1,10 @@ MCU_VARIANT = nrf52840 CFLAGS += -DNRF52840_XXAA -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk b/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk index 7d8e9bce1..94babd821 100644 --- a/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk +++ b/hw/bsp/nrf/boards/arduino_nano33_ble/board.mk @@ -8,6 +8,6 @@ LD_FILE = $(BOARD_PATH)/$(BOARD).ld # Add it to your PATH or change BOSSAC variable to match your installation BOSSAC = bossac -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) $(BOSSAC) --port=$(SERIAL) -U -i -e -w $^ -R diff --git a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk index d8530dc74..f31899eb7 100644 --- a/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/nrf/boards/circuitplayground_bluefruit/board.mk @@ -1,10 +1,10 @@ MCU_VARIANT = nrf52840 CFLAGS += -DNRF52840_XXAA -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk b/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk index d8530dc74..f31899eb7 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk +++ b/hw/bsp/nrf/boards/feather_nrf52840_express/board.mk @@ -1,10 +1,10 @@ MCU_VARIANT = nrf52840 CFLAGS += -DNRF52840_XXAA -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk index d8530dc74..f31899eb7 100644 --- a/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk +++ b/hw/bsp/nrf/boards/feather_nrf52840_sense/board.mk @@ -1,10 +1,10 @@ MCU_VARIANT = nrf52840 CFLAGS += -DNRF52840_XXAA -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk index d8530dc74..f31899eb7 100644 --- a/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk +++ b/hw/bsp/nrf/boards/itsybitsy_nrf52840/board.mk @@ -1,10 +1,10 @@ MCU_VARIANT = nrf52840 CFLAGS += -DNRF52840_XXAA -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --sd-req 0xFFFE --application $^ $@ # flash using adafruit-nrfutil dfu -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) adafruit-nrfutil --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank --touch 1200 diff --git a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk index a184fa892..3afa234aa 100644 --- a/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk +++ b/hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.mk @@ -7,9 +7,9 @@ LD_FILE = $(BOARD_PATH)/$(BOARD).ld # make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash NRFUTIL = nrfutil -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex $(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@ -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) $(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200 \ No newline at end of file diff --git a/hw/bsp/nrf/boards/pca10059/board.mk b/hw/bsp/nrf/boards/pca10059/board.mk index 25609f2fa..0b82ecdbb 100644 --- a/hw/bsp/nrf/boards/pca10059/board.mk +++ b/hw/bsp/nrf/boards/pca10059/board.mk @@ -7,9 +7,9 @@ LD_FILE = $(BOARD_PATH)/$(BOARD).ld # make BOARD=pca10059 SERIAL=/dev/ttyACM0 all flash NRFUTIL = nrfutil -$(BUILD)/$(BOARD)-firmware.zip: $(BUILD)/$(BOARD)-firmware.hex +$(BUILD)/$(PROJECT).zip: $(BUILD)/$(PROJECT).hex $(NRFUTIL) pkg generate --hw-version 52 --sd-req 0x0000 --debug-mode --application $^ $@ -flash: $(BUILD)/$(BOARD)-firmware.zip +flash: $(BUILD)/$(PROJECT).zip @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) $(NRFUTIL) dfu usb-serial --package $^ -p $(SERIAL) -b 115200 diff --git a/hw/bsp/nutiny_nuc121s/board.mk b/hw/bsp/nutiny_nuc121s/board.mk index 0a8b6e048..ce18a749c 100644 --- a/hw/bsp/nutiny_nuc121s/board.mk +++ b/hw/bsp/nutiny_nuc121s/board.mk @@ -52,5 +52,5 @@ JLINK_DEVICE = NUC121SC2AE # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit" diff --git a/hw/bsp/nutiny_nuc125s/board.mk b/hw/bsp/nutiny_nuc125s/board.mk index 31577d800..fe51b79d2 100644 --- a/hw/bsp/nutiny_nuc125s/board.mk +++ b/hw/bsp/nutiny_nuc125s/board.mk @@ -36,5 +36,5 @@ JLINK_DEVICE = NUC125SC2AE # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit" diff --git a/hw/bsp/nutiny_nuc126v/board.mk b/hw/bsp/nutiny_nuc126v/board.mk index 7bf3989fc..30cb3df03 100644 --- a/hw/bsp/nutiny_nuc126v/board.mk +++ b/hw/bsp/nutiny_nuc126v/board.mk @@ -56,5 +56,5 @@ JLINK_DEVICE = NUC126VG4AE # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit" diff --git a/hw/bsp/nutiny_sdk_nuc120/board.mk b/hw/bsp/nutiny_sdk_nuc120/board.mk index 51841643a..0d3a3bff4 100644 --- a/hw/bsp/nutiny_sdk_nuc120/board.mk +++ b/hw/bsp/nutiny_sdk_nuc120/board.mk @@ -52,5 +52,5 @@ JLINK_DEVICE = NUC120LE3 # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf openocd -f interface/nulink.cfg -f target/numicroM0.cfg -c "program $< reset exit" diff --git a/hw/bsp/nutiny_sdk_nuc505/board.mk b/hw/bsp/nutiny_sdk_nuc505/board.mk index 2d00cd9be..99103fc65 100644 --- a/hw/bsp/nutiny_sdk_nuc505/board.mk +++ b/hw/bsp/nutiny_sdk_nuc505/board.mk @@ -57,5 +57,5 @@ JLINK_DEVICE = NUC505YO13Y # Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton # Please compile and install it from github source -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf openocd -f interface/nulink.cfg -f target/numicroM4.cfg -c "program $< reset exit" diff --git a/hw/bsp/samd11_xplained/board.mk b/hw/bsp/samd11_xplained/board.mk index c80ece4a6..c12ecd214 100644 --- a/hw/bsp/samd11_xplained/board.mk +++ b/hw/bsp/samd11_xplained/board.mk @@ -42,5 +42,5 @@ FREERTOS_PORT = ARM_CM0 JLINK_DEVICE = ATSAMD11D14 # flash using edbg -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin edbg -b -t samd11 -e -pv -f $< diff --git a/hw/bsp/samd21/boards/luna/board.mk b/hw/bsp/samd21/boards/luna/board.mk index 0feae9313..5beb5e02d 100644 --- a/hw/bsp/samd21/boards/luna/board.mk +++ b/hw/bsp/samd21/boards/luna/board.mk @@ -6,6 +6,6 @@ LD_FILE = $(BOARD_PATH)/samd21g18a_flash.ld JLINK_DEVICE = ATSAMD21G18 # flash using dfu-util -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin dfu-util -a 0 -d 1d50:615c -D $< || dfu-util -a 0 -d 16d0:05a5 -D $< diff --git a/hw/bsp/samd21/family.mk b/hw/bsp/samd21/family.mk index 2f4d6b7ae..76929f74d 100644 --- a/hw/bsp/samd21/family.mk +++ b/hw/bsp/samd21/family.mk @@ -41,6 +41,6 @@ FREERTOS_PORT = ARM_CM0 # Add it to your PATH or change BOSSAC variable to match your installation BOSSAC = bossac -flash-bossac: $(BUILD)/$(BOARD)-firmware.bin +flash-bossac: $(BUILD)/$(PROJECT).bin @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x2000 -e -w $^ -R diff --git a/hw/bsp/samd51/family.mk b/hw/bsp/samd51/family.mk index 097593748..dbb0a1036 100644 --- a/hw/bsp/samd51/family.mk +++ b/hw/bsp/samd51/family.mk @@ -44,6 +44,6 @@ FREERTOS_PORT = ARM_CM4F # Add it to your PATH or change BOSSAC variable to match your installation BOSSAC = bossac -flash-bossac: $(BUILD)/$(BOARD)-firmware.bin +flash-bossac: $(BUILD)/$(PROJECT).bin @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyACM0) $(BOSSAC) --port=$(SERIAL) -U -i --offset=0x4000 -e -w $^ -R diff --git a/hw/bsp/same70_xplained/board.mk b/hw/bsp/same70_xplained/board.mk index efe597fe3..21f5350c3 100644 --- a/hw/bsp/same70_xplained/board.mk +++ b/hw/bsp/same70_xplained/board.mk @@ -54,5 +54,5 @@ JLINK_DEVICE = SAME70Q21B # flash using edbg from https://github.com/ataradov/edbg # Note: SAME70's GPNVM1 must be set to 1 to boot from flash with # edbg -t same70 -F w0,1,1 -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin edbg --verbose -t same70 -pv -f $< diff --git a/hw/bsp/samg55xplained/board.mk b/hw/bsp/samg55xplained/board.mk index 79716d36d..b574a39e7 100644 --- a/hw/bsp/samg55xplained/board.mk +++ b/hw/bsp/samg55xplained/board.mk @@ -49,5 +49,5 @@ FREERTOS_PORT = ARM_CM4F JLINK_DEVICE = ATSAMG55J19 # flash using edbg from https://github.com/ataradov/edbg -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin edbg --verbose -t samg55 -pv -f $< diff --git a/hw/bsp/spresense/board.mk b/hw/bsp/spresense/board.mk index 74b04ef5e..245976235 100644 --- a/hw/bsp/spresense/board.mk +++ b/hw/bsp/spresense/board.mk @@ -61,13 +61,13 @@ LDFLAGS += \ VENDOR = sony CHIP_FAMILY = cxd56 -$(MKSPK): $(BUILD)/$(BOARD)-firmware.elf +$(MKSPK): $(BUILD)/$(PROJECT).elf $(MAKE) -C $(TOP)/hw/mcu/sony/cxd56/mkspk -$(BUILD)/$(BOARD)-firmware.spk: $(MKSPK) +$(BUILD)/$(PROJECT).spk: $(MKSPK) @echo CREATE $@ - @$(MKSPK) -c 2 $(BUILD)/$(BOARD)-firmware.elf nuttx $@ + @$(MKSPK) -c 2 $(BUILD)/$(PROJECT).elf nuttx $@ # flash -flash: $(BUILD)/$(BOARD)-firmware.spk +flash: $(BUILD)/$(PROJECT).spk @$(TOP)/hw/mcu/sony/cxd56/tools/flash_writer.py -s -c $(SERIAL) -d -b 115200 -n $< diff --git a/hw/bsp/stm32f103bluepill/board.mk b/hw/bsp/stm32f103bluepill/board.mk index 8dc1fa3f5..e1517cfaa 100644 --- a/hw/bsp/stm32f103bluepill/board.mk +++ b/hw/bsp/stm32f103bluepill/board.mk @@ -46,5 +46,5 @@ FREERTOS_PORT = ARM_CM3 JLINK_DEVICE = stm32f103c8 # flash target ROM bootloader -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin dfu-util -R -a 0 --dfuse-address 0x08000000 -D $< diff --git a/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk b/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk index f78bb63fc..1de56fe5a 100644 --- a/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk +++ b/hw/bsp/stm32f4/boards/feather_stm32f405/board.mk @@ -8,5 +8,5 @@ SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f405xx.s JLINK_DEVICE = stm32f405rg # flash target ROM bootloader -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin dfu-util -R -a 0 --dfuse-address 0x08000000 -D $< diff --git a/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk b/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk index 2d8b10318..de0f3d4c7 100644 --- a/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk +++ b/hw/bsp/stm32f4/boards/stm32f401blackpill/board.mk @@ -8,5 +8,5 @@ SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f401xc.s JLINK_DEVICE = stm32f401cc # flash target ROM bootloader -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin dfu-util -R -a 0 --dfuse-address 0x08000000 -D $< diff --git a/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk b/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk index a8287d0bc..78be4348a 100644 --- a/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk +++ b/hw/bsp/stm32f4/boards/stm32f411blackpill/board.mk @@ -8,5 +8,5 @@ SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f411xe.s JLINK_DEVICE = stm32f411ce # flash target ROM bootloader -flash: $(BUILD)/$(BOARD)-firmware.bin +flash: $(BUILD)/$(PROJECT).bin dfu-util -R -a 0 --dfuse-address 0x08000000 -D $< diff --git a/hw/bsp/stm32l0538disco/board.mk b/hw/bsp/stm32l0538disco/board.mk index 9e3423fbc..2c9ffad69 100644 --- a/hw/bsp/stm32l0538disco/board.mk +++ b/hw/bsp/stm32l0538disco/board.mk @@ -50,5 +50,5 @@ JLINK_DEVICE = STM32L053R8 STM32Prog = STM32_Programmer_CLI # flash target using on-board stlink -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf $(STM32Prog) --connect port=swd --write $< --go diff --git a/hw/bsp/stm32l476disco/board.mk b/hw/bsp/stm32l476disco/board.mk index 994849d9e..9e44598b0 100644 --- a/hw/bsp/stm32l476disco/board.mk +++ b/hw/bsp/stm32l476disco/board.mk @@ -53,5 +53,5 @@ JLINK_DEVICE = stm32l476vg STM32Prog = STM32_Programmer_CLI # flash target using on-board stlink -flash: $(BUILD)/$(BOARD)-firmware.elf +flash: $(BUILD)/$(PROJECT).elf $(STM32Prog) --connect port=swd --write $< --go -- cgit v1.3.1 From e230d683ca5ebda82da66935daa91661ad97c662 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 26 Jan 2021 21:19:14 +0700 Subject: add copy-artifact target, and add uf2 for all family board --- examples/make.mk | 6 ++++-- examples/rules.mk | 43 ++++++++++++++++++++++++++++++++++--------- hw/bsp/imxrt/family.mk | 2 ++ hw/bsp/nrf/family.mk | 5 ++--- hw/bsp/samd21/family.mk | 2 ++ hw/bsp/samd51/family.mk | 2 ++ hw/bsp/stm32f4/family.mk | 2 ++ hw/bsp/stm32f7/family.mk | 2 ++ tools/build_family.py | 1 + 9 files changed, 51 insertions(+), 14 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index 329efa774..e820989b7 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -3,8 +3,10 @@ # --------------------------------------- # Build directory -BUILD = _build/$(BOARD) -PROJECT = $(BOARD)-$(notdir $(CURDIR)) +BUILD := _build/$(BOARD) + +PROJECT := $(BOARD)-$(notdir $(CURDIR)) +BIN := $(TOP)/_bin/$(BOARD)/$(notdir $(CURDIR)) # Handy check parameter function check_defined = \ diff --git a/examples/rules.mk b/examples/rules.mk index 12ec35043..07bf9a7df 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -2,11 +2,13 @@ # Common make rules for all examples # --------------------------------------- +# Set all as default goal +.DEFAULT_GOAL := all + ifeq ($(FAMILY),esp32s2) # Espressif IDF use CMake build system, this add wrapper target to call idf.py .PHONY: all clean flash -.DEFAULT_GOAL := all all: idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) build @@ -34,6 +36,11 @@ erase: monitor: idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) monitor +UF2_FAMILY_ID = 0xbfdd4eee +$(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex + @echo CREATE $@ + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $^ + else ifeq ($(FAMILY),rp2040) all: @@ -43,9 +50,6 @@ all: clean: $(RM) -rf $(BUILD) -#copy-artifact: -# @$(CP) - else # GNU Make build system @@ -101,8 +105,6 @@ $(info LDFLAGS $(LDFLAGS)) $(info ) $(info ASFLAGS $(ASFLAGS)) $(info ) endif -# Set all as default goal -.DEFAULT_GOAL := all all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size uf2: $(BUILD)/$(PROJECT).uf2 @@ -128,10 +130,19 @@ $(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf @echo CREATE $@ @$(OBJCOPY) -O ihex $^ $@ -UF2_FAMILY ?= 0x00 +# 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) -c -o $@ $^ + $(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 # 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 @@ -199,4 +210,18 @@ flash-pyocd: $(BUILD)/$(PROJECT).hex pyocd flash -t $(PYOCD_TARGET) $< pyocd reset -t $(PYOCD_TARGET) -endif # Make target +endif # GNU Make + +#-------------- Artifacts -------------- + +# Create binary directory +$(BIN): + @$(MKDIR) -p $@ + +# Copy binaries .elf, .bin, .hex, .uf2 to BIN for upload +copy-artifact: $(BIN) + @$(CP) $(BUILD)/$(PROJECT).elf $(BIN) + @$(CP) $(BUILD)/$(PROJECT).bin $(BIN) + @$(CP) $(BUILD)/$(PROJECT).hex $(BIN) + @$(CP) $(BUILD)/$(PROJECT).uf2 $(BIN) + diff --git a/hw/bsp/imxrt/family.mk b/hw/bsp/imxrt/family.mk index 47d403069..3311768bd 100644 --- a/hw/bsp/imxrt/family.mk +++ b/hw/bsp/imxrt/family.mk @@ -1,3 +1,5 @@ +UF2_FAMILY_ID = 0x4fb2d5bd + include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ diff --git a/hw/bsp/nrf/family.mk b/hw/bsp/nrf/family.mk index 7d8f10956..c7dff1d0c 100644 --- a/hw/bsp/nrf/family.mk +++ b/hw/bsp/nrf/family.mk @@ -1,3 +1,5 @@ +UF2_FAMILY_ID = 0xADA52840 + include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ @@ -58,6 +60,3 @@ FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = $(MCU_VARIANT)_xxaa - -# For uf2 conversion -UF2_FAMILY = 0xADA52840 diff --git a/hw/bsp/samd21/family.mk b/hw/bsp/samd21/family.mk index 76929f74d..e2bba494a 100644 --- a/hw/bsp/samd21/family.mk +++ b/hw/bsp/samd21/family.mk @@ -1,3 +1,5 @@ +UF2_FAMILY_ID = 0x68ed2b88 + include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ diff --git a/hw/bsp/samd51/family.mk b/hw/bsp/samd51/family.mk index dbb0a1036..bb895dfc4 100644 --- a/hw/bsp/samd51/family.mk +++ b/hw/bsp/samd51/family.mk @@ -1,3 +1,5 @@ +UF2_FAMILY_ID = 0x55114460 + include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ diff --git a/hw/bsp/stm32f4/family.mk b/hw/bsp/stm32f4/family.mk index 89e28174f..332d6ee02 100644 --- a/hw/bsp/stm32f4/family.mk +++ b/hw/bsp/stm32f4/family.mk @@ -1,3 +1,5 @@ +UF2_FAMILY_ID = 0x57755a57 + include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ diff --git a/hw/bsp/stm32f7/family.mk b/hw/bsp/stm32f7/family.mk index b5f58cf93..b09d8143b 100644 --- a/hw/bsp/stm32f7/family.mk +++ b/hw/bsp/stm32f7/family.mk @@ -1,3 +1,5 @@ +UF2_FAMILY_ID = 0x53b80f00 + include $(TOP)/$(BOARD_PATH)/board.mk CFLAGS += \ diff --git a/tools/build_family.py b/tools/build_family.py index 4ef7201ed..9828ab8c4 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -73,6 +73,7 @@ def build_board(example, board): success = SUCCEEDED success_count += 1 (flash_size, sram_size) = build_size(example, board) + subprocess.run("make -j -C examples/{} BOARD={} copy-artifact".format(example, board), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) else: exit_status = build_result.returncode success = FAILED -- cgit v1.3.1 From ba69da1d8f93af91685e691e5441cd3bca5c71b0 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 29 Jan 2021 11:24:05 +0700 Subject: add support for LOG=2 LOGGER=rtt is not tested since jlink doesn't support rp2040 just yet --- examples/make.mk | 7 ++++++- examples/rules.mk | 25 +++++++++++++++---------- hw/bsp/rp2040/family.c | 40 +++++++++++++++++++++++++++++++++++++--- hw/bsp/rp2040/family.cmake | 23 +++++++++++++++++++++++ 4 files changed, 81 insertions(+), 14 deletions(-) (limited to 'examples/make.mk') diff --git a/examples/make.mk b/examples/make.mk index e820989b7..5387a4ec4 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -112,13 +112,18 @@ endif # Log level is mapped to TUSB DEBUG option ifneq ($(LOG),) + CMAKE_DEFSYM += -DLOG=$(LOG) CFLAGS += -DCFG_TUSB_DEBUG=$(LOG) endif # Logger: default is uart, can be set to rtt or swo +ifneq ($(LOGGER),) + CMAKE_DEFSYM += -DLOGGER=$(LOGGER) +endif + ifeq ($(LOGGER),rtt) - RTT_SRC = lib/SEGGER_RTT CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + RTT_SRC = lib/SEGGER_RTT INC += $(TOP)/$(RTT_SRC)/RTT SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c else ifeq ($(LOGGER),swo) diff --git a/examples/rules.mk b/examples/rules.mk index aac0fbb38..5dded759c 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -11,30 +11,30 @@ ifeq ($(FAMILY),esp32s2) .PHONY: all clean flash all: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) build + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) build build: all clean: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) clean + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean fullclean: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) fullclean + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) fullclean flash: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) flash bootloader-flash: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) bootloader-flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) bootloader-flash app-flash: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) app-flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) app-flash erase: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) erase_flash + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) erase_flash monitor: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) monitor + idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) monitor UF2_FAMILY_ID = 0xbfdd4eee $(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex @@ -43,13 +43,18 @@ $(BUILD)/$(PROJECT).uf2: $(BUILD)/$(PROJECT).hex else ifeq ($(FAMILY),rp2040) -all: - [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) -DPICO_BUILD_DOCS=0 +$(BUILD): + cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) -DPICO_BUILD_DOCS=0 $(CMAKE_DEFSYM) + +all: $(BUILD) $(MAKE) -C $(BUILD) clean: $(RM) -rf $(BUILD) +flash: + @$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2 + else # GNU Make build system diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index e0dc47b39..452e4771a 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -76,6 +76,38 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)() { } #endif +//------------- Segger RTT retarget -------------// +#if defined(LOGGER_RTT) +// Logging with RTT + +#include "pico/stdio/driver.h" +#include "SEGGER_RTT.h" + +static void stdio_rtt_write (const char *buf, int length) +{ + SEGGER_RTT_Write(0, buf, length); +} + +static int stdio_rtt_read (char *buf, int len) +{ + return SEGGER_RTT_Read(0, buf, len); +} + +static stdio_driver_t stdio_rtt = +{ + .out_chars = stdio_rtt_write, + .out_flush = NULL, + .in_chars = stdio_rtt_read +}; + +void stdio_rtt_init(void) +{ + stdio_set_driver_enabled(&stdio_rtt, true); +} + +#endif + + void board_init(void) { gpio_init(LED_PIN); @@ -86,9 +118,11 @@ void board_init(void) #endif #ifdef UART_DEV - uart_init(UART_DEV, CFG_BOARD_UART_BAUDRATE); - gpio_set_function(UART_TX_PIN, GPIO_FUNC_UART); - gpio_set_function(UART_RX_PIN, GPIO_FUNC_UART); + stdio_uart_init_full(UART_DEV, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN); +#endif + +#if defined(LOGGER_RTT) + stdio_rtt_init(); #endif // todo probably set up device mode? diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index edd57a39b..e936fbb24 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -31,3 +31,26 @@ target_include_directories(${PROJECT} PUBLIC target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_MCU=OPT_MCU_RP2040 ) + +if(DEFINED LOG) + target_compile_definitions(${PROJECT} PUBLIC CFG_TUSB_DEBUG=${LOG} ) + pico_enable_stdio_uart(${PROJECT} 1) +endif() + +if(LOGGER STREQUAL "rtt") + pico_enable_stdio_uart(${PROJECT} 0) + + target_compile_definitions(${PROJECT} PUBLIC + LOGGER_RTT + SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL + ) + + target_sources(${PROJECT} PUBLIC + ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c + ) + + target_include_directories(${PROJECT} PUBLIC + ${TOP}/lib/SEGGER_RTT/RTT + ) +endif() + -- cgit v1.3.1