Rahix / atdf2svd

Converter from Atmel's atdf format to CMSIS SVD
GNU General Public License v3.0
17 stars 11 forks source link

PTC peripheral has no base address #7

Closed jkristell closed 4 years ago

jkristell commented 4 years ago

While trying to add support for the atmega328pb in avr-device I ran across a problem with parsing the atdf file for the device.

The parser paniced at https://github.com/Rahix/atdf2svd/blob/master/src/svd/peripheral.rs#L7 and after some investigation I found out that the PTC peripheral was missing a base address.

After reading about PTC here, https://github.com/jgilbert20/Libre_PTC my guess is that PTC is so secret to Atmel that they don't even include the base address for the device.

One solution would be to just skip those peripherals and log an warning, or the the PTC could be special cased and just skipped. Would be happy to create a patch, just need to know what you think is the best way to solve it.

Rahix commented 4 years ago

Ugh, that sounds lovely ... Hardware vendor secrecy is just the best.

Anyway, the core issue here (apart from the vendor being ridiculous) is the PTC peripheral not defining any registers. This is what makes .base_address() fail, because it needs at least one register to calculate a base address. I'd say we can safely assume that any such peripheral is useless and thus should be skipped with a warning.

I think the easiest way to do this is by adding a .filter() here:

https://github.com/Rahix/atdf2svd/blob/6b21b7ac3f910f9a497bbd70cdd1b64771a799d8/src/svd/chip.rs#L24-L28

As this project is rather poorly documented, if you have any questions, feel free to ask! As a start, take a look at https://github.com/Rahix/atdf2svd/blob/master/src/chip.rs, it defines all the data-structures we're operating on.