removed unnecessary actions/controls
[openocd.git] / src / target / dsp5680xx.c
index c79ee3ae3e3f9093ef1275bfce32ee1dd7b9009b..1f26b69a0d633cc9c31368e9c9962e5a7fa17c79 100644 (file)
@@ -246,7 +246,6 @@ static int eonce_read_status_reg(struct target * target, uint16_t * data){
 
 static int dsp5680xx_halt(struct target *target){
   int retval;
-  uint8_t jtag_status;
   uint16_t eonce_status;
   if(target->state == TARGET_HALTED){
     LOG_USER("Target already halted.");
@@ -254,8 +253,6 @@ static int dsp5680xx_halt(struct target *target){
   }
   retval = eonce_enter_debug_mode(target,&eonce_status);
   err_check_propagate(retval);
-  retval = dsp5680xx_jtag_status(target,&jtag_status);
-  err_check_propagate(retval);
   retval = eonce_pc_store(target);
   err_check_propagate(retval);
   //TODO is it useful to store the pc?
@@ -268,17 +265,7 @@ static int dsp5680xx_resume(struct target *target, int current, uint32_t address
     return ERROR_OK;
   }
   int retval;
-  uint8_t jtag_status;
-  uint16_t eonce_status;
-
-  // Verify that EOnCE is enabled (enable it if necessary)
-  uint16_t data_read_from_dr = 0;
-  retval = eonce_read_status_reg(target,&data_read_from_dr);
-  err_check_propagate(retval);
-  if((data_read_from_dr&DSP5680XX_ONCE_OSCR_DEBUG_M) != DSP5680XX_ONCE_OSCR_DEBUG_M){
-    retval = eonce_enter_debug_mode(target,NULL);
-       err_check_propagate(retval);
-  }
+  uint8_t eonce_status;
   if(!current){
     retval = eonce_move_value_to_pc(target,address);
     err_check_propagate(retval);
@@ -286,21 +273,17 @@ static int dsp5680xx_resume(struct target *target, int current, uint32_t address
 
   int retry = 20;
   while(retry-- > 1){
-    retval = eonce_exit_debug_mode(target,(uint8_t *)&eonce_status );
+    retval = eonce_exit_debug_mode(target,&eonce_status );
        err_check_propagate(retval);
-    retval = dsp5680xx_jtag_status(target,&jtag_status);
-       err_check_propagate(retval);
-    if((jtag_status & 0xff) == JTAG_STATUS_NORMAL){
+    if(eonce_status == DSP5680XX_ONCE_OSCR_NORMAL_M)
       break;
-    }
   }
   if(retry == 0){
     retval = ERROR_TARGET_FAILURE;
        err_check(retval,"Failed to resume...");
   }else{
     target->state = TARGET_RUNNING;
-  };
-  LOG_DEBUG("JTAG status: 0x%02X.",jtag_status);
+  }
   LOG_DEBUG("EOnCE status: 0x%02X.",eonce_status);
   return ERROR_OK;
 }
@@ -714,7 +697,14 @@ static int dsp5680xx_read(struct target * target, uint32_t address, unsigned siz
   retval = dsp5680xx_convert_address(&address, &pmem);
   err_check_propagate(retval);
 
+  context.flush = 0;
+  int counter = FLUSH_COUNT_READ_WRITE;
+
   for (unsigned i=0; i<count; i++){
+    if(--counter==0){
+      context.flush = 1;
+      counter = FLUSH_COUNT_FLASH;
+    }
     switch (size){
     case 1:
       if(!(i%2)){
@@ -734,7 +724,13 @@ static int dsp5680xx_read(struct target * target, uint32_t address, unsigned siz
       break;
     }
        err_check_propagate(retval);
+    context.flush = 0;
   }
+  
+  context.flush = 1;
+  retval = dsp5680xx_execute_queue();
+  err_check_propagate(retval);
+  
   return retval;
 }
 
@@ -903,25 +899,12 @@ static int dsp5680xx_bulk_write_memory(struct target * target,uint32_t address,
   return ERROR_FAIL;
 }
 
-// Writes to pram at address
-// r3 holds the destination address-> p:(r3)
-// r2 hold 0xf151 to flash a led (probably cannot see it due to high freq.)
-// r0 holds TX/RX address.
-//0x00000073  0x8A44FFFE017B         brclr       #1,X:(R0-2),*-2
-//0x00000076  0xE700                 nop
-//0x00000077  0xF514                 move.w      X:(R0),Y0
-//0x00000078  0xE700                 nop
-//0x00000079  0x8563                 move.w      Y0,P:(R3)+
-//0x0000007A  0x84420003             bfchg       #3,X:(R2)
-//0x0000007C  0xA976                 bra         *-9
-uint16_t pgm_write_pram[] = {0x8A44,0xFFFE,0x017D,0xE700,0xF514,0xE700,0x8563,0x8442,0x0003,0xA976};
-uint16_t pgm_write_pram_length = 10;
-
 static int dsp5680xx_write_buffer(struct target * target, uint32_t address, uint32_t size, const uint8_t * buffer){
-  // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-  // this solution works, but it's slow. it flushes USB all the time.
+  if(target->state != TARGET_HALTED){
+    LOG_USER("Target must be halted.");
+    return ERROR_OK;
+  }
   return dsp5680xx_write(target, address, 1, size, buffer);
-  // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 }
 
 static int dsp5680xx_read_buffer(struct target * target, uint32_t address, uint32_t size, uint8_t * buffer){
@@ -929,35 +912,13 @@ static int dsp5680xx_read_buffer(struct target * target, uint32_t address, uint3
     LOG_USER("Target must be halted.");
     return ERROR_OK;
   }
-  // byte addressing!
-  int retval = ERROR_OK;
-  int pmem = 1;
-  uint16_t tmp_wrd= 0;
-
-  retval = dsp5680xx_convert_address(&address, &pmem);
-  err_check_propagate(retval);
-
-  for (unsigned i=0; i<size; i++)
-    if(!(i%2)){
-      retval = dsp5680xx_read_16_single(target, address + i/2, &tmp_wrd, pmem);
-         err_check_propagate(retval);
-      //TODO find a better solution. endiannes differs from normal read, otherwise the openocd crc would do weird stuff.
-      buffer[i+1] = (uint8_t) (tmp_wrd>>8);
-      buffer[i] = (uint8_t) (tmp_wrd&0xff);
-   }
-  return retval;
+  // read_buffer is called when the verify_image command is executed.
+  // The "/2" solves the byte/word addressing issue. 
+  return dsp5680xx_read(target,address,2,size/2,buffer);
 }
 
 static int dsp5680xx_checksum_memory(struct target * target, uint32_t address, uint32_t size, uint32_t * checksum){
- //TODO implement.
-  //This will make openocd do the work, but it will fail because of the word/byte addressing issues.
-  int retval;
-  struct working_area * crc_algorithm;
-  retval = target_alloc_working_area(target, 20, &crc_algorithm);
-  if(retval != ERROR_OK)
-    return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
-  retval = target_free_working_area(target, crc_algorithm);
-  return ERROR_FAIL;
+  return ERROR_FAIL;// This will make OpenOCD do the read out the data and verify it.
 }
 
 // Data signature algorithm used by the core FM (flash module)
@@ -1038,6 +999,9 @@ static int dsp5680xx_f_execute_command(struct target * target, uint16_t command,
       err_check(retval,"FM execute command failed.");
     }
   }while (!(i&0x40));                          // wait until current command is complete
+
+  context.flush = 0;
+
   retval = eonce_move_value_at_r2_disp(target,0x00,HFM_CNFG);  // write to HFM_CNFG (lock=0, select bank) -- flash_desc.bank&0x03,0x01 == 0x00,0x01 ???
   err_check_propagate(retval);
   retval = eonce_move_value_at_r2_disp(target,0x04,HFM_USTAT);         // write to HMF_USTAT, clear PVIOL, ACCERR & BLANK bits
@@ -1065,6 +1029,11 @@ static int dsp5680xx_f_execute_command(struct target * target, uint16_t command,
   err_check_propagate(retval);
   retval = eonce_move_value_at_r2_disp(target,0x80,HFM_USTAT);         // start the command
   err_check_propagate(retval);
+
+  context.flush = 1;
+  retval = dsp5680xx_execute_queue();
+  err_check_propagate(retval);
+
   watchdog = 100;
   do{
     retval = eonce_move_at_r2_disp_to_y0(target,HFM_USTAT);    // read HMF_USTAT
@@ -1079,6 +1048,10 @@ static int dsp5680xx_f_execute_command(struct target * target, uint16_t command,
     }
   }while (!(i&0x40));      // wait until the command is complete
   *hfm_ustat = i;
+  if (i&HFM_USTAT_MASK_PVIOL_ACCER){
+    retval = ERROR_TARGET_FAILURE;
+    err_check(retval,"pviol and/or accer bits set. HFM command execution error");
+  }
   return ERROR_OK;
 }
 
@@ -1129,10 +1102,6 @@ static int dsp5680xx_f_signature(struct target * target, uint32_t address, uint3
   }
   retval = dsp5680xx_f_execute_command(target,HFM_CALCULATE_DATA_SIGNATURE,address,words,&hfm_ustat,1);
   err_check_propagate(retval);
-  if (hfm_ustat&HFM_USTAT_MASK_PVIOL_ACCER){
-    retval = ERROR_TARGET_FAILURE;
-    err_check(retval,"HFM exec error:pviol and/or accer bits set.");
-  }
   retval = dsp5680xx_read_16_single(target, HFM_BASE_ADDR|HFM_DATA, signature, 0);
   return retval;
 }
@@ -1147,10 +1116,6 @@ int dsp5680xx_f_erase_check(struct target * target, uint8_t * erased,uint32_t se
   // Check if chip is already erased.
   retval = dsp5680xx_f_execute_command(target,HFM_ERASE_VERIFY,HFM_FLASH_BASE_ADDR+sector*HFM_SECTOR_SIZE/2,0,&hfm_ustat,1); // blank check
   err_check_propagate(retval);
-  if (hfm_ustat&HFM_USTAT_MASK_PVIOL_ACCER){
-       retval = ERROR_TARGET_FAILURE;
-       err_check(retval,"pviol and/or accer bits set. EraseVerify HFM command execution error");;
-  }
   if(erased!=NULL)
     *erased = (uint8_t)(hfm_ustat&HFM_USTAT_MASK_BLANK);
   return retval;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)