-
Notifications
You must be signed in to change notification settings - Fork 371
Shell commands and modules added during link time #3424
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
Draft
kasjer
wants to merge
18
commits into
apache:master
Choose a base branch
from
kasjer:kasjer/shell-static-command-registration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Shell commands and modules added during link time #3424
kasjer
wants to merge
18
commits into
apache:master
from
kasjer:kasjer/shell-static-command-registration
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This adds macros that help with link time generated tables. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
10590d6
to
9bc2d89
Compare
Shell commands and modules used to be registered at run time by packages. This required code and RAM space. Both shell modules and commands required RAM of some fixed size (specified in syscfg). When more commands or shell modules were registered assertion failed at run time. Now it's possibly to create shell commands that will be 'registered' at link time and will not require RAM nor explicit function call. This should eliminate problem of registering to many modules or commands. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Shell commands are now registered at link time instead of compile time to compat module commands. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
9bc2d89
to
18c4367
Compare
Module prompt is not linked statically. No need for runtime registering. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
18c4367
to
3ded33b
Compare
Now fs cli commands are register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now stat cli commands are register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now flash_test commands are register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now coremark shell commands are register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now log shell commands are register at link time to reduce memory footprint. No change in functionality. Remove unfinished code depending on non-existing flag LOG_FCB_SLOT1. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now crash shell commands are register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now config shell command is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now imgr shell command is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now usb shell module is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now flashstress shell command is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now fault shell command is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now i2c_scan shell command is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now mcu shell module is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
Now mcu shell module is register at link time to reduce memory footprint. No change in functionality. Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
3ded33b
to
8396589
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: