samd21: spi: fix power regression #5868
Merged
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr commit 845ef0d introduced a power consumption regression by leaving the MISO pin floating
Despite this being a one line fix, this took us four days to find, so allow me to elaborate. @Hyungsin and I have been working on getting RIOT running at ~10uA average current for a duty cycling SAMR21 based mote, basically we have #2309 and #5608 along with a set of changes here and there. We got everything working, sampling temperature at 1Hz with ~10uA consumption and we patted ourselves on the back with a "lets quickly rebase and then submit patches upstream". We rebased, (it was just four days of commits) and one of those commits was merging #5743.
Nothing worked.
Ah well, we consoled ourselves, at least this means RIOT is active, this is a good problem to have. So we got everything to compile and redid the platform support only to find that our MCU-only power consumption had gone from 2.5uA in idle to over 70 uA. Somewhere in the more than 10k changed lines, there was a problem. We spent a few days inspecting all the clocking config (we thought there must be a new RUNSTDBY clock). We scoured the PM registers, nothing. Eventually I started bisecting the PR, and discovered that 845ef0d was to blame, but nothing seemed blatantly wrong. Eventually by reverting it line by line we discovered that the new code does not configure the pullup resistor on MISO. Adding that brought us back 👍
Hallelujah:
I guess to make this kind of thing easier to find in future we
a) might want to add power consumption tests of a physical device to the CI
b) might want to split large PR's into mostly-harmless refactor (updating the ASF and moving headers for example) and things that change implementation details, so that problems don't get buried in 10kloc batches.
Now that this is sorted out, I will get back to preparing a PR for low-power SAMR21 platforms.