summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-07 00:18:05 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-07 00:18:05 +0000
commitff94ea93e254f7ee8c91e42a3a783f5b2262a391 (patch)
tree5279f6e7d3301bc8ac8d4e747acaae7e3fd097b0 /bootloader
parentwriting to flash works now (diff)
skipping 'invalid' code doesn't work on some hardware
droping this feature git-svn-id: https://svn.spreadspace.org/pic/trunk@45 a09c6847-51d9-44de-8ef2-e725cf50f3c7
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/bootloader.asm28
1 files changed, 12 insertions, 16 deletions
diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm
index dc7d119..f8b609c 100644
--- a/bootloader/bootloader.asm
+++ b/bootloader/bootloader.asm
@@ -37,7 +37,7 @@ VERSION_MAJ EQU .0
VERSION_MIN EQU .1
DEVID_H EQU H'20'
DEVID_L EQU H'82'
-FSS EQU .8
+FSS EQU .16
MESS_H EQU .0
MESS_L EQU .64
SUPPORTED_H EQU .0
@@ -348,7 +348,7 @@ cmd_w_config
;; actual flash/eeprom functions
;; flash read --------
read_flash_segment
- movlw FSS
+ movlw FSS ; initialize EEADR:EEADRH and FSR
movwf cnt1
movlw b'01011000'
movwf STATUS
@@ -360,19 +360,19 @@ read_flash_segment
movf INDF,w
movwf EEADRH
read_flash_segment_loop
- bsf STATUS,RP0
+ bsf STATUS,RP0 ; perform the actual read
bsf EECON1,EEPGD
bsf EECON1,RD
nop
nop
bcf STATUS,RP0
- movf EEDAT,w
+ movf EEDAT,w ; load code word from EEDAT:EEDATH to combuff
movwf INDF
incf FSR,f
movf EEDATH,w
movwf INDF
incf FSR,f
- incfsz EEADR,f
+ incfsz EEADR,f ; increment flash address
goto read_flash_segment_next
incf EEADRH,f
read_flash_segment_next
@@ -404,17 +404,8 @@ write_flash_segment_loop
movf INDF,w
movwf EEDATH
- bsf STATUS,RP0 ; if code word is 0xFFFF, read the current value first
- btfss INDF,7 ; this will leave this word unchanged
- goto write_flash_segment_write
-
+ bsf STATUS,RP0 ; now start the acutal write sequence
bsf EECON1,EEPGD
- bsf EECON1,RD
- nop
- nop
-
-write_flash_segment_write
- bsf EECON1,EEPGD ; now start the acutal write sequence
bsf EECON1,WREN
movlw H'55'
movwf EECON2
@@ -431,8 +422,13 @@ write_flash_segment_write
write_flash_segment_next
decfsz cnt1,f
goto write_flash_segment_loop
+ bsf STATUS,RP0
+ clrw
+ btfsc EECON1,WRERR
+ movlw E_FLASH_WERR
bcf STATUS,RP1
- clrf combuff + .1 ; = E_OK
+ bcf STATUS,RP0
+ movwf combuff + .1 ; = E_OK
retlw .2 ; bytes to send
;; -------------------------------------