Skip to content

examples/lorawan: drop crazy STM32 hack#20883

Merged
benpicco merged 1 commit intoRIOT-OS:masterfrom
maribu:examples/lorawan/bugfix
Oct 1, 2024
Merged

examples/lorawan: drop crazy STM32 hack#20883
benpicco merged 1 commit intoRIOT-OS:masterfrom
maribu:examples/lorawan/bugfix

Conversation

@maribu
Copy link
Copy Markdown
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
Copy Markdown

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
@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