Repository navigation
tools/gen-device-svd: include the last register in cluster size - #5811
zombieleet wants to merge 2 commits into
Conversation
For a cluster with dim 1 or no dim, the size was computed from the address of the last register instead of its end. The padding after the cluster was too large, so every field after it was shifted. This fixes the SPU struct in nrf9160 and nrf5340_application, and DCNF in nrf5340_application. No other generated file changes.
0e17def to
39bca29
Compare
|
Thanks for finding this @zombieleet. I regenerated the device files before and after this change and took a good look. The following is edited from an automated review:
What do you think? |
|
Thanks for checking @deadprogram . Good point on the warnings: with this change the nrf struct size warnings go from 315 to 0, and the 6 for Atmel go away too, with no change to the Atmel output. I added that to the description. I added |
For a cluster with
dim1 or nodim, gen-device-svd computes the size from the start of the last register instead of its end. The padding after the cluster is then too large, and every following field lands at the wrong offset. This is an existing bug from #3335.Affected today:
nrf9160(SPU) andnrf5340_application(SPU,DCNF). For exampleSPU.DPPIis at 0x484 instead of 0x480. No other generated file changes. The 315 "struct size" warnings gen-device prints for the nrf files are gone, and so are the 6 for Atmel, whose output does not change.Why here and not in tinygo-org/esp32-svd: the esp-pacs SVD files in tinygo-org/esp32-svd#1 use many such clusters, so without this fix the
TIMGwatchdog registers end up at the wrong address on several ESP chips. Unlike #5797, this is a bug in existing code and the SVD files are correct. The only SVD workaround is to flatten the clusters, which renamesTIMG0.T[0].CONFIGtoTIMG0.T0CONFIGon single-timer chips only and breaks shared code likeruntime_esp32xx.go.Testing: ran
make gen-devicebefore and after, and only the two nRF files changed. Compared the real Go field offsets of every generated struct with the SVD offsets. Both nRF files and all 15 esp32-svd chips now match. AddedTestProcessClusterSizeDim1, which fails on dev (ElementSize4) and passes with this change.