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

Fix derivedFrom attribute types and enumeratedValue minOccurs #14

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

ckudera
Copy link
Contributor

@ckudera ckudera commented Jun 7, 2024

I'm working on a SVDSuite, a Python package to parse, process, manipulate, validate, and generate CMSIS SVD files. During development, I noticed a discrepancy between documentation and schema.

According to the documentation, derivedFrom can be referenced from another scope for elements cluster, register, field, and enumeratedValues. However, in the schema, the type for the derivedFrom attribute is dimableIdentifierType which does not allow the . character. Furthermore, the enumeratedValue element in enumeratedValues must be specified (minOccurs set to 1), which doesn't make sense for deriving. This issue was already reported here.

This PR addresses the described issues. It contains the following changes:

  • add referenceIdentifierType (allows <dimableIdentifierType>.<dimableIdentifierType> with any depth, but not .<dimableIdentifierType>, .<dimableIdentifierType>., or <dimableIdentifierType>.)
  • change minOccurs for element enumeratedValue from 1 to 0 to allow deriving
  • change enumeratedValues derivedFrom attribute type to referenceIdentifierType to allow referencing
  • change field derivedFrom attribute type to referenceIdentifierType to allow referencing from another scope
  • change register derivedFrom attribute type to referenceIdentifierType to allow referencing from another scope
  • change cluster derivedFrom attribute type to referenceIdentifierType to allow referencing from another scope
  • modify svd_schema.txt so that the documentation corresponds to the schema

Please let me know what you think about the PR and if it needs any modifications.

- change minOccurs for element enumeratedValue from 1 to 0 to allow deriving
- change enumeratedValues derivedFrom attribute type to referenceIdentifierType to allow referencing
- change field derivedFrom attribute type to referenceIdentifierType to allow referencing from another scope
- change register derivedFrom attribute type to referenceIdentifierType to allow referencing from another scope
- change cluster derivedFrom attribute type to referenceIdentifierType to allow referencing from another scope
@jkrech jkrech requested review from thorstendb-ARM and jkrech June 7, 2024 10:33
VincentDary added a commit to VincentDary/cmsis-svd that referenced this pull request Oct 13, 2024
- Remove development related artifacts (debugger, unused ref).
- Add @brainstorm and @BenBE as maintainer of the cmsis-svd project in the AUTHOR file.
- Rename CMSIS SVD schemas sub directory and symlink from 'cmsis_svd_schemas' to
  'schemas', and 'svd_schema_files_meta.txt' to 'metadata.txt', to avoid name repetitions.
- Include the CMSIS SVD schema 1.3.11, officially in review
  Open-CMSIS-Pack/svd-spec#14
- Include Python README feedbacks.
- Add type hint os.PathLike for path method parameters.
- Replace hardcoded SVD schema versions list by a scan of XSD files in schemas directory.
- Replace hardcoded SVD schema version in method parameter by 'latest' keyword
  to specify the latest schema version.
- Fix improper register field name filtering for reserved field name.
- Move serializer_json and serializer_xml to serializers sub package.
- Add @ckudera/@BenBE fix for path traversal (CWE-22 and related) in SVDParser.for_packaged_svd()
VincentDary added a commit to VincentDary/cmsis-svd that referenced this pull request Oct 14, 2024
- Add CHANGELOG file.
- Add AUTHOR file.
- The banner licence of each file has been changed to 'Copyright 2015-2024 cmsis-svd Authors'
- Add CMSIS SVD XML Schema Definition files for versions:
  1.0, 1.1, 1.2, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.8, 1.3.9, 1.3.10, 1.3.11.
  Schema 1.3.11 is unofficial for the moment, but officially in review by the svd spec maintainers,
  and brings major fixes, see @ckudera PR in Open-CMSIS-Pack/svd-spec#14 .
- Add CMSIS SVD Python model XML serializer SVDXmlSerializer, which is a refactored
  and modified version of the SVD XML serializer from the SVDSuite project.
- CMSIS SVD Python model improvements:
  * CMSIS SVD spec support up to 1.3.11.
  * Model classes are now based on Python dataclass.
  * New SVD data types: SVDReadActionType, SVDModifiedWriteValuesType,
    SVDEnumUsageType, SVDEndianType, SVDDataTypeType, SVDAddressBlockUsageType,
    SVDAccessType, SVDSauAccessType, SVDProtectionType, SVDCPUNameType.
  * Add XML serializer methods: to_xml(), to_xml_file(), to_xml_node().
  * Add JSON serializer methods: to_json(), to_json_file().
  * Add new methods to access to peripherals, registers and fields:
    SVDDevice.get_peripherals(), SVDPeripheral.get_registers(), SVDRegister.get_fields()
  * Python type hint and PEP8 review.
- CMSIS SVD Python parser improvements:
  * Add method for standalone SVD XML validation via: validate_xml_tree(),
    validate_xml_file() and validate_xml_str().
  * Add flexible XML data validation to SVDParser.get_device() via xml_validation,
    schema_version and schema_version_detection parameters.
  * Add parsing for SVD XML device tag attributes: namespace and noNamespaceSchemaLocation
  * Python type hint and PEP8 review.
- CMSIS SVD Python:
  * Add pyproject.toml to avoid pip install deprecation warning.
  * Replace Python dev-requirements.txt file by a DEV 'extras_require' in setup.py.
  * Python README improvements.
  * Move Python 'tests' and 'exemples' directories to the root of the Python package.
- Fix regex SyntaxWarning message during bitfield range parsing.
  Reported by @brainstorm in cmsis-svd#185 (comment)
- Fix incompatibility with the CMSIS-SVD schema for enumeratedValues in fieldType.
  Reported by @gschwaer in cmsis-svd#185 (comment)
- Fix improper register field filtering based on 'reserved' field name.
  Reported by @BenBE in cmsis-svd#185 (comment)
- Fix for path traversal (CWE-22 and related) in SVDParser.for_packaged_svd()
  Reported by @BenBE in cmsis-svd#185 (review)
  Fix proposal by @ckudera in cmsis-svd#185 (comment)
@ckudera
Copy link
Contributor Author

ckudera commented Oct 25, 2024

Hi @thorstendb-ARM, @jkrech, @JonatanAntoni,

just wanted to check in on the status of the pull request I submitted around 4 months ago. I understand you might be busy, but I'd appreciate any updates or feedback you could share.

It seems that this issue and a new issue we received at cmsis-svd highlight that this is a real concern for the community. Addressing it would likely benefit a lot of users.

Copy link
Member

@jkrech jkrech left a comment

Choose a reason for hiding this comment

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

Looks good to me. ToDo: create a test to see whether SVDConv is handling this correctly.

@jkrech jkrech merged commit 6f11e1d into Open-CMSIS-Pack:main Oct 25, 2024
1 check passed
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.

2 participants