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

Flash hex file with nrfjprog command; not able to access UICR

I have issue to program nrf52832 with nrfjprog command line.


my program use nrf52formesh sdk.
I developed with Segger Embedded Studio with GCC on the Linux PC.
I modified my_nrf52832.ld file to use UICR and GPIO function on the NFC antenna pins

my_nrf52832.ld file----------------------------------------
MEMORY
{
    . . . .
  UICR (r) : ORIGIN = 0x10001080, LENGTH = 0x4
  UICR_NFCPINS(r) : ORIGIN = 0x1000120C, LENGTH = 0x04
}
SECTIONS
{
    . . . .
  .uicr_customer :
  {
    KEEP(*(.uicr_customer))
  } > UICR

  /* Write the bootloader address in UICR. */
  .uicrNfcPinsAddress :
  {
         KEEP(*(.uicrNfcPinsAddress))
  } > UICR_NFCPINS
}

 my_code.c file--------------------------------------------

volatile uint32_t uicr_data  __attribute__ ((section(".uicr_customer"))) = (0x000000FFUL & (uint32_t)(0x53));

const uint32_t UICR_ADDR_0x20C __attribute__ ((section(".uicrNfcPinsAddress"))) __attribute__((used));

------------------------------------------------------------

With the Segger Embedded Studio, compile, build, flash and run without issue.

Now, I'd like to flash the hex file with nrfjprog command as below
$> nrfjprog -f nrf52 --eraseall
$> nrfjprog -f nrf52 --program my_build.hex

I also able to read/write the UICR as below..
nrfjprog -f nrf51 --memwr 0x10001088 --val oxo2
nrfjprog -f nrf52 --memrd 0x10001088 -n 2



After flash the hex files using "nrfjprog" command, my code not able to access the UICR value.
- again, if I downlod hex files using the Segger studio, no problem to access the UICR value.
Could you help me how can I program using nrfjprog command in this case?

Parents
  • Hi,

    It looks like you include the UICR data in the hex file, so it shouldn't be necessary to write in manually with nrfjprog?

    After flash the hex files using "nrfjprog" command, my code not able to access the UICR value.

     Can you debug the application to see what value is being read? 

  • Dear Berg,

    Thank you for reply.

    it shouldn't be necessary to write in manually with nrfjprog?

    - Yes you are right. but I try to flash with unique UICR value. so I overwrite the UICR value after flash the binary.

    Can you debug the application to see what value is being read? 

    - On the debug, I didn't get any value. by the way, I am able to read/write to 'nrfjprog --memrd/memwr' command.

    i suspect the modified linked file(my_nrf52832.ld)

    The example of the UICR does as below

    const uint32_t UICR_ADDR_0x80 __attribute__((at(0x10001080))) __attribute__((used)) = 0x12345678;

    But GCC doesn't support "at" and I have to use the code as below with modified 'ld' file.

    volatile uint32_t uicr_data  __attribute__ ((section(".uicr_customer"))) = 0x12345678;

    (Is any other easy way to do instead of modify 'ld' file?) Do you have any idea what is problem here?

    Thank you.

  • min26 said:
    Yes you are right. but I try to flash with unique UICR value. so I overwrite the UICR value after flash the binary.

     Note that you need to erase UICR to update an existing value since it's flash memory. E.g.,

    nrfjprog --eraseuicr

    nrfjprog --memwr 0x10001080 --val 0x12345678

    nrfjprog -r

    min26 said:
    On the debug, I didn't get any value.

    This is a symptom of a different problem. There is nothing in HW that can prevent the app from reading the UICR. Do the app function normally apart from not being able to read out the value? 

    min26 said:
    (Is any other easy way to do instead of modify 'ld' file?) Do you have any idea what is problem here?

     You can write to the UICR at runtime as we do when we enable the reset pin in nrf52_system.c, but the result should be the same. I think you need to do more debugging of the app to figure out why it fails to read the UICR. 

  • Dear Berg,

    1. Of cause I do 'nrfjprog -f nrf52 --eraseuicr' before write. without erase, nrfjprog doesn't let me write to the UICR.

    2 & 3. When I download flash with the Segger Studio, I don't see any problem.  In my case, the issues comes with 'nrfjprog' command.  I really like to use command line type of programmer for my Graphic Interface tool( Desktop)

    If you have alternate method of modifying linked file, please teach me. I'd like to try it  

    Thank you for your support.

  • It shouldn't be a problem to use nrfjprog as you described. So I think you have to debug the application to figure out why it's not working. There is no HW protection of the UICR as I've mentioned earlier.  

    min26 said:
    If you have alternate method of modifying linked file, please teach me. I'd like to try it 

     I'm not aware of any other GCC alternatives for absolute placement of variables. But sounds like this part is working as intended, it's just that the app is not working when you set the same registers via the programmer? 

Reply
  • It shouldn't be a problem to use nrfjprog as you described. So I think you have to debug the application to figure out why it's not working. There is no HW protection of the UICR as I've mentioned earlier.  

    min26 said:
    If you have alternate method of modifying linked file, please teach me. I'd like to try it 

     I'm not aware of any other GCC alternatives for absolute placement of variables. But sounds like this part is working as intended, it's just that the app is not working when you set the same registers via the programmer? 

Children
Related