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

A UICR write operation has been requested but UICR has not been erased

There are already a few threads about this problem but none of them helped.

I want to use GPIO9 + 10 as .. well .. GPIO.

Here's what I did:

  • added CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS in Makefile
  • added a section in linker script:

UICR_NFCPINS(r) : ORIGIN = 0x1000120C, LENGTH = 0x04

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

  • set the constant in main.c: const uint32_t UICR_ADDR_0x20C attribute ((section(".uicrNfcPinsAddress"))) attribute((used)) = 0xFFFFFFFE;

And after all, still it didn't help, I always had the "A UICR write operation..." message and the GPIOs didn't work.

Finally I did nrfjprog --memwr 0x1000120c --val 0xFFFFFFFE --family nrf52 --verify That helped but is not best practice, I guess - and still the message did not disappear (but the GPIOs work at least)

Any help please?

  • @chrismakaio: You should only have to add CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS to the Makefile, the nRF52 will then run this snippet on startup(see the system_nrf52.c file)

    #if defined (CONFIG_NFCT_PINS_AS_GPIOS)
            if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == 
                   (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NVIC_SystemReset();
            }
        #endif
    

    However, adding

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

    to main.c and modifying the linker script by adding

    UICR_NFCPINS(r) : ORIGIN = 0x1000120C, LENGTH = 0x04
    

    under MEMORY in the linker script and adding

    .uicrNfcPinsAddress : 
      { 
         KEEP(*(.uicrNfcPinsAddress)) 
      } > UICR_NFCPINS
    

    under SECTIONS should also work. Are you using nrfjprog to flash the compiled hexfile?

  • Thanks Bjorn, I have to admit I'm pretty new to the low-level coding (coming from C# in comfortable Visual Studio :) )

    After the changes I tried (in this order): Make flash_softdevice Make flash

    here's the output of flash:

    $ make flash Flashing: _build/nrf52832_xxaa.hex nrfjprog --program _build/nrf52832_xxaa.hex -f nrf52 --sectorerase Parsing hex file. Erasing page at address 0x1F000. Erasing page at address 0x20000. Erasing page at address 0x21000. Erasing page at address 0x22000. Erasing page at address 0x23000. Erasing page at address 0x24000. Erasing page at address 0x25000. Erasing page at address 0x26000. Erasing page at address 0x27000. Erasing page at address 0x28000. Erasing page at address 0x29000. Erasing page at address 0x2A000. Erasing page at address 0x2B000. Erasing page at address 0x2C000. Erasing page at address 0x2D000. WARNING: A UICR write operation has been requested but UICR has not been WARNING: erased. Please verify that the result is correct. Applying system reset. Checking that the area to write is not protected. Programing device. nrfjprog --reset -f nrf52 Applying system reset. Run.

  • Ah, its because the make flash only performs a sectorerase, which does not erase the UICR registers.Could you try flashing the board using nrjfprog directly, i.e. just run make and then erase chip using the --eraseall option and flash the compiled hex file that in the _build folder, i.e.

    nrfjprog -f nrf52 --eraseall
    nrfjprog -f nrf52 --program _build\nrf52832_xxaa.hex 
    

    This will erase the entire chip, so if you're using a SoftDevice you will have to flash it as well.

  • Alternatively, you can run make erase and then make flash.

Related