diff options
author | Rodrigo L. Rosa <rodrigorosa.lg@gmail.com> | 2011-06-10 12:23:52 -0700 |
---|---|---|
committer | Øyvind Harboe <oyvind.harboe@zylin.com> | 2011-06-12 11:18:27 +0200 |
commit | cbe201fe6bb2f004957ff8174b53c6d4ecd5bae6 (patch) | |
tree | 80d4cac7dcc9077cea9d928e2da417918cf92bc3 /src/flash/nor | |
parent | 7b0ead520dcf6969954f42255a01e63b89f96cd6 (diff) | |
download | openocd+libswd-cbe201fe6bb2f004957ff8174b53c6d4ecd5bae6.tar.gz openocd+libswd-cbe201fe6bb2f004957ff8174b53c6d4ecd5bae6.tar.bz2 openocd+libswd-cbe201fe6bb2f004957ff8174b53c6d4ecd5bae6.tar.xz openocd+libswd-cbe201fe6bb2f004957ff8174b53c6d4ecd5bae6.zip |
fix protection behavior
Diffstat (limited to 'src/flash/nor')
-rw-r--r-- | src/flash/nor/dsp5680xx_flash.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/flash/nor/dsp5680xx_flash.c b/src/flash/nor/dsp5680xx_flash.c index 9fa7b06f..b919f564 100644 --- a/src/flash/nor/dsp5680xx_flash.c +++ b/src/flash/nor/dsp5680xx_flash.c @@ -96,18 +96,10 @@ static int dsp5680xx_flash_protect_check(struct flash_bank *bank){ static int dsp5680xx_flash_protect(struct flash_bank *bank, int set, int first, int last){ // This applies security to flash module after next reset, it does not actually apply protection (protection refers to undesired access from the core) int retval; - if(set){ + if(set) retval = dsp5680xx_f_lock(bank->target); - if(retval == ERROR_OK){ - for(int i = first;i<last;i++) - bank->sectors[i].is_protected = 1; - } - }else{ + else retval = dsp5680xx_f_unlock(bank->target); - if(retval == ERROR_OK) - for(int i = first;i<last;i++) - bank->sectors[i].is_protected = 0; - } return retval; } @@ -140,10 +132,13 @@ static int dsp5680xx_flash_write(struct flash_bank *bank, uint8_t *buffer, uint3 return ERROR_FAIL; } retval = dsp5680xx_f_wr(bank->target, buffer, bank->base + offset/2, count); - if(retval == ERROR_OK) - bank->sectors[0].is_erased = 0; - else - bank->sectors[0].is_erased = -1; + uint32_t addr_word; + for(addr_word = bank->base + offset/2;addr_word<count/2;addr_word+=(HFM_SECTOR_SIZE/2)){ + if(retval == ERROR_OK) + bank->sectors[addr_word/(HFM_SECTOR_SIZE/2)].is_erased = 0; + else + bank->sectors[addr_word/(HFM_SECTOR_SIZE/2)].is_erased = -1; + } return retval; } |