summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-11 01:25:31 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-11 01:25:31 +0000
commit5c682b37051797602971f78d49935c7560568aa9 (patch)
tree205fbbb64591254e62d13a54d74166113686e0ef
parentadded inital support for 16f1847 (diff)
implemented reset command for 16f1847
also added support for reset at downloader git-svn-id: https://svn.spreadspace.org/pic/trunk@76 a09c6847-51d9-44de-8ef2-e725cf50f3c7
-rw-r--r--bootloader/bootloader-947.asm4
-rw-r--r--bootloader/cmds-16f1847.inc10
-rwxr-xr-xbootloader/downloader.py14
3 files changed, 23 insertions, 5 deletions
diff --git a/bootloader/bootloader-947.asm b/bootloader/bootloader-947.asm
index 4a1747e..602df31 100644
--- a/bootloader/bootloader-947.asm
+++ b/bootloader/bootloader-947.asm
@@ -48,9 +48,9 @@ EEPROM_SIZE_L EQU H'00'
EEPROM_SIZE_H EQU H'01' ; 0x0100 -> 256 Bytes of EEPROM
MESS EQU .64 ; this limit is because of to combuff size and single byte len field for messages
SUPPORTED_H EQU .0
-SUPPORTED_L EQU b'00000110' ; only read/write flash is supported by now
+SUPPORTED_L EQU b'00000111' ; only reset and read/write flash is supported by now
-#define HOOK_CMD_RESET cmd_not_impl
+#define HOOK_CMD_RESET cmd_reset
#define HOOK_CMD_R_FLASH cmd_r_flash
#define HOOK_CMD_W_FLASH cmd_w_flash
#define HOOK_CMD_R_EEPROM cmd_not_impl
diff --git a/bootloader/cmds-16f1847.inc b/bootloader/cmds-16f1847.inc
index 2e6d7e4..4ffb275 100644
--- a/bootloader/cmds-16f1847.inc
+++ b/bootloader/cmds-16f1847.inc
@@ -21,6 +21,16 @@
;;
;; flash read --------
+cmd_reset
+ movlw E_OK
+ call ack_cmd
+ movlb .3
+cmd_resset_wait_ack
+ btfss TXSTA,TRMT
+ goto cmd_resset_wait_ack
+ reset
+
+ ;; flash read --------
cmd_r_flash
;; movlw FSS ; initialize EEADR:EEADRH and FSR
;; movwf cnt
diff --git a/bootloader/downloader.py b/bootloader/downloader.py
index 072ca46..bbb6d13 100755
--- a/bootloader/downloader.py
+++ b/bootloader/downloader.py
@@ -251,6 +251,10 @@ def boot(dev, id, args):
print >> sys.stderr, "booting to user code"
cmd_boot(dev)
+def reset(dev, id, args):
+ print >> sys.stderr, "reseting MCU"
+ cmd_reset(dev,id)
+
def write_flash(dev, id, args):
hexdata = load_hex(args[0])
flashsegments = list(create_flash_segments(hexdata, id['fs'], id['fss']))
@@ -306,6 +310,7 @@ def verify_flash(dev, id, args):
commands = {
'boot': boot,
+ 'reset': reset,
'write': write_flash,
'read': read_flash,
'verify': verify_flash
@@ -327,8 +332,10 @@ Usage:
may be supplied more than once. The commands will be executed in the
order of appearence in the command line.
Mind that all commands after 'boot' will be ignored because the bootloader
- is no longer reachable. If verify detects an error the downloader will
- exit with '-1' immediatly, the remaining commands will get ignored.
+ is no longer reachable. The same may be true after a reset, in which case
+ depending on the state of BOOTPIN the user code may get started.
+ If verify detects an error the downloader will exit with '-1' immediatly and
+ the remaining commands will get ignored.
If you don't specify any command the downloader will connect to the
bootloader print some info and exit.
@@ -343,6 +350,7 @@ Commands:
--write=<hexfile> write <hexfile> to flash (use '-' for stdin).
--verify=<hexfile> compare flash with <hexfile> (use '-' for stdin).
--read=<hexfile> read flash and store in <hexfile> (use '-' for stdout).
+ --reset reset the MCU (this may start the user code area: BOOTPIN)
--boot boot to user code
'''
@@ -353,7 +361,7 @@ Commands:
try:
opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "version", "device=", "baud=", "name=", \
- "write=", "read=", "verify=", "boot" ])
+ "write=", "read=", "verify=", "reset", "boot" ])
for o, a in opts:
if o in ("-h", "--help"):
print >> sys.stderr, usage