aboutsummaryrefslogtreecommitdiff
path: root/src/nrf51.c
diff options
context:
space:
mode:
authorGareth McMullin2014-07-30 16:55:02 +1200
committerGareth McMullin2014-07-30 16:55:02 +1200
commit2b61bed291019b33558b32dc2bc35a881a23a0e7 (patch)
tree282f497fbd02465f6a67da6d43c967f4ab652efc /src/nrf51.c
parent4447fb428a8ca534a50a0ad69bd71e5933a19eb0 (diff)
parent7dc18768c4bfc949c8fc1f12c753a1e0df7ee0cc (diff)
Merge branch 'nrf51-uicr' of https://github.com/richardeoin/blackmagic into richardeoin-nrf51-uicr
Conflicts: src/nrf51.c
Diffstat (limited to 'src/nrf51.c')
-rw-r--r--src/nrf51.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nrf51.c b/src/nrf51.c
index 83773eb..52c9749 100644
--- a/src/nrf51.c
+++ b/src/nrf51.c
@@ -64,6 +64,9 @@ static const char nrf51_xml_memory_map[] = "<?xml version=\"1.0\"?>"
" <memory type=\"flash\" start=\"0x0\" length=\"0x40000\">"
" <property name=\"blocksize\">0x400</property>"
" </memory>"
+ " <memory type=\"flash\" start=\"0x10001000\" length=\"0x100\">"
+ " <property name=\"blocksize\">0x400</property>"
+ " </memory>"
" <memory type=\"ram\" start=\"0x20000000\" length=\"0x4000\"/>"
"</memory-map>";
@@ -90,6 +93,9 @@ static const char nrf51_xml_memory_map[] = "<?xml version=\"1.0\"?>"
#define NRF51_FICR_DEVICEADDR_LOW (NRF51_FICR + 0x0A4)
#define NRF51_FICR_DEVICEADDR_HIGH (NRF51_FICR + 0x0A8)
+/* User Information Configuration Registers (UICR) */
+#define NRF51_UICR 0x10001000
+
#define NRF51_PAGE_SIZE 1024
uint16_t nrf51_flash_write_stub[] = {
@@ -177,8 +183,14 @@ static int nrf51_flash_erase(struct target_s *target, uint32_t addr, int len)
return -1;
while (len) {
- /* Write address of first word in page to erase it */
- adiv5_ap_mem_write(ap, NRF51_NVMC_ERASEPAGE, addr);
+ if (addr == NRF51_UICR) { // Special Case
+ /* Write to the ERASE_UICR register to erase */
+ adiv5_ap_mem_write(ap, NRF51_NVMC_ERASEUICR, 0x1);
+
+ } else { // Standard Flash Page
+ /* Write address of first word in page to erase it */
+ adiv5_ap_mem_write(ap, NRF51_NVMC_ERASEPAGE, addr);
+ }
/* Poll for NVMC_READY */
while(adiv5_ap_mem_read(ap, NRF51_NVMC_READY) == 0)