|
|
пре 4 месеци | |
|---|---|---|
| docs | пре 4 месеци | |
| examples | пре 4 месеци | |
| inc | пре 4 месеци | |
| src | пре 4 месеци | |
| test | пре 4 месеци | |
| .clang-format | пре 4 месеци | |
| .gitignore | пре 4 месеци | |
| LICENSE | пре 6 година | |
| README_EN.md | пре 4 месеци | |
| SConscript | пре 6 година | |
| readme.md | пре 4 месеци | |
| thanks.md | пре 5 година |
v2.0: Compared to version 1.0, this version fixes several bugs, adds command-line TAB completion functionality, and is more stable and concise.
MCU debugging often requires interactive operations such as retrieving/configuring parameters and executing specific functions. nr_micro_shell is a low-overhead, bare-metal compatible command-line interaction tool designed to meet these needs.
The goals of nr_micro_shell are: ease of use, low overhead, reliability, and extensibility
shell_putc() function needs to be implemented at minimum. Simply use shell(c) to process the character stream, and the tool is ready for use.Comparison with rt-thread finsh (resource overhead increment):
| Metric | Original Project | Increment with nr_micro_shell | Increment with finsh |
|---|---|---|---|
| ROM | 63660 | +3832 | +26908 |
| RAM | 4696 | +1104 | +1304 |
Configuration for both tools:
Supports user-defined commands.
Pre-implemented commands:
| Command | Function Description |
|---|---|
| help | Display all commands |
| rd | Read memory |
| wr | Write memory |
| hex2dec | Convert hex to decimal |
| Name | Description |
|---|---|
| docs | Development documentation |
| examples | Demo code |
| inc | Header files |
| src | Source code |
nr_micro_shell is licensed under the MIT License. See the LICENSE file for details.
Prerequisites: Basic libc library with implementations of functions from string.h, stdio.h, stdlib.h, stdint.h, and stdarg.h.
Refer to examples/simulator and examples/linux_with_mini_config for reference.
Mandatory: nr_micro_shell_port.h
Used to pass configuration information. The shell_putc() function must be declared or defined. For other macro configurations, refer to the comments in the simulator header file.
Optional: nr_micro_shell_port.c
Implements low-level functions for adapting nr_micro_shell, such as shell_putc().
Example usage:
#include "nr_micro_shell.h"
int main(void)
{
shell_init();
while(1) {
if(/* get a char c ? */) { // Check if a character is received
shell(c); // Pass the character to the shell for processing
}
}
}
Command function prototype:
int cmd_xxx(uint8_t argc, char **argv) {
// Implement command logic here
return ret; // Return status code
}
After implementing the function, manually add it to src/nr_micro_shell_cmds.c:
struct cmd cmd_table[] = {
{ .name = "help", .func = cmd_help, .desc = "show this help" },
{ .name = "your cmd name", .func = cmd_xxx, .desc = "the description of your cmd" },
// Add more commands here
};
It is recommended to use a serial terminal that supports the standard VT100 protocol (e.g., MobaXTerm, SecureCRT). Disable terminal echo to avoid garbled characters.
It is recommended to use examples/simulator/ on Linux for development and verification. Usage steps:
cd examples/simulator/
# Compile the binary
make
# Or compile the debug binary
make debug
# Run the binary
./out/nr_shell
# Monitor DEBUG logs
tail -f ./debug.log
# Monitor key sequence records
tail -f ./key_rec.log
# Clean compiled files
make clean
# test
cd test
./test.sh
# Test results are located in the test/out/ directory (such as code coverage, etc.)
TODO (Contributions and PRs are welcome)
| TASK | STATUS |
|---|---|
| RT-Thread adaptation example | |
| FreeRTOS adaptation example | |
| STM32 adaptation example | |
| More general commands |
If you wish to contribute code, please submit a Pull Request (PR) to the GitHub repository.
For feedback or suggestions, please submit an Issue on GitHub or Gitee.