summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schlaepfer <ejs@google.com>2012-11-20 08:35:15 -0800
committerEric Schlaepfer <ejs@google.com>2012-11-20 08:35:15 -0800
commit1e6a10f89a66c9e90fab913cf449fe38bc028ad3 (patch)
treeea56daae314de43adda8965affb35fec0e61d8c7
parentf60a73c0f4b646eb54892db4670080f8b54edc46 (diff)
downloadadk2012_demo-1e6a10f89a66c9e90fab913cf449fe38bc028ad3.tar.gz
[firmware] add missing knock-knock code
This program gets loaded into the PIC on the ADK baseboard. It controls the erase line on the SAM3X. When it receives the proper signal from the host, it will erase the flash memory on the SAM3X. Change-Id: I2f2838ccc75871fc2777a87bd9be34a19848fcc6
-rw-r--r--hardware/eraser.asm101
-rw-r--r--hardware/eraser.hex10
2 files changed, 111 insertions, 0 deletions
diff --git a/hardware/eraser.asm b/hardware/eraser.asm
new file mode 100644
index 0000000..f0a2311
--- /dev/null
+++ b/hardware/eraser.asm
@@ -0,0 +1,101 @@
+;
+; Copyright (C) 2012 The Android Open Source Project
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+
+; ADK2 Sam3X Eraser Controller
+; Author: Fuller
+
+; serial DTR line as clock on GP0
+; serial RTS line as data on GP1
+; GP2 output controls Sam3X erase feature
+; GP0, input, /DTR
+; GP1, input, /RTS
+; GP2, output, erase
+; GP3, input, internal pull-up, floating
+
+ #include "P10F200.INC"
+; configuration bits
+ __CONFIG (_WDT_OFF&_CP_ON&_MCLRE_OFF)
+
+; memory map
+; only 16 bytes of RAM starting at 0x10
+ udata
+GPIO_sampled res 1
+GPIO_sampledQ res 1
+magicKeyL res 1
+magicKeyH res 1
+tick0 res 1
+tick1 res 1
+
+ code 0x00
+; initialize microcontroller
+ movlw (1<<NOT_GPWU|1<<PS2|1<<PS1|1<<PS0) ; no wake up, pull-ups
+ ; TMR0 at 1:256 for low power
+ option
+ bcf GPIO, GP2
+ movlw (1<<GP3|1<<GP1|1<<GP0) ; GP2 is only output
+ tris GPIO
+
+; initialize variables
+ clrf magicKeyH
+ clrf magicKeyL
+ bsf GPIO_sampled, GP0 ; can't get false rise if assume high
+
+sampler:
+ movf GPIO_sampled, W ; old stale sample
+ movwf GPIO_sampledQ ; clock pipe for edge detection
+ movf GPIO, W ; fresh sample
+ movwf GPIO_sampled ; sampled copy of IO's
+; check for rising clock edge
+ btfss GPIO_sampled, GP0
+ goto sampler ; if not set, then it's not rising
+ btfsc GPIO_sampledQ, GP0 ; if old is clear, then rising
+ goto sampler
+
+shifter:
+ movf GPIO, W ; sample the data
+ movwf GPIO_sampledQ ; reuse the same memory location
+ btfss GPIO_sampledQ, GP0
+ goto sampler ; if clock has already dropped, abort
+ bsf STATUS, C
+ btfss GPIO_sampledQ, GP1 ; sets C to match GP1 for shift in
+ bcf STATUS, C
+ rrf magicKeyH ; first half of..
+ rrf magicKeyL ; 16-bit shift through C
+ movlw 0xac
+ subwf magicKeyH, W
+ btfss STATUS, Z ; check for key-pattern match
+ goto sampler
+ movlw 0x5a
+ subwf magicKeyL, W
+ btfss STATUS, Z ; check for key-pattern match
+ goto sampler
+erase:
+; begin erase trigger
+ bsf GPIO, GP2
+; delay for erase trigger period, estimate 393mS for this code...
+delay:
+ clrf tick0
+ clrf tick1
+delayLoop:
+; inc16
+ incf tick0
+ btfsc STATUS, Z
+ incf tick1
+ btfss STATUS, Z
+ goto delayLoop
+; end erase trigger
+ bcf GPIO, GP2
+ goto sampler
+ end
diff --git a/hardware/eraser.hex b/hardware/eraser.hex
new file mode 100644
index 0000000..586f178
--- /dev/null
+++ b/hardware/eraser.hex
@@ -0,0 +1,10 @@
+:020000040000FA
+:10000000870C020046040B0C0600730072001005FA
+:1000100010023100060230001007080A1106080A13
+:10002000060231001107080A0305310703043303F0
+:100030003203AC0C93004307080A5A0C92004307A2
+:10004000080A460574007500B4024306B50243076A
+:06005000240A4604080A20
+:040056000008000896
+:021FFE00E30FEF
+:00000001FF