Re: [RFC] Zephyr Shell Enhancement

Tomasz Bursztyka

Hi Yael,

Clear RFC.

I have tiny inputs below

Shell service (shell_service.c)


• Add a new file: kernel/nanokernel/shell_service.c

• Responsibility: Initializes shell and add framework usage of the shell.

• Note: Memory for a specific module shell usage is not allocated if shell

is disabled in framework level, even if it is enabled in module’s level.

#define SHELL_PROMPT "shell> "

#define SHELL_FW "FW"

struct shell_cmd fw_commands[] = {

{ "sample", shell_cmd_sample, "help sample info" },

As you know the size of fw_commands (which can be declared as const
btw) at built time,
you will be able to loop directly on that count, thus you could remove
this last entry.


Memory consumption


File: include/misc/shell.h

This file is the shell header file.

The following code already exists in its current Zephyr version:

typedef int (*shell_cmd_function_t)(int argc, char *argv[]);

struct shell_cmd {

const char *cmd_name;

shell_cmd_function_t cb;

const char *help;


• Note: Currently, “help” string’s length is not limited.

However, limitation on the length of each command’s help string
should be

And supporting such help could be Kconfig based.
You may want to build the commands without their help string.

Shell Section


1. Architecture dependency:

For all supported architectures – appropriate section prolog should be


Example- X86 arch:

File: include/arch/x86/linker-common-sections.h





I don't see any blocker not to put it in romable region or?


Open issues


• Improve search:

Search (of the entity and then of the command) can be improved, for

example, by using hash tables.

This improvement has a conflict between Performance issue and Memory


The improvement may be different between nanokernel and microkernel.

This improvement is currently out of this proposal scope.
Indeed there would be a lot to try here, from a very basic alphabet
index to an hash table
or search tree etc...


Join to automatically receive all group messages.