-
Notifications
You must be signed in to change notification settings - Fork 13
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
systemcmds/reboot: Fix reboot command for kernel mode #434
Conversation
46ff0e8
to
4116231
Compare
platforms/common/shutdown.cpp
Outdated
@@ -36,6 +36,11 @@ | |||
* Implementation of the API declared in px4_shutdown.h. | |||
*/ | |||
|
|||
#ifdef __PX4_NUTTX | |||
// Make sure this is defined, this is a kernel module | |||
#define __KERNEL__ |
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.
why not just add something like "target_compile_options(mmymodule.... PRIVATE -D__KERNEL__)" into CMakeLists.txt for the module, which compiles this and goes into kernel? This is fine as well, don't really care :)
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.
Yes this is the preferred way but in this particular case, the library that takes shutdown.cpp is px4_platform and it is unambiguous where it goes. It is still not obvious / clear to me how that library should be handled. It is still just a massive mess in my head.
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.
I separated shutdown into its own target, now its compile time flags can be adjusted
7c3d6dc
to
a259ef0
Compare
Hmm now that I look at this removing reboot/shutdown from user should be unnecessary. I think the problem is like with mavlink cdcacm checker, i.e. the user work queue is not running in kernel mode:
|
What I was wondering is what the shutdown hooks in shutdown.cpp are for. Only reference I can find is this:
|
Must provide hartid to __start() as per SBI spec. In flat mode this is not strictly necessary as it is obtained during the start process, but for kernel mode this is mandatory.
The userspace work queue is not started automatically by the system, so start it when dispatching the shutdown command. It would be best if there was an init function for shutdown.cpp but this "lazy" init is just fine too.
a259ef0
to
0754659
Compare
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.
LGTM
Fixes reboot command by: