Skip to content
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

Rewrite SWJ config when modifying MAPR (fixes #105) #106

Merged
merged 1 commit into from
Aug 31, 2019

Conversation

TheZoq2
Copy link
Member

@TheZoq2 TheZoq2 commented Aug 31, 2019

This stack exchange post explains the issue pretty well https://electronics.stackexchange.com/questions/260757/timer1-remap-cause-debug-crash-on-stm32f103

The SWJ_CFG bits are write only, meaning that reads are undefined. On the blue pill, reads seem to work fine anyway, but on the RGT6, they return some other value which messes with the debug port.

My fix for it is to make the mapr function private, and only allow modifications via the modify_mapr function which remembers the state of the debug port and writes the config accordingly.

Since mapr was public, this is a breaking change. I see no reason to have it public, in fact, users can break the abstractions by modifying mapr so this new modify_mapr function is marked pub(crate)

@geomatsi
Copy link
Contributor

LGTM, thanks !

You probably mean 'SWJ_CFG bits' (not pins) in commit message. FWIW, suggested approach is extensible in terms of support of other debug port mappings. In other words, when more SWJ_CFG combinations are needed, jtag_enabled: bool can be replaced by appropriate enum.

Regards,
Sergey

@TheZoq2
Copy link
Member Author

TheZoq2 commented Aug 31, 2019

FWIW, suggested approach is extensible in terms of support of other debug port mappings

That's true, but since this is internal stuff, I'd say we can make that change if we decide to support other modes

Copy link
Member

@therealprof therealprof left a comment

Choose a reason for hiding this comment

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

LGTM

@therealprof therealprof merged commit 53288d6 into stm32-rs:master Aug 31, 2019
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.

3 participants