Open rapgenic opened 1 year ago
Sorry about that, that's a known issue. And, it's an issue with the Open-CMSIS-Pack (OCP) spec, and arguably with the RT1176 pack. The OCP spec is designed with the traditional single-core debugger in mind, so cases like this where you want to debug multiple cores but the pack defines different connect sequences for each core are simply not handled by the spec. Pack can be written to work around this, but the RT1176 pack isn't.
I do have a patch that at least corrects pyocd's behaviour to match the spec, though I haven't had time to fully test it yet. https://github.com/flit/pyOCD/tree/bugfix/debug_port_debug_seq_pname_support
This patch changes pyocd so it will only execute the DebugPortStart
sequence for the core specified by the primary_core
option. It's definitely not ideal, but that's the best that can be done with the OCP spec right now.
Making the builtin RT1176 target properly support multicore would be nice, but I don't have an RT1176 board to test with so I can't do the work myself.
You could also say there's another issue related to multicore in pyocd: there's not a defined way to start a secondary (non-boot) core running so it can be debugged. I think this is why the builtin RT1176 target is separated into M7/M4 targets. Though it could be worked around.
So, aside from the other trace component related issue, for multicore RT1176 development I'd recommend using the pack, plus a user script that releases the other core and possibly other config (like maybe SDRAM init).
Thank you for the explanation!
It's clear that this SoC is particularly complicated! I guess that for more advanced things one would need to use the NXP IDE with their own tools...
Anyway, I've made some advancements. I've discovered that, with the pack, pyocd can access the second core AP when it's already started, which means that at least I should be able to attach to a running target. Not ideal, but I've seen that most of the time booting up the system is not too difficult, there's plenty of template code from the manufacturer for that.
Anyways, the second core is still not configured, even using the pack! I've tracked this down to the target/family/target_imxrt.py
file, where the create_cores
sequence is overridden and made to create only the first core instance (with a special CortexM7_IMXRT
class)! Is there a reason to be like that? Commenting that out actually creates two gdbserver instances, but I guess that also the CortexM7_IMXRT
class serves its purpose...
Thanks for the patch, I can have a try and see if it's working, even though I don't think it'll make much of a difference, I think that the DebugPortStart
sequences inside the pack are doing more or less the same initialization pyocd is already doing hardcoded.
You should be able to use a user script with the pack target to ensure that the second core is running. Well, that's the theory…
You're right that the DebugPortStart patch won't fix the issue with the IMXRT
family class not creating the second core.
The builtin RT1176 don't inherit from the IMXRT
family class. So it's probably a bug that this family class is being used for the pack target.
I'll create a patch for you to test that fixes the family class matching. Or you can temporarily remove this line: https://github.com/pyocd/pyOCD/blob/0189b2f4888b2775edd4b2be3caede4e05a9ffa6/pyocd/target/family/__init__.py#L42
You're right that the DebugPortStart patch won't fix the issue with the
IMXRT
family class not creating the second core.
Actually I just tried the patch, and it doesn't yet work (meaning it won't execute the sequence at all). I think this is due to this check:
https://github.com/flit/pyOCD/blob/5a7f6bc359218b54b8620c879412d6ea047ed043/pyocd/coresight/dap.py#L441 (I can't get the GitHub preview to work...)
The self.has_debug_sequence('DebugPortSetup')
will return false if multiple definitions of the sequence exist, but the pname
function parameter is not specified...
Or you can temporarily remove this line:
This works. Just tested it and can detect and connect to both the cores!
Thanks for testing and debugging! Will work on a fix.
Fyi, #1594 removes the family class match expression. It looks like there is nothing extra in the builtin targets that isn't present in the debug sequences, so there's no need to use the family class for any IMXRT pack-base target.
Ok, the issue with the bugfix/debug_port_debug_seq_pname_support branch should be fixed. It was tested on an IMXRT685. Quite a different device, but it also has a DebugPortStart
sequence with a pname
.
Hi, I have another issue regarding the IMXRT1176 :smile:
I'm trying to experiment with both the builtin target and the cmsis pack one. The builtin targets allow to debug only one core at a time, so I'm trying to use the cmsis pack.
On gdbserver start i get the following error when trying to access (I think) the cortex m4 debug port (verbose log):
Looking at the log it seems that the debug sequence
DebugPortStart
is not executed, which I think is responsible to configure correctly the port and make it accessible, besides being defined in the cmsis pack:Looking at the code I think that it's not executed because there are two
Pname
s available. However shouldn't they be both executed in this case?