Skip to content

Commit e3449cd

Browse files
committed
able to build with 52833
1 parent d0389fe commit e3449cd

File tree

8 files changed

+49
-41
lines changed

8 files changed

+49
-41
lines changed

Makefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,19 @@ BUILD = _build-$(BOARD)
9090

9191
# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
9292
ifeq ($(MCU_SUB_VARIANT),nrf52)
93-
SD_NAME = s132
94-
DFU_DEV_REV = 0xADAF
95-
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
93+
SD_NAME = s132
94+
DFU_DEV_REV = 0xADAF
95+
MCU_FLAGS = -DNRF52 -DNRF52832_XXAA -DS132
9696
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
97-
SD_NAME = s140
98-
DFU_DEV_REV = 52840
99-
MCU_FLAGS = -DNRF52833_XXAA -DS140
97+
SD_NAME = s140
98+
DFU_DEV_REV = 52840
99+
MCU_FLAGS = -DNRF52833_XXAA -DS140
100+
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
101+
SD_NAME = s140
102+
DFU_DEV_REV = 52840
103+
MCU_FLAGS = -DNRF52840_XXAA -DS140
100104
else
101-
SD_NAME = s140
102-
DFU_DEV_REV = 52840
103-
MCU_FLAGS = -DNRF52840_XXAA -DS140
105+
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
104106
endif
105107

106108
#******************************************************************************

lib/sdk/components/libraries/hci/hci_slip.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
#include "app_uart.h"
4545
#include "nrf_error.h"
4646

47-
#ifdef NRF52840_XXAA
47+
// nRF has native usb peripheral
48+
#ifdef NRF_USBD
4849
#include "tusb.h"
4950
#endif
5051

@@ -121,13 +122,17 @@ static uint32_t send_tx_byte_end(void);
121122
*/
122123
uint32_t (*send_tx_byte) (void) = send_tx_byte_default;
123124

124-
#ifdef NRF52840_XXAA
125-
static uint32_t serial_put(char ch)
126-
{
127-
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
128-
}
125+
#ifdef NRF_USBD
126+
127+
static uint32_t serial_put(char ch)
128+
{
129+
return tud_cdc_write_char(ch) ? NRF_SUCCESS : NRF_ERROR_NO_MEM;
130+
}
131+
129132
#else
130-
#define serial_put app_uart_put
133+
134+
#define serial_put app_uart_put
135+
131136
#endif
132137

133138
static uint32_t send_tx_byte_end(void)
@@ -345,7 +350,7 @@ static bool rx_buffer_overflowed(void)
345350
return false;
346351
}
347352

348-
#ifdef NRF52840_XXAA
353+
#ifdef NRF_USBD
349354

