This is an automated email from Gerrit. Peter Lawrence ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/2372
-- gerrit commit 43d1ea99d393cc4e3462544b0f7e457380510add Author: Peter Lawrence <[email protected]> Date: Sun Nov 2 17:36:05 2014 -0700 arm_adi_v5: APB-AP fix for mem_ap_write() and map_ap_read() The existing routines favor packed transfers, but these are not valid with APB-AP buses. Without this change, mdx commands with count arguments result in undefined behavior (likely address that does not increment) with APB-AP buses Change-Id: Ie5511516198896e431a3ef03dbd2da00273c077a Signed-off-by: Peter Lawrence <[email protected]> diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index c76cc69..f4c32c8 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -335,8 +335,11 @@ int mem_ap_write(struct adiv5_dap *dap, const uint8_t *buffer, uint32_t size, ui uint32_t this_size = size; /* Select packed transfer if possible */ + /* per DDI 0314 Tables 2-20 (AHB-AP) and 2-29 (APB-AP), + * packed transfers are not supported in APB-AP */ if (addrinc && dap->packed_transfers && nbytes >= 4 - && max_tar_block_size(dap->tar_autoincr_block, address) >= 4) { + && max_tar_block_size(dap->tar_autoincr_block, address) >= 4 + && (AP_REG_IDR_APID_APB_AP != (dap->apid & AP_REG_IDR_APID_MASK))) { this_size = 4; retval = dap_setup_accessport_csw(dap, csw_size | CSW_ADDRINC_PACKED); } else { @@ -470,8 +473,11 @@ int mem_ap_read(struct adiv5_dap *dap, uint8_t *buffer, uint32_t size, uint32_t uint32_t this_size = size; /* Select packed transfer if possible */ + /* per DDI 0314 Tables 2-20 (AHB-AP) and 2-29 (APB-AP), + * packed transfers are not supported in APB-AP */ if (addrinc && dap->packed_transfers && nbytes >= 4 - && max_tar_block_size(dap->tar_autoincr_block, address) >= 4) { + && max_tar_block_size(dap->tar_autoincr_block, address) >= 4 + && (AP_REG_IDR_APID_APB_AP != (dap->apid & AP_REG_IDR_APID_MASK))) { this_size = 4; retval = dap_setup_accessport_csw(dap, csw_size | CSW_ADDRINC_PACKED); } else { @@ -1539,6 +1545,8 @@ COMMAND_HANDLER(dap_apsel_command) if (retval != ERROR_OK) return retval; + dap->apid = apid; + command_print(CMD_CTX, "ap %" PRIi32 " selected, identification register 0x%8.8" PRIx32, apsel, apid); diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index dee3117..39f2a6c 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -104,6 +104,11 @@ /* Generic AP register address */ #define AP_REG_IDR 0xFC +/* Fields of the MEM-AP's IDR register */ +#define AP_REG_IDR_APID_MASK (255UL << 0) +#define AP_REG_IDR_APID_AHB_AP (1UL << 0) +#define AP_REG_IDR_APID_APB_AP (2UL << 0) + /* Fields of the MEM-AP's CSW register */ #define CSW_8BIT 0 #define CSW_16BIT 1 @@ -146,6 +151,7 @@ struct adiv5_dap { uint32_t apcsw[256]; uint32_t apsel; + uint32_t apid; /** * Cache for DP_SELECT bits identifying the current AP. A DAP may -- ------------------------------------------------------------------------------ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
