embassy-rs / embassy-rs/chiptool

Incorrect code from invalid SVD file

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
65
Forks
54
PR merge metrics
No merged PRs in 30d

Description

I have been working with LPC55S16. You can find the version of the SVD I am look at [here](https://raw.githubusercontent.com/nxp-mcuxpresso/mcux-soc-svd/refs/heads/release/25.06.00/LPC55S16/LPC55S16.xml).

If you search the SVD for "SECCHANNEL", you will find a cluster with three registers in it. The addressOffset of the cluster is 0 and the dimIncrement is 0x20. It has three contained registers with addressOffsets of 0xc20, 0xc24, and 0xc28 defined as children.

0xc20 as an offset makes that register fall outside of size the first entry of the array.

The fix for the SVD is to make the offsets correct. The cluster itself should have an offset of 0xc20, and the registers should have offsets of 0, 0x4, and 0x8.

Chiptool will gladly generate incorrect code for the SVD before the fix. Svd2rust bombs out. I think the right thing would be to produce an error when the cluster size exceeds the dimIncrement size.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.