Merge commit '067956266c886d377231ffdd89e630e41aeb2783' into sam-update

This commit is contained in:
Jason Kotzin 2022-08-01 20:43:02 -07:00
commit fcf5b74542
2 changed files with 17 additions and 12 deletions

View File

@ -82,6 +82,7 @@
#define STLINK_SWD_AP_WDATA_ERROR 0x18 #define STLINK_SWD_AP_WDATA_ERROR 0x18
#define STLINK_SWD_AP_STICKY_ERROR 0x19 #define STLINK_SWD_AP_STICKY_ERROR 0x19
#define STLINK_SWD_AP_STICKYORUN_ERROR 0x1a #define STLINK_SWD_AP_STICKYORUN_ERROR 0x1a
#define STLINK_BAD_AP_ERROR 0x1d
#define STLINK_JTAG_UNKNOWN_CMD 0x42 #define STLINK_JTAG_UNKNOWN_CMD 0x42
#define STLINK_CORE_RUNNING 0x80 #define STLINK_CORE_RUNNING 0x80
@ -455,6 +456,9 @@ static int stlink_usb_error_check(uint8_t *data, bool verbose)
if (verbose) if (verbose)
DEBUG("STLINK_SWD_AP_STICKYORUN_ERROR\n"); DEBUG("STLINK_SWD_AP_STICKYORUN_ERROR\n");
return STLINK_ERROR_FAIL; return STLINK_ERROR_FAIL;
case STLINK_BAD_AP_ERROR:
/* ADIV5 probe 256 APs, most of them are non exisitant.*/
return STLINK_ERROR_FAIL;
case STLINK_JTAG_UNKNOWN_CMD : case STLINK_JTAG_UNKNOWN_CMD :
if (verbose) if (verbose)
DEBUG("STLINK_JTAG_UNKNOWN_CMD\n"); DEBUG("STLINK_JTAG_UNKNOWN_CMD\n");
@ -1055,7 +1059,7 @@ bool adiv5_ap_setup(int ap)
return true; return true;
} }
void div5_ap_cleanup(int ap) void adiv5_ap_cleanup(int ap)
{ {
uint8_t cmd[16] = { uint8_t cmd[16] = {
STLINK_DEBUG_COMMAND, STLINK_DEBUG_COMMAND,

View File

@ -390,9 +390,8 @@ static bool adiv5_component_probe(ADIv5_AP_t *ap, uint32_t addr, int recursion,
} }
return res; return res;
} }
bool adiv5_ap_setup(int i);
bool __attribute__((weak)) adiv5_ap_setup(int i) {(void)i; return true;} void adiv5_ap_cleanup(int i);
void __attribute__((weak)) adiv5_ap_cleanup(int i) {(void)i;}
ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel) ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel)
{ {
@ -528,6 +527,11 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
#define ALIGNOF(x) (((x) & 3) == 0 ? ALIGN_WORD : \ #define ALIGNOF(x) (((x) & 3) == 0 ? ALIGN_WORD : \
(((x) & 1) == 0 ? ALIGN_HALFWORD : ALIGN_BYTE)) (((x) & 1) == 0 ? ALIGN_HALFWORD : ALIGN_BYTE))
#if !defined(JTAG_HL)
bool adiv5_ap_setup(int i) {(void)i; return true;}
void adiv5_ap_cleanup(int i) {(void)i;}
/* Program the CSW and TAR for sequencial access at a given width */ /* Program the CSW and TAR for sequencial access at a given width */
static void ap_mem_access_setup(ADIv5_AP_t *ap, uint32_t addr, enum align align) static void ap_mem_access_setup(ADIv5_AP_t *ap, uint32_t addr, enum align align)
{ {
@ -567,8 +571,7 @@ static void * extract(void *dest, uint32_t src, uint32_t val, enum align align)
return (uint8_t *)dest + (1 << align); return (uint8_t *)dest + (1 << align);
} }
void __attribute__((weak)) void adiv5_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
adiv5_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
{ {
uint32_t tmp; uint32_t tmp;
uint32_t osrc = src; uint32_t osrc = src;
@ -598,8 +601,7 @@ adiv5_mem_read(ADIv5_AP_t *ap, void *dest, uint32_t src, size_t len)
extract(dest, src, tmp, align); extract(dest, src, tmp, align);
} }
void __attribute__((weak)) void adiv5_mem_write_sized(ADIv5_AP_t *ap, uint32_t dest, const void *src,
adiv5_mem_write_sized(ADIv5_AP_t *ap, uint32_t dest, const void *src,
size_t len, enum align align) size_t len, enum align align)
{ {
uint32_t odest = dest; uint32_t odest = dest;
@ -634,16 +636,14 @@ adiv5_mem_write_sized(ADIv5_AP_t *ap, uint32_t dest, const void *src,
} }
} }
void __attribute__((weak)) void adiv5_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
adiv5_ap_write(ADIv5_AP_t *ap, uint16_t addr, uint32_t value)
{ {
adiv5_dp_write(ap->dp, ADIV5_DP_SELECT, adiv5_dp_write(ap->dp, ADIV5_DP_SELECT,
((uint32_t)ap->apsel << 24)|(addr & 0xF0)); ((uint32_t)ap->apsel << 24)|(addr & 0xF0));
adiv5_dp_write(ap->dp, addr, value); adiv5_dp_write(ap->dp, addr, value);
} }
uint32_t __attribute__((weak)) uint32_t adiv5_ap_read(ADIv5_AP_t *ap, uint16_t addr)
adiv5_ap_read(ADIv5_AP_t *ap, uint16_t addr)
{ {
uint32_t ret; uint32_t ret;
adiv5_dp_write(ap->dp, ADIV5_DP_SELECT, adiv5_dp_write(ap->dp, ADIV5_DP_SELECT,
@ -651,6 +651,7 @@ adiv5_ap_read(ADIv5_AP_t *ap, uint16_t addr)
ret = adiv5_dp_read(ap->dp, addr); ret = adiv5_dp_read(ap->dp, addr);
return ret; return ret;
} }
#endif
void adiv5_mem_write(ADIv5_AP_t *ap, uint32_t dest, const void *src, size_t len) void adiv5_mem_write(ADIv5_AP_t *ap, uint32_t dest, const void *src, size_t len)
{ {