How to access UICR.CUSTOMER[] after setting CONFIG_SOC_FLASH_NRF_UICR=y. (Zephyr on nRF52832)

Hi,

I need to read/write a range of values in the UICR.CUSTOMR[] flash. 

The docs for the option mentioned in the title says: "Once enabled UICR are written or read as ordinary flash memory. Erase is possible for whole UICR at once."

But, I'm having trouble figuring out how to get a handle (device handle or some flash ID) to the UICR flash area to then use the 'ordinary [Zephyr]' API.

I've tried referencing it as `soc_nv_flash` and adding a flash controller entry into the DTS but no joy.

Any tips would be appreciated.

Thanks

Wayne

Versions:

nRF Connect SDK v1.9.0

nRF52832

Parents Reply Children
  • Hi,
    
    
    In prj.conf
    
    CONFIG_SOC_FLASH_NRF_UICR=y
    CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
    
    
    Roughly speaking:
    
    
    #include <devicetree.h>
    #include <drivers/flash.h>
    #include <storage/flash_map.h>
    
    
    static const struct device *flash_device;
    
    
    // DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL resolves to "NRF_FLASH_DRV_NAME", for me anyway.
    flash_device = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
    
    if (!flash_device) {
        LOG_ERR("Flash not found");
        return;
    }
    
    
    if (flash_device) {
        flash_write(flash_device, flash_offset, src, src_len));        
    }
    
    
    if (flash_device) {
        flash_read(flash_device, flash_offset, dest, dest_len));
    }
    
    
    
    Note that I seem to recall that ‘flash_erase’ can only erase the entire UICR.

Related