From ff94ea93e254f7ee8c91e42a3a783f5b2262a391 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 7 Jul 2013 00:18:05 +0000 Subject: 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 --- bootloader/bootloader.asm | 28 ++++++++++++---------------- downloader/proto.txt | 8 +++++--- 2 files changed, 17 insertions(+), 19 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 ;; ------------------------------------- diff --git a/downloader/proto.txt b/downloader/proto.txt index f4f32c8..e85368e 100644 --- a/downloader/proto.txt +++ b/downloader/proto.txt @@ -60,8 +60,8 @@ identify: fss: 1byte, flash segment size The number of words of one flash segment which has to be written at once. - The downloader can fill up holes by supplying the illegal code word 0xFFFF - for some addresses. The bootloader will skip those areas. + If less than should be updated the downloader has to perform a read + operation first. mess: 2bytes, maximum eeprom segment size @@ -133,7 +133,9 @@ write flash: 5 | | The bootloader writes (which has to contain exactly words) to address - inside the flash. + inside the flash. The start address has to be aligned to boundaries. + Before writing the memory region will be erased. If there are words which shouldn't + be altered the downloader has to read these words first and reprogram the whole segment. read eeprom: -- cgit v1.2.3