able to build with 52833

This commit is contained in:
hathach 2019-11-29 01:02:05 +07:00
parent d0389fe8f4
commit e3449cd771
8 changed files with 49 additions and 41 deletions

View File

@ -90,17 +90,19 @@ BUILD = _build-$(BOARD)
# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
ifeq ($(MCU_SUB_VARIANT),nrf52)
SD_NAME = s132
DFU_DEV_REV = 0xADAF
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
SD_NAME = s132
DFU_DEV_REV = 0xADAF
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
SD_NAME = s140
DFU_DEV_REV = 52840
MCU_FLAGS = -DNRF52833_XXAA -DS140
SD_NAME = s140
DFU_DEV_REV = 52840
MCU_FLAGS = -DNRF52833_XXAA -DS140
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
SD_NAME = s140
DFU_DEV_REV = 52840
MCU_FLAGS = -DNRF52840_XXAA -DS140
else
SD_NAME = s140
DFU_DEV_REV = 52840
MCU_FLAGS = -DNRF52840_XXAA -DS140
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
endif
#******************************************************************************

View File

@ -44,7 +44,8 @@
#include "app_uart.h"
#include "nrf_error.h"
#ifdef NRF52840_XXAA
// nRF has native usb peripheral
#ifdef NRF_USBD
#include "tusb.h"
#endif
@ -121,13 +122,17 @@ static uint32_t send_tx_byte_end(void);
*/
uint32_t (*send_tx_byte) (void) = send_tx_byte_default;
#ifdef NRF52840_XXAA
static uint32_t serial_put(char ch)
{
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
}
#ifdef NRF_USBD
static uint32_t serial_put(char ch)
{
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
}
#else
#define serial_put app_uart_put
#define serial_put app_uart_put
#endif
static uint32_t send_tx_byte_end(void)
@ -345,7 +350,7 @@ static bool rx_buffer_overflowed(void)
return false;
}
#ifdef NRF52840_XXAA
#ifdef NRF_USBD
static uint32_t slip_uart_open(void)
{
@ -441,7 +446,8 @@ uint32_t hci_slip_open()
uint32_t hci_slip_close()
{
m_current_state = SLIP_OFF;
#ifdef NRF52840_XXAA
#ifdef NRF_USBD
return NRF_SUCCESS;
#else
uint32_t err_code = app_uart_close();

View File

@ -40,11 +40,11 @@
#define INVALID_OPCODE 0x00 /**< Invalid op code identifier. */
#ifdef NRF51
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
#elif defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
#elif defined(NRF52_SERIES)
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
#else
#error No target defined
#error No target defined
#endif

View File

@ -32,7 +32,7 @@
#include "boards.h"
#ifdef NRF52840_XXAA
#ifdef NRF_USBD
#include "tusb.h"
#endif
@ -40,11 +40,11 @@
#define IRQ_ENABLED 0x01 /**< Field identifying if an interrupt is enabled. */
/**< Maximum number of interrupts available. */
/**< Maximum number of interrupts available. (from IRQn_Type) */
#if defined(NRF52832_XXAA)
#define MAX_NUMBER_INTERRUPTS 39
#elif defined(NRF52840_XXAA)
#define MAX_NUMBER_INTERRUPTS 48
#define MAX_NUMBER_INTERRUPTS 39
#elif defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
#define MAX_NUMBER_INTERRUPTS 48
#endif
/**@brief Enumeration for specifying current bootloader status.
@ -127,9 +127,8 @@ static void wait_for_events(void)
// Event received. Process it from the scheduler.
app_sched_execute();
#ifdef NRF52840_XXAA
#ifdef NRF_USBD
// skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
extern bool usb_inited(void);
if ( tusb_inited() )
{
tud_task();

View File

@ -31,7 +31,7 @@ __root const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOT_START_A
#endif
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
#if defined(NRF52_SERIES)
#if defined ( __CC_ARM )
uint8_t m_mbr_params_page[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS))) __attribute__((used)); /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
@ -50,7 +50,7 @@ __no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE] @ BOOTLOADER_MBR_PARAMS_
__root const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS; /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
#endif
#endif // defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
#endif // NRF52_SERIES
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)

View File

@ -30,22 +30,20 @@
#include "app_util.h"
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
#define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18) /**< Register where the mbr params page is stored in the UICR register. (Only in use in nRF52 MBR).*/
#endif
#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 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)
// Flash = 512 KB
#if defined(NRF52832_XXAA) || defined(NRF52833_XXAA)
#define BOOTLOADER_REGION_START 0x00074000 /**< 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 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. */
// Flash = 1024 KB
#elif defined(NRF52840_XXAA)
#define BOOTLOADER_REGION_START 0x000F4000 /**< 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. */

View File

@ -83,7 +83,7 @@
*/
#define ADAFRUIT_DEVICE_TYPE 0x0052
#ifdef NRF52840_XXAA
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
#define ADAFRUIT_DEV_REV 52840
#elif defined NRF52832_XXAA
#define ADAFRUIT_DEV_REV 0xADAF

View File

@ -68,7 +68,7 @@
#include "nrfx_nvmc.h"
#ifdef NRF52840_XXAA
#ifdef NRF_USBD
#include "nrf_usbd.h"
#include "tusb.h"
@ -120,9 +120,12 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
#define APPDATA_ADDR_START (BOOTLOADER_REGION_START-DFU_APP_DATA_RESERVED)
#ifdef NRF52840_XXAA
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
// Flash 1024 KB
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
#else
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
// Flash 512 KB
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
#endif
@ -423,7 +426,7 @@ uint32_t proc_soc(void)
{
pstorage_sys_event_handler(soc_evt);
#ifdef NRF52840_XXAA
#ifdef NRF_USBD
extern void tusb_hal_nrf_power_event(uint32_t event);
/*------------- usb power event handler -------------*/
int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED: