Skip to content

Commit

Permalink
mspm0: handle MSPM0 devices specially and fix base-addr masking
Browse files Browse the repository at this point in the history
At least mspm0l reports a working AP as no-debug-entry (BASE.P bit is zero). Report such AP as valid.

Also fix masking ap.base to discard flag bits too early in the function.
It is needed untouched to compare to legacy "AP not present" value and
only later lower bits can be reset.
  • Loading branch information
hardesk committed Jun 26, 2024
1 parent 29e45dd commit 3af4810
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/target/adiv5.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,26 +765,26 @@ adiv5_access_port_s *adiv5_new_ap(adiv5_debug_port_s *dp, uint8_t apsel)
ap.flags |= ADIV5_AP_FLAGS_64BIT;
ap.base |= (uint64_t)adiv5_ap_read(&ap, ADIV5_AP_BASE_HIGH) << 32U;
/* Check the Debug Base Address register for not-present (legacy format). See ADIv5 Specification C2.6.1 */
} else if ((uint32_t)ap.base == ADIV5_AP_BASE_NOT_PRESENT) {
DEBUG_INFO(" -> Not Present\n");
return NULL;
}
/* Make sure we only pay attention to the base address, not the presence and format bits */
ap.base &= ADIV5_AP_BASE_BASEADDR;
/* Check for ADIv5 no-entry flag. */
if (base_flags == (ADIV5_AP_BASE_FORMAT_ADIV5 | ADIV5_AP_BASE_PRESENT_NO_ENTRY)) {
/* Check the Debug Base Address register for not-present. See ADIv5 Specification C2.6.1 */
if (base_flags == (ADIV5_AP_BASE_FORMAT_ADIV5 | ADIV5_AP_BASE_PRESENT_NO_ENTRY) ||
(!(ap.flags & ADIV5_AP_FLAGS_64BIT) && (uint32_t)ap.base == ADIV5_AP_BASE_NOT_PRESENT)) {
/*
* Debug Base Address not present in this MEM-AP
* No debug entries... useless AP
* AP0 on STM32MP157C reads 0x00000002
* Unless it's a TI MSPM0, which reads present flag as no entry while reporting a ROM table
*/
if (!(dp->target_designer_code == JEP106_MANUFACTURER_TEXAS && ap.base != 0U)) {
* Debug Base Address not present in this MEM-AP
* No debug entries... useless AP
* AP0 on STM32MP157C reads 0x00000002
*
* NB: MSPM0 parts erroneously set BASE.P = 0 despite there being
* valid debug components on AP0, so we have to have an exception
* for this part family.
*/
if (dp->target_designer_code != JEP106_MANUFACTURER_TEXAS || ap.base != 0xf0000002U) {
DEBUG_INFO(" -> Not Present\n");
return NULL;
}
}

/* Make sure we only pay attention to the base address, not the presence and format bits */
ap.base &= ADIV5_AP_BASE_BASEADDR;
/* Check if the AP is disabled, skipping it if that is the case */
if ((ap.csw & ADIV5_AP_CSW_AP_ENABLED) == 0U) {
DEBUG_INFO(" -> Disabled\n");
Expand Down

0 comments on commit 3af4810

Please sign in to comment.