NRF52840 Memory Layout

Hi guys,

I'm leading a project with the nrf52840 dongle connected to a Raspberry Pi via the GPIO header. 

The firmware updating options for the Nordic are a bit limited in the sense that the dongle needs DFU via USB port and I don't want to make this extra connection. So instead I'm exploring openocd for programming via the SWDIO & SWDCLK pins. I was able to get it to work with some ease but now I'm struggling to understand the flash memory regions. 

In my project, I'm using Bluetooth and my linker file looks something like this:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xd9000
  RAM (rwx) :  ORIGIN = 0x20002300, LENGTH = 0x3dd00
}

Using the Nordic programming tool and dragging the hex file I can see the address starting in the position 0x27000 as expected and with the length of the program. Doing some calculations 0x27000+0xd9000 = 0x100000, so I was expecting the memory regions from 0x27000 to 0x100000 to be all program-related. However, when I type the command to erase everything from 0x27000 to 0x100000 the bootloader stops working, making me believe that I'm also messing with some bootloader regions... Is that true? Or it is openocd not working as expected?

Also, do you know in what region of the memory are the User Information Configuration Registers (UICR)? I want to avoid deleting it or erasing it by mistake since it would make the regulator use 1.8V instead of 3V.

Best regards,

Fernando Fontes

  • Ok now it is a lot clear to me. So right now the reason why it is working is because I've erased the memory from address 0x27000 with len of 0xD9000. No bootloader on 0xE0000 and softdevice points the application to 0x27000. However, if for some reason I write something to 0xE0000 it will stop working. Go it. 

    There is an erase all command. But the reason I don't want to do it is exactly because of the REGOUT0 register. That part is still a bit confusing to me. How can I enable it before Softdevice? Isn't the softdevice that runs first and then calls the program region 0x27000? Or your suggestion is to put that code on my application and since the softdevice will call the application the REGOUT0 gets updated and after SystemReset the voltage gets fixed again?

    Best,

  • There is an erase all command. But the reason I don't want to do it is exactly because of the REGOUT0 register. That part is still a bit confusing to me. How can I enable it before Softdevice?

    If you need to set it before the softdevice, then you will need use the debugger to write to it. Otherwise, you can run the code snippet I posted before initializing the Softdevice. This will update the register setting on first startup (UICR is in NV memory, so it will only need to be set once).

    code on my application and since the softdevice will call the application the REGOUT0 gets updated and after SystemReset the voltage gets fixed again?

    Yes.

  • Thank you. Now I have full understanding thanks to you. 

    Best regards,

Related