kasjer opened a new pull request, #3424:
URL: https://github.com/apache/mynewt-core/pull/3424

   ### Shell commands registration
   So far shell commands could be added with `shell_cmd_register()` and modules 
(set of commands) could be added with `shell_register()`
   
   This approach requires function call usually added in package initialization 
function.
   Registering commands requires some RAM two tables:
   ```c
   static struct shell_module shell_modules[MYNEWT_VAL(SHELL_MAX_MODULES)];
   static struct shell_cmd 
compat_commands[MYNEWT_VAL(SHELL_MAX_COMPAT_COMMANDS) + 1];
   ```
   Number of modules that can be registered is defined by two mynewt values 
`SHELL_MAX_MODULES` and `SHELL_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 
using `SHELL_MODULE_WITH_TABLE()`.
   Both register commands and modules does not use RAM and do not need function 
calls.
   
   For backward compatibility `shell_cmd_register()` and `shell_register()` can 
still be used.
   To minimize memory usage syscfg values `SHELL_MAX_MODULES` and 
`SHELL_MAX_COMPAT_COMMANDS` can be set to 0.
   
   ### Benefits of new shell commands registration
   - Memory usage is reduced both RAM and flash
   - commands are in alphabetical order (they were displayed in order they were 
registered)
   - Targets don't need to specify maximum number of command and modules so 
adding some package will not result in unexpected assert(0) that instruct you 
to increase limits.
   ### Scope of this PR
   - Macros for module and commands creation
   - Rework of shell command handling to use link time tables
   - Update of many packages (not all yet) to use new way of making shell 
commands
   ### Comparison of size for target that with many commands
   Code without this changes
   ```
   objsize
      text         data     bss     dec     hex filename
    121368         1744   30572  153684   25854 
bin/targets/blackpill411ce-slinky/app/@apache-mynewt-core/apps/slinky/slinky.elf
   ```
   Same application after change are applied:
   ```
   objsize
      text         data     bss     dec     hex filename
    120844         1496   29988  152328   25308 
bin/targets/blackpill411ce-slinky/app/@apache-mynewt-core/apps/slinky/slinky.elf
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to