Skip to content

Commit 74c6508

Browse files
committed
more update
1 parent af10512 commit 74c6508

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ erase:
340340
# flash SD only
341341
sd:
342342
@echo Flashing: $(SD_HEX)
343-
$(NRFJPROG) --program $(SD_HEX) -f nrf52 --chiperase --reset
343+
$(NRFJPROG) --program $(SD_HEX) -f nrf52 --sectorerase --reset
344344

345345
# flash MBR only
346346
mbr:

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
#define SD_MAGIC_NUMBER 0x51B1E5DB
3434
#endif
3535

36-
#define SD_MAGIC_OK() (*((uint32_t*)(SOFTDEVICE_INFO_STRUCT_ADDRESS+4)) == SD_MAGIC_NUMBER)
36+
static inline bool is_sd_existed(void)
37+
{
38+
return *((uint32_t*)(SOFTDEVICE_INFO_STRUCT_ADDRESS+4)) == SD_MAGIC_NUMBER;
39+
}
3740

3841
#define NRF_UICR_BOOT_START_ADDRESS (NRF_UICR_BASE + 0x14) /**< Register where the bootloader start address is stored in the UICR register. */
3942
#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).*/
4043

4144
// TODO more testing/checking
42-
#define CODE_REGION_1_START (SD_MAGIC_OK() ? SD_SIZE_GET(MBR_SIZE) : 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. */
45+
#define CODE_REGION_1_START (is_sd_existed() ? SD_SIZE_GET(MBR_SIZE) : 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. */
4346
#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. */
4447
#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. */
4548

src/boards.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool is_ota(void);
119119
#define PRINT_MESS(x) printf("%s: %d: %s \n" , __FUNCTION__, __LINE__, (char*)(x))
120120
#define PRINT_STR(x) printf("%s: %d: " #x " = %s\n" , __FUNCTION__, __LINE__, (char*)(x) )
121121
#define PRINT_INT(x) printf("%s: %d: " #x " = %ld\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
122-
#define PRINT_HEX(x) printf("%s: %d: " #x " = 0x%X\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
122+
#define PRINT_HEX(x) printf("%s: %d: " #x " = 0x%lX\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
123123

124124
#define PRINT_BUFFER(buf, n) \
125125
do {\

src/usb/uf2/uf2cfg.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88
#define CFG_UF2_FLASH_SIZE (1024*1024) // 1 MB
99

1010
// Softdevice Address Space
11-
#define CFG_UF2_SOFTDEVICE_ADDR_START 0
12-
#define CFG_UF2_SOFTDEVICE_ADDR_END USER_FLASH_START
11+
#define CFG_UF2_SOFTDEVICE_ADDR_START MBR_SIZE // skip MBR included in SD hex
12+
#define CFG_UF2_SOFTDEVICE_ADDR_END SD_SIZE_GET(MBR_SIZE)
1313

1414
// Application Address Space
15-
#ifdef SOFTDEVICE_PRESENT
16-
#define USER_FLASH_START (SD_FLASH_SIZE + MBR_SIZE)
17-
#else
18-
#define USER_FLASH_START 0x1000 // MBR is still required
19-
#endif
20-
15+
#define USER_FLASH_START MBR_SIZE // skip MBR included in SD hex
2116
#define USER_FLASH_END 0xAD000
2217

2318
// Bootloader Address Space

src/usb/usb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void usb_init(bool cdc_only)
6666
#ifdef SOFTDEVICE_PRESENT
6767
uint8_t sd_en = false;
6868

69-
if ( SD_MAGIC_OK() )
69+
if ( is_sd_existed() )
7070
{
7171
sd_softdevice_is_enabled(&sd_en);
7272
}

0 commit comments

Comments
 (0)