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

How to include UICR in hex

Please tell me how to include UICR in hex in the following environment.
  CPU: nRF51822
  Integrated environment: keil

Parents
  • Hi,

    There is an example of this in the SDK, where the bootloader start address is written to the UICR. You can use the same approach to place a constant at any other part of the UICR (of flash in general). Specifically this is the relevant line from SDK 12.3:

    uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START;      /**< 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. */
    The address is in the UICR as you see here:

    #define NRF_UICR_BOOT_START_ADDRESS     (NRF_UICR_BASE + 0x14)                                  /**< Register where the bootloader start address is stored in the UICR register. */

    (just change the offset to use another part of the UICR)

  • thank you for your answer.
    Is it possible to include UICR in HEX in this way even in the integrated environment SEGGER?

  • Hi,

    Yes, it is the same principle with other toolchains as well, though the actual implementation differs. You can refer to for instance how it is done with m_uicr_bootloader_start_address for SES in SDK 17.0.2 (or older, though none of the SDK versions with nRF51 support include SES projects).

    Specifically, you have this part in nrf_bootlaoder_info.c:

        volatile uint32_t m_uicr_bootloader_start_address  __attribute__ ((section(".uicr_bootloader_start_address")))
                                                = BOOTLOADER_START_ADDR;

    and in flash_placement.xml that segment is defined:

      <MemorySegment name="uicr_bootloader_start_address" start="0x10001014" size="0x4">
        <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_bootloader_start_address" address_symbol="__start_uicr_bootloader_start_address" end_symbol="__stop_uicr_bootloader_start_address" start = "0x10001014" size="0x4" />
      </MemorySegment>

    And under linker_section_placements_segments in the emProject file you also list uicr_bootloader_start_address. This can be done by editing the emProject file in an editor or from the GUI:

    Yere you could modify the name and address of this section so that you can place any data at any fixed address in the hex file.

  • I added the following and built it, but I could not place the data at any fixed address.
    Please let me know if there are any mistakes.
    ------
    main.c
    ------
    volatile uint32_t m_uicr_clenr0 __attribute__ ((section(".uicr_clenr0"))) = 0x00018000;
    volatile uint32_t m_uicr_rbpconf __attribute__ ((section(".uicr_rbpconf"))) = 0xFFFFFFFF;
    ------

    There is no "Memory Segments" in SEGGER version V4.12.
    I edited flash_placement.xml with an editor.
    -------------------
    flash_placement.xml
    -------------------
    <MemorySegment name="uicr_clenr0" start="0x10001000" size="0x4">
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_clenr0" address_symbol="__start_uicr_clenr0" end_symbol="__stop_uicr_clenr0" start = "0x10001000" size="0x4" />
    </MemorySegment>
    <MemorySegment name="uicr_rbpconf" start="0x10001004" size="0x4">
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_rbpconf" address_symbol="__start_uicr_rbpconf" end_symbol="__stop_uicr_rbpconf" start = "0x10001004" size="0x4" />
    </MemorySegment>
    -------------------

Reply
  • I added the following and built it, but I could not place the data at any fixed address.
    Please let me know if there are any mistakes.
    ------
    main.c
    ------
    volatile uint32_t m_uicr_clenr0 __attribute__ ((section(".uicr_clenr0"))) = 0x00018000;
    volatile uint32_t m_uicr_rbpconf __attribute__ ((section(".uicr_rbpconf"))) = 0xFFFFFFFF;
    ------

    There is no "Memory Segments" in SEGGER version V4.12.
    I edited flash_placement.xml with an editor.
    -------------------
    flash_placement.xml
    -------------------
    <MemorySegment name="uicr_clenr0" start="0x10001000" size="0x4">
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_clenr0" address_symbol="__start_uicr_clenr0" end_symbol="__stop_uicr_clenr0" start = "0x10001000" size="0x4" />
    </MemorySegment>
    <MemorySegment name="uicr_rbpconf" start="0x10001004" size="0x4">
    <ProgramSection alignment="4" keep="Yes" load="Yes" name=".uicr_rbpconf" address_symbol="__start_uicr_rbpconf" end_symbol="__stop_uicr_rbpconf" start = "0x10001004" size="0x4" />
    </MemorySegment>
    -------------------

Children
No Data
Related