1 /***************************************************************************
2 * Copyright (C) 2011 by Rodrigo L. Rosa *
3 * rodrigorosa.LG@gmail.com *
5 * Based on dsp563xx_once.h written by Mathias Kuester *
6 * mkdorg@users.sourceforge.net *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22 ***************************************************************************/
28 #include "target_type.h"
29 #include "dsp5680xx.h"
31 struct dsp5680xx_common dsp5680xx_context
;
33 #define _E "DSP5680XX_ERROR:%d\nAt:%s:%d:%s"
34 #define err_check(r, c, m) if (r != ERROR_OK) {LOG_ERROR(_E, c, __func__, __LINE__, m); return r; }
35 #define err_check_propagate(retval) if (retval != ERROR_OK) return retval;
37 int dsp5680xx_execute_queue(void){
39 retval
= jtag_execute_queue();
43 static int dsp5680xx_drscan(struct target
* target
, uint8_t * data_to_shift_into_dr
, uint8_t * data_shifted_out_of_dr
, int len
){
44 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
47 // - data_to_shift_into_dr: This is the data that will be shifted into the JTAG DR reg.
48 // - data_shifted_out_of_dr: The data that will be shifted out of the JTAG DR reg will stored here
49 // - len: Length of the data to be shifted to JTAG DR.
51 // Note: If data_shifted_out_of_dr == NULL, discard incoming bits.
53 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
54 int retval
= ERROR_OK
;
55 if (NULL
== target
->tap
){
57 err_check(retval
, DSP5680XX_ERROR_JTAG_INVALID_TAP
, "Invalid tap");
61 err_check(retval
, DSP5680XX_ERROR_JTAG_DR_LEN_OVERFLOW
, "dr_len overflow, maxium is 32");
63 //TODO what values of len are valid for jtag_add_plain_dr_scan?
64 //can i send as many bits as i want?
65 //is the casting necessary?
66 jtag_add_plain_dr_scan(len
,data_to_shift_into_dr
,data_shifted_out_of_dr
, TAP_IDLE
);
67 if(dsp5680xx_context
.flush
){
68 retval
= dsp5680xx_execute_queue();
69 err_check(retval
, DSP5680XX_ERROR_JTAG_DRSCAN
, "drscan failed!");
71 if(data_shifted_out_of_dr
!=NULL
){
72 LOG_DEBUG("Data read (%d bits): 0x%04X",len
,*data_shifted_out_of_dr
);
74 LOG_DEBUG("Data read was discarded.");
78 /** -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
80 * - data_to_shift_into_ir: This is the data that will be shifted into the JTAG IR reg.
81 * - data_shifted_out_of_ir: The data that will be shifted out of the JTAG IR reg will be
83 * - len: Length of the data to be shifted to JTAG IR.
85 * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
87 static int dsp5680xx_irscan(struct target
*target
, uint32_t *d_in
, uint32_t *d_out
, uint8_t ir_len
)
89 int retval
= ERROR_OK
;
90 uint16_t tap_ir_len
= DSP5680XX_JTAG_MASTER_TAP_IRLEN
;
91 if (NULL
== target
->tap
) {
93 err_check(retval
, DSP5680XX_ERROR_JTAG_INVALID_TAP
, "Invalid tap");
95 if (ir_len
!= target
->tap
->ir_length
) {
96 if (target
->tap
->enabled
) {
98 err_check(retval
, DSP5680XX_ERROR_INVALID_IR_LEN
, "Invalid irlen");
100 struct jtag_tap
*t
= jtag_tap_by_string("dsp568013.chp");
101 if ((t
== NULL
) || ((t
->enabled
) && (ir_len
!= tap_ir_len
))) {
103 err_check(retval
, DSP5680XX_ERROR_INVALID_IR_LEN
, "Invalid irlen");
107 jtag_add_plain_ir_scan(ir_len
, (uint8_t *)d_in
, (uint8_t *)d_out
, TAP_IDLE
);
108 if (dsp5680xx_context
.flush
) {
109 retval
= dsp5680xx_execute_queue();
110 err_check(retval
, DSP5680XX_ERROR_JTAG_IRSCAN
, "irscan failed!");
115 static int dsp5680xx_jtag_status(struct target
*target
, uint8_t * status
){
116 uint32_t read_from_ir
;
119 instr
= JTAG_INSTR_ENABLE_ONCE
;
120 retval
= dsp5680xx_irscan(target
,& instr
, & read_from_ir
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
121 err_check_propagate(retval
);
123 *status
= (uint8_t)read_from_ir
;
127 static int jtag_data_read(struct target
* target
, uint8_t * data_read
, int num_bits
){
128 uint32_t bogus_instr
= 0;
129 int retval
= dsp5680xx_drscan(target
,(uint8_t *) & bogus_instr
,data_read
,num_bits
);
130 LOG_DEBUG("Data read (%d bits): 0x%04X",num_bits
,*data_read
);//TODO remove this or move to jtagio?
134 #define jtag_data_read8(target,data_read) jtag_data_read(target,data_read,8)
135 #define jtag_data_read16(target,data_read) jtag_data_read(target,data_read,16)
136 #define jtag_data_read32(target,data_read) jtag_data_read(target,data_read,32)
138 static uint32_t data_read_dummy
;
139 static int jtag_data_write(struct target
* target
, uint32_t instr
,int num_bits
, uint32_t * data_read
){
141 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & data_read_dummy
,num_bits
);
142 err_check_propagate(retval
);
143 if(data_read
!= NULL
)
144 *data_read
= data_read_dummy
;
148 #define jtag_data_write8(target,instr,data_read) jtag_data_write(target,instr,8,data_read)
149 #define jtag_data_write16(target,instr,data_read) jtag_data_write(target,instr,16,data_read)
150 #define jtag_data_write24(target,instr,data_read) jtag_data_write(target,instr,24,data_read)
151 #define jtag_data_write32(target,instr,data_read) jtag_data_write(target,instr,32,data_read)
154 * Executes EOnCE instruction.
157 * @param instr Instruction to execute.
161 * @param eonce_status Value read from the EOnCE status register.
165 static int eonce_instruction_exec_single(struct target
* target
, uint8_t instr
, uint8_t rw
, uint8_t go
, uint8_t ex
,uint8_t * eonce_status
){
168 uint8_t instr_with_flags
= instr
|(rw
<<7)|(go
<<6)|(ex
<<5);
169 retval
= jtag_data_write(target
,instr_with_flags
,8,&dr_out_tmp
);
170 err_check_propagate(retval
);
171 if(eonce_status
!= NULL
)
172 *eonce_status
= (uint8_t) dr_out_tmp
;
176 ///wrappers for multi opcode instructions
177 #define dsp5680xx_exe_1(target,opcode1,opcode2,opcode3) dsp5680xx_exe1(target,opcode1)
178 #define dsp5680xx_exe_2(target,opcode1,opcode2,opcode3) dsp5680xx_exe2(target,opcode1,opcode2)
179 #define dsp5680xx_exe_3(target,opcode1,opcode2,opcode3) dsp5680xx_exe3(target,opcode1,opcode2,opcode3)
180 #define dsp5680xx_exe_generic(target,words,opcode1,opcode2,opcode3) dsp5680xx_exe_##words(target,opcode1,opcode2,opcode3)
182 /// Executes one word DSP instruction
183 static int dsp5680xx_exe1(struct target
* target
, uint16_t opcode
){
185 retval
= eonce_instruction_exec_single(target
,0x04,0,1,0,NULL
);
186 err_check_propagate(retval
);
187 retval
= jtag_data_write16(target
,opcode
,NULL
);
188 err_check_propagate(retval
);
192 /// Executes two word DSP instruction
193 static int dsp5680xx_exe2(struct target
* target
,uint16_t opcode1
, uint16_t opcode2
){
195 retval
= eonce_instruction_exec_single(target
,0x04,0,0,0,NULL
);
196 err_check_propagate(retval
);
197 retval
= jtag_data_write16(target
,opcode1
,NULL
);
198 err_check_propagate(retval
);
199 retval
= eonce_instruction_exec_single(target
,0x04,0,1,0,NULL
);
200 err_check_propagate(retval
);
201 retval
= jtag_data_write16(target
,opcode2
,NULL
);
202 err_check_propagate(retval
);
206 /// Executes three word DSP instruction
207 static int dsp5680xx_exe3(struct target
* target
, uint16_t opcode1
,uint16_t opcode2
,uint16_t opcode3
){
209 retval
= eonce_instruction_exec_single(target
,0x04,0,0,0,NULL
);
210 err_check_propagate(retval
);
211 retval
= jtag_data_write16(target
,opcode1
,NULL
);
212 err_check_propagate(retval
);
213 retval
= eonce_instruction_exec_single(target
,0x04,0,0,0,NULL
);
214 err_check_propagate(retval
);
215 retval
= jtag_data_write16(target
,opcode2
,NULL
);
216 err_check_propagate(retval
);
217 retval
= eonce_instruction_exec_single(target
,0x04,0,1,0,NULL
);
218 err_check_propagate(retval
);
219 retval
= jtag_data_write16(target
,opcode3
,NULL
);
220 err_check_propagate(retval
);
225 * --------------- Real-time data exchange ---------------
226 * The EOnCE Transmit (OTX) and Receive (ORX) registers are data memory mapped, each with an upper and lower 16 bit word.
227 * Transmit and receive directions are defined from the core’s perspective.
228 * The core writes to the Transmit register and reads the Receive register, and the host through JTAG writes to the Receive register and reads the Transmit register.
229 * Both registers have a combined data memory mapped OTXRXSR which provides indication when each may be accessed.
230 *ref: eonce_rev.1.0_0208081.pdf@36
233 /// writes data into upper ORx register of the target
234 static int core_tx_upper_data(struct target
* target
, uint16_t data
, uint32_t * eonce_status_low
){
236 retval
= eonce_instruction_exec_single(target
,DSP5680XX_ONCE_ORX1
,0,0,0,NULL
);
237 err_check_propagate(retval
);
238 retval
= jtag_data_write16(target
,data
,eonce_status_low
);
239 err_check_propagate(retval
);
243 /// writes data into lower ORx register of the target
244 #define core_tx_lower_data(target,data) eonce_instruction_exec_single(target,DSP5680XX_ONCE_ORX,0,0,0,NULL);\
245 jtag_data_write16(target,data)
250 * @param data_read: Returns the data read from the upper OTX register via JTAG.
251 * @return: Returns an error code (see error code documentation)
253 static int core_rx_upper_data(struct target
* target
, uint8_t * data_read
)
256 retval
= eonce_instruction_exec_single(target
,DSP5680XX_ONCE_OTX1
,1,0,0,NULL
);
257 err_check_propagate(retval
);
258 retval
= jtag_data_read16(target
,data_read
);
259 err_check_propagate(retval
);
266 * @param data_read: Returns the data read from the lower OTX register via JTAG.
267 * @return: Returns an error code (see error code documentation)
269 static int core_rx_lower_data(struct target
* target
,uint8_t * data_read
)
272 retval
= eonce_instruction_exec_single(target
,DSP5680XX_ONCE_OTX
,1,0,0,NULL
);
273 err_check_propagate(retval
);
274 retval
= jtag_data_read16(target
,data_read
);
275 err_check_propagate(retval
);
280 * -- -- -- -- --- -- -- -- --- -- -- -- --- -- -- -- --- -- -- -- --- --
281 * -- -- -- -- --- -- -- -Core Instructions- -- -- -- --- -- -- -- --- --
282 * -- -- -- -- --- -- -- -- --- -- -- -- --- -- -- -- --- -- -- -- --- --
286 #define core_move_long_to_r0(target,value) dsp5680xx_exe_generic(target,3,0xe418,value&0xffff,value>>16)
289 #define core_move_long_to_n(target,value) dsp5680xx_exe_generic(target,3,0xe41e,value&0xffff,value>>16)
292 #define core_move_at_r0_to_y0(target) dsp5680xx_exe_generic(target,1,0xF514,0,0)
295 #define core_move_at_r0_to_y1(target) dsp5680xx_exe_generic(target,1,0xF714,0,0)
298 #define core_move_long_at_r0_y(target) dsp5680xx_exe_generic(target,1,0xF734,0,0)
301 #define core_move_y0_at_r0(target) dsp5680xx_exe_generic(target,1,0xd514,0,0)
303 /// bfclr #value,x:(r0)
304 #define eonce_bfclr_at_r0(target,value) dsp5680xx_exe_generic(target,2,0x8040,value,0)
307 #define core_move_value_to_y0(target,value) dsp5680xx_exe_generic(target,2,0x8745,value,0)
309 /// move.w y0,x:(r0)+
310 #define core_move_y0_at_r0_inc(target) dsp5680xx_exe_generic(target,1,0xd500,0,0)
312 /// move.w y0,p:(r0)+
313 #define core_move_y0_at_pr0_inc(target) dsp5680xx_exe_generic(target,1,0x8560,0,0)
315 /// move.w p:(r0)+,y0
316 #define core_move_at_pr0_inc_to_y0(target) dsp5680xx_exe_generic(target,1,0x8568,0,0)
318 /// move.w p:(r0)+,y1
319 #define core_move_at_pr0_inc_to_y1(target) dsp5680xx_exe_generic(target,1,0x8768,0,0)
322 #define core_move_long_to_r2(target,value) dsp5680xx_exe_generic(target,3,0xe41A,value&0xffff,value>>16)
325 #define core_move_y0_at_r2(target) dsp5680xx_exe_generic(target,1,0xd516,0,0)
327 /// move.w #<value>,x:(r2)
328 #define core_move_value_at_r2(target,value) dsp5680xx_exe_generic(target,2,0x8642,value,0)
330 /// move.w #<value>,x:(r0)
331 #define core_move_value_at_r0(target,value) dsp5680xx_exe_generic(target,2,0x8640,value,0)
333 /// move.w #<value>,x:(R2+<disp>)
334 #define core_move_value_at_r2_disp(target,value,disp) dsp5680xx_exe_generic(target,3,0x8646,value,disp)
337 #define core_move_at_r2_to_y0(target) dsp5680xx_exe_generic(target,1,0xF516,0,0)
339 /// move.w p:(r2)+,y0
340 #define core_move_at_pr2_inc_to_y0(target) dsp5680xx_exe_generic(target,1,0x856A,0,0)
343 #define core_move_long_to_r1(target,value) dsp5680xx_exe_generic(target,3,0xE419,value&0xffff,value>>16)
346 #define core_move_long_to_r3(target,value) dsp5680xx_exe_generic(target,3,0xE41B,value&0xffff,value>>16)
348 /// move.w y0,p:(r3)+
349 #define core_move_y0_at_pr3_inc(target) dsp5680xx_exe_generic(target,1,0x8563,0,0)
352 #define core_move_y0_at_r3(target) dsp5680xx_exe_generic(target,1,0xD503,0,0)
355 #define core_move_long_to_r4(target,value) dsp5680xx_exe_generic(target,3,0xE41C,value&0xffff,value>>16)
358 #define core_move_pc_to_r4(target) dsp5680xx_exe_generic(target,1,0xE716,0,0)
361 #define core_move_r4_to_y(target) dsp5680xx_exe_generic(target,1,0xe764,0,0)
363 /// move.w p:(r0)+,y0
364 #define core_move_at_pr0_inc_to_y0(target) dsp5680xx_exe_generic(target,1,0x8568,0,0)
366 /// move.w x:(r0)+,y0
367 #define core_move_at_r0_inc_to_y0(target) dsp5680xx_exe_generic(target,1,0xf500,0,0)
370 #define core_move_at_r0_y0(target) dsp5680xx_exe_generic(target,1,0xF514,0,0)
373 #define eonce_nop(target) dsp5680xx_exe_generic(target,1,0xe700,0,0)
375 /// move.w x:(R2+<disp>),Y0
376 #define core_move_at_r2_disp_to_y0(target,disp) dsp5680xx_exe_generic(target,2,0xF542,disp,0)
379 #define core_move_y1_at_r2(target) dsp5680xx_exe_generic(target,1,0xd716,0,0)
382 #define core_move_y1_at_r0(target) dsp5680xx_exe_generic(target,1,0xd714,0,0)
384 /// move.bp y0,x:(r0)+
385 #define core_move_byte_y0_at_r0(target) dsp5680xx_exe_generic(target,1,0xd5a0,0,0)
387 /// move.w y1,p:(r0)+
388 #define core_move_y1_at_pr0_inc(target) dsp5680xx_exe_generic(target,1,0x8760,0,0)
390 /// move.w y1,x:(r0)+
391 #define core_move_y1_at_r0_inc(target) dsp5680xx_exe_generic(target,1,0xD700,0,0)
394 #define core_move_long_to_y(target,value) dsp5680xx_exe_generic(target,3,0xe417,value&0xffff,value>>16)
396 static int core_move_value_to_pc(struct target
* target
, uint32_t value
){
397 if (!(target
->state
== TARGET_HALTED
)){
398 LOG_ERROR("Target must be halted to move PC. Target state = %d.",target
->state
);
399 return ERROR_TARGET_NOT_HALTED
;
402 retval
= dsp5680xx_exe_generic(target
,3,0xE71E,value
&0xffff,value
>>16);
403 err_check_propagate(retval
);
407 static int eonce_load_TX_RX_to_r0(struct target
* target
)
410 retval
= core_move_long_to_r0(target
,((MC568013_EONCE_TX_RX_ADDR
)+(MC568013_EONCE_OBASE_ADDR
<<16)));
414 static int core_load_TX_RX_high_addr_to_r0(struct target
* target
)
417 retval
= core_move_long_to_r0(target
,((MC568013_EONCE_TX1_RX1_HIGH_ADDR
)+(MC568013_EONCE_OBASE_ADDR
<<16)));
421 static int dsp5680xx_read_core_reg(struct target
* target
, uint8_t reg_addr
, uint16_t * data_read
)
423 //TODO implement a general version of this which matches what openocd uses.
425 uint32_t dummy_data_to_shift_into_dr
;
426 retval
= eonce_instruction_exec_single(target
,reg_addr
,1,0,0,NULL
);
427 err_check_propagate(retval
);
428 retval
= dsp5680xx_drscan(target
,(uint8_t *)& dummy_data_to_shift_into_dr
,(uint8_t *) data_read
, 8);
429 err_check_propagate(retval
);
430 LOG_DEBUG("Reg. data: 0x%02X.",*data_read
);
434 static int eonce_read_status_reg(struct target
* target
, uint16_t * data
){
436 retval
= dsp5680xx_read_core_reg(target
,DSP5680XX_ONCE_OSR
,data
);
437 err_check_propagate(retval
);
442 * Takes the core out of debug mode.
445 * @param eonce_status Data read from the EOnCE status register.
449 static int eonce_exit_debug_mode(struct target
* target
,uint8_t * eonce_status
){
451 retval
= eonce_instruction_exec_single(target
,0x1F,0,0,1,eonce_status
);
452 err_check_propagate(retval
);
456 static int switch_tap(struct target
* target
, struct jtag_tap
* master_tap
,struct jtag_tap
* core_tap
){
457 int retval
= ERROR_OK
;
459 uint32_t ir_out
;//not used, just to make jtag happy.
460 if(master_tap
== NULL
){
461 master_tap
= jtag_tap_by_string("dsp568013.chp");
462 if(master_tap
== NULL
){
464 err_check(retval
, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER
, "Failed to get master tap.");
467 if(core_tap
== NULL
){
468 core_tap
= jtag_tap_by_string("dsp568013.cpu");
469 if(core_tap
== NULL
){
471 err_check(retval
, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE
, "Failed to get core tap.");
475 if(!(((int)master_tap
->enabled
) ^ ((int)core_tap
->enabled
))){
476 LOG_WARNING("Wrong tap enabled/disabled status:\nMaster tap:%d\nCore Tap:%d\nOnly one tap should be enabled at a given time.\n",(int)master_tap
->enabled
,(int)core_tap
->enabled
);
479 if(master_tap
->enabled
){
481 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_MASTER_TAP_IRLEN
);
482 err_check_propagate(retval
);
484 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & ir_out
,4);
485 err_check_propagate(retval
);
486 core_tap
->enabled
= true;
487 master_tap
->enabled
= false;
490 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
491 err_check_propagate(retval
);
493 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & ir_out
,4);
494 err_check_propagate(retval
);
495 core_tap
->enabled
= false;
496 master_tap
->enabled
= true;
502 * Puts the core into debug mode, enabling the EOnCE module.
503 * This will not always work, eonce_enter_debug_mode executes much
504 * more complicated routine, which is guaranteed to work, but requires
505 * a reset. This will complicate comm with the flash module, since
506 * after a reset clock divisors must be set again.
507 * This implementation works most of the time, and is not accesible to the
511 * @param eonce_status Data read from the EOnCE status register.
515 static int eonce_enter_debug_mode_without_reset(struct target
* target
, uint16_t * eonce_status
){
517 uint32_t instr
= JTAG_INSTR_DEBUG_REQUEST
;
518 uint32_t ir_out
;//not used, just to make jtag happy.
520 retval
= dsp5680xx_irscan(target
,& instr
,& ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
521 err_check_propagate(retval
);
523 // Enable EOnCE module
524 instr
= JTAG_INSTR_ENABLE_ONCE
;
525 //Two rounds of jtag 0x6 (enable eonce) to enable EOnCE.
526 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
527 err_check_propagate(retval
);
528 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
529 err_check_propagate(retval
);
530 // Verify that debug mode is enabled
531 uint16_t data_read_from_dr
;
532 retval
= eonce_read_status_reg(target
,&data_read_from_dr
);
533 err_check_propagate(retval
);
534 if((data_read_from_dr
&0x30) == 0x30){
535 LOG_DEBUG("EOnCE successfully entered debug mode.");
536 target
->state
= TARGET_HALTED
;
539 retval
= ERROR_TARGET_FAILURE
;
541 * No error msg here, since there is still hope with full halting sequence
543 err_check_propagate(retval
);
545 if(eonce_status
!=NULL
)
546 *eonce_status
= data_read_from_dr
;
550 #define TIME_DIV_FREESCALE 0.3
552 * Puts the core into debug mode, enabling the EOnCE module.
555 * @param eonce_status Data read from the EOnCE status register.
559 static int eonce_enter_debug_mode(struct target
* target
, uint16_t * eonce_status
){
560 int retval
= ERROR_OK
;
561 uint32_t instr
= JTAG_INSTR_DEBUG_REQUEST
;
562 uint32_t ir_out
;//not used, just to make jtag happy.
566 // First try the easy way
567 retval
= eonce_enter_debug_mode_without_reset(target
,eonce_status
);
568 if(retval
== ERROR_OK
)
571 struct jtag_tap
* tap_chp
;
572 struct jtag_tap
* tap_cpu
;
573 tap_chp
= jtag_tap_by_string("dsp568013.chp");
576 err_check(retval
, DSP5680XX_ERROR_JTAG_TAP_FIND_MASTER
, "Failed to get master tap.");
578 tap_cpu
= jtag_tap_by_string("dsp568013.cpu");
581 err_check(retval
, DSP5680XX_ERROR_JTAG_TAP_FIND_CORE
, "Failed to get master tap.");
585 tap_chp
->enabled
= true;
586 tap_cpu
->enabled
= false;
588 instr
= MASTER_TAP_CMD_IDCODE
;
589 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_MASTER_TAP_IRLEN
);
590 err_check_propagate(retval
);
591 jtag_add_sleep(TIME_DIV_FREESCALE
*100*1000);
593 // Enable EOnCE module
595 jtag_add_sleep(TIME_DIV_FREESCALE
*200*1000);
596 instr
= 0x0606ffff;// This was selected experimentally.
597 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & ir_out
,32);
598 err_check_propagate(retval
);
599 // ir_out now hold tap idcode
602 tap_chp
->enabled
= true;
603 retval
= switch_tap(target
,tap_chp
,tap_cpu
);
604 err_check_propagate(retval
);
606 instr
= JTAG_INSTR_ENABLE_ONCE
;
607 //Two rounds of jtag 0x6 (enable eonce) to enable EOnCE.
608 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
609 err_check_propagate(retval
);
610 instr
= JTAG_INSTR_DEBUG_REQUEST
;
611 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
612 err_check_propagate(retval
);
614 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr_16
,(uint8_t *) & read_16
,8);
615 err_check_propagate(retval
);
617 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr_16
,(uint8_t *) & read_16
,8);
618 err_check_propagate(retval
);
619 jtag_add_sleep(TIME_DIV_FREESCALE
*100*1000);
621 jtag_add_sleep(TIME_DIV_FREESCALE
*300*1000);
623 instr
= JTAG_INSTR_ENABLE_ONCE
;
624 //Two rounds of jtag 0x6 (enable eonce) to enable EOnCE.
625 for(int i
= 0; i
<3; i
++){
626 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
627 err_check_propagate(retval
);
630 for(int i
= 0; i
<3; i
++){
632 dsp5680xx_drscan(target
,(uint8_t *) & instr_16
,(uint8_t *) & read_16
,16);
634 dsp5680xx_drscan(target
,(uint8_t *) & instr_16
,(uint8_t *) & read_16
,16);
637 // Verify that debug mode is enabled
638 uint16_t data_read_from_dr
;
639 retval
= eonce_read_status_reg(target
,&data_read_from_dr
);
640 err_check_propagate(retval
);
641 if((data_read_from_dr
&0x30) == 0x30){
642 LOG_DEBUG("EOnCE successfully entered debug mode.");
643 target
->state
= TARGET_HALTED
;
646 const char *msg
= "Failed to set EOnCE module to debug mode";
647 retval
= ERROR_TARGET_FAILURE
;
648 err_check(retval
, DSP5680XX_ERROR_ENTER_DEBUG_MODE
, msg
);
650 if(eonce_status
!=NULL
)
651 *eonce_status
= data_read_from_dr
;
656 * Reads the current value of the program counter and stores it.
662 static int eonce_pc_store(struct target
* target
){
665 retval
= core_move_pc_to_r4(target
);
666 err_check_propagate(retval
);
667 retval
= core_move_r4_to_y(target
);
668 err_check_propagate(retval
);
669 retval
= eonce_load_TX_RX_to_r0(target
);
670 err_check_propagate(retval
);
671 retval
= core_move_y0_at_r0(target
);
672 err_check_propagate(retval
);
673 retval
= core_rx_lower_data(target
,tmp
);
674 err_check_propagate(retval
);
675 LOG_USER("PC value: 0x%X%X\n",tmp
[1],tmp
[0]);
676 dsp5680xx_context
.stored_pc
= (tmp
[0]|(tmp
[1]<<8));
680 static int dsp5680xx_target_create(struct target
*target
, Jim_Interp
* interp
){
681 struct dsp5680xx_common
*dsp5680xx
= calloc(1, sizeof(struct dsp5680xx_common
));
682 target
->arch_info
= dsp5680xx
;
686 static int dsp5680xx_init_target(struct command_context
*cmd_ctx
, struct target
*target
){
687 dsp5680xx_context
.stored_pc
= 0;
688 dsp5680xx_context
.flush
= 1;
689 LOG_DEBUG("target initiated!");
690 //TODO core tap must be enabled before running these commands, currently this is done in the .cfg tcl script.
694 static int dsp5680xx_arch_state(struct target
*target
){
695 LOG_USER("%s not implemented yet.",__FUNCTION__
);
699 int dsp5680xx_target_status(struct target
* target
, uint8_t * jtag_st
, uint16_t * eonce_st
){
700 return target
->state
;
703 static int dsp5680xx_assert_reset(struct target
*target
){
704 target
->state
= TARGET_RESET
;
708 static int dsp5680xx_deassert_reset(struct target
*target
){
709 target
->state
= TARGET_RUNNING
;
713 static int dsp5680xx_halt(struct target
*target
){
715 uint16_t eonce_status
= 0xbeef;
716 if(target
->state
== TARGET_HALTED
){
717 LOG_USER("Target already halted.");
720 retval
= eonce_enter_debug_mode(target
,&eonce_status
);
721 err_check_propagate(retval
);
722 retval
= eonce_pc_store(target
);
723 err_check_propagate(retval
);
724 //TODO is it useful to store the pc?
728 static int dsp5680xx_poll(struct target
*target
){
731 uint8_t eonce_status
;
733 retval
= dsp5680xx_jtag_status(target
,&jtag_status
);
734 err_check_propagate(retval
);
735 if (jtag_status
== JTAG_STATUS_DEBUG
)
736 if (target
->state
!= TARGET_HALTED
){
737 retval
= eonce_enter_debug_mode(target
,&read_tmp
);
738 err_check_propagate(retval
);
739 eonce_status
= (uint8_t) read_tmp
;
740 if((eonce_status
&EONCE_STAT_MASK
) != DSP5680XX_ONCE_OSCR_DEBUG_M
){
741 LOG_WARNING("%s: Failed to put EOnCE in debug mode. Is flash locked?...",__FUNCTION__
);
742 return ERROR_TARGET_FAILURE
;
744 target
->state
= TARGET_HALTED
;
748 if (jtag_status
== JTAG_STATUS_NORMAL
){
749 if(target
->state
== TARGET_RESET
){
750 retval
= dsp5680xx_halt(target
);
751 err_check_propagate(retval
);
752 retval
= eonce_exit_debug_mode(target
,&eonce_status
);
753 err_check_propagate(retval
);
754 if((eonce_status
&EONCE_STAT_MASK
) != DSP5680XX_ONCE_OSCR_NORMAL_M
){
755 LOG_WARNING("%s: JTAG running, but cannot make EOnCE run. Try resetting...",__FUNCTION__
);
756 return ERROR_TARGET_FAILURE
;
758 target
->state
= TARGET_RUNNING
;
762 if(target
->state
!= TARGET_RUNNING
){
763 retval
= eonce_read_status_reg(target
,&read_tmp
);
764 err_check_propagate(retval
);
765 eonce_status
= (uint8_t) read_tmp
;
766 if((eonce_status
&EONCE_STAT_MASK
) != DSP5680XX_ONCE_OSCR_NORMAL_M
){
767 LOG_WARNING("Inconsistent target status. Restart!");
768 return ERROR_TARGET_FAILURE
;
771 target
->state
= TARGET_RUNNING
;
774 if(jtag_status
== JTAG_STATUS_DEAD
){
775 LOG_ERROR("%s: Cannot communicate with JTAG. Check connection...",__FUNCTION__
);
776 target
->state
= TARGET_UNKNOWN
;
777 return ERROR_TARGET_FAILURE
;
779 if (target
->state
== TARGET_UNKNOWN
){
780 LOG_ERROR("%s: Target status invalid - communication failure",__FUNCTION__
);
781 return ERROR_TARGET_FAILURE
;
786 static int dsp5680xx_resume(struct target
*target
, int current
, uint32_t address
,int handle_breakpoints
, int debug_execution
){
787 if(target
->state
== TARGET_RUNNING
){
788 LOG_USER("Target already running.");
792 uint8_t eonce_status
;
794 retval
= core_move_value_to_pc(target
,address
);
795 err_check_propagate(retval
);
800 retval
= eonce_exit_debug_mode(target
,&eonce_status
);
801 err_check_propagate(retval
);
802 if(eonce_status
== DSP5680XX_ONCE_OSCR_NORMAL_M
)
806 retval
= ERROR_TARGET_FAILURE
;
807 err_check(retval
, DSP5680XX_ERROR_RESUME
, "Failed to resume...");
809 target
->state
= TARGET_RUNNING
;
811 LOG_DEBUG("EOnCE status: 0x%02X.",eonce_status
);
821 * The value of @address determines if it corresponds to P: (program) or X: (data) memory. If the address is over 0x200000 then it is considered X: memory, and @pmem = 0.
822 * The special case of 0xFFXXXX is not modified, since it allows to read out the memory mapped EOnCE registers.
829 static int dsp5680xx_convert_address(uint32_t * address
, int * pmem
){
830 // Distinguish data memory (x:) from program memory (p:) by the address.
831 // Addresses over S_FILE_DATA_OFFSET are considered (x:) memory.
832 if(*address
>= S_FILE_DATA_OFFSET
){
834 if(((*address
)&0xff0000)!=0xff0000)
835 *address
-= S_FILE_DATA_OFFSET
;
840 static int dsp5680xx_read_16_single(struct target
* target
, uint32_t address
, uint8_t * data_read
, int r_pmem
){
842 retval
= core_move_long_to_r0(target
,address
);
843 err_check_propagate(retval
);
845 retval
= core_move_at_pr0_inc_to_y0(target
);
847 retval
= core_move_at_r0_to_y0(target
);
848 err_check_propagate(retval
);
849 retval
= eonce_load_TX_RX_to_r0(target
);
850 err_check_propagate(retval
);
851 retval
= core_move_y0_at_r0(target
);
852 err_check_propagate(retval
);
853 // at this point the data i want is at the reg eonce can read
854 retval
= core_rx_lower_data(target
,data_read
);
855 err_check_propagate(retval
);
856 LOG_DEBUG("%s: Data read from 0x%06X: 0x%02X%02X",__FUNCTION__
, address
,data_read
[1],data_read
[0]);
860 static int dsp5680xx_read_32_single(struct target
* target
, uint32_t address
, uint8_t * data_read
, int r_pmem
){
862 address
= (address
& 0xFFFFFE);
863 // Get data to an intermediate register
864 retval
= core_move_long_to_r0(target
,address
);
865 err_check_propagate(retval
);
867 retval
= core_move_at_pr0_inc_to_y0(target
);
868 err_check_propagate(retval
);
869 retval
= core_move_at_pr0_inc_to_y1(target
);
870 err_check_propagate(retval
);
872 retval
= core_move_at_r0_inc_to_y0(target
);
873 err_check_propagate(retval
);
874 retval
= core_move_at_r0_to_y1(target
);
875 err_check_propagate(retval
);
877 // Get lower part of data to TX/RX
878 retval
= eonce_load_TX_RX_to_r0(target
);
879 err_check_propagate(retval
);
880 retval
= core_move_y0_at_r0_inc(target
); // This also load TX/RX high to r0
881 err_check_propagate(retval
);
882 // Get upper part of data to TX/RX
883 retval
= core_move_y1_at_r0(target
);
884 err_check_propagate(retval
);
885 // at this point the data i want is at the reg eonce can read
886 retval
= core_rx_lower_data(target
,data_read
);
887 err_check_propagate(retval
);
888 retval
= core_rx_upper_data(target
,data_read
+2);
889 err_check_propagate(retval
);
893 static int dsp5680xx_read(struct target
* target
, uint32_t address
, unsigned size
, unsigned count
, uint8_t * buffer
){
894 if(target
->state
!= TARGET_HALTED
){
895 LOG_USER("Target must be halted.");
898 int retval
= ERROR_OK
;
901 retval
= dsp5680xx_convert_address(&address
, &pmem
);
902 err_check_propagate(retval
);
904 dsp5680xx_context
.flush
= 0;
905 int counter
= FLUSH_COUNT_READ_WRITE
;
907 for (unsigned i
=0; i
<count
; i
++){
909 dsp5680xx_context
.flush
= 1;
910 counter
= FLUSH_COUNT_READ_WRITE
;
915 retval
= dsp5680xx_read_16_single(target
, address
+ i
/2, buffer
+ i
, pmem
);
919 retval
= dsp5680xx_read_16_single(target
, address
+ i
, buffer
+2*i
, pmem
);
922 retval
= dsp5680xx_read_32_single(target
, address
+ 2*i
, buffer
+ 4*i
, pmem
);
925 LOG_USER("%s: Invalid read size.",__FUNCTION__
);
928 err_check_propagate(retval
);
929 dsp5680xx_context
.flush
= 0;
932 dsp5680xx_context
.flush
= 1;
933 retval
= dsp5680xx_execute_queue();
934 err_check_propagate(retval
);
939 static int dsp5680xx_write_16_single(struct target
*target
, uint32_t address
, uint16_t data
, uint8_t w_pmem
){
941 retval
= core_move_long_to_r0(target
,address
);
942 err_check_propagate(retval
);
944 retval
= core_move_value_to_y0(target
,data
);
945 err_check_propagate(retval
);
946 retval
= core_move_y0_at_pr0_inc(target
);
947 err_check_propagate(retval
);
949 retval
= core_move_value_at_r0(target
,data
);
950 err_check_propagate(retval
);
955 static int dsp5680xx_write_32_single(struct target
*target
, uint32_t address
, uint32_t data
, int w_pmem
){
957 retval
= core_move_long_to_r0(target
,address
);
958 err_check_propagate(retval
);
959 retval
= core_move_long_to_y(target
,data
);
960 err_check_propagate(retval
);
962 retval
= core_move_y0_at_pr0_inc(target
);
964 retval
= core_move_y0_at_r0_inc(target
);
965 err_check_propagate(retval
);
967 retval
= core_move_y1_at_pr0_inc(target
);
969 retval
= core_move_y1_at_r0_inc(target
);
970 err_check_propagate(retval
);
974 static int dsp5680xx_write_8(struct target
* target
, uint32_t address
, uint32_t count
, const uint8_t * data
, int pmem
){
975 if(target
->state
!= TARGET_HALTED
){
976 LOG_ERROR("%s: Target must be halted.",__FUNCTION__
);
983 int counter
= FLUSH_COUNT_READ_WRITE
;
984 for(iter
= 0; iter
<count
/2; iter
++){
986 dsp5680xx_context
.flush
= 1;
987 counter
= FLUSH_COUNT_READ_WRITE
;
989 data_16
=(data
[2*iter
]|(data
[2*iter
+1]<<8));
990 retval
= dsp5680xx_write_16_single(target
,address
+iter
,data_16
, pmem
);
991 if(retval
!= ERROR_OK
){
992 LOG_ERROR("%s: Could not write to p:0x%04X",__FUNCTION__
,address
);
993 dsp5680xx_context
.flush
= 1;
996 dsp5680xx_context
.flush
= 0;
998 dsp5680xx_context
.flush
= 1;
1000 // Only one byte left, let's not overwrite the other byte (mem is 16bit)
1001 // Need to retrieve the part we do not want to overwrite.
1003 if((count
==1)||(count
%2)){
1004 retval
= dsp5680xx_read(target
,address
+iter
,1,1,(uint8_t *)&data_old
);
1005 err_check_propagate(retval
);
1007 data_old
=(((data_old
&0xff)<<8)|data
[0]);// preserve upper byte
1009 data_old
=(((data_old
&0xff)<<8)|data
[2*iter
+1]);
1010 retval
= dsp5680xx_write_16_single(target
,address
+iter
,data_old
, pmem
);
1011 err_check_propagate(retval
);
1016 static int dsp5680xx_write_16(struct target
* target
, uint32_t address
, uint32_t count
, const uint8_t * data
, int pmem
){
1017 int retval
= ERROR_OK
;
1018 if(target
->state
!= TARGET_HALTED
){
1019 retval
= ERROR_TARGET_NOT_HALTED
;
1020 err_check(retval
, DSP5680XX_ERROR_WRITE_WITH_TARGET_RUNNING
, "Target must be halted.");
1023 int counter
= FLUSH_COUNT_READ_WRITE
;
1025 for(iter
= 0; iter
<count
; iter
++){
1027 dsp5680xx_context
.flush
= 1;
1028 counter
= FLUSH_COUNT_READ_WRITE
;
1030 retval
= dsp5680xx_write_16_single(target
,address
+iter
,data
[iter
], pmem
);
1031 if(retval
!= ERROR_OK
){
1032 LOG_ERROR("%s: Could not write to p:0x%04X",__FUNCTION__
,address
);
1033 dsp5680xx_context
.flush
= 1;
1036 dsp5680xx_context
.flush
= 0;
1038 dsp5680xx_context
.flush
= 1;
1042 static int dsp5680xx_write_32(struct target
* target
, uint32_t address
, uint32_t count
, const uint8_t * data
, int pmem
){
1043 int retval
= ERROR_OK
;
1044 if(target
->state
!= TARGET_HALTED
){
1045 retval
= ERROR_TARGET_NOT_HALTED
;
1046 err_check(retval
, DSP5680XX_ERROR_WRITE_WITH_TARGET_RUNNING
, "Target must be halted.");
1049 int counter
= FLUSH_COUNT_READ_WRITE
;
1051 for(iter
= 0; iter
<count
; iter
++){
1053 dsp5680xx_context
.flush
= 1;
1054 counter
= FLUSH_COUNT_READ_WRITE
;
1056 retval
= dsp5680xx_write_32_single(target
,address
+(iter
<<1),data
[iter
], pmem
);
1057 if(retval
!= ERROR_OK
){
1058 LOG_ERROR("%s: Could not write to p:0x%04X",__FUNCTION__
,address
);
1059 dsp5680xx_context
.flush
= 1;
1062 dsp5680xx_context
.flush
= 0;
1064 dsp5680xx_context
.flush
= 1;
1069 * Writes @buffer to memory.
1070 * The parameter @address determines whether @buffer should be written to P: (program) memory or X: (data) memory.
1074 * @param size Bytes (1), Half words (2), Words (4).
1075 * @param count In bytes.
1080 static int dsp5680xx_write(struct target
*target
, uint32_t address
, uint32_t size
, uint32_t count
, const uint8_t * buffer
){
1081 //TODO Cannot write 32bit to odd address, will write 0x12345678 as 0x5678 0x0012
1082 if(target
->state
!= TARGET_HALTED
){
1083 err_check(ERROR_FAIL
, DSP5680XX_ERROR_WRITE_WITH_TARGET_RUNNING
, "Target must be halted.");
1087 retval
= dsp5680xx_convert_address(&address
, &p_mem
);
1088 err_check_propagate(retval
);
1092 retval
= dsp5680xx_write_8(target
, address
, count
, buffer
, p_mem
);
1095 retval
= dsp5680xx_write_16(target
, address
, count
, buffer
, p_mem
);
1098 retval
= dsp5680xx_write_32(target
, address
, count
, buffer
, p_mem
);
1101 retval
= ERROR_TARGET_DATA_ABORT
;
1102 err_check(retval
, DSP5680XX_ERROR_INVALID_DATA_SIZE_UNIT
, "Invalid data size.");
1108 static int dsp5680xx_bulk_write_memory(struct target
* target
,uint32_t address
, uint32_t aligned
, const uint8_t * buffer
){
1109 LOG_ERROR("Not implemented yet.");
1113 static int dsp5680xx_write_buffer(struct target
* target
, uint32_t address
, uint32_t size
, const uint8_t * buffer
){
1114 if(target
->state
!= TARGET_HALTED
){
1115 LOG_USER("Target must be halted.");
1118 return dsp5680xx_write(target
, address
, 1, size
, buffer
);
1122 * This function is called by verify_image, it is used to read data from memory.
1125 * @param address Word addressing.
1126 * @param size In bytes.
1131 static int dsp5680xx_read_buffer(struct target
* target
, uint32_t address
, uint32_t size
, uint8_t * buffer
){
1132 if(target
->state
!= TARGET_HALTED
){
1133 LOG_USER("Target must be halted.");
1136 // The "/2" solves the byte/word addressing issue.
1137 return dsp5680xx_read(target
,address
,2,size
/2,buffer
);
1141 * This function is not implemented.
1142 * It returns an error in order to get OpenOCD to do read out the data and calculate the CRC, or try a binary comparison.
1145 * @param address Start address of the image.
1146 * @param size In bytes.
1151 static int dsp5680xx_checksum_memory(struct target
* target
, uint32_t address
, uint32_t size
, uint32_t * checksum
){
1156 * Calculates a signature over @word_count words in the data from @buff16. The algorithm used is the same the FM uses, so the @return may be used to compare with the one generated by the FM module, and check if flashing was successful.
1157 * This algorithm is based on the perl script available from the Freescale website at FAQ 25630.
1164 static int perl_crc(uint8_t * buff8
,uint32_t word_count
){
1165 uint16_t checksum
= 0xffff;
1166 uint16_t data
,fbmisr
;
1168 for(i
=0;i
<word_count
;i
++){
1169 data
= (buff8
[2*i
]|(buff8
[2*i
+1]<<8));
1170 fbmisr
= (checksum
& 2)>>1 ^ (checksum
& 4)>>2 ^ (checksum
& 16)>>4 ^ (checksum
& 0x8000)>>15;
1171 checksum
= (data
^ ((checksum
<< 1) | fbmisr
));
1174 for(;!(i
&0x80000000);i
--){
1175 data
= (buff8
[2*i
]|(buff8
[2*i
+1]<<8));
1176 fbmisr
= (checksum
& 2)>>1 ^ (checksum
& 4)>>2 ^ (checksum
& 16)>>4 ^ (checksum
& 0x8000)>>15;
1177 checksum
= (data
^ ((checksum
<< 1) | fbmisr
));
1183 * Resets the SIM. (System Integration Module).
1189 int dsp5680xx_f_SIM_reset(struct target
* target
){
1190 int retval
= ERROR_OK
;
1191 uint16_t sim_cmd
= SIM_CMD_RESET
;
1193 if(strcmp(target
->tap
->chip
,"dsp568013")==0){
1194 sim_addr
= MC568013_SIM_BASE_ADDR
+S_FILE_DATA_OFFSET
;
1195 retval
= dsp5680xx_write(target
,sim_addr
,1,2,(const uint8_t *)&sim_cmd
);
1196 err_check_propagate(retval
);
1202 * Halts the core and resets the SIM. (System Integration Module).
1208 static int dsp5680xx_soft_reset_halt(struct target
*target
){
1209 //TODO is this what this function is expected to do...?
1211 retval
= dsp5680xx_halt(target
);
1212 err_check_propagate(retval
);
1213 retval
= dsp5680xx_f_SIM_reset(target
);
1214 err_check_propagate(retval
);
1218 int dsp5680xx_f_protect_check(struct target
* target
, uint16_t * protected) {
1220 if (dsp5680xx_target_status(target
,NULL
,NULL
) != TARGET_HALTED
){
1221 retval
= dsp5680xx_halt(target
);
1222 err_check_propagate(retval
);
1224 if(protected == NULL
){
1225 const char *msg
= "NULL pointer not valid.";
1226 err_check(ERROR_FAIL
, DSP5680XX_ERROR_PROTECT_CHECK_INVALID_ARGS
, msg
);
1228 retval
= dsp5680xx_read_16_single(target
,HFM_BASE_ADDR
|HFM_PROT
,(uint8_t *)protected,0);
1229 err_check_propagate(retval
);
1234 * Executes a command on the FM module. Some commands use the parameters @address and @data, others ignore them.
1237 * @param command Command to execute.
1238 * @param address Command parameter.
1239 * @param data Command parameter.
1240 * @param hfm_ustat FM status register.
1241 * @param pmem Address is P: (program) memory (@pmem==1) or X: (data) memory (@pmem==0)
1245 static int dsp5680xx_f_execute_command(struct target
* target
, uint16_t command
, uint32_t address
, uint32_t data
, uint16_t * hfm_ustat
, int pmem
){
1247 retval
= core_load_TX_RX_high_addr_to_r0(target
);
1248 err_check_propagate(retval
);
1249 retval
= core_move_long_to_r2(target
,HFM_BASE_ADDR
);
1250 err_check_propagate(retval
);
1254 retval
= core_move_at_r2_disp_to_y0(target
,HFM_USTAT
); // read HMF_USTAT
1255 err_check_propagate(retval
);
1256 retval
= core_move_y0_at_r0(target
);
1257 err_check_propagate(retval
);
1258 retval
= core_rx_upper_data(target
,i
);
1259 err_check_propagate(retval
);
1260 if((watchdog
--)==1){
1261 retval
= ERROR_TARGET_FAILURE
;
1262 const char *msg
= "Timed out waiting for FM to finish old command.";
1263 err_check(retval
, DSP5680XX_ERROR_FM_BUSY
, msg
);
1265 }while (!(i
[0]&0x40)); // wait until current command is complete
1267 dsp5680xx_context
.flush
= 0;
1269 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 ???
1270 err_check_propagate(retval
);
1271 retval
= core_move_value_at_r2_disp(target
,0x04,HFM_USTAT
); // write to HMF_USTAT, clear PVIOL, ACCERR & BLANK bits
1272 err_check_propagate(retval
);
1273 retval
= core_move_value_at_r2_disp(target
,0x10,HFM_USTAT
); // clear only one bit at a time
1274 err_check_propagate(retval
);
1275 retval
= core_move_value_at_r2_disp(target
,0x20,HFM_USTAT
);
1276 err_check_propagate(retval
);
1277 retval
= core_move_value_at_r2_disp(target
,0x00,HFM_PROT
); // write to HMF_PROT, clear protection
1278 err_check_propagate(retval
);
1279 retval
= core_move_value_at_r2_disp(target
,0x00,HFM_PROTB
); // write to HMF_PROTB, clear protection
1280 err_check_propagate(retval
);
1281 retval
= core_move_value_to_y0(target
,data
);
1282 err_check_propagate(retval
);
1283 retval
= core_move_long_to_r3(target
,address
); // write to the flash block
1284 err_check_propagate(retval
);
1286 retval
= core_move_y0_at_pr3_inc(target
);
1287 err_check_propagate(retval
);
1289 retval
= core_move_y0_at_r3(target
);
1290 err_check_propagate(retval
);
1292 retval
= core_move_value_at_r2_disp(target
,command
,HFM_CMD
); // write command to the HFM_CMD reg
1293 err_check_propagate(retval
);
1294 retval
= core_move_value_at_r2_disp(target
,0x80,HFM_USTAT
); // start the command
1295 err_check_propagate(retval
);
1297 dsp5680xx_context
.flush
= 1;
1298 retval
= dsp5680xx_execute_queue();
1299 err_check_propagate(retval
);
1303 retval
= core_move_at_r2_disp_to_y0(target
,HFM_USTAT
); // read HMF_USTAT
1304 err_check_propagate(retval
);
1305 retval
= core_move_y0_at_r0(target
);
1306 err_check_propagate(retval
);
1307 retval
= core_rx_upper_data(target
,i
);
1308 err_check_propagate(retval
);
1309 if((watchdog
--)==1){
1310 retval
= ERROR_TARGET_FAILURE
;
1311 err_check(retval
, DSP5680XX_ERROR_FM_CMD_TIMED_OUT
, "FM execution did not finish.");
1313 }while (!(i
[0]&0x40)); // wait until the command is complete
1314 *hfm_ustat
= ((i
[0]<<8)|(i
[1]));
1315 if (i
[0]&HFM_USTAT_MASK_PVIOL_ACCER
){
1316 retval
= ERROR_TARGET_FAILURE
;
1317 const char *msg
= "pviol and/or accer bits set. HFM command execution error";
1318 err_check(retval
, DSP5680XX_ERROR_FM_EXEC
, msg
);
1324 * Prior to the execution of any Flash module command, the Flash module Clock Divider (CLKDIV) register must be initialized. The values of this register determine the speed of the internal Flash Clock (FCLK). FCLK must be in the range of 150kHz ≤ FCLK ≤ 200kHz for proper operation of the Flash module. (Running FCLK too slowly wears out the module, while running it too fast under programs Flash leading to bit errors.)
1330 static int set_fm_ck_div(struct target
* target
){
1333 retval
= core_move_long_to_r2(target
,HFM_BASE_ADDR
);
1334 err_check_propagate(retval
);
1335 retval
= core_load_TX_RX_high_addr_to_r0(target
);
1336 err_check_propagate(retval
);
1337 retval
= core_move_at_r2_to_y0(target
);// read HFM_CLKD
1338 err_check_propagate(retval
);
1339 retval
= core_move_y0_at_r0(target
);
1340 err_check_propagate(retval
);
1341 retval
= core_rx_upper_data(target
,i
);
1342 err_check_propagate(retval
);
1343 unsigned int hfm_at_wrong_value
= 0;
1344 if ((i
[0]&0x7f)!=HFM_CLK_DEFAULT
) {
1345 LOG_DEBUG("HFM CLK divisor contained incorrect value (0x%02X).",i
[0]&0x7f);
1346 hfm_at_wrong_value
= 1;
1348 LOG_DEBUG("HFM CLK divisor was already set to correct value (0x%02X).",i
[0]&0x7f);
1351 retval
= core_move_value_at_r2(target
,HFM_CLK_DEFAULT
); // write HFM_CLKD
1352 err_check_propagate(retval
);
1353 retval
= core_move_at_r2_to_y0(target
); // verify HFM_CLKD
1354 err_check_propagate(retval
);
1355 retval
= core_move_y0_at_r0(target
);
1356 err_check_propagate(retval
);
1357 retval
= core_rx_upper_data(target
,i
);
1358 err_check_propagate(retval
);
1359 if (i
[0]!=(0x80|(HFM_CLK_DEFAULT
&0x7f))) {
1360 retval
= ERROR_TARGET_FAILURE
;
1361 err_check(retval
, DSP5680XX_ERROR_FM_SET_CLK
, "Unable to set HFM CLK divisor.");
1363 if(hfm_at_wrong_value
)
1364 LOG_DEBUG("HFM CLK divisor set to 0x%02x.",i
[0]&0x7f);
1369 * Executes the FM calculate signature command. The FM will calculate over the data from @address to @address + @words -1. The result is written to a register, then read out by this function and returned in @signature. The value @signature may be compared to the the one returned by perl_crc to verify the flash was written correctly.
1372 * @param address Start of flash array where the signature should be calculated.
1373 * @param words Number of words over which the signature should be calculated.
1374 * @param signature Value calculated by the FM.
1378 static int dsp5680xx_f_signature(struct target
* target
, uint32_t address
, uint32_t words
, uint16_t * signature
){
1381 if (dsp5680xx_target_status(target
,NULL
,NULL
) != TARGET_HALTED
){
1382 retval
= eonce_enter_debug_mode_without_reset(target
,NULL
);
1383 err_check_propagate(retval
);
1385 retval
= dsp5680xx_f_execute_command(target
,HFM_CALCULATE_DATA_SIGNATURE
,address
,words
,&hfm_ustat
,1);
1386 err_check_propagate(retval
);
1387 retval
= dsp5680xx_read_16_single(target
, HFM_BASE_ADDR
|HFM_DATA
, (uint8_t *)signature
, 0);
1391 int dsp5680xx_f_erase_check(struct target
* target
, uint8_t * erased
,uint32_t sector
){
1394 if (dsp5680xx_target_status(target
,NULL
,NULL
) != TARGET_HALTED
){
1395 retval
= dsp5680xx_halt(target
);
1396 err_check_propagate(retval
);
1398 retval
= set_fm_ck_div(target
);
1399 err_check_propagate(retval
);
1400 // Check if chip is already erased.
1401 retval
= dsp5680xx_f_execute_command(target
,HFM_ERASE_VERIFY
,HFM_FLASH_BASE_ADDR
+sector
*HFM_SECTOR_SIZE
/2,0,&hfm_ustat
,1); // blank check
1402 err_check_propagate(retval
);
1404 *erased
= (uint8_t)(hfm_ustat
&HFM_USTAT_MASK_BLANK
);
1409 * Executes the FM page erase command.
1412 * @param sector Page to erase.
1413 * @param hfm_ustat FM module status register.
1417 static int erase_sector(struct target
* target
, int sector
, uint16_t * hfm_ustat
){
1419 retval
= dsp5680xx_f_execute_command(target
,HFM_PAGE_ERASE
,HFM_FLASH_BASE_ADDR
+sector
*HFM_SECTOR_SIZE
/2,0,hfm_ustat
,1);
1420 err_check_propagate(retval
);
1425 * Executes the FM mass erase command. Erases the flash array completely.
1428 * @param hfm_ustat FM module status register.
1432 static int mass_erase(struct target
* target
, uint16_t * hfm_ustat
){
1434 retval
= dsp5680xx_f_execute_command(target
,HFM_MASS_ERASE
,0,0,hfm_ustat
,1);
1438 int dsp5680xx_f_erase(struct target
* target
, int first
, int last
){
1440 if (dsp5680xx_target_status(target
,NULL
,NULL
) != TARGET_HALTED
){
1441 retval
= dsp5680xx_halt(target
);
1442 err_check_propagate(retval
);
1444 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1446 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1447 retval
= dsp5680xx_f_SIM_reset(target
);
1448 err_check_propagate(retval
);
1449 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1451 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1452 retval
= set_fm_ck_div(target
);
1453 err_check_propagate(retval
);
1456 int do_mass_erase
= ((!(first
|last
)) || ((first
==0)&&(last
== (HFM_SECTOR_COUNT
-1))));
1459 retval
= mass_erase(target
,&hfm_ustat
);
1460 err_check_propagate(retval
);
1462 for(int i
= first
;i
<=last
;i
++){
1463 retval
= erase_sector(target
,i
,&hfm_ustat
);
1464 err_check_propagate(retval
);
1471 * Algorithm for programming normal p: flash
1472 * Follow state machine from "56F801x Peripheral Reference Manual"@163.
1473 * Registers to set up before calling:
1474 * r0: TX/RX high address.
1475 * r2: FM module base address.
1476 * r3: Destination address in flash.
1478 * hfm_wait: // wait for command to finish
1479 * brclr #0x40,x:(r2+0x13),hfm_wait
1480 * rx_check: // wait for input buffer full
1481 * brclr #0x01,x:(r0-2),rx_check
1482 * move.w x:(r0),y0 // read from Rx buffer
1484 * move.w #0x20,x:(r2+0x14) // write PGM command
1485 * move.w #0x80,x:(r2+0x13) // start the command
1486 * brclr #0x20,X:(R2+0x13),accerr_check // protection violation check
1487 * bfset #0x20,X:(R2+0x13) // clear pviol
1490 * brclr #0x10,X:(R2+0x13),hfm_wait // access error check
1491 * bfset #0x10,X:(R2+0x13) // clear accerr
1492 * bra hfm_wait // loop
1493 *0x00000073 0x8A460013407D brclr #0x40,X:(R2+0x13),*+0
1494 *0x00000076 0xE700 nop
1495 *0x00000077 0xE700 nop
1496 *0x00000078 0x8A44FFFE017B brclr #1,X:(R0-2),*-2
1497 *0x0000007B 0xE700 nop
1498 *0x0000007C 0xF514 move.w X:(R0),Y0
1499 *0x0000007D 0x8563 move.w Y0,P:(R3)+
1500 *0x0000007E 0x864600200014 move.w #0x20,X:(R2+0x14)
1501 *0x00000081 0x864600800013 move.w #0x80,X:(R2+0x13)
1502 *0x00000084 0x8A4600132004 brclr #0x20,X:(R2+0x13),*+7
1503 *0x00000087 0x824600130020 bfset #0x20,X:(R2+0x13)
1504 *0x0000008A 0xA968 bra *-23
1505 *0x0000008B 0x8A4600131065 brclr #0x10,X:(R2+0x13),*-24
1506 *0x0000008E 0x824600130010 bfset #0x10,X:(R2+0x13)
1507 *0x00000091 0xA961 bra *-30
1509 const uint16_t pgm_write_pflash
[] = {0x8A46,0x0013,0x407D,0xE700,0xE700,0x8A44,0xFFFE,0x017B,0xE700,0xF514,0x8563,0x8646,0x0020,0x0014,0x8646,0x0080,0x0013,0x8A46,0x0013,0x2004,0x8246,0x0013,0x0020,0xA968,0x8A46,0x0013,0x1065,0x8246,0x0013,0x0010,0xA961};
1510 const uint32_t pgm_write_pflash_length
= 31;
1512 int dsp5680xx_f_wr(struct target
* target
, uint8_t *buffer
, uint32_t address
, uint32_t count
, int is_flash_lock
){
1513 int retval
= ERROR_OK
;
1514 if (dsp5680xx_target_status(target
,NULL
,NULL
) != TARGET_HALTED
){
1515 retval
= eonce_enter_debug_mode(target
,NULL
);
1516 err_check_propagate(retval
);
1518 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1519 // Download the pgm that flashes.
1520 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1521 uint32_t my_favourite_ram_address
= 0x8700; // This seems to be a safe address. This one is the one used by codewarrior in 56801x_flash.cfg
1523 retval
= dsp5680xx_write(target
, my_favourite_ram_address
, 1, pgm_write_pflash_length
*2,(uint8_t *) pgm_write_pflash
);
1524 err_check_propagate(retval
);
1525 retval
= dsp5680xx_execute_queue();
1526 err_check_propagate(retval
);
1528 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1530 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1531 retval
= set_fm_ck_div(target
);
1532 err_check_propagate(retval
);
1533 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1534 // Setup registers needed by pgm_write_pflash
1535 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1537 dsp5680xx_context
.flush
= 0;
1539 retval
= core_move_long_to_r3(target
,address
); // Destination address to r3
1540 err_check_propagate(retval
);
1541 core_load_TX_RX_high_addr_to_r0(target
); // TX/RX reg address to r0
1542 err_check_propagate(retval
);
1543 retval
= core_move_long_to_r2(target
,HFM_BASE_ADDR
);// FM base address to r2
1544 err_check_propagate(retval
);
1545 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1546 // Run flashing program.
1547 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1548 retval
= core_move_value_at_r2_disp(target
,0x00,HFM_CNFG
); // write to HFM_CNFG (lock=0, select bank)
1549 err_check_propagate(retval
);
1550 retval
= core_move_value_at_r2_disp(target
,0x04,HFM_USTAT
);// write to HMF_USTAT, clear PVIOL, ACCERR & BLANK bits
1551 err_check_propagate(retval
);
1552 retval
= core_move_value_at_r2_disp(target
,0x10,HFM_USTAT
);// clear only one bit at a time
1553 err_check_propagate(retval
);
1554 retval
= core_move_value_at_r2_disp(target
,0x20,HFM_USTAT
);
1555 err_check_propagate(retval
);
1556 retval
= core_move_value_at_r2_disp(target
,0x00,HFM_PROT
);// write to HMF_PROT, clear protection
1557 err_check_propagate(retval
);
1558 retval
= core_move_value_at_r2_disp(target
,0x00,HFM_PROTB
);// write to HMF_PROTB, clear protection
1559 err_check_propagate(retval
);
1561 //TODO implement handling of odd number of words.
1562 retval
= ERROR_FAIL
;
1563 const char *msg
= "Cannot handle odd number of words.";
1564 err_check(retval
, DSP5680XX_ERROR_FLASHING_INVALID_WORD_COUNT
, msg
);
1567 dsp5680xx_context
.flush
= 1;
1568 retval
= dsp5680xx_execute_queue();
1569 err_check_propagate(retval
);
1571 uint32_t drscan_data
;
1572 uint16_t tmp
= (buffer
[0]|(buffer
[1]<<8));
1573 retval
= core_tx_upper_data(target
,tmp
,&drscan_data
);
1574 err_check_propagate(retval
);
1576 retval
= dsp5680xx_resume(target
,0,my_favourite_ram_address
,0,0);
1577 err_check_propagate(retval
);
1579 int counter
= FLUSH_COUNT_FLASH
;
1580 dsp5680xx_context
.flush
= 0;
1582 for(i
=1; (i
<count
/2)&&(i
<HFM_SIZE_WORDS
); i
++){
1584 dsp5680xx_context
.flush
= 1;
1585 counter
= FLUSH_COUNT_FLASH
;
1587 tmp
= (buffer
[2*i
]|(buffer
[2*i
+1]<<8));
1588 retval
= core_tx_upper_data(target
,tmp
,&drscan_data
);
1589 if(retval
!=ERROR_OK
){
1590 dsp5680xx_context
.flush
= 1;
1591 err_check_propagate(retval
);
1593 dsp5680xx_context
.flush
= 0;
1595 dsp5680xx_context
.flush
= 1;
1597 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1598 // Verify flash (skip when exec lock sequence)
1599 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
1602 retval
= dsp5680xx_f_signature(target
,address
,i
,&signature
);
1603 err_check_propagate(retval
);
1604 pc_crc
= perl_crc(buffer
,i
);
1605 if(pc_crc
!= signature
){
1606 retval
= ERROR_FAIL
;
1607 const char *msg
= "Flashed data failed CRC check, flash again!";
1608 err_check(retval
, DSP5680XX_ERROR_FLASHING_CRC
, msg
);
1614 // Reset state machine
1615 static int reset_jtag(void){
1617 tap_state_t states
[2];
1618 const char *cp
= "RESET";
1619 states
[0] = tap_state_by_name(cp
);
1620 retval
= jtag_add_statemove(states
[0]);
1621 err_check_propagate(retval
);
1622 retval
= jtag_execute_queue();
1623 err_check_propagate(retval
);
1624 jtag_add_pathmove(0, states
+ 1);
1625 retval
= jtag_execute_queue();
1629 int dsp5680xx_f_unlock(struct target
* target
){
1630 int retval
= ERROR_OK
;
1631 uint16_t eonce_status
;
1636 struct jtag_tap
* tap_chp
;
1637 struct jtag_tap
* tap_cpu
;
1638 tap_chp
= jtag_tap_by_string("dsp568013.chp");
1639 if(tap_chp
== NULL
){
1640 retval
= ERROR_FAIL
;
1641 err_check(retval
, DSP5680XX_ERROR_JTAG_TAP_ENABLE_MASTER
, "Failed to get master tap.");
1643 tap_cpu
= jtag_tap_by_string("dsp568013.cpu");
1644 if(tap_cpu
== NULL
){
1645 retval
= ERROR_FAIL
;
1646 err_check(retval
, DSP5680XX_ERROR_JTAG_TAP_ENABLE_CORE
, "Failed to get master tap.");
1649 retval
= eonce_enter_debug_mode(target
,&eonce_status
);
1650 if(retval
== ERROR_OK
){
1651 LOG_WARNING("Memory was not locked.");
1654 jtag_add_reset(0,1);
1655 jtag_add_sleep(TIME_DIV_FREESCALE
*200*1000);
1657 retval
= reset_jtag();
1658 err_check(retval
, DSP5680XX_ERROR_JTAG_RESET
, "Failed to reset JTAG state machine");
1659 jtag_add_sleep(150);
1662 tap_chp
->enabled
= true;
1663 retval
= switch_tap(target
,tap_chp
,tap_cpu
);
1664 err_check_propagate(retval
);
1666 instr
= JTAG_INSTR_DEBUG_REQUEST
;
1667 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
1668 err_check_propagate(retval
);
1669 jtag_add_sleep(TIME_DIV_FREESCALE
*100*1000);
1670 jtag_add_reset(0,0);
1671 jtag_add_sleep(TIME_DIV_FREESCALE
*300*1000);
1673 // Enable master tap
1674 tap_chp
->enabled
= false;
1675 retval
= switch_tap(target
,tap_chp
,tap_cpu
);
1676 err_check_propagate(retval
);
1678 // Execute mass erase to unlock
1679 instr
= MASTER_TAP_CMD_FLASH_ERASE
;
1680 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_MASTER_TAP_IRLEN
);
1681 err_check_propagate(retval
);
1683 instr
= HFM_CLK_DEFAULT
;
1684 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & ir_out
,16);
1685 err_check_propagate(retval
);
1687 jtag_add_sleep(TIME_DIV_FREESCALE
*150*1000);
1688 jtag_add_reset(0,1);
1689 jtag_add_sleep(TIME_DIV_FREESCALE
*200*1000);
1691 retval
= reset_jtag();
1692 err_check(retval
, DSP5680XX_ERROR_JTAG_RESET
, "Failed to reset JTAG state machine");
1693 jtag_add_sleep(150);
1696 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & ir_out
,32);
1697 err_check_propagate(retval
);
1701 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_MASTER_TAP_IRLEN
);
1702 err_check_propagate(retval
);
1704 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr
,(uint8_t *) & ir_out
,4);
1705 err_check_propagate(retval
);
1707 tap_cpu
->enabled
= true;
1708 tap_chp
->enabled
= false;
1710 instr
= JTAG_INSTR_ENABLE_ONCE
;
1711 //Two rounds of jtag 0x6 (enable eonce) to enable EOnCE.
1712 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
1713 err_check_propagate(retval
);
1714 instr
= JTAG_INSTR_DEBUG_REQUEST
;
1715 retval
= dsp5680xx_irscan(target
, & instr
, & ir_out
,DSP5680XX_JTAG_CORE_TAP_IRLEN
);
1716 err_check_propagate(retval
);
1718 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr_16
,(uint8_t *) & read_16
,8);
1719 err_check_propagate(retval
);
1721 retval
= dsp5680xx_drscan(target
,(uint8_t *) & instr_16
,(uint8_t *) & read_16
,8);
1722 err_check_propagate(retval
);
1723 jtag_add_sleep(TIME_DIV_FREESCALE
*100*1000);
1724 jtag_add_reset(0,0);
1725 jtag_add_sleep(TIME_DIV_FREESCALE
*300*1000);
1729 int dsp5680xx_f_lock(struct target
* target
){
1731 uint16_t lock_word
[] = {HFM_LOCK_FLASH
};
1732 retval
= dsp5680xx_f_wr(target
,(uint8_t *)(lock_word
),HFM_LOCK_ADDR_L
,2,1);
1733 err_check_propagate(retval
);
1735 jtag_add_reset(0,1);
1736 jtag_add_sleep(TIME_DIV_FREESCALE
*200*1000);
1738 retval
= reset_jtag();
1739 err_check(retval
, DSP5680XX_ERROR_JTAG_RESET
, "Failed to reset JTAG state machine");
1740 jtag_add_sleep(TIME_DIV_FREESCALE
*100*1000);
1741 jtag_add_reset(0,0);
1742 jtag_add_sleep(TIME_DIV_FREESCALE
*300*1000);
1747 static int dsp5680xx_step(struct target
* target
,int current
, uint32_t address
, int handle_breakpoints
){
1748 err_check(ERROR_FAIL
, DSP5680XX_ERROR_NOT_IMPLEMENTED_STEP
, "Not implemented yet.");
1751 /** Holds methods for dsp5680xx targets. */
1752 struct target_type dsp5680xx_target
= {
1753 .name
= "dsp5680xx",
1755 .poll
= dsp5680xx_poll
,
1756 .arch_state
= dsp5680xx_arch_state
,
1758 .target_request_data
= NULL
,
1760 .halt
= dsp5680xx_halt
,
1761 .resume
= dsp5680xx_resume
,
1762 .step
= dsp5680xx_step
,
1764 .write_buffer
= dsp5680xx_write_buffer
,
1765 .read_buffer
= dsp5680xx_read_buffer
,
1767 .assert_reset
= dsp5680xx_assert_reset
,
1768 .deassert_reset
= dsp5680xx_deassert_reset
,
1769 .soft_reset_halt
= dsp5680xx_soft_reset_halt
,
1771 .read_memory
= dsp5680xx_read
,
1772 .write_memory
= dsp5680xx_write
,
1773 .bulk_write_memory
= dsp5680xx_bulk_write_memory
,
1775 .checksum_memory
= dsp5680xx_checksum_memory
,
1777 .target_create
= dsp5680xx_target_create
,
1778 .init_target
= dsp5680xx_init_target
,