Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Bitfield stripping is broken on indexed peripherals #17

Open
MabezDev opened this issue Jan 30, 2020 · 4 comments · Fixed by #19
Open

Bitfield stripping is broken on indexed peripherals #17

MabezDev opened this issue Jan 30, 2020 · 4 comments · Fixed by #19
Labels
bug Something isn't working

Comments

@MabezDev
Copy link
Member

Seems like #14 has unfortunately & subtley broken the code gen for indexed registers.

@MabezDev MabezDev added the bug Something isn't working label Jan 30, 2020
@davidkern
Copy link
Contributor

Ah that is unfortunate. :/

If you'd like to back out #14, that'd be fine. I'm trying to approach this more generally directly in the idf2svd tool, but don't have that ready to go yet.

On the idf2svd front, I can identify which of the peripherals are indexed by looking for defines which look like REG_(.*)_BASE(i). Meanwhile the DR_REG_(.*)_BASE defines in soc.h seem like the cleanest starting point for which peripherals should exist. Unfortunately this inverts the existing logic a bit so its not an easy change. I'm taking a slight detour to see if it would be useful to use https://docs.rs/nom/5.1.0/nom/ to capture more of the information out of the defines. Perhaps I'll have something soon or someone will have a better approach.

@MabezDev
Copy link
Member Author

I will try and figure out why svdtools isn't patching the copied peripherals, but I will resort to reverting #14 if I can't figure it out.

On the idf2svd front, I can identify which of the peripherals are indexed by looking for defines which look like REG_(.)BASE(i). Meanwhile the DR_REG(.)_BASE

I looked into a similar approach but didn't go any further with it because of the inconsistencies in soc.h, for example the timer groups are referred to everywhere as timg but inside soc.h they are referred to as timergroup. I hope you have more luck than I did!

@MabezDev
Copy link
Member Author

MabezDev commented Feb 4, 2020

I have an idea as to why this stopped working. Instead of _copying we used to _derive indexed peripherals from the general one i.e I2C0 & I2C1 were derived from I2C, hence applying the fix to just the I2C peripheral worked.

Now that we _copy, we have to change the registers on the copied peripherals too.

Something like changing the following line from:

I2C* might do it, as this should capture all the copied peripherals too. If this does work this will have to be repeated for all peripherals where multiple exist.

@MabezDev
Copy link
Member Author

Re-opening as we had to revert the fix in #19

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants