adiv5/swdp: Check early for valid DP idcode.

This commit is contained in:
Uwe Bonnes 2020-11-28 17:40:37 +01:00 committed by UweBonnes
parent 3b6432912d
commit f45c56af83
1 changed files with 6 additions and 0 deletions

View File

@ -614,6 +614,12 @@ ADIv5_AP_t *adiv5_new_ap(ADIv5_DP_t *dp, uint8_t apsel)
void adiv5_dp_init(ADIv5_DP_t *dp) void adiv5_dp_init(ADIv5_DP_t *dp)
{ {
/* Check IDCODE for a valid designer*/
if ((dp->idcode & 0xfff) == 0) {
DEBUG_WARN("Invalid DP idcode %08" PRIx32 "\n", dp->idcode);
free(dp);
return;
}
DEBUG_INFO("DPIDR 0x%08" PRIx32 " (v%d %srev%d)\n", dp->idcode, DEBUG_INFO("DPIDR 0x%08" PRIx32 " (v%d %srev%d)\n", dp->idcode,
(dp->idcode >> 12) & 0xf, (dp->idcode >> 12) & 0xf,
(dp->idcode & 0x10000) ? "MINDP " : "", dp->idcode >> 28); (dp->idcode & 0x10000) ? "MINDP " : "", dp->idcode >> 28);