-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
1962 lines (1479 loc) · 66.6 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
apps/nshlib
^^^^^^^^^^^
This directory contains the NuttShell (NSH) library. This library can be
linked with other logic to provide a simple shell application for NuttX.
- Console/NSH Front End
- Command Overview
- Conditional Command Execution
- Looping
- Built-In Variables
- Current Working Directory
Environment Variables
- NSH Start-Up Script
- Simple Commands
- Built-In Applications
- NSH Configuration Settings
Command Dependencies on Configuration Settings
Built-in Application Configuration Settings
NSH-Specific Configuration Settings
- Common Problems
Console/NSH Front End
^^^^^^^^^^^^^^^^^^^^^
Using settings in the configuration file, NSH may be configured to
use either the serial stdin/out or a telnet connection as the console
or BOTH. When NSH is started, you will see the following welcome on
either console:
NuttShell (NSH)
nsh>
'nsh>' is the NSH prompt and indicates that you may enter a command
from the console.
Command Overview
^^^^^^^^^^^^^^^^
This directory contains the NuttShell (NSH). This is a simple
shell-like application. At present, NSH supports the following commands
forms:
Simple command: <cmd>
Command with re-directed output: <cmd> > <file>
<cmd> >> <file>
Background command: <cmd> &
Re-directed background command: <cmd> > <file> &
<cmd> >> <file> &
Where:
<cmd> is any one of the simple commands listed later.
<file> is the full or relative path to any writeable object
in the file system name space (file or character driver).
Such objects will be referred to simply as files throughout
this README.
NSH executes at the mid-priority (128). Backgrounded commands can
be made to execute at higher or lower priorities using nice:
[nice [-d <niceness>>]] <cmd> [> <file>|>> <file>] [&]
Where <niceness> is any value between -20 and 19 where lower
(more negative values) correspond to higher priorities. The
default niceness is 10.
Multiple commands per line. NSH will accept multiple commands per
command line with each command separated with the semi-colon character (;).
If CONFIG_NSH_CMDPARMS is selected, then the output from commands, from
file applications, and from NSH built-in commands can be used as arguments
to other commands. The entity to be executed is identified by enclosing
the command line in back quotes. For example,
set FOO `myprogram $BAR`
Will execute the program named myprogram passing it the value of the
environment variable BAR. The value of the environment variable FOO
is then set output of myprogram on stdout. Because this feature commits
significant resources, it is disabled by default.
If CONFIG_NSH_ARGCAT is selected, the support concatenation of strings
with environment variables or command output. For example:
set FOO XYZ
set BAR 123
set FOOBAR ABC_${FOO}_${BAR}
would set the environment variable FOO to XYZ, BAR to 123 and FOOBAR
to ABC_XYZ_123. If NSH_ARGCAT is not selected, then a slightly small
FLASH footprint results but then also only simple environment
variables like $FOO can be used on the command line.
CONFIG_NSH_QUOTE enables back-slash quoting of certain characters within
the command. This option is useful for the case where an NSH script is
used to dynamically generate a new NSH script. In that case, commands
must be treated as simple text strings without interpretation of any
special characters. Special characters such as $, `, ", and others must
be retained intact as part of the test string. This option is currently
only available is CONFIG_NSH_ARGCAT is also selected.
Conditional Command Execution
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
An if-then[-else]-fi construct is also supported in order to
support conditional execution of commands. This works from the
command line but is primarily intended for use within NSH scripts
(see the sh command). The syntax is as follows:
if [!] <cmd>
then
[sequence of <cmd>]
else
[sequence of <cmd>]
fi
Looping
^^^^^^^
while-do-done and until-do-done looping constructs are also supported.
These works from the command line but are primarily intended for use
within NSH scripts (see the sh command). The syntax is as follows:
while <test-cmd>; do <cmd-sequence>; done
Execute <cmd-sequence> as long as <test-cmd> has an exit status of
zero.
until <test-cmd>; do <cmd-sequence>; done
Execute <cmd-sequence> as long as <test-cmd> has a non-zero exit
status.
A break command is also supported. The break command is only meaningful
within the body of the a while or until loop, between the do and done
tokens. If the break command is executed within the body of a loop, the
loop will immediately terminate and execution will continue with the
next command immediately following the done token.
Built-In Variables
^^^^^^^^^^^^^^^^^^
$? - The result of the last simple command execution
Current Working Directory
^^^^^^^^^^^^^^^^^^^^^^^^^
All path arguments to commands may be either an absolute path or a
path relative to the current working directory. The current working
directory is set using the 'cd' command and can be queried either
by using the 'pwd' command or by using the 'echo $PWD' command.
Environment Variables:
----------------------
PWD - The current working directory
OLDPWD - The previous working directory
NSH Start-Up Script
^^^^^^^^^^^^^^^^^^^
NSH supports options to provide a start up script for NSH. In general
this capability is enabled with CONFIG_NSH_ROMFSETC, but has
several other related configuration options as described in the final
section of this README. This capability also depends on:
- CONFIG_DISABLE_MOUNTPOINT not set
- CONFIG_NFILE_DESCRIPTORS > 4
- CONFIG_FS_ROMFS
Default Start-Up Behavior
-------------------------
The implementation that is provided is intended to provide great flexibility
for the use of Start-Up files. This paragraph will discuss the general
behavior when all of the configuration options are set to the default
values.
In this default case, enabling CONFIG_NSH_ROMFSETC will cause
NSH to behave as follows at NSH startup time:
- NSH will create a read-only RAM disk (a ROM disk), containing a tiny
ROMFS file system containing the following:
|--init.d/
`-- rcS
Where rcS is the NSH start-up script
- NSH will then mount the ROMFS file system at /etc, resulting in:
|--dev/
| `-- ram0
`--etc/
`--init.d/
`-- rcS
- By default, the contents of rcS script are:
# Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX
mkrd -m 1 -s 512 1024
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /tmp
- NSH will execute the script at /etc/init.d/rcS at start-up (before the
first NSH prompt. After execution of the script, the root FS will look
like:
|--dev/
| |-- ram0
| `-- ram1
|--etc/
| `--init.d/
| `-- rcS
`--tmp/
Modifying the ROMFS Image
-------------------------
The contents of the /etc directory are retained in the file
apps/nshlib/nsh_romfsimg.h (OR, if CONFIG_NSH_ARCHROMFS
is defined, include/arch/board/rcS.template). In order to modify
the start-up behavior, there are three things to study:
1. Configuration Options.
The additional CONFIG_NSH_ROMFSETC configuration options
discussed in the final section of this README.
2. tools/mkromfsimg.sh Script.
The script tools/mkromfsimg.sh creates nsh_romfsimg.h.
It is not automatically executed. If you want to change the
configuration settings associated with creating and mounting
the /tmp directory, then it will be necessary to re-generate
this header file using the mkromfsimg.sh script.
The behavior of this script depends upon three things:
- The configuration settings of the installed NuttX configuration.
- The genromfs tool (available from http://romfs.sourceforge.net).
- The file apps/nshlib/rcS.template (OR, if
CONFIG_NSH_ARCHROMFS is defined, include/arch/board/rcs.template)
3. rcS.template.
The file apps/nshlib/rcS.template contains the general form
of the rcS file; configured values are plugged into this
template file to produce the final rcS file.
NOTE:
apps/nshlib/rcS.template generates the standard, default
nsh_romfsimg.h file. If CONFIG_NSH_ARCHROMFS is defined
in the NuttX configuration file, then a custom, board-specific
nsh_romfsimg.h file residing in boards/<arch>/<chip>/<board>/include
will be used. NOTE when the OS is configured, include/arch/board will
be linked to boards/<arch>/<chip>/<board>/include.
All of the startup-behavior is contained in rcS.template. The
role of mkromfsimg.sh is to (1) apply the specific configuration
settings to rcS.template to create the final rcS, and (2) to
generate the header file nsh_romfsimg.h containing the ROMFS
file system image.
Simple Commands
^^^^^^^^^^^^^^^
o [ <expression> ]
o test <expression>
These are two alternative forms of the same command. They support
evaluation of a boolean expression which sets $?. This command
is used most frequently as the conditional command following the
'if' in the if-then[-else]-fi construct.
Expression Syntax:
------------------
expression = simple-expression | !expression |
expression -o expression | expression -a expression
simple-expression = unary-expression | binary-expression
unary-expression = string-unary | file-unary
string-unary = -n string | -z string
file-unary = -b file | -c file | -d file | -e file | -f file |
-r file | -s file | -w file
binary-expression = string-binary | numeric-binary
string-binary = string = string | string == string | string != string
numeric-binary = integer -eq integer | integer -ge integer |
integer -gt integer | integer -le integer |
integer -lt integer | integer -ne integer
o addroute <target> [<netmask>] <router>
addroute default <ipaddr> <interface>
This command adds an entry in the routing table. The new entry
will map the IP address of a router on a local network(<router>)
to an external network characterized by the <target> IP address and
a network mask <netmask>
The netmask may also be expressed using IPv4 CIDR or IPv6 slash
notation. In that case, the netmask need not be provided.
Example:
nsh> addroute 11.0.0.0 255.255.255.0 10.0.0.2
which is equivalent to
nsh> addroute 11.0.0.0/24 10.0.0.2
The second form of the addroute command can be used to set the default
gateway.
o arp [-t|-a <ipaddr>|-d <ipaddr>|-s <ipaddr> <hwaddr>]
Access the OS ARP table.
-a <ipaddr>
Will show the hardware address that the IP address <ipaddr> is mapped to.
-d <ipaddr>
Will delete the mapping for the IP address <ipaddr> from the ARP table.
-s <ipaddr> <hwaddr>
Will set (or replace) the mapping of the IP address <ipaddr> to the
hardware address <hwaddr>.
-t
Will dump the entire content of the ARP table. This option is only
available if CONFIG_NETLINK_ROUTE is enabled.
Example:
nsh> arp -a 10.0.0.1
nsh: arp: no such ARP entry: 10.0.0.1
nsh> arp -s 10.0.0.1 00:13:3b:12:73:e6
nsh> arp -a 10.0.0.1
HWAddr: 00:13:3b:12:73:e6
nsh> arp -d 10.0.0.1
nsh> arp -a 10.0.0.1
nsh: arp: no such ARP entry: 10.0.0.1
o base64dec [-w] [-f] <string or filepath>
o base64dec [-w] [-f] <string or filepath>
o basename <path> [<suffix>]
Extract the final string from a <path> by removing the preceding path
segments and (optionally) removing any trailing <suffix>.
o break
The break command is only meaningful within the body of the a while or
until loop, between the do and done tokens. Outside of a loop, break
command does nothing. If the break command is executed within the body
of a loop, the loop will immediately terminate and execution will
continue with the next command immediately following the done token.
o cat <path> [<path> [<path> ...]]
This command copies and concatenates all of the files at <path>
to the console (or to another file if the output is redirected).
o cd [<dir-path>|-|~|..]
Changes the current working directory (PWD). Also sets the
previous working directory environment variable (OLDPWD).
FORMS:
------
'cd <dir-path>' sets the current working directory to <dir-path>.
'cd -' sets the current working directory to the previous
working directory ($OLDPWD). Equivalent to 'cd $OLDPWD'.
'cd' or 'cd ~' set the current working directory to the 'home'
directory. The 'home' directory can be configured by setting
CONFIG_LIB_HOMEDIR in the configuration file. The default
'home' directory is '/'.
'cd ..' sets the current working directory to the parent directory.
o cmp <path1> <path2>
Compare of the contents of the file at <file1> with the contents of
the file at <path2>. Returns an indication only if the files differ.
o cp <source-path> <dest-path>
Copy of the contents of the file at <source-path> to the location
in the file system indicated by <path-path>
o date [-s "MMM DD HH:MM:SS YYYY"]
Show or set the current date and time.
Only one format is used both on display and when setting the date/time:
MMM DD HH:MM:SS YYYY. For example,
data -s "Sep 1 11:30:00 2011"
24-hour time format is assumed.
o dd if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]
Copy blocks from <infile> to <outfile>. <nfile> or <outfile> may
be the path to a standard file, a character device, or a block device.
Examples:
1. Read from character device, write to regular file. This will
create a new file of the specified size filled with zero.
nsh> dd if=/dev/zero of=/tmp/zeros bs=64 count=16
nsh> ls -l /tmp
/tmp:
-rw-rw-rw- 1024 ZEROS
2. Read from character device, write to block device. This will
fill the entire block device with zeros.
nsh> ls -l /dev
/dev:
brw-rw-rw- 0 ram0
crw-rw-rw- 0 zero
nsh> dd if=/dev/zero of=/dev/ram0
3. Read from a block device, write to a character device. This
will read the entire block device and dump the contents in
the bit bucket.
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
nsh> dd if=/dev/ram0 of=/dev/null
o delroute <target> [<netmask>]
This command removes an entry from the routing table. The entry
removed will be the first entry in the routing table that matches
the external network characterized by the <target> IP address and
the network mask <netmask>
The netmask may also be expressed using IPv4 CIDR or IPv6 slash
notation. In that case, the netmask need not be provided.
Example:
nsh> delroute 11.0.0.0 255.255.255.0
which is equivalent to
nsh> delroute 11.0.0.0/24
o df
Show the state of each mounted volume.
Example:
nsh> mount
/etc type romfs
/tmp type vfat
nsh> df
Block Number
Size Blocks Used Available Mounted on
64 6 6 0 /etc
512 985 2 983 /tmp
nsh>
o dirname <path>
Extract the path string leading up to the full <path> by removing
the final directory or file name.
o dmesg
This command can be used to dump (and clear) the content of any
buffered syslog output messages. This command is only available
if CONFIG_RAMLOG_SYSLOG is enabled. In that case, syslog output
will be collected in an in-memory, circular buffer. Entering the
'dmesg' command will dump the content of that in-memory, circular
buffer to the NSH console output. 'dmesg' has the side effect of
clearing the buffered data so that entering 'dmesg' again will
show only newly buffered data.
o echo [-n] [<string|$name> [<string|$name>...]]
Copy the sequence of strings and expanded environment variables to
console out (or to a file if the output is re-directed).
The -n option will suppress the trailing newline character.
o env
Show the current name-value pairs in the environment. Example:
nsh> env
PATH=/bin
nsh> set foo bar
nsh> env
PATH=/bin
foo=bar
nsh> unset PATH
nsh> env
foo=bar
nsh>
NOTE: NSH variables are *not* shown by the env command.
o exec <hex-address>
Execute the user logic at address <hex-address>. NSH will pause
until the execution unless the user logic is executed in background
via 'exec <hex-address> &'
o exit
Exit NSH. Only useful if you have started some other tasks (perhaps
using the 'exec' command') and you would like to have NSH out of the
way.
o export <name> [<value>]
The 'export' command sets an environment variable, or promotes an
NSH variable to an environment variable. As examples:
1. Using 'export' to promote an NSH variable to an environment variable.
nsh> env
PATH=/bin
nsh> set foo bar
nsh> env
PATH=/bin
nsh> export foo
nsh> env
PATH=/bin
foo=bar
A group-wide environment variable is created with the same value as the
local NSH variable; the local NSH variable is removed.
NOTE: This behavior differs from the Bash shell. Bash will retain the
local Bash variable which will shadow the environment variable of the
same name and same value.
2. Using 'export' to set an environment variable
nsh> export dog poop
nsh> env
PATH=/bin
foo=bar
dog=poop
The export command is not supported by NSH unless both CONFIG_NSH_VARS=y
and CONFIG_DISABLE_ENVIRON is not set.
o free
Show the current state of the memory allocator. For example,
nsh> free
free
total used free largest
Mem: 4194288 1591552 2602736 2601584
Where:
total - This is the total size of memory allocated for use
by malloc in bytes.
used - This is the total size of memory occupied by
chunks handed out by malloc.
free - This is the total size of memory occupied by
free (not in use) chunks.
largest - Size of the largest free (not in use) chunk
o get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>
Use TFTP to copy the file at <remote-address> from the host whose IP
address is identified by <ip-address>. Other options:
-f <local-path>
The file will be saved relative to the current working directory
unless <local-path> is provided.
-b|-n
Selects either binary ("octet") or test ("netascii") transfer
mode. Default: text.
o help [-v] [<cmd>]
Presents summary information about NSH commands to console. Options:
-v
Show verbose output will full command usage
<cmd>
Show full command usage only for this command
o hexdump <file or device>
Dump data in hexadecimal format from a file or character device.
o ifconfig [nic_name [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]
Show the current configuration of the network, for example:
nsh> ifconfig
eth0 HWaddr 00:18:11:80:10:06
IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
if networking statistics are enabled (CONFIG_NET_STATISTICS), then
this command will also show the detailed state of transfers by protocol.
NOTE: This commands depends upon having the procfs file system configured
into the system. The procfs file system must also have been mounted
with a command like:
nsh> mount -t procfs /proc
o ifdown <interface>
Take down the interface identified by the name <interface>.
Example:
ifdown eth0
o ifup <interface>
Bring up down the interface identified by the name <interface>.
Example:
ifup eth0
o insmod <file-path> <module-name>
Install the loadable OS module at <file-path> as module <module-name>
Example:
nsh> ls -l /mnt/romfs
/mnt/romfs:
dr-xr-xr-x 0 .
-r-xr-xr-x 9153 chardev
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
crw-rw-rw- 0 ttyS0
nsh> insmod /mnt/romfs/chardev mydriver
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 chardev
crw-rw-rw- 0 console
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
crw-rw-rw- 0 ttyS0
nsh> lsmod
NAME INIT UNINIT ARG TEXT SIZE DATA SIZE
mydriver 20404659 20404625 0 20404580 552 204047a8 0
o irqinfo
Show the current count of interrupts taken on all attached interrupts.
Example:
nsh> irqinfo
IRQ HANDLER ARGUMENT COUNT RATE
3 00001b3d 00000000 156 19.122
15 0000800d 00000000 817 100.000
30 00000fd5 20000018 20 2.490
o kill -<signal> <pid>
Send the <signal> to the task identified by <pid>.
o losetup [-d <dev-path>] | [[-o <offset>] [-r] <ldev-path> <file-path>]
Setup or teardown the loop device:
1. Teardown the setup for the loop device at <dev-path>:
losetup d <dev-path>
2. Setup the loop device at <dev-path> to access the file at <file-path>
as a block device:
losetup [-o <offset>] [-r] <dev-path> <file-path>
Example:
nsh> dd if=/dev/zero of=/tmp/image bs=512 count=512
nsh> ls -l /tmp
/tmp:
-rw-rw-rw- 262144 IMAGE
nsh> losetup /dev/loop0 /tmp/image
nsh> ls -l /dev
/dev:
brw-rw-rw- 0 loop0
nsh> mkfatfs /dev/loop0
nsh> mount -t vfat /dev/loop0 /mnt/example
nsh> ls -l /mnt
ls -l /mnt
/mnt:
drw-rw-rw- 0 example/
nsh> echo "This is a test" >/mnt/example/atest.txt
nsh> ls -l /mnt/example
/mnt/example:
-rw-rw-rw- 16 ATEST.TXT
nsh> cat /mnt/example/atest.txt
This is a test
nsh>
o ln [-s] <target> <link>
The link command will create a new symbolic link at <link> for the
existing file or directory, <target>. This implementation is simplied
for use with NuttX in these ways:
- Links may be created only within the NuttX top-level, pseudo file
system. No file system currently supported by NuttX provides
symbolic links.
- For the same reason, only soft links are implemented.
- File privileges are ignored.
- c_time is not updated.
o ls [-lRs] <dir-path>
Show the contents of the directory at <dir-path>. NOTE:
<dir-path> must refer to a directory and no other file system
object.
Options:
--------
-R Show the constents of specified directory and all of its
sub-directories.
-s Show the size of the files along with the filenames in the
listing
-l Show size and mode information along with the filenames
in the listing.
o lsmod
Show information about the currently installed OS modules. This information includes:
- The module name assigned to the module when it was installed (NAME, string).
- The address of the module initialization function (INIT, hexadecimal).
- The address of the module un-initialization function (UNINIT, hexadecimal).
- An argument that will be passed to the module un-initialization function (ARG, hexadecimal).
- The start of the .text memory region (TEXT, hexadecimal).
- The size of the .text memory region size (SIZE, decimal).
- The start of the .bss/.data memory region (DATA, hexadecimal).
- The size of the .bss/.data memory region size (SIZE, decimal).
Example:
nsh> lsmod
NAME INIT UNINIT ARG TEXT SIZE DATA SIZE
mydriver 20404659 20404625 0 20404580 552 204047a8 0
o md5 [-f] <string or filepath>
o mb <hex-address>[=<hex-value>][ <hex-byte-count>]
o mh <hex-address>[=<hex-value>][ <hex-byte-count>]
o mw <hex-address>[=<hex-value>][ <hex-byte-count>]
Access memory using byte size access (mb), 16-bit accesses (mh),
or 32-bit access (mw). In each case,
<hex-address>. Specifies the address to be accessed. The current
value at that address will always be read and displayed.
<hex-address>=<hex-value>. Read the value, then write <hex-value>
to the location.
<hex-byte-count>. Perform the mb, mh, or mw operation on a total
of <hex-byte-count> bytes, increment the <hex-address> appropriately
after each access
Example
nsh> mh 0 16
0 = 0x0c1e
2 = 0x0100
4 = 0x0c1e
6 = 0x0110
8 = 0x0c1e
a = 0x0120
c = 0x0c1e
e = 0x0130
10 = 0x0c1e
12 = 0x0140
14 = 0x0c1e
nsh>
o mkdir <path>
Create the directory at <path>. All components of of <path>
except the final directory name must exist on a mounted file
system; the final directory must not.
Recall that NuttX uses a pseudo file system for its root file system.
The mkdir command can only be used to create directories in volumes
set up with the mount command; it cannot be used to create directories
in the pseudo file system.
Example:
^^^^^^^^
nsh> mkdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
drw-rw-rw- 0 TESTDIR/
drw-rw-rw- 0 TMP/
nsh>
o mkfatfs [-F <fatsize>] [-r <rootdirentries>] <block-driver>
Format a fat file system on the block device specified by <block-driver>
path. The FAT size may be provided as an option. Without the <fatsize>
option, mkfatfs will select either the FAT12 or FAT16 format. For
historical reasons, if you want the FAT32 format, it must be explicitly
specified on the command line.
The -r option may be specified to select the the number of entries in
the root directory. Typical values for small volumes would be 112 or 224;
512 should be used for large volumes, such as hard disks or very large
SD cards. The default is 512 entries in all cases.
The reported number of root directory entries used with FAT32 is zero
because the FAT32 root directory is a cluster chain.
NSH provides this command to access the mkfatfs() NuttX API.
This block device must reside in the NuttX pseudo file system and
must have been created by some call to register_blockdriver() (see
include/nuttx/fs/fs.h).
o mkfifo <path>
Creates a FIFO character device anywhere in the pseudo file system,
creating whatever pseudo directories that may be needed to complete
the full path. By convention, however, device drivers are place in
the standard /dev directory. After it is created, the FIFO device
may be used as any other device driver. NSH provides this command
to access the mkfifo() NuttX API.
Example:
^^^^^^^^
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
nsh> mkfifo /dev/fifo
nsh> ls -l /dev
ls -l /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 fifo
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
nsh>
o mkrd [-m <minor>] [-s <sector-size>] <nsectors>
Create a ramdisk consisting of <nsectors>, each of size
<sector-size> (or 512 bytes if <sector-size> is not specified).
The ramdisk will be registered as /dev/ram<minor>. If <minor> is
not specified, mkrd will attempt to register the ramdisk as
/dev/ram0.
Example:
^^^^^^^^
nsh> ls /dev
/dev:
console
null
ttyS0
ttyS1
nsh> mkrd 1024
nsh> ls /dev
/dev:
console
null
ram0
ttyS0
ttyS1
nsh>
Once the ramdisk has been created, it may be formatted using
the mkfatfs command and mounted using the mount command.
Example:
^^^^^^^^
nsh> mkrd 1024
nsh> mkfatfs /dev/ram0
nsh> mount -t vfat /dev/ram0 /tmp
nsh> ls /tmp
/tmp:
nsh>
o mount [-t <fstype> [-o <options>] <block-device> <dir-path>]
The mount command performs one of two different operations. If no
parameters are provided on the command line after the mount command,
then the 'mount' command will enumerate all of the current
mountpoints on the console.
If the mount parameters are provied on the command after the 'mount'
command, then the 'mount' command will mount a file system in the
NuttX pseudo-file system. 'mount' performs a three way association,
binding:
File system. The '-t <fstype>' option identifies the type of
file system that has been formatted on the <block-device>. As
of this writing, vfat is the only supported value for <fstype>
Block Device. The <block-device> argument is the full or relative
path to a block driver inode in the pseudo file system. By convention,
this is a name under the /dev sub-directory. This <block-device>
must have been previously formatted with the same file system
type as specified by <fstype>
Mount Point. The mount point is the location in the pseudo file
system where the mounted volume will appear. This mount point
can only reside in the NuttX pseudo file system. By convention, this
mount point is a subdirectory under /mnt. The mount command will
create whatever pseudo directories that may be needed to complete
the full path but the full path must not already exist.
After the volume has been mounted in the NuttX pseudo file
system, it may be access in the same way as other objects in the
file system.
Examples:
^^^^^^^^^
nsh> ls -l /dev
/dev:
crw-rw-rw- 0 console
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
nsh> ls /mnt
nsh: ls: no such directory: /mnt
nsh> mount -t vfat /dev/ram0 /mnt/fs
nsh> ls -l /mnt/fs/testdir
/mnt/fs/testdir:
-rw-rw-rw- 15 TESTFILE.TXT
nsh> echo "This is a test" >/mnt/fs/testdir/example.txt
nsh> ls -l /mnt/fs/testdir
/mnt/fs/testdir:
-rw-rw-rw- 15 TESTFILE.TXT
-rw-rw-rw- 16 EXAMPLE.TXT
nsh> cat /mnt/fs/testdir/example.txt
This is a test
nsh>
nsh> mount
/etc type romfs
/tmp type vfat
/mnt/fs type vfat
o mv <old-path> <new-path>
Rename the file object at <old-path> to <new-path>. Both paths must
reside in the same mounted file system.
o nfsmount <server-address> <mount-point> <remote-path>
Mount the remote NFS server directory <remote-path> at <mount-point> on the target machine.
<server-address> is the IP address of the remote server.
o nslookup <host-name>
Lookup and print the IP address associated with <host-name>
o passwd <username> <password>
Set the password for the existing user <username> to <password>
o pmconfig [stay|relax] [normal|idle|standby|sleep]
Control power management subsystem.