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

Fix MSD flashing for kl26z (microbit) #853

Merged
merged 2 commits into from
Oct 16, 2021

Conversation

mathias-arm
Copy link
Collaborator

I bisected to find out when kl26z_microbit_if MSD flashing stopped working (DAPLink crashes). This led me to [f1bb93e]. The attached heavy-handed change fixes for gcc and armcc.

@gerargz, @flit, @carlosperate: other nRF51822 platforms seem to work without this patch, but I am not sure why why it only impacts kl26z.

@microbit-carlos
Copy link
Contributor

@gerargz do you have a bit more info about why this addition was required?

@flit
Copy link
Collaborator

flit commented Sep 21, 2021

Do you know why DAPLink crashes with this code in place? What are the fault syndrome register values, and which instruction faulted? Could it be a stack overflow?

If you're getting an imprecise fault, you can add this code to init to force precise faults (at small performance penalty):

    // Disable write buffer to make bus faults precise.
    SCnSCB->ACTLR = SCnSCB_ACTLR_DISDEFWBUF_Msk;

(Frankly, it's bad that DAPLink wasn't powering down debug after MSD programming all along.)

@flit
Copy link
Collaborator

flit commented Sep 21, 2021

@microbit-carlos Powering down debug after programming will reduce power consumption of the target.

@mathias-arm
Copy link
Collaborator Author

This issue might be relevant: microbit-foundation#9

@mathias-arm
Copy link
Collaborator Author

I checked with micro:bit board and the problem is that the first call to read DP_CTRL_STAT fails. With the assumption that after a reset the target is not ready for SWD, I have added a call to swd_init_debug() and it seems to fix the issue. It is probably does a few superfluous operations, but I think it is cleaner.

@mathias-arm
Copy link
Collaborator Author

I also changed the checks mentioned in microbit-foundation#9

@mathias-arm mathias-arm merged commit 4021607 into ARMmbed:develop Oct 16, 2021
gaborcsapo pushed a commit to gaborcsapo/DAPLink that referenced this pull request Jun 29, 2022
* Call swd_init_debug() after reset + fix ACK checks
gaborcsapo pushed a commit to gaborcsapo/DAPLink that referenced this pull request Jun 29, 2022
* Call swd_init_debug() after reset + fix ACK checks
gaborcsapo pushed a commit to gaborcsapo/DAPLink that referenced this pull request Jun 29, 2022
* Call swd_init_debug() after reset + fix ACK checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants