This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Please help me decide this address?

Hello, I'm migrating a project from nrf51 to nrf52, and there is this function:

uint32_t dfu_init(void)
{
    m_cmd_handler = *((bl_if_cmd_handler_t*) (0x20000000 + ((uint32_t) (NRF_FICR->SIZERAMBLOCKS * NRF_FICR->NUMRAMBLOCK) - 4)));

(uint32_t) m_cmd_handler >= (NRF_FICR->CODESIZE * NRF_FICR->CODEPAGESIZE) ||
    (uint32_t) m_cmd_handler < NRF_UICR->BOOTLOADERADDR)

Clearly, this "m_cmd_handler" is stored at the calculated address.

In Nrf52, both NRF_FICR->SIZERAMBLOCKS * NRF_FICR->NUMRAMBLOCK are removed. Since I'm using nrf52840, by reading technical documents, I found that it's RAM size is 256KB, so I assume the above code can be modified to:

uint32_t dfu_init(void)
{
    m_cmd_handler = *((bl_if_cmd_handler_t*) (0x20000000 + ((uint32_t) (256*1024 - 4)));

there is only one problem: I don't know if the "0x20000000" in above code is still applicable. I don't know exactly what this code is trying to get other than to guess that it's the bootloader start address whatnot, and I'm not sure if this "0x20000000", which I assume has something to do with the RAM starting address, should match my settings in keil:

image description

So... can I just use 0x20000000? Also, is (256*1024 - 4) correct?

Also, as the function name suggests, it has something to do with dfu.

Parents
  • Hi Mitch, the RAM is memory-mapped from 0x20000000 on both the nRF51 and nRF52 Series, so that is correct. The total amount of RAM of the nRF52840 is stored in the INFO.RAM registers, so you can check it to verify that the RAM size is correct. What exactly is this command handler? If I have understood your implementation correct, then you've placed the flash location of this command handler in RAM?

Reply
  • Hi Mitch, the RAM is memory-mapped from 0x20000000 on both the nRF51 and nRF52 Series, so that is correct. The total amount of RAM of the nRF52840 is stored in the INFO.RAM registers, so you can check it to verify that the RAM size is correct. What exactly is this command handler? If I have understood your implementation correct, then you've placed the flash location of this command handler in RAM?

Children
No Data
Related