dsp5680xx - mark erase after unlocking flash

the unlocking procedure erases the flash mem (even if it wasn't locked), so it should be marked as erased after unlocking.

Change-Id: I5cc6a1e1d6cf4e1f243de532eff54111ffd66187
Signed-off-by: Rodrigo L. Rosa <rodrigorosa.lg@gmail.com>
Reviewed-on: http://openocd.zylin.com/222
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
This commit is contained in:
rodrigo_l_rosa 2011-11-19 15:39:20 -08:00 committed by Øyvind Harboe
parent e0c0810a8e
commit c725167ba8
2 changed files with 61 additions and 50 deletions

View File

@ -132,8 +132,15 @@ static int dsp5680xx_flash_protect(struct flash_bank *bank, int set, int first,
int retval; int retval;
if(set) if(set)
retval = dsp5680xx_f_lock(bank->target); retval = dsp5680xx_f_lock(bank->target);
else else{
retval = dsp5680xx_f_unlock(bank->target); retval = dsp5680xx_f_unlock(bank->target);
if (retval == ERROR_OK) {
/* mark all as erased */
for (int i = 0; i <= (HFM_SECTOR_COUNT-1); i++)
/* FM does not recognize it as erased if erased via JTAG. */
bank->sectors[i].is_erased = 1;
}
}
return retval; return retval;
} }

View File

@ -64,17 +64,19 @@ static int reset_jtag(void){
return retval; return retval;
} }
static int dsp5680xx_drscan(struct target * target, uint8_t * data_to_shift_into_dr, uint8_t * data_shifted_out_of_dr, int len){ static int dsp5680xx_drscan(struct target *target, uint8_t *d_in, uint8_t *d_out, int len)
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- {
// /** -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// Inputs: *
// - data_to_shift_into_dr: This is the data that will be shifted into the JTAG DR reg. * Inputs:
// - data_shifted_out_of_dr: The data that will be shifted out of the JTAG DR reg will stored here * - d_in: This is the data that will be shifted into the JTAG DR reg.
// - len: Length of the data to be shifted to JTAG DR. * - d_out: The data that will be shifted out of the JTAG DR reg will stored here
// * - len: Length of the data to be shifted to JTAG DR.
// Note: If data_shifted_out_of_dr == NULL, discard incoming bits. *
// * Note: If d_out == NULL, discard incoming bits.
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- *
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
*/
int retval = ERROR_OK; int retval = ERROR_OK;
if (NULL == target->tap) { if (NULL == target->tap) {
retval = ERROR_FAIL; retval = ERROR_FAIL;
@ -87,14 +89,14 @@ static int dsp5680xx_drscan(struct target * target, uint8_t * data_to_shift_into
//TODO what values of len are valid for jtag_add_plain_dr_scan? //TODO what values of len are valid for jtag_add_plain_dr_scan?
//can i send as many bits as i want? //can i send as many bits as i want?
//is the casting necessary? //is the casting necessary?
jtag_add_plain_dr_scan(len,data_to_shift_into_dr,data_shifted_out_of_dr, TAP_IDLE); jtag_add_plain_dr_scan(len, d_in, d_out, TAP_IDLE);
if(dsp5680xx_context.flush){ if(dsp5680xx_context.flush){
retval = dsp5680xx_execute_queue(); retval = dsp5680xx_execute_queue();
err_check(retval, DSP5680XX_ERROR_JTAG_DRSCAN, "drscan failed!"); err_check(retval, DSP5680XX_ERROR_JTAG_DRSCAN, "drscan failed!");
} }
if(data_shifted_out_of_dr!=NULL){ if (d_out != NULL)
LOG_DEBUG("Data read (%d bits): 0x%04X",len,*data_shifted_out_of_dr); LOG_DEBUG("Data read (%d bits): 0x%04X", len, *d_out);
}else else
LOG_DEBUG("Data read was discarded."); LOG_DEBUG("Data read was discarded.");
return retval; return retval;
} }
@ -482,7 +484,8 @@ static int switch_tap(struct target * target, struct jtag_tap * master_tap,struc
master_tap = jtag_tap_by_string("dsp568013.chp"); master_tap = jtag_tap_by_string("dsp568013.chp");
if (master_tap == NULL) { if (master_tap == NULL) {
retval = ERROR_FAIL; retval = ERROR_FAIL;
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER, "Failed to get master tap."); const char *msg = "Failed to get master tap.";
err_check(retval, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER, msg);
} }
} }
if (core_tap == NULL) { if (core_tap == NULL) {
@ -1368,7 +1371,8 @@ if ((watchdog--) == 1) {
dsp5680xx_context.flush = 0; dsp5680xx_context.flush = 0;
retval = core_move_value_at_r2_disp(target,0x00,HFM_CNFG); // write to HFM_CNFG (lock=0, select bank) -- flash_desc.bank&0x03,0x01 == 0x00,0x01 ??? /* write to HFM_CNFG (lock=0, select bank) -- flash_desc.bank&0x03,0x01 == 0x00,0x01 ??? */
retval = core_move_value_at_r2_disp(target, 0x00, HFM_CNFG);
err_check_propagate(retval); err_check_propagate(retval);
retval = core_move_value_at_r2_disp(target,0x04,HFM_USTAT); // write to HMF_USTAT, clear PVIOL, ACCERR & BLANK bits retval = core_move_value_at_r2_disp(target,0x04,HFM_USTAT); // write to HMF_USTAT, clear PVIOL, ACCERR & BLANK bits
err_check_propagate(retval); err_check_propagate(retval);