return retval;
}
-/* Compatibility wrappers around mem_ap_write(). Note that the count is in bytes for these. */
-int mem_ap_write_buf_u32(struct adiv5_dap *dap, const uint8_t *buffer, int count, uint32_t address, bool addr_incr)
-{
- return mem_ap_write(dap, buffer, 4, count / 4, address, true);
-}
-
-int mem_ap_write_buf_u16(struct adiv5_dap *dap, const uint8_t *buffer, int count, uint32_t address)
-{
- return mem_ap_write(dap, buffer, 2, count / 2, address, true);
-}
-
-int mem_ap_write_buf_u8(struct adiv5_dap *dap, const uint8_t *buffer, int count, uint32_t address)
-{
- return mem_ap_write(dap, buffer, 1, count, address, true);
-}
-
/**
* Synchronous read of a block of memory, using a specific access size.
*
return retval;
}
-/* Compatibility wrappers around mem_ap_read(). Note that the count is in bytes for these (despite
- * what their doxygen documentation said). */
-int mem_ap_read_buf_u32(struct adiv5_dap *dap, uint8_t *buffer,
- int count, uint32_t address, bool addr_incr)
-{
- return mem_ap_read(dap, buffer, 4, count / 4, address, addr_incr);
-}
-
-int mem_ap_read_buf_u16(struct adiv5_dap *dap, uint8_t *buffer,
- int count, uint32_t address)
-{
- return mem_ap_read(dap, buffer, 2, count / 2, address, true);
-}
-
-int mem_ap_read_buf_u8(struct adiv5_dap *dap, uint8_t *buffer,
- int count, uint32_t address)
-{
- return mem_ap_read(dap, buffer, 1, count, address, true);
-}
-
/*--------------------------------------------------------------------*/
/* Wrapping function with selection of AP */
/*--------------------------------------------------------------------*/
return mem_ap_write_atomic_u32(swjdp, address, value);
}
-int mem_ap_sel_read_buf_u8(struct adiv5_dap *swjdp, uint8_t ap,
- uint8_t *buffer, int count, uint32_t address)
+int mem_ap_sel_read_buf(struct adiv5_dap *swjdp, uint8_t ap,
+ uint8_t *buffer, uint32_t size, uint32_t count, uint32_t address)
{
dap_ap_select(swjdp, ap);
- return mem_ap_read_buf_u8(swjdp, buffer, count, address);
+ return mem_ap_read(swjdp, buffer, size, count, address, true);
}
-int mem_ap_sel_read_buf_u16(struct adiv5_dap *swjdp, uint8_t ap,
- uint8_t *buffer, int count, uint32_t address)
+int mem_ap_sel_write_buf(struct adiv5_dap *swjdp, uint8_t ap,
+ const uint8_t *buffer, uint32_t size, uint32_t count, uint32_t address)
{
dap_ap_select(swjdp, ap);
- return mem_ap_read_buf_u16(swjdp, buffer, count, address);
+ return mem_ap_write(swjdp, buffer, size, count, address, true);
}
-int mem_ap_sel_read_buf_u32_noincr(struct adiv5_dap *swjdp, uint8_t ap,
- uint8_t *buffer, int count, uint32_t address)
+int mem_ap_sel_read_buf_noincr(struct adiv5_dap *swjdp, uint8_t ap,
+ uint8_t *buffer, uint32_t size, uint32_t count, uint32_t address)
{
dap_ap_select(swjdp, ap);
- return mem_ap_read_buf_u32(swjdp, buffer, count, address, false);
+ return mem_ap_read(swjdp, buffer, size, count, address, false);
}
-int mem_ap_sel_read_buf_u32(struct adiv5_dap *swjdp, uint8_t ap,
- uint8_t *buffer, int count, uint32_t address)
+int mem_ap_sel_write_buf_noincr(struct adiv5_dap *swjdp, uint8_t ap,
+ const uint8_t *buffer, uint32_t size, uint32_t count, uint32_t address)
{
dap_ap_select(swjdp, ap);
- return mem_ap_read_buf_u32(swjdp, buffer, count, address, true);
-}
-
-int mem_ap_sel_write_buf_u8(struct adiv5_dap *swjdp, uint8_t ap,
- const uint8_t *buffer, int count, uint32_t address)
-{
- dap_ap_select(swjdp, ap);
- return mem_ap_write_buf_u8(swjdp, buffer, count, address);
-}
-
-int mem_ap_sel_write_buf_u16(struct adiv5_dap *swjdp, uint8_t ap,
- const uint8_t *buffer, int count, uint32_t address)
-{
- dap_ap_select(swjdp, ap);
- return mem_ap_write_buf_u16(swjdp, buffer, count, address);
-}
-
-int mem_ap_sel_write_buf_u32(struct adiv5_dap *swjdp, uint8_t ap,
- const uint8_t *buffer, int count, uint32_t address)
-{
- dap_ap_select(swjdp, ap);
- return mem_ap_write_buf_u32(swjdp, buffer, count, address, true);
-}
-
-int mem_ap_sel_write_buf_u32_noincr(struct adiv5_dap *swjdp, uint8_t ap,
- const uint8_t *buffer, int count, uint32_t address)
-{
- dap_ap_select(swjdp, ap);
- return mem_ap_write_buf_u32(swjdp, buffer, count, address, false);
+ return mem_ap_write(swjdp, buffer, size, count, address, false);
}
#define MDM_REG_STAT 0x00
#define MEM_CTRL_VLLSX_DBG_ACK (1<<6)
#define MEM_CTRL_VLLSX_STAT_ACK (1<<7)
+#define MDM_ACCESS_TIMEOUT 3000 /* ms */
+
/**
*
*/
{
uint32_t val;
int retval;
+ int timeout = 0;
enum reset_types jtag_reset_config = jtag_get_reset_config();
dap_ap_select(dap, 1);
dap_run(dap);
if (val != 0x001C0000) {
- LOG_DEBUG("id doesn't match %08X != 0x001C0000", val);
+ LOG_DEBUG("id doesn't match %08" PRIX32 " != 0x001C0000", val);
dap_ap_select(dap, 0);
return ERROR_FAIL;
}
* it's important that the device is out of
* reset here
*/
- retval = dap_queue_ap_read(dap, MDM_REG_STAT, &val);
- if (retval != ERROR_OK)
- return retval;
- dap_run(dap);
+ while (1) {
+ if (timeout++ > MDM_ACCESS_TIMEOUT) {
+ LOG_DEBUG("MDMAP : flash ready timeout");
+ return ERROR_FAIL;
+ }
+ retval = dap_queue_ap_read(dap, MDM_REG_STAT, &val);
+ if (retval != ERROR_OK)
+ return retval;
+ dap_run(dap);
- LOG_DEBUG("MDM_REG_STAT %08X", val);
+ LOG_DEBUG("MDM_REG_STAT %08" PRIX32, val);
+ if (val & MDM_STAT_FREADY)
+ break;
+ alive_sleep(1);
+ }
- if ((val & (MDM_STAT_SYSSEC|MDM_STAT_FREADY)) != (MDM_STAT_FREADY)) {
+ if ((val & MDM_STAT_SYSSEC)) {
LOG_DEBUG("MDMAP: system is secured, masserase needed");
if (!(val & MDM_STAT_FMEEN))
dap_ap_select(dap, 0);
return ERROR_FAIL;
}
-
+ timeout = 0;
while (1) {
+ if (timeout++ > MDM_ACCESS_TIMEOUT) {
+ LOG_DEBUG("MDMAP : flash ready timeout");
+ return ERROR_FAIL;
+ }
retval = dap_queue_ap_write(dap, MDM_REG_CTRL, MEM_CTRL_FMEIP);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
dap_run(dap);
- LOG_DEBUG("MDM_REG_STAT %08X", val);
+ LOG_DEBUG("MDM_REG_STAT %08" PRIX32, val);
if ((val & 1))
break;
+ alive_sleep(1);
}
-
+ timeout = 0;
while (1) {
+ if (timeout++ > MDM_ACCESS_TIMEOUT) {
+ LOG_DEBUG("MDMAP : flash ready timeout");
+ return ERROR_FAIL;
+ }
retval = dap_queue_ap_write(dap, MDM_REG_CTRL, 0);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
dap_run(dap);
- LOG_DEBUG("MDM_REG_STAT %08X", val);
+ LOG_DEBUG("MDM_REG_STAT %08" PRIX32, val);
/* read control register and wait for ready */
retval = dap_queue_ap_read(dap, MDM_REG_CTRL, &val);
if (retval != ERROR_OK)
return retval;
dap_run(dap);
- LOG_DEBUG("MDM_REG_CTRL %08X", val);
+ LOG_DEBUG("MDM_REG_CTRL %08" PRIX32, val);
if (val == 0x00)
break;
+ alive_sleep(1);
}
}
}
while (tap != NULL) {
if (tap->hasidcode && (dap_syssec_filter_data[i].idcode == tap->idcode)) {
- LOG_DEBUG("DAP: mdmap_init for idcode: %08x", tap->idcode);
+ LOG_DEBUG("DAP: mdmap_init for idcode: %08" PRIx32, tap->idcode);
dap_syssec_filter_data[i].dap_init(dap);
}
tap = tap->next_tap;
((id_val & 0x0FFF0000) == 0x04770000) && /* Jedec codes match */
((id_val & 0xFF) == type_to_find)) { /* type matches*/
- LOG_DEBUG("Found %s at AP index: %d (IDR=0x%08X)",
+ LOG_DEBUG("Found %s at AP index: %d (IDR=0x%08" PRIX32 ")",
(type_to_find == AP_TYPE_AHB_AP) ? "AHB-AP" :
(type_to_find == AP_TYPE_APB_AP) ? "APB-AP" :
(type_to_find == AP_TYPE_JTAG_AP) ? "JTAG-AP" : "Unknown",