Setting REGOUT0 in merged.hex

Hi there,

Our firmware is built on NCS 2.6.1 (soon to be ported to 2.7.0) and uses MCUboot.

I want to set REGOUT0 to 5 (which corresponds to 3.3V) and the `nrfjprog --memwr 0x10001304 --val 5` command works for this purpose.

However, I want this REGOUT0 value to be put into merged.hex during the build procedure. I've read numerous related forum threads, but none explains exactly how to achieve this. To the best of my knowledge, a linker script is the solution.

Please provide exact instructions.

Thanks in advance!

- Laci

Parents
  • There should be one way that I think you can try using linked script 

    add a linker script in your project folder for example my_regout0_settings.ld like this

    SECTIONS
    {
        .uicr_regout0 (0x10001304) :
        {
            KEEP(*(.uicr_regout0))
        } >UICR
    }
    

    In your CMakeLists.txt: Include the custom linker script in the build process:

    set_property(GLOBAL APPEND PROPERTY linker_script custom_uicr.ld)
    If set_property does not work, then just use set

    In your application somewhere, set the REGOUT0 value like this

    __attribute__((section(".uicr_regout0")))
    const uint32_t regout0 = 0xFFFFFF05; // 3.3V

Reply
  • There should be one way that I think you can try using linked script 

    add a linker script in your project folder for example my_regout0_settings.ld like this

    SECTIONS
    {
        .uicr_regout0 (0x10001304) :
        {
            KEEP(*(.uicr_regout0))
        } >UICR
    }
    

    In your CMakeLists.txt: Include the custom linker script in the build process:

    set_property(GLOBAL APPEND PROPERTY linker_script custom_uicr.ld)
    If set_property does not work, then just use set

    In your application somewhere, set the REGOUT0 value like this

    __attribute__((section(".uicr_regout0")))
    const uint32_t regout0 = 0xFFFFFF05; // 3.3V

Children
  • Thanks for your help, Susheel!

    Unfortunately, the suggested solution didn't make a difference. I used claude.ai to get closer to the solution.

    Instead of using set_property or set, I used:

    zephyr_linker_sources(SECTIONS my_regout0_settings.ld)
     
    Which included the my_regout0_settings.ld
    But then the build failed because the UICR memory section wasn't present, so I included it:
    MEMORY
    {
        UICR (rw) : ORIGIN = 0x10001000, LENGTH = 0x1000
    }
    The build failed due to multiple memory sections, so I included the following in the device tree:
    soc {
        uicr: uicr@10001000 {
            compatible = "zephyr,memory-region";
            reg = <0x10001000 0x1000>;
            zephyr,memory-region = "UICR";
            status = "okay";
        };
    };
     
    The above devicetree fragment created the memory section in linker.cmd.
    Then I added the following to my_regout0_settings.ld:
    SECTIONS
    {
        .uicr_regout0 (0x10001304) :
        {
            KEEP(*(.uicr_regout0))
        } >UICR
    }
    The build failed, presumably because of multiple sections. I added the following devicetree fragment which doesn't make a difference:
    regout0_partition: partition@10001304 {
        compatible = "zephyr,code-partition";
        reg = <0x10001304 0x4>;
        zephyr,memory-region = "UICR";
        zephyr,section-name = "uicr_regout0";
    };
    I'm stuck at this point.
    Do any of you at Nordic have further suggestions?
Related