I developed a bootloader and an application using PCA10040 and all works fine, but when I set the same code to my custom board (that use the same chip) I get a very strange error, the micro is resetting all the time. In order to find the error in bootloader I commented some functions, one of them nrf_dfu_settings_init
, and I found that if I comment the line memcpy((void*)&s_dfu_settings, &m_dfu_settings_buffer[0], sizeof(nrf_dfu_settings_t));
the bootloader works fine.
I think that there's some problem with the size or the reserved space for m_dfu_settings_buffer
becuase if I change sizeof(nrf_dfu_settings_t)
to 4
it works, but I'm not able to find the reason.
My question is, why this code works in PCA10040 and not in my custom board if all the memory areas are defined in the same way?
Another test I've done is only program softdevice and bootloader, but not the application, and in this case the bootloader works fine.
Below I leave some information about my code:
NRF52832QFAAB0
s132 3.1
SDK 12.2
#define BOOTLOADER_SETTINGS_ADDRESS (0x0007F000UL) ...
...
uint8_t m_dfu_settings_buffer[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS)))
__attribute__((used));
Bootloader Read/Only Memory Areas
IROM1 Start: 0x78000
IROM1 Size: 0x6000
IRAM1 Start: 0x200030B8
IRAM1 Size: 0xCF48
Application Read/Only Memory Areas
IROM1 Start: 0x1F000
IROM1 Size: 0x61000
IRAM1 Start: 0x200030B8
IRAM1 Size: 0xCF48
Memory read at position 0x0007F000 (agrees with the bootloader settings generated)
0x0007F000: 0F130A1A 00000001 00000001 00000001 |................|
0x0007F010: 00000000 00000000 0002B860 2153CA96 |........`.....S!|
0x0007F020: 00000001 00000000 00000000 00000000 |................|
0x0007F030: 00000000 00000000 00000000 00000000 |................|
0x0007F040: 00000000 00000000 00000000 00000000 |................|
0x0007F050: 00000000 00000000 00000000 FFFFFFFF |................|
All of this works in PCA10040 but not in my custom board.