Shell commands and modules added during link time #3424
+411
−196
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.
Shell commands registration
So far shell commands could be added with
shell_cmd_register()
and modules (set of commands) could be added withshell_register()
This approach requires function call usually added in package initialization function.
Registering commands requires some RAM two tables:
Number of modules that can be registered is defined by two mynewt values
SHELL_MAX_MODULES
andSHELL_MAX_COMPAT_COMMANDS
.When code tries to add more commands or modules system will crash with assert(0).
Link time table for commands registration
Now when link time table can be used shell commands and modules can be added to be available in shell.
Commands can be added with macro
MAKE_SHELL_CMD()
and modules can be added usingSHELL_MODULE_WITH_TABLE()
.Both register commands and modules does not use RAM and do not need function calls.
For backward compatibility
shell_cmd_register()
andshell_register()
can still be used.To minimize memory usage syscfg values
SHELL_MAX_MODULES
andSHELL_MAX_COMPAT_COMMANDS
can be set to 0.Benefits of new shell commands registration
Scope of this PR
Comparison of size for target that with many commands
Code without this changes
Same application after change are applied: