dongjiuzhu1
5585c9d347
nshlib/dd: remove nsh dd cmd
...
using system/dd to instead nsh dd cmd
remove related to config, file.
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com >
2025-04-20 00:41:18 +08:00
Alin Jerpelea
27d8ae36ba
nshlib: migrate to SPDX identifier
...
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com >
2024-12-30 18:02:50 +08:00
chao an
e861ea8b53
nshlib/[cd|ls|pwd]: add support for local CWD(Current working directory)
...
This PR will still allow basic shell operations such as cd/ls/pwd to be used even when the environment is disabled.
Signed-off-by: chao an <anchao@lixiang.com >
2024-12-12 02:12:55 +08:00
wangjianyu3
687c1cacd9
nshlib/cmd_wait: Wait failed if "PROCFS/PROCES" not enabled
...
Env
sim:nsh
- CONFIG_FS_PROCFS_EXCLUDE_PROCES=y
Error
nsh> sleep 5 &
sh [4:100]
nsh> wait 4
nsh: wait: wait failed: 2
cmd_wait():
snprintf(path, sizeof(path), "/proc/%d/status", tid);
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com >
2024-11-14 23:20:39 +08:00
wangjianyu3
e5a1bb1796
nshlib/dd: Add support for reading from/writing to standard input/output
...
Test
1. Input from stdin and output to stdout
Keyboard input: 12345AAAAABBBBB
nsh> dd bs=5
1234512345AAAAAAAAAABBBBBBBBBB
2. Input from file and output to stdout
nsh> dd if=/etc/init.d/rc.sysinit
mkrd -m 2 -s 512 1024
mkfatfs /dev/ram2
mount -t vfat /dev/ram2 "/tmp"
3. Input from stdin and output to file
Keyboard input: QWERT
dd of=/data/dd_stdout bs=5
Then, cat the output file in host (based on HostFS):
$ cat ./dd_stdout
QWERT
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com >
2024-10-19 14:07:32 +08:00
yinshengkai
59c21c7aee
nsh: support watch command
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com >
2024-10-17 18:06:32 +08:00
anjiahao
6979fca4dc
nshlib: Support top command
...
show thread sort by cpuloading:
use `top [-n <num> ][ -d <delay>] [ -p <pidlist>] [ -h ]`
Signed-off-by: anjiahao <anjiahao@xiaomi.com >
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com >
2024-10-16 18:23:54 +08:00
yinshengkai
b90899b1d5
nshlib: ps supports noheap parameter
...
Obtaining the heap usage size requires traversing all memory.
When the number of threads is large, it will become very slow.
ps -heap
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK HEAP STACK USED FILLED COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 4338432 2162672 0005196 0.2% Idle_Task
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com >
2024-10-16 18:23:54 +08:00
zhushiqshi
a655e067ef
apps: added pid list for ps command.
...
Signed-off-by: zhushiqshi <zhushiqshi@xiaomi.com >
2024-10-16 18:23:54 +08:00
anjiahao
c916f163f2
nsh:support wait command to wait task exit.
...
usage like:
nsh> sleep 10 &
[5:100]
nsh>set pid1=$!
nsh>sleep 15 &
[6:100]
nsh>set pid2=$!
nsh>wait $pid1 $pid2
'wait' command will block nsh from running until pid1 and pid2 finish.
This is useful for parallel requirements to perform certain tasks
Signed-off-by: anjiahao <anjiahao@xiaomi.com >
2024-10-02 21:13:54 +08:00
dongjiuzhu1
97a33e7491
nshlib: support dd with conv=notrunc,nocreat
...
refs to: https://man7.org/linux/man-pages/man1/dd.1.html
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com >
2024-09-30 14:16:40 +08:00
anjiahao
5dcfe93a95
nsh:support $! get last pid use nsh run
...
test:
nsh> hello &
hello [4:100]
nsh> Hello, World!!
nsh> echo $!
4
nsh> echo $!
3
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 0069616 Idle_Task
1 1 224 FIFO Kthread - Waiting Signal 0000000000000000 0067536 loop_task
2 2 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067504 hpwork 0x45ae80 0x45aea8
3 3 100 FIFO Task - Running 0000000000000000 0067536 nsh_main
nsh>
Signed-off-by: anjiahao <anjiahao@xiaomi.com >
2024-09-28 11:28:15 +08:00
Michal Lenc
f81a094283
nshlib: add support for pkill command
...
This command looks through the currently running processes and kills
the those that match the selection criteria. This way system can send
signal to processes by name and without knowing the IDs.
Example (kill application hello):
pkill -15 hello
The command can be turned off by NSH_DISABLE_PKILL option and depends
on FS_PROCFS.
Signed-off-by: Michal Lenc <michallenc@seznam.cz >
2024-09-23 08:40:54 +08:00
wangjianyu3
aaf4e9d480
nshlib: Support "-f" option for command "rm"
...
In below two cases "rm" command with "-f" option will return 0:
a. Bad arguments
b. File not exists
Following "rm" of GNU coreutils 8.32
GNU coreutils
$ rm --version
rm (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html >.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Rubin, David MacKenzie, Richard M. Stallman,
and Jim Meyering.
$ rm /FILE_NOT_EXISTS
rm: cannot remove '/FILE_NOT_EXISTS': No such file or directory
$ echo $?
1
$ rm -f
$ echo $?
0
$ rm -f /FILE_NOT_EXISTS
$ echo $?
0
Without this patch
nsh> rm
nsh: rm: missing required argument(s)
nsh> rm /FILE_NOT_EXISTS
nsh: rm: unlink failed: 2
nsh> echo $?
1
With this patch
nsh> rm -f
nsh> echo $?
0
nsh> rm -f /FILE_NOT_EXISTS
nsh> echo $?
0
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com >
2024-09-19 03:45:37 +08:00
chao an
8ad39537dd
nshlib: move g_builtin_prompt from data to rodata
...
1. move g_builtin_prompt from data to rodata
2. add g_ prefix to some global variables
Signed-off-by: chao an <anchao@lixiang.com >
2024-09-05 09:49:44 +08:00
Marco Casaroli
8fba726a7d
feat(nsh_cat): allow cat to read from stdin
...
Now, if we run cat without arguments, it will just read from stdin.
It can be used with redirect like `cat < infile > outfile`.
2024-08-08 19:19:18 -03:00
Alan Carvalho de Assis
b4ec000dec
apps/nsh_commands: Use quit to poweroff
...
Currently new users when try to run NuttX using the SIM
get stuck into simulator, because they have no idea that
poweroff command is used to leave it. Let use KISS approach
and use quit as an alias to poweroff command.
Signed-off-by: Alan C. Assis <acassis@gmail.com >
2024-04-13 15:17:50 +08:00
chao an
20c90d5b43
nshlib/irqaff: add irq affinity command
...
add support for set an IRQ affinity to CPUs by software
qemu-armv7a/bmp: switch uart irq to different CPUs
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 004080 000536 13.1% CPU0 IDLE
1 1 192 RR Kthread - Waiting Semaphore 0000000000000000 004032 000296 7.3% hpwork 0x4013f51c 0x4013f530
2 2 100 RR Task - Running 0000000000000000 004056 001168 28.7% nsh_main
nsh> irqaff 33 0x2
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 004080 000736 18.0% CPU1 IDLE
1 1 192 RR Kthread - Waiting Semaphore 0000000000000000 004032 000296 7.3% hpwork 0x4013f544 0x4013f558
2 2 100 RR Task - Running 0000000000000000 004056 001288 31.7% nsh_main
nsh> irqaff 33 0x4
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 004080 000736 18.0% CPU2 IDLE
1 1 192 RR Kthread - Waiting Semaphore 0000000000000000 004032 000296 7.3% hpwork 0x4013f56c 0x4013f580
2 2 100 RR Task - Running 0000000000000000 004056 001168 28.7% nsh_main
nsh> irqaff 33 0x8
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK USED FILLED COMMAND
0 0 0 FIFO Kthread - Ready 0000000000000000 004080 000736 18.0% CPU3 IDLE
1 1 192 RR Kthread - Waiting Semaphore 0000000000000000 004032 000296 7.3% hpwork 0x4013f594 0x4013f5a8
2 2 100 RR Task - Running 0000000000000000 004056 001168 28.7% nsh_main
Signed-off-by: chao an <anchao@lixiang.com >
2024-03-29 16:16:07 +08:00
chenrun1
e8470f7d0e
cp:support -r recursive copies
...
The cp command supports recursive copying. Use "cp -r" to copy a folder.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com >
2024-02-25 21:59:57 -08:00
chenrun1
bd1cc85ad4
dd:support "seek"
...
Now the dd command can use the "seek" parameter to adjust how many bytes need to be skipped before being written to the target.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com >
2024-02-25 06:36:43 -08:00
wangyongrong
32f269a079
nsh_syscmds: update rptun_ping to rpmsg_ping, add cmd_rpmsg.
...
To support rpmsg ioctl, add cmd_rpmsg function, and update rptun ping to rpmsg ping.
depends on apache/nuttx#11618
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com >
2024-01-30 20:42:49 -08:00
yangjian11
09122debe9
nsh_timcmds: display date using set format
...
Reference: https://www.geeksforgeeks.org/date-command-linux-examples/?ref=gcse#9-list-of-format-specifiers-used-with-date-command
Signed-off-by: yangjian11 <yangjian11@xiaomi.com >
2024-01-26 19:13:25 -08:00
Junbo Zheng
c699b05f74
nshlib: add expr
command support
...
It is a mini version for the `expr` command, which implements the features of addition, subtraction, multiplication, division and mod.
Reference: https://www.geeksforgeeks.org/expr-command-in-linux-with-examples/
bl2>
bl2> expr 1 + 2
3
bl2> expr
Usage: expr <operand1> <operator> <operand2>
bl2> expr 5 - 2
3
bl2> set hello 10
bl2> expr $hello - 2
8
bl2> expr 8 a 9
Unknown operator
bl2> expr 20 / 5
4
bl2> expr 10 % 4
2
bl2> expr 10 / 0
operand2 invalid
bl2>
bl2> expr mi + 100
invalid parameter
bl2> expr 100 + mi
invalid parameter
bl2> expr 100 + 0
100
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com >
2024-01-25 18:12:28 -08:00
wangyongrong
51762a8958
nsh cmd rptun: add rptun ping useage description
...
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com >
2024-01-06 04:33:48 -08:00
yuanyongjian
dcfb4d0662
nshlib:dmesg add '-c|-C' opt
...
Signed-off-by: yuanyongjian <yuanyongjian@xiaomi.com >
2023-12-14 20:14:25 -08:00
Zhe Weng
56ef320d6f
nshlib/ifconfig: Add support for add/del a single IPv6 address
...
Note: We're using similar error codes as Linux:
```
linux> sudo ifconfig eth0 inet6 add fc00::2/64
linux> sudo ifconfig eth0 inet6 del fc00::2/112
SIOCDIFADDR: Cannot assign requested address
linux> sudo ifconfig eth0 inet6 del fc00::3/64
SIOCDIFADDR: Cannot assign requested address
linux> sudo ifconfig eth0 inet6 add fc00::2/64
SIOCSIFADDR: File exists
nuttx> ifconfig eth0 inet6 add fc00::2/64
nuttx> ifconfig eth0 inet6 del fc00::2/112
Failed to manage IPv6 address: Cannot assign requested address
nuttx> ifconfig eth0 inet6 del fc00::3/112
Failed to manage IPv6 address: Cannot assign requested address
nuttx> ifconfig eth0 inet6 add fc00::2/64
Failed to manage IPv6 address: File exists
```
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com >
2023-11-08 00:20:19 +08:00
Xiang Xiao
fe7f217497
nshlib: losetup/lomtd change "-s <sectsize>" to "-b <sectsize>"
...
to follow host tool usage:
https://github.com/util-linux/util-linux/blob/master/sys-utils/losetup.c#L473
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-10-16 13:14:48 -04:00
wangmingrong
7981278021
apps/nshlib: Add the pidof command and API nsh_getpid
...
Add the API "nsh_getpid" in "nsh_fsutils. c" and the nsh command pidof. Temporarily support two parameters, - s, and process name
Signed-off-by: wangmingrong <wangmingrong@xiaomi.com >
2023-08-29 02:58:45 +08:00
yinshengkai
105fd2aac5
nsh: fix a buffer overflow in help
...
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com >
2023-08-09 18:22:09 +08:00
chenrun1
415168dde6
nshlib: Add fdinfo to get information about the process associated fd
...
Signed-off-by: chenrun1 <chenrun1@xiaomi.com >
2023-07-16 16:39:11 +08:00
Junbo Zheng
9de5a2550e
nshlib: add -h
option for ls command
...
config: ./tools/configure.sh sim:nsh
CONFIG_LIBC_FLOATINGPOINT=y
```
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 gpio0
crw-rw-rw- 0 gpio1
crw-rw-rw- 0 gpio2
crw-rw-rw- 0 gpio3
crw-rw-rw- 0 loop
crw-rw-rw- 0 null
crw-rw-rw- 0 oneshot
brw-rw-rw- 1048576 ram0
brw-rw-rw- 1024 ram1
brw-rw-rw- 524288 ram2
crw-rw-rw- 0 zero
nsh> ls /lh /dev
nsh: ls: too many arguments
nsh> ls -lh /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 gpio0
crw-rw-rw- 0 gpio1
crw-rw-rw- 0 gpio2
crw-rw-rw- 0 gpio3
crw-rw-rw- 0 loop
crw-rw-rw- 0 null
crw-rw-rw- 0 oneshot
brw-rw-rw- 1.0M ram0
brw-rw-rw- 1.0K ram1
brw-rw-rw- 512.0K ram2
crw-rw-rw- 0 zero
```
config: ./tools/configure.sh ../vendor/sim/boards/miwear/configs/miwear -j16
```
nsh> ls -l /resource/misc/media
/resource/misc/media:
-rwxrwxr-x 384044 AlexaTimer.wav
-rwxrwxr-x 57001 AlexaReminder.mp3
-rwxrwxr-x 384132 AlexaAlarm.wav
-rw-rw-r-- 20733 Clank.mp3
-rw-rw-r-- 45183 NotificationXylophone.mp3
-rw-rw-r-- 27420 Robot.mp3
-rw-rw-r-- 21986 FadeIn.mp3
-rw-rw-r-- 42049 Flute.mp3
-rw-rw-r-- 362748 Latona-15s.mp3
drwxrwxr-x 4096 .
-rw-rw-r-- 47198 alarm_volume_adjust.mp3
-rw-rw-r-- 95338 Expect.mp3
drwxrwxr-x 4096 ..
-rw-rw-r-- 409435 Sunrise.mp3
-rw-rw-r-- 55841 Fresh.mp3
-rw-rw-r-- 36685 Bells-1s.mp3
-rw-rw-r-- 4432 camera_click.mp3
-rw-rw-r-- 469621 MiRemix.mp3
nsh>
nsh> ls -lh /resource/misc/media
/resource/misc/media:
-rwxrwxr-x 375.0K AlexaTimer.wav
-rwxrwxr-x 55.7K AlexaReminder.mp3
-rwxrwxr-x 375.1K AlexaAlarm.wav
-rw-rw-r-- 20.2K Clank.mp3
-rw-rw-r-- 44.1K NotificationXylophone.mp3
-rw-rw-r-- 26.8K Robot.mp3
-rw-rw-r-- 21.5K FadeIn.mp3
-rw-rw-r-- 41.1K Flute.mp3
-rw-rw-r-- 354.2K Latona-15s.mp3
drwxrwxr-x 4.0K .
-rw-rw-r-- 46.1K alarm_volume_adjust.mp3
-rw-rw-r-- 93.1K Expect.mp3
drwxrwxr-x 4.0K ..
-rw-rw-r-- 399.8K Sunrise.mp3
-rw-rw-r-- 54.5K Fresh.mp3
-rw-rw-r-- 35.8K Bells-1s.mp3
-rw-rw-r-- 4.3K camera_click.mp3
-rw-rw-r-- 458.6K MiRemix.mp3
```
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com >
2023-07-05 16:25:27 +08:00
chao an
e4cf94b509
nshlib/command: exclude usage to reduce data size
...
Test on sim/nsh (CONFIG_NSH_DISABLE_HELP=y):
text data bss dec hex filename
393746 26824 4000 424570 67a7a nuttx /* before */
391858 26440 4000 422298 6719a nuttx /* after */
-1888 -384
Signed-off-by: chao an <anchao@xiaomi.com >
2023-06-10 02:20:49 +08:00
Xiang Xiao
e81227f99d
Indent the define statement by two spaces
...
follow the code style convention
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-05-22 11:57:40 +02:00
anjiahao
e68d5ffb98
support memdump can dump by seq number
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com >
2023-05-21 00:08:48 +08:00
wangchen
cb292d0608
nshlib/netcmds:modify the description of setting MTU
...
modify the description of setting MTU
Signed-off-by: wangchen <wangchen41@xiaomi.com >
2023-05-10 19:56:04 +08:00
Xiang Xiao
bebae28bdd
nsh: Fix the typo error cmd_swtichboot -> cmd_switchboot
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-05-03 17:40:49 +03:00
wangchen
c2f75330f7
nshlib/netcmds:support to set MTU
...
Usage:ifconfig interfacename mtu ***
Signed-off-by: wangchen <wangchen41@xiaomi.com >
2023-04-27 18:02:23 +08:00
Xiang Xiao
1d3e6510e6
nshlib: Add switchboot command
...
switchboot <image path>
Switch to the updated or specified boot system. This command depends on
hardware support CONFIG_BOARDCTL_SWITCH_BOOT. `<image path>` point to a
partion or file which contain the firmware to boot.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-04-07 13:44:49 +03:00
Xiang Xiao
49418d6de5
nshlib: Align the command table
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-04-04 13:53:28 +03:00
Xiang Xiao
4f7dd7be7c
nshlib: Add boot command
...
boot [<image path> [<header size>]]
Boot a new firmware image. This command depends on hardware support
CONFIG_BOARDCTL_BOOT_IMAGE. <image path> may point to a partion or file
which contain the firmware to boot. The optional, numeric argument
<header size> may be useful for skipping metadata information preprended
to the firmware image.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-04-04 13:53:28 +03:00
Ville Juven
f9dfb51001
nsh/nshlib: Add alias support for nsh
...
This adds support for string aliases into nsh. There are some nuances that
are not handled correctly yet:
- Reserved words can be overloaded, which is a clear POSIX violation
2023-03-23 22:10:19 +02:00
Huang Qi
dbf7d34a2a
nsh: Fix a potential buffer overflow in cmd help
...
Follow https://github.com/apache/nuttx-apps/pull/1621 , fix issue of builtin command list.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com >
2023-03-09 01:42:38 +08:00
Huang Qi
12d31075eb
nsh: Fix a buffer overflow in help
...
Introduced by https://github.com/apache/nuttx-apps/pull/1610 ,
internal line buffer should have more bytes for tab before newline and '\0'.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com >
2023-03-05 11:18:59 +02:00
Huang Qi
e957e1633c
nsh: Improve performance of help
by line buffer
...
This change reduce the usage of `printf`,
which will improve both CPU usage and IO performance.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com >
2023-03-03 17:41:39 +09:00
Xiang Xiao
359f66ad37
nshlib: Remove the remaining CONFIG_FILE_STREAM dependence
...
continue the change from https://github.com/apache/nuttx-apps/pull/1559
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
2023-02-24 17:38:19 +08:00
Oreh
f63a3cac0e
Add NSH lomtd command (creates MTD loop device)
2023-02-19 19:55:52 +08:00
Zhe Weng
93b4dc2692
ifconfig: Support ifconfig interface
and update arg limit
...
From comment in cmd_ifconfig, it seems that we support `ifconfig [interface]`, but actually not considering the interface param now. After this commit, we only print the information of interface specified in param, just like linux.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com >
2023-02-01 11:12:24 +08:00
zhanghongyu
df3121213e
cmd_arp: add device input for arp interface
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com >
2022-12-14 21:19:37 +08:00
anjiahao
14465b85c4
cmd_dd:support dd can do verify
...
After writing the file, compare the contents of the two files again
Signed-off-by: anjiahao <anjiahao@xiaomi.com >
2022-11-14 20:40:43 +08:00
Xiang Xiao
36a0c924f7
netutils: Support telnetd in the kernel mode
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com >
Signed-off-by: chao an <anchao@xiaomi.com >
2022-11-07 15:24:08 +09:00