This is an automated email from Gerrit.

Tobias Ferner ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/4296

-- gerrit

commit ff07146748be8ff2bdec00a83767c12493fc664b
Author: Tobias Ferner <[email protected]>
Date:   Fri Nov 17 17:36:18 2017 +0000

    topic: Shell script to mass-erase secured SAMD device
    
    ATSAMD devices can not be mass-erased to unsecure them without putting them 
into cold plugging state. This shell script achieves this on a Raspberry Pi 3 
by toggling the GPIO pins used for SWD accordingly and running OpenOCD to erase 
the flash.
    
    Change-Id: Ia229b3dfd7b8397ab1d32deaaca6eb5ab0d0b496
    Signed-off-by: Tobias Ferner <[email protected]>

diff --git a/contrib/shell-helpers/samd_unprotect_on_RPi.sh 
b/contrib/shell-helpers/samd_unprotect_on_RPi.sh
new file mode 100644
index 0000000..d2154fd
--- /dev/null
+++ b/contrib/shell-helpers/samd_unprotect_on_RPi.sh
@@ -0,0 +1,30 @@
+# Shell script placing a SAMD device into cold plugging mode and mass-erasing 
its flash from a Raspberry Pi.
+# This is necessary to be able to mass-erase a secured chip.
+# Notice:      This script needs root rights to have access to the RPi's GPIOs.
+# Usage:       sudo sh samd_unprotect_on_RPi.sh
+# Author:      Tobias Ferner, 2017
+#              [email protected]
+
+# Set proper swd pins here (bcm2835 numbering):
+SWCLK=27
+SWDIO=17
+RST=22
+
+echo "Exporting SWCLK and RST pins."
+echo $SWCLK > /sys/class/gpio/export
+echo $RST > /sys/class/gpio/export
+echo "out" > /sys/class/gpio/gpio$SWCLK/direction
+echo "out" > /sys/class/gpio/gpio$RST/direction
+
+echo "Setting SWCLK low and pulsing RST."
+echo "0" > /sys/class/gpio/gpio$SWCLK/value
+echo "0" > /sys/class/gpio/gpio$RST/value
+echo "1" > /sys/class/gpio/gpio$RST/value
+
+echo "Unexporting SWCLK and RST pins."
+echo $SWCLK > /sys/class/gpio/unexport
+echo $RST > /sys/class/gpio/unexport
+
+echo "Ready for mass erase."
+openocd -c "source [find interface/raspberrypi2-native.cfg]; 
bcm2835gpio_swd_nums $SWCLK $SWDIO; bcm2835gpio_srst_num $RST; transport select 
swd; set CHIPNAME samd20; source [find target/at91samdXX.cfg]; adapter_khz 276; 
init; reset; reset; at91samd chip-erase; shutdown"
+echo "Done."

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to