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
  • Laszlo,

    I think it is getting complicated with the changes going the route of having it in linker file. I think simpler would be just add it to the merged.hex in a different way. 

    I had another thought

    create a regout0.hex with this content

    :020000041000EA
    :0403040050000005E3
    :00000001FF

    and add custom merge in CMakeLists.txt

    # Path to the custom HEX file
    set(REGOUT0_HEX ${CMAKE_CURRENT_SOURCE_DIR}/regout0.hex)
    
    # Append REGOUT0_HEX to the final merged.hex
    add_custom_command(
        TARGET ${APPLICATION}
        POST_BUILD
        COMMAND mergehex --merge ${CMAKE_BINARY_DIR}/zephyr/merged.hex ${REGOUT0_HEX} --output ${CMAKE_BINARY_DIR}/zephyr/merged_with_regout.hex
        COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/zephyr/merged_with_regout.hex ${CMAKE_BINARY_DIR}/zephyr/merged.hex
    )
     

    verify through nrfjprog after you flash this new merged.hex

    nrfjprog --readcode output.hex
    grep "10001304" output.hex
    

  • Hi Susheel,

    `mergehex --merge dongle-merged-3ba9eec.hex regout0.hex --output dongle-merged-3ba9eec-regout0.hex` yields:

    Failed to parse line 1 : ":0403040050000005E3"ERROR: One of the files to merge is not a valid hex file.

    dongle-merged-3ba9eec.hex

    regout0.hex

    Can you help with this error?

  • I am sorry, missed to see this ticket. I think I created a wrong hex file, but my intention was to show you how it is done.

    There are so many ways to create an intel HEX one I could think of is using objcopy

    printf "\x05\x00\x00\x00" > regout0.bin
    arm-none-eabi-objcopy --adjust-vma=0x10001304 -I binary -O ihex regout0.bin regout0.hex
    mergehex -m app.hex regout0.hex -o merged.hex
    nrfjprog --program merged.hex --verify
    nrfjprog --memrd 0x10001304 --n 4

    I think that should work. 


Reply
  • I am sorry, missed to see this ticket. I think I created a wrong hex file, but my intention was to show you how it is done.

    There are so many ways to create an intel HEX one I could think of is using objcopy

    printf "\x05\x00\x00\x00" > regout0.bin
    arm-none-eabi-objcopy --adjust-vma=0x10001304 -I binary -O ihex regout0.bin regout0.hex
    mergehex -m app.hex regout0.hex -o merged.hex
    nrfjprog --program merged.hex --verify
    nrfjprog --memrd 0x10001304 --n 4

    I think that should work. 


Children
No Data
Related