supporting feather52832
This commit is contained in:
parent
64d39e3672
commit
907272b68f
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
#define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE) /**< This field should correspond to the size of Code Region 0, (which is identical to Start of Code Region 1), found in UICR.CLEN0 register. This value is used for compile safety, as the linker will fail if application expands into bootloader. Runtime, the bootloader will use the value found in UICR.CLEN0. */
|
||||||
#define SOFTDEVICE_REGION_START MBR_SIZE /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
#define SOFTDEVICE_REGION_START MBR_SIZE /**< This field should correspond to start address of the bootloader, found in UICR.RESERVED, 0x10001014, register. This value is used for sanity check, so the bootloader will fail immediately if this value differs from runtime value. The value is used to determine max application size for updating. */
|
||||||
|
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
|
||||||
|
|
||||||
|
|
||||||
#if defined(NRF52832_XXAA)
|
#if defined(NRF52832_XXAA)
|
||||||
@ -45,7 +46,6 @@
|
|||||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
|
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
|
||||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
|
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
|
||||||
|
|
||||||
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
|
|
||||||
|
|
||||||
#elif defined(NRF52840_XXAA)
|
#elif defined(NRF52840_XXAA)
|
||||||
|
|
||||||
@ -60,8 +60,6 @@
|
|||||||
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
|
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */
|
||||||
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
|
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
|
||||||
|
|
||||||
#define CODE_PAGE_SIZE 0x1000 /**< Size of a flash codepage. Used for size of the reserved flash space in the bootloader region. Will be runtime checked against NRF_UICR->CODEPAGESIZE to ensure the region is correct. */
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#error No target defined
|
#error No target defined
|
||||||
|
107
src/Makefile
107
src/Makefile
@ -15,6 +15,7 @@ SDK11_PATH = ../lib/sdk11/components
|
|||||||
|
|
||||||
SRC_PATH = .
|
SRC_PATH = .
|
||||||
TUSB_PATH = ../lib/tinyusb/src
|
TUSB_PATH = ../lib/tinyusb/src
|
||||||
|
NRFX_PATH = ../lib/nrfx
|
||||||
|
|
||||||
|
|
||||||
SD_VER1 = 6
|
SD_VER1 = 6
|
||||||
@ -26,7 +27,7 @@ SD_VERSION_FULL = $(SD_VERSION)r$(SD_VER4)
|
|||||||
|
|
||||||
SD_PATH = ../lib/softdevice/$(SD_NAME)/$(SD_VERSION)
|
SD_PATH = ../lib/softdevice/$(SD_NAME)/$(SD_VERSION)
|
||||||
SD_HEX = $(SD_PATH)/hex/$(SD_NAME)_nrf52_$(SD_VERSION)_softdevice.hex
|
SD_HEX = $(SD_PATH)/hex/$(SD_NAME)_nrf52_$(SD_VERSION)_softdevice.hex
|
||||||
LINKER_SCRIPT = $(SRC_PATH)/$(SD_NAME)_$(SD_VERSION).ld
|
LD_FILE = $(SRC_PATH)/linker/$(SD_NAME)_$(SD_VERSION).ld
|
||||||
|
|
||||||
OUTPUT_FILENAME = $(BOARD)_bootloader
|
OUTPUT_FILENAME = $(BOARD)_bootloader
|
||||||
BOOT_SD_NAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION_FULL)
|
BOOT_SD_NAME = $(OUTPUT_FILENAME)_$(SD_NAME)_$(SD_VERSION_FULL)
|
||||||
@ -108,10 +109,6 @@ remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-ou
|
|||||||
|
|
||||||
C_SOURCE_FILES += $(SRC_PATH)/main.c
|
C_SOURCE_FILES += $(SRC_PATH)/main.c
|
||||||
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
|
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
|
||||||
C_SOURCE_FILES += $(SRC_PATH)/usb/tusb_descriptors.c
|
|
||||||
C_SOURCE_FILES += $(SRC_PATH)/usb/usb.c
|
|
||||||
C_SOURCE_FILES += $(SRC_PATH)/usb/msc_uf2.c
|
|
||||||
C_SOURCE_FILES += $(SRC_PATH)/usb/uf2/ghostfat.c
|
|
||||||
|
|
||||||
# SDK 11 files
|
# SDK 11 files
|
||||||
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
|
||||||
@ -144,6 +141,15 @@ C_SOURCE_FILES += $(SDK_PATH)/libraries/util/nrf_assert.c
|
|||||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/common/nrf_drv_common.c
|
||||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/hal/nrf_nvmc.c
|
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/hal/nrf_nvmc.c
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ($(IS_NRF52840),)
|
||||||
|
|
||||||
|
C_SOURCE_FILES += $(SRC_PATH)/usb/tusb_descriptors.c
|
||||||
|
C_SOURCE_FILES += $(SRC_PATH)/usb/usb.c
|
||||||
|
C_SOURCE_FILES += $(SRC_PATH)/usb/msc_uf2.c
|
||||||
|
C_SOURCE_FILES += $(SRC_PATH)/usb/uf2/ghostfat.c
|
||||||
|
|
||||||
|
|
||||||
C_SOURCE_FILES += $(SDK_PATH)/toolchain/system_nrf52840.c
|
C_SOURCE_FILES += $(SDK_PATH)/toolchain/system_nrf52840.c
|
||||||
|
|
||||||
# Tinyusb stack
|
# Tinyusb stack
|
||||||
@ -157,6 +163,14 @@ C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c
|
|||||||
C_SOURCE_FILES += $(TUSB_PATH)/class/custom/custom_device.c
|
C_SOURCE_FILES += $(TUSB_PATH)/class/custom/custom_device.c
|
||||||
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
|
C_SOURCE_FILES += $(TUSB_PATH)/tusb.c
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
C_SOURCE_FILES += $(NRFX_PATH)/mdk/system_nrf52.c
|
||||||
|
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# Assembly Files
|
# Assembly Files
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -165,44 +179,48 @@ ASM_SOURCE_FILES = $(SDK_PATH)/toolchain/gcc/gcc_startup_nrf52840.S
|
|||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# INCLUDE PATH
|
# INCLUDE PATH
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
INC_PATHS += -I$(SRC_PATH)/
|
IPATH += $(SRC_PATH)/
|
||||||
INC_PATHS += -I$(SRC_PATH)/usb
|
IPATH += $(SRC_PATH)/usb
|
||||||
INC_PATHS += -I$(TUSB_PATH)/
|
IPATH += $(TUSB_PATH)/
|
||||||
|
|
||||||
INC_PATHS += -I$(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
|
IPATH += $(NRFX_PATH)/mdk
|
||||||
INC_PATHS += -I$(SDK11_PATH)/libraries/bootloader_dfu
|
|
||||||
INC_PATHS += -I$(SDK11_PATH)/drivers_nrf/pstorage
|
|
||||||
INC_PATHS += -I$(SDK11_PATH)/ble/common
|
|
||||||
INC_PATHS += -I$(SDK11_PATH)/ble/ble_services/ble_dfu
|
|
||||||
INC_PATHS += -I$(SDK11_PATH)/ble/ble_services/ble_dis
|
|
||||||
INC_PATHS += -I$(SDK11_PATH)/libraries/util
|
|
||||||
|
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/timer
|
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/scheduler
|
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/crc16
|
IPATH += $(SDK11_PATH)/drivers_nrf/pstorage
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/util
|
IPATH += $(SDK11_PATH)/ble/common
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/hci/config
|
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dfu
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/uart
|
IPATH += $(SDK11_PATH)/ble/ble_services/ble_dis
|
||||||
INC_PATHS += -I$(SDK_PATH)/libraries/hci
|
IPATH += $(SDK11_PATH)/libraries/util
|
||||||
|
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/common
|
IPATH += $(SDK_PATH)/libraries/timer
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/hal
|
IPATH += $(SDK_PATH)/libraries/scheduler
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/config
|
IPATH += $(SDK_PATH)/libraries/crc16
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/delay
|
IPATH += $(SDK_PATH)/libraries/util
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/uart
|
IPATH += $(SDK_PATH)/libraries/hci/config
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/power
|
IPATH += $(SDK_PATH)/libraries/uart
|
||||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/usbd
|
IPATH += $(SDK_PATH)/libraries/hci
|
||||||
|
|
||||||
INC_PATHS += -I$(SDK_PATH)/device
|
IPATH += $(SDK_PATH)/drivers_nrf/common
|
||||||
|
IPATH += $(SDK_PATH)/drivers_nrf/hal
|
||||||
|
IPATH += $(SDK_PATH)/drivers_nrf/config
|
||||||
|
IPATH += $(SDK_PATH)/drivers_nrf/delay
|
||||||
|
IPATH += $(SDK_PATH)/drivers_nrf/uart
|
||||||
|
IPATH += $(SDK_PATH)/drivers_nrf/power
|
||||||
|
IPATH += $(SDK_PATH)/drivers_nrf/usbd
|
||||||
|
|
||||||
INC_PATHS += -I$(SDK_PATH)/toolchain/cmsis/include
|
IPATH += $(SDK_PATH)/device
|
||||||
INC_PATHS += -I$(SDK_PATH)/toolchain/gcc
|
|
||||||
INC_PATHS += -I$(SDK_PATH)/toolchain
|
IPATH += $(SDK_PATH)/toolchain/cmsis/include
|
||||||
|
IPATH += $(SDK_PATH)/toolchain/gcc
|
||||||
|
IPATH += $(SDK_PATH)/toolchain
|
||||||
|
|
||||||
|
|
||||||
INC_PATHS += -I$(SD_PATH)/common
|
IPATH += $(SD_PATH)/headers
|
||||||
INC_PATHS += -I$(SD_PATH)/headers
|
IPATH += $(SD_PATH)/headers/nrf52
|
||||||
INC_PATHS += -I$(SD_PATH)/headers/nrf52
|
|
||||||
|
|
||||||
|
INC_PATHS = $(addprefix -I,$(IPATH))
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# Compiler Flags
|
# Compiler Flags
|
||||||
@ -221,9 +239,8 @@ CFLAGS += -fno-builtin --short-enums
|
|||||||
|
|
||||||
# Defined Symbol (MACROS)
|
# Defined Symbol (MACROS)
|
||||||
CFLAGS += -DBOOTLOADER_VERSION=0x0$(SD_VER1)0$(SD_VER2)0$(SD_VER3)0$(SD_VER4)UL
|
CFLAGS += -DBOOTLOADER_VERSION=0x0$(SD_VER1)0$(SD_VER2)0$(SD_VER3)0$(SD_VER4)UL
|
||||||
CFLAGS += -DNRF52840_XXAA
|
|
||||||
CFLAGS += -D__HEAP_SIZE=0
|
CFLAGS += -D__HEAP_SIZE=0
|
||||||
CFLAGS += -DS140
|
|
||||||
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||||
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||||
CFLAGS += -DBSP_DEFINES_ONLY
|
CFLAGS += -DBSP_DEFINES_ONLY
|
||||||
@ -235,6 +252,18 @@ CFLAGS += -DDFU_APP_DATA_RESERVED=7*4096
|
|||||||
|
|
||||||
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
||||||
|
|
||||||
|
ifneq ($(IS_NRF52840),)
|
||||||
|
|
||||||
|
CFLAGS += -DNRF52840_XXAA
|
||||||
|
CFLAGS += -DS140
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
CFLAGS += -DNRF52
|
||||||
|
CFLAGS += -DS132
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# Linker Flags
|
# Linker Flags
|
||||||
@ -243,7 +272,7 @@ CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
|||||||
|
|
||||||
# keep every function in separate section. This will allow linker to dump unused functions
|
# keep every function in separate section. This will allow linker to dump unused functions
|
||||||
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map
|
LDFLAGS += -Xlinker -Map=$(BUILD)/$(OUTPUT_FILENAME).map
|
||||||
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/ -T$(LINKER_SCRIPT)
|
LDFLAGS += -mthumb -mabi=aapcs -L$(SRC_PATH)/ -T$(LD_FILE)
|
||||||
LDFLAGS += -mcpu=cortex-m4
|
LDFLAGS += -mcpu=cortex-m4
|
||||||
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
|
||||||
|
18
src/main.c
18
src/main.c
@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void usb_init(void);
|
void usb_init(void);
|
||||||
void usb_teardown();
|
void usb_teardown(void);
|
||||||
|
|
||||||
/* tinyusb function that handles power event (detected, ready, removed)
|
/* 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. */
|
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
|
||||||
@ -76,6 +76,12 @@ enum {
|
|||||||
NRFX_POWER_USB_EVT_REMOVED, /**< USB power removed from the connector. */
|
NRFX_POWER_USB_EVT_REMOVED, /**< USB power removed from the connector. */
|
||||||
NRFX_POWER_USB_EVT_READY /**< USB power regulator ready. */
|
NRFX_POWER_USB_EVT_READY /**< USB power regulator ready. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define usb_init()
|
||||||
|
#define usb_teardown()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +124,12 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
|
|||||||
|
|
||||||
// Adafruit for factory reset
|
// Adafruit for factory reset
|
||||||
#define APPDATA_ADDR_START (BOOTLOADER_REGION_START-DFU_APP_DATA_RESERVED)
|
#define APPDATA_ADDR_START (BOOTLOADER_REGION_START-DFU_APP_DATA_RESERVED)
|
||||||
|
|
||||||
|
#ifdef NRF52840_XXAA
|
||||||
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
|
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
|
||||||
|
#else
|
||||||
|
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void adafruit_factory_reset(void);
|
void adafruit_factory_reset(void);
|
||||||
@ -466,7 +477,8 @@ void adafruit_factory_reset(void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
||||||
{
|
{
|
||||||
verify_breakpoint();
|
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */
|
||||||
|
if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,12 +525,14 @@ uint32_t proc_soc(void)
|
|||||||
{
|
{
|
||||||
pstorage_sys_event_handler(soc_evt);
|
pstorage_sys_event_handler(soc_evt);
|
||||||
|
|
||||||
|
#ifdef NRF52840_XXAA
|
||||||
/*------------- usb power event handler -------------*/
|
/*------------- usb power event handler -------------*/
|
||||||
int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED:
|
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_POWER_READY) ? NRFX_POWER_USB_EVT_READY :
|
||||||
(soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1;
|
(soc_evt == NRF_EVT_POWER_USB_REMOVED ) ? NRFX_POWER_USB_EVT_REMOVED : -1;
|
||||||
|
|
||||||
if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt);
|
if ( usbevt >= 0) tusb_hal_nrf_power_event(usbevt);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
Reference in New Issue
Block a user