Skip to content

[scripts/makehtml] Fix displaying of registers with the same addressOffset and parsing of addressOffset #591

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

Merged
merged 3 commits into from
Aug 15, 2021

Conversation

maximeborges
Copy link
Member

This pull request fix two bugs in the makehtml.py script:

  • When parsing the addressOffset value, the value is parsed as base16 even if it's in base10.
  • When two registers have the same addressOffset, one of the two is suppressed

The first bug is fixed by checking if the addressOffset starts with 0x to parse from base16, or parse from base10 by default (when a register is generated from a patch).

The second bug is fixed by changing the index used for the list of registers from the addressOffset to the register name.

@maximeborges maximeborges changed the title [scripts/makehtml] Fix displaying of registers with the same addressO… [scripts/makehtml] Fix displaying of registers with the same addressOffset and parsing of addressOffset Aug 15, 2021
@github-actions
Copy link

Memory map comparison

@maximeborges
Copy link
Member Author

Note about the memory map comparison:
It looks like a lot of registers with splitted fields now have a proper bitOffset, so it explains why there is tons of modifications here

@github-actions
Copy link

Memory map comparison

maximeborges and others added 2 commits August 15, 2021 15:47
Co-authored-by: Adam Greig <adam@adamgreig.com>
@maximeborges maximeborges force-pushed the bugfix/makehtml_same_addressoffset branch from 9a12c78 to 2064371 Compare August 15, 2021 13:47
@github-actions
Copy link

Memory map comparison

@@ -146,7 +146,7 @@ def parse_device(svdfile):
# Bodge to prevent /0 when there are no fields in a register
if register_fields_total == 0:
register_fields_total = 1
registers[roffset] = {"name": rname,
registers[rname] = {"name": rname,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
registers[rname] = {"name": rname,
registers[(roffset, rname)] = {"name": rname,

I had to check to remember what this is used for, but it's inside makehtml.template.html, where the registers are iterated over by sorted key order, so previously they were in register-offset order but now they'd be in register-alphabetical order. If we make this key (offset, name), we preserve the sort order but allow the overlapping registers to still appear.

I think it would be good to also change makehtml.template.html L121 to something like {% for _, register in peripheral.registers|dictsort %} (changing roffset to _) to make it clear that the key isn't used later, since it's now a tuple.

Finally the indentation of the fields below needs updating since this line changes length.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, I thought registers were inserted by their roffset already, but I missed the sorting function.

@github-actions
Copy link

Memory map comparison

Copy link
Member

@adamgreig adamgreig left a comment

Choose a reason for hiding this comment

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

Great, thanks!

bors merge

@bors bors bot merged commit e664fe2 into stm32-rs:master Aug 15, 2021
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