-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
888 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) 2021 HPMicro | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
|
||
set(CONFIG_CHERRYRB 1) | ||
set(CONFIG_CHERRYUSB 1) | ||
set(CONFIG_USB_DEVICE 1) | ||
set(CONFIG_USB_DEVICE_CDC 1) | ||
|
||
find_package(hpm-sdk REQUIRED HINTS $ENV{HPM_SDK_BASE}) | ||
project(cherryshell) | ||
|
||
sdk_compile_options("-O2") | ||
|
||
sdk_inc(inc) | ||
sdk_inc(../../../) | ||
|
||
sdk_app_src( | ||
src/main.c | ||
src/shell.c | ||
../../../chry_shell.c | ||
../../../builtin/help.c | ||
../../../builtin/shsize.c | ||
../../../builtin/login.c | ||
) | ||
|
||
generate_ses_project() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Cherry Shell Barebone USB | ||
|
||
## Overview | ||
|
||
The Cherry Shell Barebone example project demonstrates the basic usage of shell in bare-metal mode. In this project, you need to connect via USB PORT, and the shell requires a login. The default password is 12345678. After entering the password and pressing Enter, you will enter the shell. You can use the "help" command to view the available commands and variables. | ||
|
||
Please refrain from using USB PORT assistants and consider downloading and using [MobaXterm](https://mobaxterm.mobatek.net/download.html) | ||
|
||
## Board Setting | ||
|
||
No special settings | ||
|
||
## Running the example | ||
|
||
- After the project runs successfully, the serial terminal will output the following information: | ||
|
||
```console | ||
login as: cherry | ||
cherry@hpm5301evklite's password: | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
|
||
``` | ||
|
||
- If you manually enter the correct password "12345678" and press Enter, the terminal will output the following information: | ||
|
||
```console | ||
login as: cherry | ||
cherry@hpm5301evklite's password: | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
|
||
welcome to cherry shell | ||
cherry@hpm5301evklite:/$ | ||
``` | ||
|
||
- If you manually enter the command "help" and press Enter, the terminal will output the following information: | ||
|
||
```console | ||
cherry@hpm5301evklite:/$ help | ||
total function 6 | ||
test -> /bin | ||
toggle_led -> /bin | ||
write_led -> /bin | ||
exit -> /sbin | ||
help -> /sbin | ||
shsize -> /sbin | ||
|
||
total variable 2 | ||
$PATH r- 11 | ||
$ZERO r- 1 | ||
cherry@hpm5301evklite:/$ | ||
``` | ||
|
||
- If you manually enter the command "toggle_led" and press Enter, the LED will toggle. | ||
- If you manually enter the command "write_led 1" and press Enter, the LED will turn on. | ||
- If you manually enter the command "write_led 0" and press Enter, the LED will turn off. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Cherry Shell Barebone USB | ||
|
||
## 概述 | ||
|
||
Cherry Shell Barebone示例工程展示了shell的裸机模式基本使用。在这个工程中,需要连接 USB,shell默认需要登陆,密码为12345678。输入密码后回车,进入shell,输入help可以查看命令和变量。 | ||
请勿使用串口助手,推荐下载使用 [MobaXterm](https://mobaxterm.mobatek.net/download.html) | ||
|
||
## 硬件设置 | ||
|
||
无特殊设置 | ||
|
||
## 运行现象 | ||
|
||
- 当工程正确运行后,串口终端会输出如下信息: | ||
|
||
```console | ||
login as: cherry | ||
cherry@hpm5301evklite's password: | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
|
||
``` | ||
|
||
- 如果此时通过键盘手动输入正确密码"12345678"并回车,终端会输出如下信息: | ||
|
||
```console | ||
login as: cherry | ||
cherry@hpm5301evklite's password: | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
other task interval 5S | ||
|
||
welcome to cherry shell | ||
cherry@hpm5301evklite:/$ | ||
``` | ||
|
||
- 如果此时通过键盘手动输入命令"help"并回车,终端会输出如下信息: | ||
|
||
```console | ||
cherry@hpm5301evklite:/$ help | ||
total function 6 | ||
test -> /bin | ||
toggle_led -> /bin | ||
write_led -> /bin | ||
exit -> /sbin | ||
help -> /sbin | ||
shsize -> /sbin | ||
|
||
total variable 2 | ||
$PATH r- 11 | ||
$ZERO r- 1 | ||
cherry@hpm5301evklite:/$ | ||
``` | ||
|
||
- 如果此时通过键盘手动输入命令"toggle_led"并回车,LED将会翻转 | ||
- 如果此时通过键盘手动输入命令"write_led 1"并回车,LED将会点亮 | ||
- 如果此时通过键盘手动输入命令"write_led 0"并回车,LED将会熄灭 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2022, Egahp | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef CSH_CONFIG_H | ||
#define CSH_CONFIG_H | ||
|
||
/*!< argument check */ | ||
#define CONFIG_CSH_DEBUG 0 | ||
|
||
/*!< default row */ | ||
#define CONFIG_CSH_DFTROW 25 | ||
|
||
/*!< default column */ | ||
#define CONFIG_CSH_DFTCOL 80 | ||
|
||
/*!< history support <+550byte> */ | ||
#define CONFIG_CSH_HISTORY 1 | ||
|
||
/*!< completion support <+1100byte> */ | ||
#define CONFIG_CSH_COMPLETION 1 | ||
|
||
/*!< max completion item list count (use stack 4 x count byte) */ | ||
#define CONFIG_CSH_MAX_COMPLETION 40 | ||
|
||
/*!< prompt edit support <+1000byte> */ | ||
#define CONFIG_CSH_PROMPTEDIT 1 | ||
|
||
/*!< prompt segment count */ | ||
#define CONFIG_CSH_PROMPTSEG 7 | ||
|
||
/*!< xterm support */ | ||
#define CONFIG_CSH_XTERM 0 | ||
|
||
/*!< newline */ | ||
#define CONFIG_CSH_NEWLINE "\r\n" | ||
|
||
/*!< tab space count */ | ||
#define CONFIG_CSH_SPACE 4 | ||
|
||
/*!< independent ctrl map */ | ||
#define CONFIG_CSH_CTRLMAP 0 | ||
|
||
/*!< independent alt map */ | ||
#define CONFIG_CSH_ALTMAP 0 | ||
|
||
/*!< refresh prompt */ | ||
#define CONFIG_CSH_REFRESH_PROMPT 1 | ||
|
||
/*!< no waiting for sget */ | ||
#define CONFIG_CSH_NOBLOCK 1 | ||
|
||
/*!< help information */ | ||
#define CONFIG_CSH_HELP "" | ||
|
||
/*!< path length 0:const path, <=255:variable path */ | ||
#define CONFIG_CSH_MAXLEN_PATH 128 | ||
|
||
/*!< path segment count */ | ||
#define CONFIG_CSH_MAXSEG_PATH 16 | ||
|
||
/*!< user count */ | ||
#define CONFIG_CSH_MAX_USER 1 | ||
|
||
/*!< max argument count */ | ||
#define CONFIG_CSH_MAX_ARG 8 | ||
|
||
/*!< linebuffer static or on stack */ | ||
#define CONFIG_CSH_LNBUFF_STATIC 1 | ||
|
||
/*!< linebuffer size (valid only if lnbuff on stack) */ | ||
#define CONFIG_CSH_LNBUFF_SIZE 256 | ||
|
||
/*!< multi-thread mode */ | ||
#define CONFIG_CSH_MULTI_THREAD 0 | ||
|
||
/*!< independent signal handler (for multi instances) */ | ||
#define CONFIG_CSH_SIGNAL_HANDLER 0 | ||
|
||
/*!< Ctrl+c/d/q/s/z/\ F1-F12 UE <+120byte> */ | ||
#define CONFIG_CSH_USER_CALLBACK 1 | ||
|
||
/*!< enable macro export symbol table */ | ||
#define CONFIG_CSH_SYMTAB 1 | ||
|
||
/*!< print buffer size */ | ||
#define CONFIG_CSH_PRINT_BUFFER_SIZE 512 | ||
|
||
#endif |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2022, Egahp | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef SHELL_H | ||
#define SHELL_H | ||
|
||
#include "csh.h" | ||
|
||
extern int shell_init(uint8_t busid, uint32_t regbase, bool need_login); | ||
extern int shell_main(void); | ||
extern void shell_lock(void); | ||
extern void shell_unlock(void); | ||
|
||
#endif |
Oops, something went wrong.