350355
static uint32_t slip_uart_open(void)
351356
{
@@ -441,7 +446,8 @@ uint32_t hci_slip_open()
441446
uint32_t hci_slip_close()
442447
{
443448
m_current_state = SLIP_OFF;
444-
#ifdef NRF52840_XXAA
449+
450+
#ifdef NRF_USBD
445451
return NRF_SUCCESS;
446452
#else
447453
uint32_t err_code = app_uart_close();

lib/sdk11/components/drivers_nrf/pstorage/pstorage_raw.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
#define INVALID_OPCODE 0x00 /**< Invalid op code identifier. */
4141

4242
#ifdef NRF51
43-
#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. */
44-
#elif defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
45-
#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. */
43+
#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. */
44+
#elif defined(NRF52_SERIES)
45+
#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. */
4646
#else
47-
#error No target defined
47+
#error No target defined
4848
#endif
4949

5050

lib/sdk11/components/libraries/bootloader_dfu/bootloader.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232

3333
#include "boards.h"
3434

35-
#ifdef NRF52840_XXAA
35+
#ifdef NRF_USBD
3636
#include "tusb.h"
3737
#endif
3838

3939
#define APP_TIMER_PRESCALER 0
4040

4141
#define IRQ_ENABLED 0x01 /**< Field identifying if an interrupt is enabled. */
4242

43-
/**< Maximum number of interrupts available. */
43+
/**< Maximum number of interrupts available. (from IRQn_Type) */
4444
#if defined(NRF52832_XXAA)
45-
#define MAX_NUMBER_INTERRUPTS 39
46-
#elif defined(NRF52840_XXAA)
47-
#define MAX_NUMBER_INTERRUPTS 48
45+
#define MAX_NUMBER_INTERRUPTS 39
46+
#elif defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
47+
#define MAX_NUMBER_INTERRUPTS 48
4848
#endif
4949

5050
/**@brief Enumeration for specifying current bootloader status.
@@ -127,9 +127,8 @@ static void wait_for_events(void)
127127
// Event received. Process it from the scheduler.
128128
app_sched_execute();
129129

130-
#ifdef NRF52840_XXAA
130+
#ifdef NRF_USBD
131131
// skip if usb is not inited ( e.g OTA / finializing sd/bootloader )
132-
extern bool usb_inited(void);
133132
if ( tusb_inited() )
134133
{
135134
tud_task();

lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ __root const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOT_START_A
3131

3232
#endif
3333

34-
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
34+
#if defined(NRF52_SERIES)
3535
#if defined ( __CC_ARM )
3636

3737
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_
5050
__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. */
5151

5252
#endif
53-
#endif // defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
53+
#endif // NRF52_SERIES
5454

5555

5656
void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)

lib/sdk11/components/libraries/bootloader_dfu/dfu_types.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@
3030
#include "app_util.h"
3131

3232
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
33-
34-
#if defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
3533
#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).*/
36-
#endif
3734

3835
#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. */
3936
#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. */
4037
#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. */
4138

42-
43-
#if defined(NRF52832_XXAA)
39+
// Flash = 512 KB
40+
#if defined(NRF52832_XXAA) || defined(NRF52833_XXAA)
4441

4542
#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. */
4643
#define BOOTLOADER_SETTINGS_ADDRESS 0x0007F000 /**< The field specifies the page location of the bootloader settings address. */
4744
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0007E000 /**< The field specifies the page location of the mbr params page address. */
4845

46+
// Flash = 1024 KB
4947
#elif defined(NRF52840_XXAA)
5048

5149
#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. */

src/dfu_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
*/
8484
#define ADAFRUIT_DEVICE_TYPE 0x0052
8585

86-
#ifdef NRF52840_XXAA
86+
#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA)
8787
#define ADAFRUIT_DEV_REV 52840
8888
#elif defined NRF52832_XXAA
8989
#define ADAFRUIT_DEV_REV 0xADAF

src/main.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#include "nrfx_nvmc.h"
6969

7070

71-
#ifdef NRF52840_XXAA
71+
#ifdef NRF_USBD
7272
#include "nrf_usbd.h"
7373
#include "tusb.h"
7474

@@ -120,9 +120,12 @@ enum { BLE_CONN_CFG_HIGH_BANDWIDTH = 1 };
120120
#define APPDATA_ADDR_START (BOOTLOADER_REGION_START-DFU_APP_DATA_RESERVED)
121121

122122
#ifdef NRF52840_XXAA
123-
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
123+
// Flash 1024 KB
124+
STATIC_ASSERT( APPDATA_ADDR_START == 0xED000);
125+
124126
#else
125-
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
127+
// Flash 512 KB
128+
STATIC_ASSERT( APPDATA_ADDR_START == 0x6D000);
126129
#endif
127130

128131

@@ -423,7 +426,7 @@ uint32_t proc_soc(void)
423426
{
424427
pstorage_sys_event_handler(soc_evt);
425428

426-
#ifdef NRF52840_XXAA
429+
#ifdef NRF_USBD
427430
extern void tusb_hal_nrf_power_event(uint32_t event);
428431
/*------------- usb power event handler -------------*/
429432
int32_t usbevt = (soc_evt == NRF_EVT_POWER_USB_DETECTED ) ? NRFX_POWER_USB_EVT_DETECTED:

0 commit comments

Comments
 (0)