blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.14k stars 760 forks source link

nRF5340 support #1779

Open maxd-nordic opened 4 months ago

maxd-nordic commented 4 months ago

Hi! I'm wondering whether it would be feasible to add nRF53 support to BMP. The nRF5340 is a little bit different than the others though, so I'm not sure if this is compatible with BMP's architecture:

dragonmux commented 4 months ago

👋🏼 It's nice to see some help showing up from one of the vendors for once 😄

So: 1) When BMD discovers the target, it will find each core individually. If there's a way to tell which core is which, the probe routine can register just the Flash region for that core with the target structure representing it. 2) If the application core is discovered first, the probe routine can, just as with the Flash, do core-specific actions such as powering up other cores - APs are discovered and probed sequentially, so as long as AP0 can bring up AP1 (for example), then BMD won't notice the changing environment and discovery will work how you'd hope. 3) That's unfortunate though, if we can identify a nRF53 device from the DP information or otherwise inject AP preparation somewhere in https://github.com/blackmagic-debug/blackmagic/blob/e52eafaa781f3c0430c051461edff3a1638a8aab/src/target/adiv5.c#L867 then as long as the debugger is able to re-enable the APs, that's solvable. 4) That's rather more awkward 5) Where are those in the AP sequence? If we can identify an nRF53 part from the DP information such as the DP TARGETID register, or via the ID information (IDR, any other specific identification registers Nordic implements in their CTRL-AP register space) of those CTRL-APs, that can be solved for. It's a bit more awkward but not impossible to go back and re-evaluate an AP if the CTRL-APs come after the core ones.

Hope that helps, and we'll be happy to provide a guiding hand and advice if you're able to contribute an implementation for discovery of nRF53 devices. Our feature/64-bit-cortex-support branch is probably highly indicated to be merged before this though due to all the fixes it does to https://github.com/blackmagic-debug/blackmagic/blob/e52eafaa781f3c0430c051461edff3a1638a8aab/src/target/adiv5.c#L708 which currently grossly mishandles AP discovery for non-MEM-AP types, and which doesn't handle CSW correctly for all MEM-AP types.