-
Notifications
You must be signed in to change notification settings - Fork 2k
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
tests/periph_pm: make usage more intuitive and move shell commands to sys/ #11731
Conversation
Nice contribution! I like the idea of having access to the pm blocker status from the shell. The new |
Thanks. Yes I also think it seems like a good improvement to merge the commands into one. I only didn't for brevity. I have even thought that these commands would be useful to move outside of I've been postponing most of the shell command changes I've wanted to make because I'd like to benefit effort-wise from (the concept of) #9538, but since we only need simple parsing here I don't mind so much. However, I suppose this topic is at risk of rapidly deviating from what I hoped might be a relatively quick merge (ultimately I am trying to push #7897 forward along with subsequent PM efforts). I would be content to aim for a minimal PR for now, provided that consideration is given to forward compatibility with future improvements. Probably I will be looking at PM on EFM32 and EFR32 after this, so I will still have plenty of opportunity and context to make improvements here during that. |
For example the current command |
Having all subcommands under
Calling Maybe you could rename the new |
5161072
to
3a851bd
Compare
I changed the command to Also the command is run automatically when
|
Will have a look tomorrow :) |
In that case Also if the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
I will give this another test so we can merge asap! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are minor things that could still be improved in this PR. See my suggestions below.
Otherwise, I think that the definition of pm_blocker_t
could be moved to pm_layered.h
(and related TODOs could be removed).
Sorry for the delay. I moved |
I think I've addressed all your comments @aabadie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments from my side:
-
Why did you define the commands
block
,unblock
andset
commands twice, once intests/periph_pm
and once insc_pm.c
? They should be placed insc_pm
andtests/periph_pm
should use them as a module. -
We should have all PM commands in
sc_pm.c
available. Ok, thereboot
command is a standard shell command, butoff
should be also available if featureperiph_pm
is provided. Theunblock_rtc
is only for testing and is the only command that could stay intests/periph_pm
from my point of view. -
Indeed, a question is whether the
pm
command should be included whenever the featureperiph_pm
is provided or the modulepm_layered
is used. It depends on the purpose. If it is to be a standard command, it should be included whenever the featureperiph_pm
is provided or modulepm_layered
is used. However, if it is only intended for testing, it should only be included explicitly. In any case, it will increase the the ROM size.
f79e3ec
to
edc21ef
Compare
|
Yes.
I would like to have it considered in this PR for the following reasons:
Therefore, I would suggest to provide the command by a separate pseudomodule @aabadie How do you think about that? |
I think it's a good idea. So basically use:
ifneq (,$(filter periph_pm,$(USEMODULE)))
SRC += sc_pm.c
endif
#ifdef MODULE_PM_LAYERED
#include "pm_layered.h"
extern volatile pm_blocker_t pm_blocker; /* sys/pm_layered/pm.c */
#endif /* MODULE_PM_LAYERED */
static void _print_usage(void) {
puts("Usage:");
#ifdef MODULE_PM_LAYERED
puts("\tpm show: display current blockers for each power mode");
puts("\tpm set <mode>: manually set power mode (lasts until WFI returns)");
puts("\tpm block <mode>: manually block power mode");
puts("\tpm unblock <mode>: manually unblock power mode");
#endif /* MODULE_PM_LAYERED */
puts("\tpm off: call pm_off()");
}
#ifdef MODULE_PM_LAYERED
static int check_mode(int argc, char **argv)
{
[...]
#endif /* MODULE_PM_LAYERED */
static int cmd_off(char *arg)
{
(void)arg;
pm_off();
return 0;
}
[...] etc @benemorius, would mind updating this PR once more ? After that we should be good to go. Thanks! |
@benemorius @gschorcht, let's move forward with this one. Is it ok for both of you if I take over this PR and open a new one adding the requested changes ? |
Yes, and I don't see where is the typo :) |
c21ab6e
to
591e43a
Compare
591e43a
to
9659300
Compare
9659300
to
325ab42
Compare
I finally went for the force-push option in your branch @benemorius. Maybe someone could give a final round ? @fjmolinas ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I think there is no reason for unclock_rtc
to not be moved as well, but that can be in a followup. For what I can see @aabadie just implemented the final nitpicks that had already been agreed on, ACK.
USEMODULE=rtt_rtc PROGRAMMER=jlink BOARD=openmote-b make -C tests/periph_pm flash term
2020-04-28 17:13:41,402 # help
2020-04-28 17:13:41,403 # Command Description
2020-04-28 17:13:41,403 # ---------------------------------------
2020-04-28 17:13:41,405 # unblock_rtc temporarily unblock power mode
2020-04-28 17:13:41,406 # reboot Reboot the node
2020-04-28 17:13:41,418 # version Prints current RIOT_VERSION
2020-04-28 17:13:41,419 # pm interact with layered PM subsystem
2020-04-28 17:13:41,420 # rtc control RTC peripheral interface
> rtc
2020-04-28 17:13:44,266 # rtc
2020-04-28 17:13:44,266 # usage: rtc <command> [arguments]
2020-04-28 17:13:44,267 # commands:
2020-04-28 17:13:44,267 # poweron power the interface on
2020-04-28 17:13:44,268 # poweroff power the interface off
2020-04-28 17:13:44,268 # clearalarm deactivate the current alarm
2020-04-28 17:13:44,282 # getalarm print the currently alarm time
2020-04-28 17:13:44,284 # setalarm YYYY-MM-DD HH:MM:SS
2020-04-28 17:13:44,285 # set an alarm for the specified time
2020-04-28 17:13:44,286 # gettime print the current time
2020-04-28 17:13:44,287 # settime YYYY-MM-DD HH:MM:SS
2020-04-28 17:13:44,287 # set the current time
unblock_rtc 1 3
2020-04-28 17:14:08,041 # unblock_rtc 1 3
2020-04-28 17:14:08,042 # Unblocking power mode 1 for 3 seconds.
pm show
2020-04-28 17:14:14,136 # pm show
2020-04-28 17:14:14,137 # mode 0 blockers: 1
2020-04-28 17:14:14,138 # mode 1 blockers: 1
2020-04-28 17:14:14,152 # mode 2 blockers: 1
2020-04-28 17:14:14,152 # mode 3 blockers: 1
2020-04-28 17:14:14,153 # Lowest allowed mode: 4
unblock_rtc 1 3
2020-04-28 17:14:15,960 # unblock_rtc 1 3
2020-04-28 17:14:15,961 # Unblocking power mode 1 for 3 seconds.
pm show 3
2020-04-28 17:14:16,936 # pm show
2020-04-28 17:14:16,937 # mode 0 blockers: 1
2020-04-28 17:14:16,952 # mode 1 blockers: 0
2020-04-28 17:14:16,952 # mode 2 blockers: 1
2020-04-28 17:14:16,953 # mode 3 blockers: 1
2020-04-28 17:14:16,953 # Lowest allowed mode: 4
pm show
2020-04-28 17:14:19,656 # pm show
2020-04-28 17:14:19,657 # mode 0 blockers: 1
2020-04-28 17:14:19,672 # mode 1 blockers: 1
2020-04-28 17:14:19,672 # mode 2 blockers: 1
2020-04-28 17:14:19,673 # mode 3 blockers: 1
2020-04-28 17:14:19,673 # Lowest allowed mode: 4
pm unblock 2
2020-04-28 17:14:28,808 # pm unblock 2
2020-04-28 17:14:28,809 # Unblocking power mode 2.
pm show
2020-04-28 17:14:31,975 # pm show
2020-04-28 17:14:31,977 # mode 0 blockers: 1
2020-04-28 17:14:31,977 # mode 1 blockers: 1
2020-04-28 17:14:31,978 # mode 2 blockers: 0
2020-04-28 17:14:31,979 # mode 3 blockers: 1
2020-04-28 17:14:31,979 # Lowest allowed mode: 4
unblock_rtc 3 3
2020-04-28 17:14:41,034 # unblock_rtc 3 3
help
2020-04-28 17:14:45,433 # Unblocking power mode 3 ���x
��f�����`��?��������help
2020-04-28 17:14:45,436 # Command Description
2020-04-28 17:14:45,438 # ---------------------------------------
2020-04-28 17:14:45,439 # unblock_rtc temporarily unblock power mode
2020-04-28 17:14:45,449 # reboot Reboot the node
2020-04-28 17:14:45,450 # version Prints current RIOT_VERSION
2020-04-28 17:14:45,451 # pm interact with layered PM subsystem
2020-04-28 17:14:45,466 # rtc control RTC peripheral interface
pm show
2020-04-28 17:14:51,385 # pm show
2020-04-28 17:14:51,386 # mode 0 blockers: 1
2020-04-28 17:14:51,388 # mode 1 blockers: 1
2020-04-28 17:14:51,389 # mode 2 blockers: 0
2020-04-28 17:14:51,389 # mode 3 blockers: 1
2020-04-28 17:14:51,390 # Lowest allowed mode: 4
> pm show
2020-04-28 17:14:55,225 # pm show
2020-04-28 17:14:55,225 # mode 0 blockers: 1
2020-04-28 17:14:55,225 # mode 1 blockers: 1
2020-04-28 17:14:55,241 # mode 2 blockers: 0
2020-04-28 17:14:55,242 # mode 3 blockers: 1
2020-04-28 17:14:55,242 # Lowest allowed mode: 4
Some boards doesn't have enough memory now. I'll exclude them from the CI. |
And go! |
Contribution description
Using tests/periph_pm can be unintuitive if you aren't already very familiar with the PM subsystem. I identified and addressed two specific causes and I think this greatly improves the situation.
This PR addresses 1) by adding a new command
pm show
to view blockers and 2) by adding a check to print a friendly error message when unblocking an unblocked mode.Testing procedure
Issues/PRs references
I think some confusion earlier in #7897 can be avoided with these changes.
Updates
pm show
). In case we boot into an unresponsive shell, we at least get some direction for troubleshooting, as this tells us which power mode must have been entered.pm_set()
verbosity. It may not be obvious to the user that running shell commandset %i
(which callspm_set(i)
) is forcing the CPU into the specified power mode, and that such manual forcing is not necessarily an orthodox thing to do. I tried to increase the verbosity somewhat so the process is clearer. Also, this verbosity provides an event (some printf output) which indicates the moment when the CPU woke up, whereas previously we didn't know when it had woken up except by typing into the shell to check for a response. In some cases, the CPU might always wake immediately (or just sooner than expected) afterset %i
. This should reveal those cases.