adafruit / Adafruit_Adalink

Python wrapper for Segger's J-Link Commander & STMicro STLink V2 to flash various ARM MCUs
MIT License
125 stars 33 forks source link

Make 'wipe' optionally MCU specific #17

Closed microbuilder closed 8 years ago

microbuilder commented 8 years ago

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:

****** 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

screen shot 2016-03-11 at 20 34 59

4001E50C = ERASEALL

screen shot 2016-03-11 at 20 35 25

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.

screen shot 2016-03-11 at 20 55 35