Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle inheritance of <debug> element attributes #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jnkr-ifx
Copy link

The spec states: https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/pdsc_family_pg.html#element_debug

Multiple debug elements can be defined which are either specific to a
processor identified by attribute Pname, or which apply to all
connections.

The current implementation did not handle this correctly: it only looked for a single debug element defined on either the device or subfamily. Debug attributes can be defined on the family as well; and if the innermost debug element does not have the attribute we're looking for, we need to look at debug elements on parent elements rather than assuming it's undefined.

This patch is necessary to correctly parse PSOC 6 CMSIS packs, which define debug elements at the family level and define additional attributes at more specific levels:

<family Dfamily="PSoC 62" Dvendor="Infineon:7">
  <processor Pname="Cortex-M0p" Dcore="Cortex-M0+" DcoreVersion="r0p1" Dfpu="NO_FPU" Dmpu="MPU" Dendian="Little-endian" Dclock="100000000" />
  <processor Pname="Cortex-M4" Dcore="Cortex-M4" DcoreVersion="r0p1" Dfpu="SP_FPU" Dmpu="MPU" Dendian="Little-endian" Dclock="150000000" />
  <debug Pname="Cortex-M0p" __ap="1" defaultResetSequence="ResetProcessor" />
  <debug Pname="Cortex-M4" __ap="2" defaultResetSequence="ResetSystem">
  ....
  <subFamily DsubFamily="CY8C62x4">
    <debug Pname="Cortex-M0p" svd="SVD/psoc6_04.svd" />
    <debug Pname="Cortex-M4" svd="SVD/psoc6_04.svd" />

@mathias-arm
Copy link
Collaborator

It seems we are going to have to fix CI.

@mathias-arm mathias-arm self-requested a review February 19, 2025 21:59
Copy link
Collaborator

@mathias-arm mathias-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase for CI to run?

Copy link
Collaborator

@mathias-arm mathias-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is that the changes to the Debug struct makes it an API change.

@jnkr-ifx: What software are you using this change with?

@jnkr-ifx
Copy link
Author

@mathias-arm I don't think this is a public API change -- the device module is private and the Debug struct is not reexported:

mod device;
pub use component::{ComponentBuilders, FileRef};
pub use condition::{Condition, Conditions};
pub use device::{AccessPort, Algorithm, Core, Device, Devices, Memories, Processor};

I'm using this with probe-rs's target-gen tool, and Infineon CAT1A and CAT1B CMSIS packs

Copy link
Member

@ithinuel ithinuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

little nit, otherwise looks fine by me.

The spec states: https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/pdsc_family_pg.html#element_debug

> Multiple debug elements can be defined which are either specific to a
> processor identified by attribute Pname, or which apply to all
> connections.

The current implementation did not handle this correctly: it only
looked for a single debug element defined on either the device or
subfamily. Iif the innermost debug element does not have the
attribute we're looking for, we need to check debug elements on parent
elements as well.

This patch is necessary to correctly parse PSOC 6 CMSIS packs.
The previous implementation failed to parse this:

      <accessportV2 __apid="0" address="0xF0000000" />
      <accessportV2 __apid="1" address="0xF0002000" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants