The nRF51822 requires that some UICR bits are set before an entire chip erase can take place or you'll get an error like this:
****** Error: Failed to prepare for programming.
Failed to download RAMCode!
ERROR: Erase returned with error code -1.
The following commands need to be run on clean chips before the flash wipe can succeed:
connect
w4 4001E504, 2 # Enable erase
w4 4001e50C, 1 # Erase memory
sleep 100 # Wait for erase the complete
w4 4001e504, 1 # Enable writing
sleep 100
r
If 'wipe' was available in nrf51822.py with the JLink we could insert this nRF51822 specific code there, but that will mean allows 'wipe' to be extended, which is currently implement in a generic way in jlink.py.
Register Description
4001E504 = CONFIG
4001E50C = ERASEALL
Erase Time
The time it takes to perform an ERASEALL command is specified by tERASEALL in
the product specification. The CPU is halted while the NVMC performs the erase operation.
Problem Overview
The nRF51822 requires that some UICR bits are set before an entire chip erase can take place or you'll get an error like this:
The following commands need to be run on clean chips before the flash wipe can succeed:
If 'wipe' was available in nrf51822.py with the JLink we could insert this nRF51822 specific code there, but that will mean allows 'wipe' to be extended, which is currently implement in a generic way in jlink.py.
Register Description
4001E504 = CONFIG
4001E50C = ERASEALL
Erase Time