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

examples/lorawan: drop crazy STM32 hack #20883

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Oct 1, 2024

Contribution description

We cannot just decrement the reference counter of power modes without any coordination. First, this will trigger an assert()ion on non STM32 MCUs that have power modes that are not used (the ref count would be decremented below zero). Second, there hopefully is a reason a certain power mode is blocked, e.g. because a periph driver needs a certain clock to function.

Likely the periph_uart driver on STM32 boards keeps power modes blocked after TX is completed even when no RX callback is present, which is the waste of power this hack tries to address. But that should be addressed there.

Testing procedure

With master on wemos-zero we get:

2024-10-01 15:34:30,055 # main(): This is RIOT! (Version: 2024.10-devel-217-g61df1)
2024-10-01 15:34:30,056 # LoRaWAN Class A low-power application
2024-10-01 15:34:30,056 # =====================================
2024-10-01 15:34:30,056 # sys/pm_layered/pm.c:92 => *** RIOT kernel panic:
2024-10-01 15:34:30,056 # FAILED ASSERTION.
2024-10-01 15:34:30,056 # 
2024-10-01 15:34:30,056 # *** halted.
2024-10-01 15:34:30,056 # 

With this PR, we get:

2024-10-01 15:49:14,045 # main(): This is RIOT! (Version: 2024.10-devel-218-g4b6ad-examples/lorawan/bugfix)
2024-10-01 15:49:14,045 # LoRaWAN Class A low-power application
2024-10-01 15:49:14,045 # =====================================
2024-10-01 15:49:14,045 # Starting join procedure
[...] (No LoRaWAN Gateway close enough...)

Issues/PRs references

#17895

We cannot just decrement the reference counter of power modes without
any coordination. First, this will trigger an `assert()`ion on non
STM32 MCUs that have power modes that are not used (the ref count would
be decremented below zero). Second, there hopefully is a reason a
certain power mode is blocked, e.g. because a periph driver needs a
certain clock to function.

Likely the `periph_uart` driver on STM32 boards keeps power modes
blocked after TX is completed even when no RX callback is present, which
is the waste of power this hack tries to address. But that should be
addressed there.
@github-actions github-actions bot added the Area: examples Area: Example Applications label Oct 1, 2024
@maribu maribu requested a review from benpicco October 1, 2024 13:50
@maribu maribu added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 1, 2024
@riot-ci
Copy link

riot-ci commented Oct 1, 2024

Murdock results

✔️ PASSED

4b6ad3b examples/lorawan: drop crazy STM32 hack

Success Failures Total Runtime
18 0 18 01m:41s

Artifacts

@benpicco benpicco added this pull request to the merge queue Oct 1, 2024
Merged via the queue into RIOT-OS:master with commit 068db8b Oct 1, 2024
28 checks passed
@maribu maribu deleted the examples/lorawan/bugfix branch October 10, 2024 08:25
@benpicco benpicco added this to the Release 2024.10 milestone Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: examples Area: Example Applications CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants