summaryrefslogtreecommitdiffstats
path: root/nuttx/Documentation/NuttShell.html
blob: 72629580f83f0c8856221dac1dec8dcf436cd7f2 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
<html>
<head>
<title>NuttShell</title>
</head>
<body background="backgd.gif">
<hr><hr>
<table width ="100%">
  <tr align="center" bgcolor="#e4e4e4">
    <td>
      <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
      <p>Last Updated: June 11, 2012</p>
    </td>
  </tr>
</table>
<hr><hr>
<table width ="100%">
  <tr bgcolor="#e4e4e4">
    <td>
  <h1>Table of Contents</h1>
    </td>
  </tr>
</table>

<center><table width ="80%">
<tr>
<td>
<table>
<tr>
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
  <td>
    <a href="#overview">1.0 Overview</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#frontend">1.1 Console/NSH Front End</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdoverview">1.2 Command Overview</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#conditional">1.3 Conditional Command Execution</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#builtinvars">1.4 Built-In Variables</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#currentwd">1.5 Current Working Directory</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#environvars">1.6 Environment Variables</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#startupscript">1.7 NSH Start-Up Script</a>
  </td>
</tr>

<tr>
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
  <td>
    <a href="#commands">2.0 Commands</a>.
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdtest">2.1 Evaluate Expression (test)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdcat">2.2 Concatenate Files (cat)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdcd">2.3 Change Current Working Directory (cd)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdcp">2.4 Copy Files (cp)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmddate">2.5 Show or set the date and time (date)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmddd">2.6 Copy and Convert Files (dd)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdecho">2.7 Echo Strings and Variables (echo)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdexec">2.8 Execute User Code (exec)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdexit">2.9 Exit NSH (exit)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdfree">2.10 Show Memory Manager Status (free)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdget">2.11 Get File Via TFTP (get)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdhelp">2.12 Show Usage Command Usage (help)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdifconfig">2.13 Show Network Configuration (ifconfig)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdkill">2.14 Send a signal to a task (kill)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdlosetup">2.15 Setup/teardown the Loop Device (losetup)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdls">2.16 List Directory Contents (ls)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmbhw">2.17 Access Memory (mb, mh, and mw)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdps">2.18 Show Current Tasks and Threads (ps)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmkdir">2.19 Create a Directory (mkdir)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmkfatfs">2.20 Create a FAT Filesystem (mkfatfs)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmkfifo">2.21 Create a FIFO (mkfifo)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmkrd">2.22 Create a RAMDISK (mkrd)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmount">2.23 Mount a File System (mount)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdmv">2.24 Rename a File (mv)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdping">2.25 Check Network Peer (ping)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdput">2.26 Send File Via TFTP (put)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdpwd">2.27 Show Current Working Directory (pwd)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdrm">2.28 Remove a File (rm)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdrmdir">2.29 Remove a Directory (rmdir)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdset">2.30 Set an Environment Variable (set)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdsh">2.31 Execute an NSH Script (sh)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdsleep">2.32 Wait for Seconds (sleep)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdunmount">2.33 Unmount a File System (umount)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdunset">2.34 Unset an Environment Variable (unset)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdusleep">2.35 Wait for Microseconds (usleep)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdwget">2.36 Get File Via HTTP (wget)</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmdxd">2.37 Hexadecimal Dump (xd)</a>
  </td>
</tr>
<tr>
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
  <td>
    <a href="#configuration">3.0 Configuration Settings</a>
</td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#cmddependencies">3.1 Command Dependencies on Configuration Settings</a>
  </td>
</tr>
<tr>
  <td><br></td>
  <td>
    <a href="#nshconfiguration">3.2  NSH-Specific Configuration Settings</a>
  </td>
</tr>
<tr>
  <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
  <td>
    <a href="#index">Index</a>
</td>
</table>
</td>
</tr>
</table></center>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="overview"><h1>1.0 Overview</h1></a>
  </td>
  </tr>
</table>

<p>
  The <code>apps/nshlib</code> sub-directory contains the NuttShell (NSH)
  library.
  This library can easily to linked to produce a NSH application (See as an example <code>apps/nshlib</code>).
  NSH is a simple shell application for NuttX.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="frontend"><h2>1.1 Console/NSH Front End</h2></a>
  </td>
  </tr>
</table>

<p>
  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:
  <ul><pre>
NuttShell (NSH)
nsh&gt;
</pre></ul>
  <code>nsh&gt;</code> is the NSH prompt and indicates that you may enter a command
   from the console.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdoverview"><h2>1.2 Command Overview</h2></a>
  </td>
  </tr>
</table>

<p>
  <b>Simple, Re-directed, and Background Commands</b>.
  The NuttShell (NSH) is a simple shell application.
  NSH supports the following commands forms:
</p>
<ul><table>
  <tr>
     <td>Simple command:</td>
     <td><code>&lt;cmd&gt;</code></td>
  </tr>
  <tr>
     <td>Command with re-directed output:</td>
     <td><code>
         &lt;cmd&gt; &gt; &lt;file&gt;<br>
         &lt;cmd&gt; &gt;&gt; &lt;file&gt;
     </code></td>
  </tr>
  <tr>
     <td>Background command:</td>
     <td><code>&lt;cmd&gt; &amp;</code></td>
  </tr>
  <tr>
     <td>Re-directed background command:</td>
     <td><code>
       &lt;cmd&gt; &gt; &lt;file&gt; &amp;<br>
       &lt;cmd&gt; &gt;&gt; &lt;file&gt; &amp;
     </code></td>
  </tr>
</table></ul>
<p>Where:</p>
<ul><table>
  <tr>
    <td><code>&lt;cmd&gt;</code></td>
    <td>
      is any one of the simple commands listed later.
    </td>
  </tr>
  <tr>
    <td><code>&lt;file&gt;</code></td>
    <td>
      is the full or relative path to any writable object
      in the filesystem name space (file or character driver).
      Such objects will be referred to simply as files throughout
      this document.
    </td>
  </tr>
</table></ul>
<p>
  <b><big><code>nice</code></big>'d Background Commands</b>
  NSH executes at the mid-priority (128).  Backgrounded commands can
  be made to execute at higher or lower priorities using <code>nice</code>:
</p>
<ul><code>
  [nice [-d &lt;niceness&gt;&gt;]] &lt;cmd&gt; [&gt; &lt;file&gt;|&gt;&gt; &lt;file&gt;] [&amp;]
</code></ul>
<p>
  Where <code>&lt;niceness&gt;</code> is any value between -20 and 19 where lower
  (more negative values) correspond to higher priorities.
  The default niceness is 10.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="conditional"><h2>1.3 Conditional Command Execution</h2></a>
  </td>
  </tr>
</table>

<p>
  An <code>if-then[-else]-fi</code> 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 <a href="#cmdsh"><code>sh</code></a> commnd).  The syntax is as follows:
</p>
<ul><pre>
if &lt;cmd&gt;
then
  [sequence of &lt;cmd&gt;]
else
  [sequence of &lt;cmd&gt;]
fi
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="builtinvars"><h2>1.4 Built-In Variables</h2></a>
  </td>
  </tr>
</table>

<ul><table>
  <tr>
    <td valign="top"><b><code>$?</code></b></td>
    <td>
      The result of the last simple command execution.
      On backgrounded commands, this variable holds only the result of spawning the background command.
    </td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="currentwd"><h2>1.5 Current Working Directory</h2></a>
  </td>
  </tr>
</table>

<p>
  <b><code>cd</code> and <code>pwd</code></b>.
  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 <a href="#cmdcd"><code>cd</code></a> command and can be queried either
  by using the <a href="#cmdpwd"><code>pwd</code></a> command or by
  using the <a href="#cmdecho"><code>echo</code></a> <a href="#environvars"><code>$PWD</code></a>
  command.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="environvars"><h2>1.6 Environment Variables</h2></a>
  </td>
  </tr>
</table>

<p>
  <b>Environment Variables:</b>
</p>
<ul><table>
  <tr>
    <td><b><code>PWD</code></b></td><td>The current working directory</td>
  </tr>
  <tr>
    <td><b><code>OLDPWD</code></b></td><td>The previous working directory</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="startupscript"><h2>1.7 NSH Start-Up Script</h2></a>
  </td>
  </tr>
</table>

<p>
  <b>NSH Start-Up Script</b>.
  NSH supports options to provide a start up script for NSH.  In general
  this capability is enabled with <code>CONFIG_NSH_ROMFSETC</code>, but has
  several other related configuration options as described with the
  <a href="#nshconfiguration">NSH-specific configuration settings</a>.
  This capability also depends on:
  <ul>
    <li><code>CONFIG_DISABLE_MOUNTPOINT</code> not set
    <li><code>CONFIG_NFILE_DESCRIPTORS</code> &lt; 4
    <li><code>CONFIG_FS_ROMFS</code> enabled
  </ul>
</p>

<p>
  <b>Default Start-Up Behavior</b>.
  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.
</p>
<p>
  In this default case, enabling <code>CONFIG_NSH_ROMFSETC</code> will cause
  NSH to behave as follows at NSH startup time:
  <ul>
    <li>
      NSH will create a read-only RAM disk (a ROM disk), containing a tiny
      ROMFS filesystem containing the following:
<ul><pre>
`--init.d/
     `-- rcS
</pre></ul>
      Where rcS is the NSH start-up script.
    </li>
    <li>
      NSH will then mount the ROMFS filesystem at <code>/etc</code>, resulting in:
<ul><pre>
|--dev/
|   `-- ram0
`--etc/
    `--init.d/
        `-- rcS
</pre></ul>
    </li>
    <li>
      By default, the contents of rcS script are:
<ul><pre>
# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX

mkrd -m 1 -s 512 1024
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /tmp
</pre></ul>
    </li>
    <li>
      NSH will execute the script at <code>/etc/init.d/rcS</code> at start-up (before the
      first NSH prompt.  After execution of the script, the root FS will look
      like:
<ul><pre>
|--dev/
|   |-- ram0
|   `-- ram1
|--etc/
|   `--init.d/
|       `-- rcS
`--tmp/
</pre></ul>
    </li>
  </ul>
</p>
<p>
  <b>Modifying the ROMFS Image</b>.
  The contents of the <code>/etc</code> directory are retained in the file <code>apps/nshlib/nsh_romfsimg.h</code> OR, if <code>CONFIG_NSH_ARCHROMFS</code> is defined, <code>include/arch/board/rcs.template</code>).
  In order to modify the start-up behavior, there are three things to study:
  <ol>
    <li>
      <b>Configuration Options.</b>
      The additional <code>CONFIG_NSH_ROMFSETC</code> configuration options
      discussed with the other <a href="#nshconfiguration">NSH-specific configuration settings</a>.
    </li>
    <li>
      <p>
        <b><code>tools/mkromfsimg.sh</code> Script</b>.
        The script <code>tools/mkromfsimg.sh</code> creates <code>nsh_romfsimg.h</code>.
        It is not automatically executed.  If you want to change the
        configuration settings associated with creating and mounting
        the <code>/tmp</code> directory, then it will be necessary to re-generate
        this header file using the <code>tools/mkromfsimg.sh</code> script.
      </p>
      <p>
        The behavior of this script depends upon three things:
        <ul>
          <li>The configuration settings then installed configuration.
          <li>The <code>genromfs</code> tool (available from <a href="http://romfs.sourceforge.net">http://romfs.sourceforge.net</a>).
          <li>The file <code>apps/nshlib/rcS.template</code>
		    (OR, if <code>CONFIG_NSH_ARCHROMFS</code> is defined <code>include/arch/board/rcs.template</code>.
        </ul>
      </p>
    </li>
    <li>
      <b><code>rcS.template</code></b>.
      The file <code>apps/nshlib/rcS.template</code> contains the general form
      of the <code>rcS</code> file; configured values are plugged into this
      template file to produce the final <code>rcS</code> file.
    </li>
  </ol>
</p>
<p>
  <b>NOTE</b>:
  <code>apps/nshlib/rcS.template</code> generates the standard, default <code>nsh_romfsimg.h</code> file.
  If <code>CONFIG_NSH_ARCHROMFS</code> is defined in the NuttX configuration file, then a custom, board-specific <code>nsh_romfsimg.h</code> file residing in <code>configs/&lt;board&gt;/include</code> will be used.
  NOTE when the OS is configured, <code>include/arch/board</code> will be linked to <code>configs/&lt;board&gt;/include</code>.
</p>
<p>
  All of the startup-behavior is contained in <code>rcS.template</code>.  The
  role of <code>mkromfsimg.sh</code> is to (1) apply the specific configuration
  settings to <code>rcS.template</code> to create the final <code>rcS</code>, and (2) to
  generate the header file <code>nsh_romfsimg.h</code> containg the ROMFS
  file system image.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="commands"><h1>2.0 Commands</h1></a>
  </td>
  </tr>
</table>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdtest"><h2>2.1 Evaluate Expression (test)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
[ &lt;expression&gt; ]
test &lt;expression&gt;
</pre></ul>
<p>
   <b>Synopsis</b>.
   These are two alternative forms of the same command.  They support
   evaluation of a boolean expression which sets <a href="#builtinvars"><code>$?</code></a>.
   This command is used most frequently as the conditional command following the
   <code>if</code> in the <a href="#conditional"><code>if-then[-else]-fi</code></a> construct.
</p>
<p><b>Expression Syntax:</b></p>
<ul>
  <p>
     expression = simple-expression | !expression | expression -o expression | expression -a expression
  </p>
  <p>
     simple-expression = unary-expression | binary-expression
  </p>
  <p>
     unary-expression = string-unary | file-unary
  </p>
  <p>
     string-unary = -n string | -z string
  </p>
  <p>
     file-unary = -b file | -c file | -d file | -e file | -f file | -r file | -s file | -w file
  </p>
  <p>
     binary-expression = string-binary | numeric-binary
  </p>
  <p>
     string-binary = string = string | string == string | string != string
  </p>
  <p>
     numeric-binary = integer -eq integer | integer -ge integer | integer -gt integer | integer -le integer |
                      integer -lt integer | integer -ne integer
  </p>
</ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdcat"><h2>2.2 Concatenate Files (cat)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
cat <code>&lt;path&gt;</code> [<code>&lt;path&gt;</code> [<code>&lt;path&gt;</code> ...]]
</pre></ul>
<p>
  <b>Synopsis</b>.
  This command copies and concatentates all of the files at <code>&lt;path&gt;</code>
  to the console (or to another file if the output is redirected).
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdcd"><h2>2.3 Change Current Working Directory (cd)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
cd [&lt;dir-path&gt;|-|~|..]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Changes the current working directory (<code>PWD</code>).  Also sets the
  previous working directory environment variable (<code>OLDPWD</code>).
<p>
<p><b>Forms:</b></p>
<ul><table>
  <tr>
    <td><b><code>cd &lt;dir-path&gt;</code></b></td>
    <td>sets the current working directory to <code>&lt;dir-path&gt;</code>.</td>
  </tr>
  <tr>
    <td><b><code>cd -</code></b></td>
    <td>sets the current working directory to the previous
       working directory ($<a href="#environvars"><code>OLDPWD</code></a>).
      Equivalent to <code><a href="#cmdcd">cd</a> $<a href="#environvars">OLDPWD</a></code>.</td>
  </tr>
  <tr>
    <td><b><code>cd</code> or <b><code>cd ~</code></b></td>
    <td>set the current working directory to the 'home'
       directory.  The <i>home</i> directory can be configured by setting
       <code>CONFIG_LIB_HOMEDIR</code> in the configuration file.  The default
       <i>home</i> directory is <code>/</code>.</td>
  </tr>
  <tr>
    <td><b><code>cd ..</code></td>
    <td>sets the current working directory to the parent directory.</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdcp"><h2>2.4 Copy Files (cp)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
cp &lt;source-path&gt; &lt;dest-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy of the contents of the file at <code>&lt;source-path&gt;</code> to the location
  in the filesystem indicated by <code>&lt;dest-path&gt;</code>.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmddate"><h2>2.5 Show or set the date and time (date)</h2></a>
  </td>
  </tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
date [-s &quot;MMM DD HH:MM:SS YYYY&quot;]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show or set the current date and time.
  This command is only supported if the platform supported RTC hardware (<code>CONFIG_RTC=y</code>).
</p>
<p>
  Only one format is used both on display and when setting the date/time:
  <code>MMM DD HH:MM:SS YYYY</code>.  For example,
<ul><pre>
data -s &quot;Sep 1 11:30:00 2011&quot;
</pre></ul>
</p>
<p>
  24-hour time is used.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmddd"><h2>2.6 Copy and Convert Files (dd)</h2></a>
  </td>
  </tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
dd if=&lt;infile&gt; of=&lt;outfile&gt; [bs=&lt;sectsize&gt;] [count=&lt;sectors&gt;] [skip=&lt;sectors&gt;]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy blocks from &lt;infile&gt; to &lt;outfile&gt;.
  &lt;infile&gt; or &lt;outfile&gt; may be the path to a standard file, a character device, or a block device.
  Examples follow:
</p>
<ol>
  <li>
    Read from character device, write to regular file.
    This will create a new file of the specified size filled with zero.
<ul><pre>
nsh&gt; ls -l /dev
/dev:
 crw-rw-rw-       0 zero
nsh&gt; dd if=/dev/zero of=/tmp/zeros bs=64 count=16
nsh&gt; ls -l /tmp
/tmp:
 -rw-rw-rw-    1024 ZEROS
</pre></ul>
  </li>
  <li>
    Read from character device, write to block device.
    This will fill the entire block device with zeros.
  </li>
<ul><pre>
nsh&gt; ls -l /dev
/dev:
 brw-rw-rw-       0 ram0
 crw-rw-rw-       0 zero
nsh&gt; dd if=/dev/zero of=/dev/ram0
</pre></ul>
  </li>
  <li>
    Read from a block devic, write to a character device.  This
    will read the entire block device and dump the contents in
    the bit bucket.
  </li>
<ul><pre>
nsh&gt; ls -l /dev
/dev:
 crw-rw-rw-       0 null
 brw-rw-rw-       0 ram0
nsh&gt; dd if=/dev/ram0 of=/dev/null
</pre></ul>
  </li>
</ol>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdecho"><h2>2.7 Echo Strings and Variables (echo)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
echo [&lt;string|$name&gt; [&lt;string|$name&gt;...]]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy the sequence of strings and expanded environment variables to
  console output (or to a file if the output is re-directed).
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdexec"><h2>2.8 Execute User Code (exec)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
exec &lt;hex-address&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Execute the user logic at address <code>&lt;hex-address&gt;</code>.  NSH will pause
  until the execution unless the user logic is executed in background
  via <code><a href="#cmdexec">exec</a> &lt;hex-address&gt; &amp;</code>.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdexit"><h2>2.9 Exit NSH (exit)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
exit
</pre></ul>
<p>
  <b>Synopsis</b>.
  Exit NSH.  Only useful for the serial front end if you have started some other tasks (perhaps
  using the <code><a href="#cmdexec">exec</a></code> command) and you would like to have NSH out of the
  way.  For the telnet front-end, <code>exit</code> terminates the telenet session.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdfree"><h2>2.10 Show Memory Manager Status (free)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
free
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the current state of the memory allocator.  For example,
</p>
<ul><pre>
nsh&gt; free
             total       used       free    largest
Mem:       4194288    1591552    2602736    2601584
nsh&gt;
</pre></ul>
<p><b>Where:</b></p>
<ul><table>
  <tr>
    <td><b><code>total</code></b></td>
    <td>This is the total size of memory allocated for use by malloc in bytes.</td>
  </tr>
  <tr>
    <td><b><code>used</code></b></td>
    <td>This is the total size of memory occupied by chunks handed out by malloc.</td>
  </tr>
  <tr>
    <td><b><code>free</code></b></td>
    <td>This is the total size of memory occupied by free (not in use) chunks.</td>
  </tr>
  <tr>
    <td><b><code>largest</code></b></td>
    <td>Size of the largest free (not in use) chunk.</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdget"><h2>2.11 Get File Via TFTP (get)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
get [-b|-n] [-f &lt;local-path&gt;] -h &lt;ip-address&gt; &lt;remote-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy the file at <code>&lt;remote-address&gt;</code> from the host whose IP address is
  identified by <code>&lt;ip-address&gt;</code>.
</p>
<p><b>Other options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-f &lt;local-path&gt;</code></b></td>
    <td>
      The file will be saved relative to the current working directory
      unless <code>&lt;local-path&gt;</code> is provided.
    </td>
  </tr>
  <tr>
    <td><b><code>-b|-n</code></b></td>
    <td>
      Selects either binary (&quot;octect&quot;) or test (&quot;netascii&quot;) transfer
      mode.  Default: text.
    </td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdhelp"><h2>2.12 Show Usage Command Usage (help)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
help
</pre></ul>
<p>
  <b>Synopsis</b>.
  Presents summary information about each command to console.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdifconfig"><h2>2.13 Show Network Configuration (ifconfig)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
ifconfig [nic_name [ip_address]]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Two forms of the <code>ifconfig</code>command are supported:
</p>
<ol>
  <li>
    <p>
      With one or no arguments, <code>ifconfig</code> will shows the
      current configuration of the network and, perhaps, the status of ethernet
      device:
    </p>
    <ul><pre>
ifconfig
ifconfig [nic_name]
</pre></ul>
    <p>
      As an example:
    </p>
    <ul><pre>
nsh&gt; ifconfig
eth0    HWaddr 00:18:11:80:10:06
        IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
</pre></ul>
    <p>
      If uIP statistics are enabled (<code>CONFIG_NET_STATISTICS</code>), then
      this command will also show the detailed state of uIP.
    </p>
  </li>
  <li>
    <p>
      If both the network interface name and an IP address are supplied as arguments,
      then <code>ifconfig</code> will set the address of the ethernet device:
    </p>
    <ul><pre>
ifconfig nic_name ip_address
</pre><ul>
  </li>
</ol>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdkill"><h2>2.14 Send a signal to a task (kill)</h2></a>
  </td>
  </tr>
</table>

<ul><pre>
kill -&lt;signal&gt; &lt;pid&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Send the &lt;signal&gt; to the task identified by &lt;pid&gt;.
</p>
<ul><pre>
nsh&gt; mkfifo /dev/fifo
nsh&gt; cat /dev/fifo &
cat [2:128]
nsh&gt; ps
PID   PRI SCHD TYPE   NP STATE    NAME
    0   0 FIFO TASK      READY    Idle Task()
    1 128 FIFO TASK      RUNNING  init()
    2 128 FIFO PTHREAD   WAITSEM  <pthread>(51ea50)
nsh&gt; kill -9 2
nsh: cat: open failed: 4
nsh&gt; ps
PID   PRI SCHD TYPE   NP STATE    NAME
    0   0 FIFO TASK      READY    Idle Task()
    1 128 FIFO TASK      RUNNING  init()
nsh&gt;
</pre></ul>
<p><small>
  <b>NOTE</b>:
  NuttX does not support a FULL POSIX signalling system.
  Standard signals like SIGCHLD, SIGINTR, SIGKILL, etc. do not exist in NuttX and sending those signal may not have the result that you expect.
  Rather, NuttX supports only what are referred to as POSIX real-time signals.
  These signals may be used to communicate with running tasks, may be use to waiting waiting tasks, etc.
  But, as an example, <code>kill -9</code> (SIGKILL) will not terminate a task.
</p></small>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdlosetup"><h2>2.15 Setup/teardown the Loop Device (losetup)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax 1:</b></p>
<ul><pre>
losetup [-o <offset>] [-r] &lt;dev-path&gt; &lt;file-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
   Setup the loop device at &lt;dev-path&gt; to access the file at &lt;file-path&gt; as a block device.
   In the following example a 256Kb file is created (<code>dd</code>) and <code>losetup</code> is
   used to make the file accessible as a block device. 
   A FAT file system is created (<code>mkfatfs</code>) and mounted (<code>mount</code>).
   Files can then be managed on the loop-mounted file.
<ul><pre>
nsh&gt; dd if=/dev/zero of=/tmp/image bs=512 count=512
nsh&gt; ls -l /tmp
/tmp:
 -rw-rw-rw-   262144 IMAGE
nsh&gt; losetup /dev/loop0 /tmp/image
nsh&gt; ls -l /dev
/dev:
 brw-rw-rw-       0 loop0
nsh&gt; mkfatfs /dev/loop0
nsh&gt; mount -t vfat /dev/loop0 /mnt/example
nsh&gt; ls -l /mnt
ls -l /mnt
/mnt:
 drw-rw-rw-       0 example/
nsh&gt; echo &quot;This is a test&quot; &gt;/mnt/example/atest.txt
nsh&gt; ls -l /mnt/example
/mnt/example:
 -rw-rw-rw-      16 ATEST.TXT
nsh&gt; cat /mnt/example/atest.txt
This is a test
nsh&gt;
</pre></ul>
</p>

<p><b>Command Syntax 2:</b></p>
<ul><pre>
losetup d &lt;dev-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Teardown the setup for the loop device at &lt;dev-path&gt;.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdls"><h2>2.16 List Directory Contents (ls)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
ls [-lRs] &lt;dir-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the contents of the directory at <code>&lt;dir-path&gt;</code>.  NOTE:
  <code>&lt;dir-path&gt;</code> must refer to a directory and no other filesystem
  object.
</p>
<p><b>Options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-R</code></b></td>
    <td>Show the constents of specified directory and all of its
        sub-directories.</td>
  </tr>
  <tr>
    <td><b><code>-s</code></b></td>
    <td>Show the size of the files along with the filenames in the
        listing</td>
  </tr>
  <tr>
    <td><b><code>-l</code></b></td>
    <td>Show size and mode information along with the filenames
        in the listing.</td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmbhw"><h2>2.17 Access Memory (mb, mh, and mw)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mb &lt;hex-address&gt;[=&lt;hex-value&gt;][ &lt;hex-byte-count&gt;]
mh &lt;hex-address&gt;[=&lt;hex-value&gt;][ &lt;hex-byte-count&gt;]
mw &lt;hex-address&gt;[=&lt;hex-value&gt;][ &lt;hex-byte-count&gt;]
</pre></ul>
<p>
  <b>Synopsis</b>.
  Access memory using byte size access (mb), 16-bit accesses (mh),
  or 32-bit access (mw).  In each case,
</p>
<ul><table>
  <tr>
    <td><code>&lt;hex-address&gt;</code>.</td>
    <td>Specifies the address to be accessed.  The current
      value at that address will always be read and displayed.
  </tr>
  <tr>
    <td><code>&lt;hex-address&gt;=&lt;hex-value&gt;</code>.</td>
    <td>Read the value, then write <code>&lt;hex-value&gt;</code>
      to the location.
  </tr>
  <tr>
    <td><code>&lt;hex-byte-count&gt;</code>.</td>
    <td>Perform the mb, mh, or mw operation on a total
      of <code>&lt;hex-byte-count&gt;</code> bytes, increment the <code>&lt;hex-address&gt;</code> appropriately
      after each access
  </tr>
</table></ul>
<p><b>Example:</b><p>
<ul><pre>
nsh&gt; 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&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdps"><h2>2.18 Show Current Tasks and Threads (ps)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
ps
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the currently active threads and tasks.  For example,
</p>
<ul><pre>
nsh&gt; ps
PID   PRI SCHD TYPE   NP STATE    NAME
    0   0 FIFO TASK      READY    Idle Task()
    1 128 RR   TASK      RUNNING  init()
    2 128 FIFO TASK      WAITSEM  nsh_telnetmain()
    3 100 RR   PTHREAD   WAITSEM  &lt;pthread&gt;(21)
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmkdir"><h2>2.19 Create a Directory (mkdir)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mkdir &lt;path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Create the directory at <code>&lt;path&gt;</code>.
  All components of of <code>&lt;path&gt;</code> except the final directory name must exist on a mounted file
  system; the final directory must not.
</p>
<p>
  <b>Limited to Mounted File Systems</b>.
  Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file
  system.
  The <code>mkdir</code> command can only be used to create directories in volumes set up with the
  <a href="#cmdmount"><code>mount</code></a> command; it cannot be used to create directories in the <i>pseudo</i> filesystem.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> mkdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
 drw-rw-rw-       0 TESTDIR/
 drw-rw-rw-       0 TMP/
nsh>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmkfatfs"><h2>2.20 Create a FAT Filesystem (mkfatfs)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mkfatfs &lt;path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Format a fat file system on the block device specified by <code>&lt;path&gt;</code>.
  NSH provides this command to access the <a href="mkfatfs"><code>mkfatfs()</code></a> NuttX API.
  This block device must reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> and
  must have been created by some call to <code>register_blockdriver()</code> (see <code>include/nuttx/fs/fs.h</code>).
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmkfifo"><h2>2.21 Create a FIFO (mkfifo)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mkfifo &lt;path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Creates a FIFO character device anywhere in the pseudo file system, creating
  whatever psuedo directories that may be needed to complete the <code>&lt;path&gt;</code>.
  By convention, however, device drivers are place in the standard <code>/dev</code> directory.
  After it is created, the FIFO device may be used as any other device driver.
  NSH provides this command to access the <a href="NuttxUserGuide.html#mkfifo"><code>mkfifo()</code></a> NuttX API.
</p>
<p><b>Example</b></p>
<ul><pre>
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>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmkrd"><h2>2.22 Create a RAMDISK (mkrd)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mkrd [-m &lt;minor&gt;] [-s &lt;sector-size&gt;] &lt;nsectors&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Create a ramdisk consisting of <code>&lt;nsectors&gt;</code>, each of size
  <code>&lt;sector-size&gt;</code> (or 512 bytes if <code>&lt;sector-size&gt;</code> is not specified.
  The ramdisk will be registered as <code>/dev/ram&lt;n&gt;</code> (if <code>&lt;n&gt;</code> is not
  specified, mkrd will attempt to register the ramdisk as <code>/dev/ram0</code>.
</p>
<p><b>Example</b></p>
<ul><pre>
nsh&gt; ls /dev
/dev:
 console
 null
 ttyS0
 ttyS1
nsh&gt; mkrd 1024
nsh&gt; ls /dev
/dev:
 console
 null
 ram0
 ttyS0
 ttyS1
nsh&gt;
</pre></ul>
<p>
  Once the ramdisk has been created, it may be formatted using
  the <code>mkfatfs</code> command and mounted using the <code>mount</code> command.
</p>
<p><b>Example</b></p>
<ul><pre>
nsh&gt; mkrd 1024
nsh&gt; mkfatfs /dev/ram0
nsh&gt; mount -t vfat /dev/ram0 /tmp
nsh&gt; ls /tmp
/tmp:
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmount"><h2>2.23 Mount a File System (mount)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mount -t &lt;fstype&gt; &lt;block-device&gt; <code>&lt;dir-path&gt;</code>
</pre></ul>
<p>
  <b>Synopsis</b>.
  The 'm  ount' command mounts a file system in the NuttX psuedo
  filesystem.  'mount' performs a three way associating, binding:
</p>
<ol>
  <li><b>File system.</b>
    The '-t <code>&lt;fstype&gt;</code>' option identifies the type of
    file system that has been formatted on the <code>&lt;block-device&gt;</code>.
    As of this writing, <code>vfat</code> is the only supported value for <code>&lt;fstype&gt;</code>
  </li>
  <li><b>Block Device.</b>
    The <code>&lt;block-device&gt;</code> argument is the full or relative
    path to a block driver inode in the <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>.
    By convention, this is a name under the <code>/dev</code> sub-directory.
    This <code>&lt;block-device&gt;</code>  must have been previously formatted with the same file system
    type as specified by <code>&lt;fstype&gt;</code>
  </li>
  <li><b>Mount Point.</b>
    The mount point, <code>&lt;dir-path&gt;</code>, is the location in the
    <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> where the mounted volume will appear.
    This mount point can only reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>.
    By convention, this mount point is a subdirectory under <code>/mnt</code>.
    The mount command will create whatever psuedo directories that may be needed to complete the
    full path but the full path must not already exist.
  </li>
</ol>
<p>
  After the volume has been mounted in the NuttX
  <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>,
  it may be access in the same way as other objects in thefile system.
</p>
<p><b>Example</b></p>
<ul><pre>
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>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdmv"><h2>2.24 Rename a File (mv)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
mv &lt;old-path&gt; &lt;new-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Rename the file object at <code>&lt;old-path&gt;</code> to <code>&lt;new-path&gt;</code>.
  Both paths must reside in the same mounted filesystem.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdping"><h2>2.25 Check Network Peer (ping)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
ping [-c &lt;count&gt;] [-i &lt;interval&gt;] &lt;ip-address&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Test the network communication with a remote peer.  Example,
</p>
<ul><pre>
nsh&gt; ping 10.0.0.1
PING 10.0.0.1 56 bytes of data
56 bytes from 10.0.0.1: icmp_seq=1 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=2 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=3 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=4 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=5 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=6 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=7 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=8 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=9 time=0 ms
56 bytes from 10.0.0.1: icmp_seq=10 time=0 ms
10 packets transmitted, 10 received, 0% packet loss, time 10190 ms
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdput"><h2>2.26 Send File Via TFTP (put)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
put [-b|-n] [-f &lt;remote-path&gt;] -h &lt;ip-address&gt; &lt;local-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Copy the file at <code>&lt;local-address&gt;</code> to the host whose IP address is
  identified by <code>&lt;ip-address&gt;</code>.
</p>
<p><b>Other options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-f &lt;remote-path&gt;</code></b></td>
    <td>
      The file will be saved relative with the same name on the host
      unless <code>&lt;remote-path&gt;</code> is provided.
    </td>
  </tr>
  <tr>
    <td><b><code>-b|-n</code></b></td>
    <td>
      Selects either binary (&quot;octect&quot;) or test (&quot;netascii&quot;) transfer
      mode.  Default: text.
    </td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdpwd"><h2>2.27 Show Current Working Directory (pwd)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
pwd
</pre></ul>
<p>
  <b>Synopsis</b>.
  Show the current working directory.
</p>
<ul><pre>
nsh&gt; cd /dev
nsh&gt; pwd
/dev
nsh&gt;
</pre></ul>

<p>Same as <code><a href="#cmdecho">echo</a> <a href="#environvars">$PWD</a></code>.</p>
<ul><pre>
nsh&gt; echo $PWD
/dev
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdrm"><h2>2.28 Remove a File (rm)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
rm &lt;file-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Remove the specified <code>&lt;file-path&gt;</code> name from the mounted file system.
  Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file
  system.
  The <code>rm</code> command can only be used to remove (unlink) files in volumes set up with the
  <a href="#cmdmount"><code>mount</code></a> command;
  it cannot be used to remove names in the <i>pseudo</i> filesystem.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> ls /mnt/fs/testdir
/mnt/fs/testdir:
 TESTFILE.TXT
 EXAMPLE.TXT
nsh> rm /mnt/fs/testdir/example.txt
nsh> ls /mnt/fs/testdir
/mnt/fs/testdir:
 TESTFILE.TXT
nsh>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdrmdir"><h2>2.29 Remove a Directory (rmdir)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
rmdir &lt;dir-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Remove the specified <code>&lt;dir-path&gt;</code> directory from the mounted file system.
  Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file
  system.
  The <code>rmdir</code> command can only be used to remove directories from volumes set up with the
  <a href="#cmdmount"><code>mount</code></a> command;
  it cannot be used to remove directories from the <i>pseudo</i> filesystem.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> mkdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
 drw-rw-rw-       0 TESTDIR/
 drw-rw-rw-       0 TMP/
nsh> rmdir /mnt/fs/tmp
nsh> ls -l /mnt/fs
/mnt/fs:
 drw-rw-rw-       0 TESTDIR/
nsh>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdset"><h2>2.30 Set an Environment Variable (set)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
set &lt;name&gt; &lt;value&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Set the environment variable <code>&lt;name&gt;</code> to the string <code>&lt;value&gt;</code>.
  For example,
</p>
<ul><pre>
nsh&gt; echo $foobar

nsh&gt; set foobar foovalue
nsh&gt; echo $foobar
foovalue
nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdsh"><h2>2.31 Execute an NSH Script (sh)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
sh &lt;script-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Execute the sequence of NSH commands in the file referred
  to by <code>&lt;script-path&gt;</code>.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdsleep"><h2>2.32 Wait for Seconds (sleep)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
sleep &lt;sec&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Pause execution (sleep) for <code>&lt;sec&gt;</code> seconds.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdunmount"><h2>2.33 Unmount a File System (umount)</h2></a>
  </td>
</tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
umount &lt;dir-path&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Un-mount the file system at mount point <code>&lt;dir-path&gt;</code>.
  The <code>umount</code> command can only be used to un-mount volumes previously mounted using
  <a href="#cmdmount"><code>mount</code></a> command.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> ls /mnt/fs
/mnt/fs:
 TESTDIR/
nsh> umount /mnt/fs
nsh> ls /mnt/fs
/mnt/fs:
nsh: ls: no such directory: /mnt/fs
nsh>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdunset"><h2>2.34 Unset an Environment Variable (unset)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
unset &lt;name&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Remove the value associated with the environment variable
  <code>&lt;name&gt;</code>.  Example:
</p>
<ul><pre>
nsh&gt; echo $foobar
foovalue
nsh&gt; unset foobar
nsh&gt; echo $foobar

nsh&gt;
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdusleep"><h2>2.35 Wait for Microseconds (usleep)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
usleep &lt;usec&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Pause execution (sleep) of <code>&lt;usec&gt;</code> microseconds.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdwget">2.36 Get File Via HTTP (wget)</a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
wget [-o &lt;local-path&gt;] &lt;url&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Use HTTP to copy the file at <code>&lt;url&gt;</code> to the current directory.
</p>
<p><b>Options:</b></p>
<ul><table>
  <tr>
    <td><b><code>-o &lt;local-path&gt;</code></b></td>
    <td>
      The file will be saved relative to the current working directory
      and with the same name as on the HTTP server unless <code>&lt;local-path&gt;</code> is provided.
    </td>
  </tr>
</table></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmdxd"><h2>2.37 Hexadecimal dump (xd)</h2></a>
  </td>
  </tr>
</table>

<p><b>Command Syntax:</b></p>
<ul><pre>
xd &lt;hex-address&gt; &lt;byte-count&gt;
</pre></ul>
<p>
  <b>Synopsis</b>.
  Dump <code>&lt;byte-count&gt;</code> bytes of data from address <code>&lt;hex-address&gt;</code>.
</p>
<p><b>Example:</b></p>
<ul><pre>
nsh> xd 410e0 512
Hex dump:
0000: 00 00 00 00 9c 9d 03 00 00 00 00 01 11 01 10 06 ................
0010: 12 01 11 01 25 08 13 0b 03 08 1b 08 00 00 02 24 ....%..........$
...
01f0: 08 3a 0b 3b 0b 49 13 00 00 04 13 01 01 13 03 08 .:.;.I..........
nsh>
</pre></ul>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="configuration"><h1>3.0 Configuration Settings</h1></a>
  </td>
  </tr>
</table>

<p>
  The availability of the above commands depends upon features that
  may or may not be enabled in the NuttX configuration file.  The 
  following <a href="#cmddependencies">table</a> indicates the dependency of each command on NuttX
  configuration settings.  General configuration settings are discussed
  in the <a href="NuttxPortingGuide.html">NuttX Porting Guide.</a>
  Configuration settings specific to NSH as discussed at the <a href="#nshconfiguration">bottom</a> of this document.
</p>

<p>
  Note that in addition to general NuttX configuation settings, each NSH command can be
  individually disabled via the settings in the rightmost column.
  All of these settings make the configuration of NSH potentially complex but also allow it to
  squeeze into very small memory footprints.
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="cmddependencies"><h2>3.1 Command Dependencies on Configuration Settings</h2></a>
  </td>
  </tr>
</table>

<center><p>Table. Command Dependencies on Configuration Settings</p>
<table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Command</th>
    <th align="left">Depends on Configuration</th>
    <th align="left">Can Be Disabled with</th>
  </tr>
  <tr>
    <td><b><code>[</code></b></td>
    <td>!<code>CONFIG_NSH_DISABLESCRIPT</code></td>
    <td><code>CONFIG_NSH_DISABLE_TEST</code></td>
  </tr>
  <tr>
    <td><b><code>cat</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_CAT</code></td>
  </tr>
  <tr>
    <td><b><code>cd</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_CD</code></td>
  </tr>
  <tr>
    <td><b><code>cp</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_CP</code></td>
  </tr>
  <tr>
    <td><b><code>date</code></b></td>
    <td>!<code>CONFIG_DISABLE_CLOCK</code> &amp;&amp; <code>CONFIG_RTC</code></td>
    <td><code>CONFIG_NSH_DISABLE_DATE</code></td>
  </tr>
  <tr>
    <td><b><code>dd</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_DD</code></td>
  </tr>
  <tr>
    <td><b><code>echo</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_ECHO</code></td>
  </tr>
  <tr>
    <td><b><code>exec</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_EXEC</code></td>
  </tr>
  <tr>
    <td><b><code>exit</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_EXIT</code></td>
  </tr>
  <tr>
    <td><b><code>free</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_FREE</code></td>
  </tr>
  <tr>
    <td><b><code>get</code></b></td>
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_UDP</code> &amp;&amp;
        <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_NET_BUFSIZE</code> &gt;= 558<sup>1</sup></td>
    <td><code>CONFIG_NSH_DISABLE_GET</code></td>
  </tr>
  <tr>
    <td><b><code>help</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_HELP</code></td>
  </tr>
  <tr>
    <td><b><code>ifconfig</code></b></td>
    <td><code>CONFIG_NET</code></td>
    <td><code>CONFIG_NSH_DISABLE_IFCONFIG</code></td>
  </tr>
  <tr>
    <td><b><code>kill</code></b></td>
    <td>!<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_NSH_DISABLE_KILL</code></td>
  </tr>
  <tr>
    <td><b><code>losetup</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_LOSETUP</code></td>
  </tr>
  <tr>
    <td><b><code>ls</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_LS</code></td>
  </tr>
  <tr>
    <td><b><code>mb,mh,mw</code></b></td>
    <td><br></td>
    <td>
      <code>CONFIG_NSH_DISABLE_MB</code>,<br>
      <code>CONFIG_NSH_DISABLE_MH</code>,<br>
      <code>CONFIG_NSH_DISABLE_MW</code>
    </td>
  </tr>
  <tr>
    <td><b><code>mkdir</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_NSH_DISABLE_MKDIR</code></td>
  </tr>
  <tr>
    <td><b><code>mkfatfs</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_FAT</code></td>
    <td><code>CONFIG_NSH_DISABLE_MKFATFS</code></td>
  </tr>
  <tr>
    <td><b><code>mkfifo</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_MKFIFO</code></td>
  </tr>
  <tr>
    <td><b><code>mkrd</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_NSH_DISABLE_MKRD</code></td>
  </tr>
  <tr>
    <td><b><code>mount</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
    <td><code>CONFIG_NSH_DISABLE_MOUNT</code></td>
  </tr>
  <tr>
    <td><b><code>mv</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>3</sup></td>
    <td><code>CONFIG_NSH_DISABLE_MV</code></td>
  </tr>
  <tr>
    <td><b><code>ping</code></b></td>
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_ICMP</code> &amp;&amp;
        <code>CONFIG_NET_ICMP_PING</code>  &amp;&amp; !<code>CONFIG_DISABLE_CLOCK</code> &amp;&amp;
        !<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_NSH_DISABLE_PING</code></td>
  </tr>
  <tr>
    <td><b><code>ps</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_PS</code></td>
  </tr>
  <tr>
    <td><b><code>put</code></b></td>
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_UDP</code> &amp;&amp;
    <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_NET_BUFSIZE</code> &gt;= 558<sup>1,2</sup></td>
    <td><code>CONFIG_NSH_DISABLE_PUT</code></td>
  </tr>
  <tr>
    <td><b><code>pwd</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_PWD</code></td>
  </tr>
  <tr>
    <td><b><code>rm</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_NSH_DISABLE_RM</code></td>
  </tr>
  <tr>
    <td><b><code>rmdir</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td>
    <td><code>CONFIG_NSH_DISABLE_RMDIR</code></td>
  </tr>
  <tr>
    <td><b><code>set</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code></td>
    <td><code>CONFIG_NSH_DISABLE_SET</code></td>
  </tr>
  <tr>
    <td><b><code>sh</code></b></td>
    <td><code>CONFIG_NFILE_DESCRIPTORS &gt; 0 &amp;&amp; <code>CONFIG_NFILE_STREAMS &gt; 0 &amp;&amp; !<code>CONFIG_NSH_DISABLESCRIPT</code></td>
    <td><code>CONFIG_NSH_DISABLE_SH</code></td>
  </tr>
  <tr>
    <td><b><code>sleep</code></b></td>
    <td>!<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_NSH_DISABLE_SLEEP</code></td>
  </tr>
  <tr>
    <td><b><code>test</code></b></td>
    <td>!<code>CONFIG_NSH_DISABLESCRIPT</code></td>
    <td><code>CONFIG_NSH_DISABLE_TEST</code></td>
  </tr>
  <tr>
    <td><b><code>umount</code></b></td>
    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
    <td><code>CONFIG_NSH_DISABLE_UMOUNT</code></td>
  </tr>
  <tr>
    <td><b><code>unset</code></b></td>
    <td>!<code>CONFIG_DISABLE_ENVIRON</code></td>
    <td><code>CONFIG_NSH_DISABLE_UNSET</code></td>
  </tr>
  <tr>
    <td><b><code>usleep</code></b></td>
    <td>!<code>CONFIG_DISABLE_SIGNALS</code></td>
    <td><code>CONFIG_NSH_DISABLE_USLEEP</code></td>
  </tr>
  <tr>
    <td><b><code>wget</code></b></td>
    <td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_TCP</code> &amp;&amp;
        <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
    <td><code>CONFIG_NSH_DISABLE_WGET</code></td>
  </tr>
  <tr>
    <td><b><code>xd</code></b></td>
    <td><br></td>
    <td><code>CONFIG_NSH_DISABLE_XD</code></td>
  </tr>
</table></center>

<p><sup>1</sup><small>
  Because of hardware padding, the actual required packet size may be larger</small><br>
  <sup>2</sup><small>
  Special TFTP server start-up optionss will probably be required to permit
  creation of files for the correct operation of the <code>put</code> command.</small><br>
  <sup>3</sup><small>
  <code>CONFIG_FS_READABLE</code> is not a user configuration but is set automatically
  if any readable filesystem is selected.  At present, this is either <code>CONFIG_FS_FAT</code>
  or <code>CONFIG_FS_ROMFS</code>.</small><br>
  <sup>4</sup><small>
  <code>CONFIG_FS_WRITABLE</code> is not a user configuration but is set automatically
  if any writable filesystem is selected.  At present, this is only <code>CONFIG_FS_FAT</code>.</small><br>
</p>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="nshconfiguration"><h2>3.2  NSH-Specific Configuration Settings</h2></a>
  </td>
  </tr>
</table>

<p>
  The behavior of NSH can be modified with the following settings in
  the <code>configs/&lt;board-name&gt;/defconfig</code> file:
</p>

<center><table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Configuration</th>
    <th align="left">Description</th>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_BUILTIN_APPS</code></b></td>
    <td>
      Support external registered, &quot;named&quot; applications that can be
      executed from the NSH command line (see apps/README.txt for
      more information).
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_FILEIOSIZE</code></b></td>
    <td>
      Size of a static I/O buffer used for file access (ignored if
      there is no filesystem). Default is 1024.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_STRERROR</code></b></td>
    <td>
      strerror(errno) makes more readable output but strerror() is
      very large and will not be used unless this setting is <i>y</i>
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_LINELEN</code></b></td>
    <td>
      The maximum length of one command line and of one output line.
      Default: 80
    </td>
  </tr>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_NESTDEPTH</code></b></td>
    <td>
      The maximum number of nested <a href="#conditional"><code>if-then[-else]-fi</code></a> sequences that
      are permissable.  Default: 3
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_DISABLESCRIPT</code></b></td>
    <td>
      This can be set to <i>y</i> to suppress support for scripting.  This
      setting disables the <a href="#cmdsh"><code>sh</code></a>, <a href="#cmdtest"><code>test</code></a>, and <a href="#cmtest"><code>[</code></a> commands and the
      <a href="#conditional"><code>if-then[-else]-fi</code></a> construct.  This would only be set on systems
      where a minimal footprint is a necessity and scripting is not.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_DISABLEBG</code></b></td>
    <td>
      This can be set to <i>y</i> to suppress support for background
      commands.  This setting disables the <a href="#cmdoverview"><code>nice</code></a> command prefix and
      the <a href="#cmdoverview"><code>&amp;</code></a> command suffix.  This would only be set on systems
      where a minimal footprint is a necessity and background command execution is not.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_MMCSDMINOR</code></b></td>
    <td>
      If the architecture supports an MMC/SD slot and if the NSH
      architecture specific logic is present, this option will provide
      the MMC/SD minor number, i.e., the MMC/SD block driver will
      be registered as <code>/dev/mmcsd</code><i>N</i> where <i>N</i> is the minor number.
      Default is zero.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_ROMFSETC</code></b></td>
    <td>
      Mount a ROMFS filesystem at <code>/etc</code> and provide a startup script
      at <code>/etc/init.d/rcS</code>.  The default startup script will mount
      a FAT FS RAMDISK at <code>/tmp</code> but the logic is
      <a href="#startupscript">easily extensible</a>.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_CONSOLE</code></b></td>
    <td>
      <p>
        If <code>CONFIG_NSH_CONSOLE</code> is set to <i>y</i>, then a serial
        console front-end is selected.
      </p>
      <p>
        Normally, the serial console device is a UART and RS-232 interface.
        However, if  <code>CONFIG_USBDEV</code> is defined, then a USB serial device may, instead, be used if the one of the following are defined:
      </p>
      <ul>
        <li>
          <code>CONFIG_PL2303</code> and <code>CONFIG_PL2303_CONSOLE</code>.
          Sets up the Prolifics PL2303 emulation as a console device at <code>/dev/console</code>.
        </li>
        <li>
          <code>CONFIG_CDCACM</code> and <code>CONFIG_CDCACM_CONSOLE</code>.
          Sets up the CDC/ACM serial device as a console device at <code>/dev/console</code>.
        </li>
        <li>
          <code>CONFIG_NSH_USBCONSOLE</code>.
          If defined, then the an arbitrary USB device may be used to as the NSH console.
          In this case, <code>CONFIG_NSH_CONDEV</code> must be defined to indicate which USB device to use as the console. 
          The advantage of using a device other that /dev/console is that normal debug output can not use /dev/console while NSH uses <code>CONFIG_NSH_USBCONDEV</code>.
          <p>
          <code>CONFIG_NSH_USBCONDEV</code>.
          If <code>CONFIG_NSH_USBCONSOLE</code> is set to 'y', then <code>CONFIG_NSH_USBCONDEV</code> must also be set to select the USB device used to support the NSH console.
          This should be set to the quoted name of a readable/write-able USB driver such as: <code>CONFIG_NSH_USBCONDEV="/dev/ttyACM0"</code>.
          </p>
        </li>
      </ul>
      <p>
        If there are more than one USB slots, then a USB device minor number may also need to be provided:
      </p>
      <ul>
        <li>
          <code>CONFIG_NSH_UBSDEV_MINOR</code>.
          The minor device number of the USB device.  Default: 0
        </li>
      </ul>
      <p>
        If USB tracing is enabled (<code>CONFIG_USBDEV_TRACE</code>), then NSH will initialize USB tracing as requested by the following.
        Default:  Only USB errors are traced.
      </p>
      <ul>
        <li>
          <code>CONFIG_NSH_USBDEV_TRACEINIT</code>.
          Show initialization events
        </li>
        <li>
          <code>CONFIG_NSH_USBDEV_TRACECLASS</code>.
          Show class driver events
        </li>
        <li>
          <code>CONFIG_NSH_USBDEV_TRACETRANSFERS</code>.
          Show data transfer events
        </li>
        <li>
          <code>CONFIG_NSH_USBDEV_TRACECONTROLLER</code>.
          Show controller events
        <li>
          <code>CONFIG_NSH_USBDEV_TRACEINTERRUPTS</code>.
          Show interrupt-related events.
        </li>
      </ul>
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_CONDEV</code></b></td>
    <td>
      If <code>CONFIG_NSH_CONSOLE</code> is set to <i>y</i>, then <code>CONFIG_NSH_CONDEV</code>
      may also be set to select the serial device used to support the NSH console.
      This should be set to the quoted name of a readable/write-able character driver such as:
      <code>CONFIG_NSH_CONDEV=&quot;/dev/ttyS1&quot;</code>.
      This is useful, for example, to separate the NSH command line from the system console
      when the system console is used to provide debug output.
      Default:  <code>stdin</code> and <code>stdout</code> (probably &quot;<code>/dev/console</code>&quot;)
      <ul><small>
        NOTE: When any other device other than <code>/dev/console</code> is used for a user interface,
        (1) linefeeds (<code>\n</code>) will not be expanded to carriage return / linefeeds (<code>\r\n</code>).
        You will need to configure your terminal program to account for this.
        And (2) input is not automatically echoed so you will have to turn local echo on.
      </small></ul>
    </td>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_TELNET</code></b></td>
    <td>
      If <code>CONFIG_NSH_TELNET</code> is set to <i>y</i>, then a TELENET
      server front-end is selected.  When this option is provided,
      you may log into NuttX remotely using telnet in order to
      access NSH.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_ARCHINIT</code></b></td>
    <td>
      Set <code>CONFIG_NSH_ARCHINIT</code> if your board provides architecture
      specific initialization  via the board-specific function <code>nsh_archinitialize()</code>.
      This function will be called early in NSH initialization to allow board logic to
      do such things as configure MMC/SD slots.
    </td>
  </tr>
</table></center>

<p>
  If Telnet is selected for the NSH console, then we must configure
  the resources used by the Telnet daemon and by the Telnet clients.
</p>

<center><table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Configuration</th>
    <th align="left">Description</th>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_TELNETD_PORT</code></b></td>
    <td>
      The telnet daemon will listen on this TCP port number for connections.  Default: 23
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_TELNETD_DAEMONPRIO</code></b></td>
    <td>
      Priority of the Telnet daemon.
      Default: <code>SCHED_PRIORITY_DEFAULT</code>
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_TELNETD_DAEMONSTACKSIZE</code></b></td>
    <td>
      Stack size allocated for the
      Telnet daemon. Default: 2048
    </td>
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_TELNETD_CLIENTPRIO</code></b></td>
    <td>
      Priority of the Telnet client.
      Default: <code>SCHED_PRIORITY_DEFAULT</code>
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_TELNETD_CLIENTSTACKSIZE</code></b></td>
    <td>
      Stack size allocated for the Telnet client. Default: 2048
    </td>
  </tr>
</table></center>

<p>
  One or both of <code>CONFIG_NSH_CONSOLE</code> and <code>CONFIG_NSH_TELNET</code>
  must be defined.  If <code>CONFIG_NSH_TELNET</code> is selected, then there some
  other configuration settings that apply:
</p>

<center><table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Configuration</th>
    <th align="left">Description</th>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NET=y</code></b></td>
    <td>
      Of course, networking must be enabled.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSOCKET_DESCRIPTORS</code></b></td>
    <td>
      And, of course, you must allocate some socket descriptors.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NET_TCP=y</code></b></td>
    <td>
      TCP/IP support is required for telnet (as well as various other TCP-related configuration settings).
    </td>
  </tr>
    <td valign="top"><b><code>CONFIG_NSH_IOBUFFER_SIZE</code></b></td>
    <td>
      Determines the size of the I/O buffer to use for sending/
      receiving TELNET commands/reponses
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_DHCPC</code></b></td>
    <td>
      Obtain the IP address via DHCP.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_IPADDR</code></b></td>
    <td>
      If <code>CONFIG_NSH_DHCPC</code> is NOT set, then the static IP
      address must be provided.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_DRIPADDR</code></b></td>
    <td>
      Default router IP address
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_NETMASK</code></b></td>
    <td>
      Network mask
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_NOMAC</code></b></td>
    <td>
      Set if your ethernet hardware has no built-in MAC address.
      If set, a bogus MAC will be assigned.
    </td>
  </tr>
</table></center>

<p>
  If you use DHCPC, then some special configuration network options are
  required.  These include:
</p>

<center><table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Configuration</th>
    <th align="left">Description</th>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NET=y</code></b></td>
    <td>
      Of course, networking must be enabled.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSOCKET_DESCRIPTORS</code></b></td>
    <td>
      And, of course, you must allocate some socket descriptors.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NET_UDP=y</code></b></td>
    <td>
      UDP support is required for DHCP (as well as various other UDP-related configuration settings).
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NET_BROADCAST=y</code></b></td>
    <td>
      UDP broadcast support is needed.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NET_BUFSIZE=650</code></b> (or larger)</td>
    <td>
      Per RFC2131 (p. 9), the DHCP client must be prepared to receive DHCP messages of up to
      576 bytes (excluding Ethernet, IP, or UDP headers and FCS).
    </td>
  </tr>
</table></center>

<p>
  If <code>CONFIG_NSH_ROMFSETC</code> is selected, then the following additional
  configuration setting apply:
</p>

<center><table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Configuration</th>
    <th align="left">Description</th>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_ARCHROMFS</code></b></td>
    <td>
      May be defined to specify an alternative ROMFS image that can be found at <code>configs/&lt;board&gt;/include/nsh_romfsimg.h</code>.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_ROMFSMOUNTPT</code></b></td>
    <td>
      The default mountpoint for the ROMFS volume is <code>&quot;/etc&quot;</code>, but that
      can be changed with this setting.  This must be a absolute path
      beginning with '<code>/</code>' and enclosed in quotes.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_INITSCRIPT</code></b></td>
    <td>
      This is the relative path to the startup script within the mountpoint.
      The default is <code>&quot;init.d/rcS&quot;</code>.  This is a relative path and must not
      start with '<code>/</code>' but must be enclosed in quotes.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_ROMFSDEVNO</code></b></td>
    <td>
      This is the minor number of the ROMFS block device.  The default is
      '<code>0</code>' corresponding to <code>/dev/ram0</code>.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_ROMFSSECTSIZE</code></b></td>
    <td>
      This is the sector size to use with the ROMFS volume.  Since the
      default volume is very small, this defaults to 64 but should be
      increased if the ROMFS volume were to be become large.  Any value
      selected must be a power of 2.
    </td>
  </tr>
</table></center>

<p>
  When the default <code>rcS</code> file used when <code>CONFIG_NSH_ROMFSETC</code> is
  selected, it will mount a FAT FS under <code>/tmp</code>.  The following selections
  describe that FAT FS.
</p>

<center><table width="100%">
  <tr bgcolor="#e4e4e4">
    <th align="left" width="25%">Configuration</th>
    <th align="left">Description</th>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_FATDEVNO</code></b></td>
    <td>
      This is the minor number of the FAT FS block device.  The default is
      '<code>1</code>' corresponding to <code>/dev/ram1</code>.
    </td>
  </tr>
  <tr>
    <td valign="top"><b><code>CONFIG_NSH_FATSECTSIZE</code></b></td>
    <td>
      This is the sector size use with the FAT FS. Default is 512.
    </td>
  </tr>
</table></center>

<table width ="100%">
  <tr bgcolor="#e4e4e4">
  <td>
    <a name="index"><h1>Index</h1></a>
  </td>
  </tr>
</table>

<table width="100%">
<tr><td width="50%">
<ul>
  <li><a href="#builtinvars"><code>$?</code></a></li>
  <li><a href="#cmdtest"><code>[</code></a></li>
  <li><a href="#cmdoverview">Background commands</a></li>
  <li><a href="#cmdoverview">Background command priority</a></li>
  <li><a href="#builtinvars">Built-in variables</a></li>
  <li><a href="#cmdcat"><code>cat</code></a></li>
  <li><a href="#cmdcd"><code>cd</code></a></li>
  <li><a href="#commands">Command summaries</a></li>
  <li><a href="#conditional">Conditional command execution</a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_CONSOLE</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_DHCPC</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_DISABLEBG</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_DISABLESCRIPT</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_DRIPADDR</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_FATDEVNO</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_FATMOUNTPT</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_FATNSECTORS</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_FATSECTSIZE</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_FILEIOSIZE</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_INITSCRIPT</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_IOBUFFER_SIZE</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_IPADDR</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_LINELEN</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_NESTDEPTH</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_NETMASK</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_NOMAC</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_ROMFSDEVNO</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_ROMFSETC</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_ARCHROMFS</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_ROMFSMOUNTPT</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_ROMFSSECTSIZE</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_STRERROR</code></a></li>
  <li><a href="#nshconfiguration"><code>CONFIG_NSH_TELNET</code></a></li>
  <li><a href="#configuration">Configuration settings</a></li>
  <li><a href="#cmddependencies">Configuration settings, command dependencies</a></li>
  <li><a href="#nshconfiguration">Configuration settings, NSH-specific</a></li>
  <li><a href="#cmdcp"><code>cp</code></a></li>
  <li><a href="#currentwd">Current working directory</a></li>
  <li><a href="#cmddate"><code>date</code></a></li>
  <li><a href="#cmddd"><code>dd</code></a></li>
  <li><a href="#cmdecho"><code>echo</code></a></li>
  <li><a href="#environvars">Environment Variables</a></li>
  <li><a href="#startupscript"><code>/etc/init.d/rcS</code></a>
</ul></td>
<td></ul>
  <li><a href="#cmdexec"><code>exec</code></a></li>
  <li><a href="#cmdexit"><code>exit</code></a></li>
  <li><a href="#cmdfree"><code>free</code></a></li>
  <li><a href="#cmdget"><code>get</code></a></li>
  <li><a href="#frontend">Greeting</a></li>
  <li><a href="#cmdhelp"><code>help</code></a></li>
  <li><a href="#conditional"><code>if-then[-else]-fi</code></a></li>
  <li><a href="#cmdifconfig"><code>ifconfig</code></a></li>
  <li><a href="#cmdkill"><code>kill</code></a></li>
  <li><a href="#cmdlosetup"><code>losetup</code></a></li>
  <li><a href="#cmdls">ls</code></a></li>
  <li><a href="#cmdmbhw"><code>mb</code></a></li>
  <li><a href="#cmdmbhw"><code>mh</code></a></li>
  <li><a href="#cmdmbhw"><code>mw</code></a></li>
  <li><a href="#cmdmkdir"><code>mkdir</code></a></li>
  <li><a href="#cmdmkfatfs"><code>mkfatfs</code></a></li>
  <li><a href="#cmdmkfifo"><code>mkfifo</code></a></li>
  <li><a href="#cmdmkrd"><code>mkrd</code></a></li>
  <li><a href="#cmdmount"><code>mount</code></a></li>
  <li><a href="#cmdmv"><code>mv</code></a></li>
  <li><a href="#cmdoverview"><code>nice</code></a></li>
  <li><a href="#environvars"><code>OLDPWD</code></a></li>
  <li><a href="#overview">Overview</a></li>
  <li><a href="#cmdping"><code>ping</code></a></li>
  <li><a href="#frontend">Prompt</a></li>
  <li><a href="#cmdps"><code>ps</code></a></li>
  <li><a href="#cmdput"><code>put</code></a></li>
  <li><a href="#cmdpwd"><code>pwd</code></a></li>
  <li><a href="#environvars"><code>PWD</code></a></li>
  <li><a href="#cmdoverview">Re-directed commands</a></li>
  <li><a href="#cmdrm"><code>rm</code></a></li>
  <li><a href="#cmdrmdir"><code>rmdir</code></a></li>
  <li><a href="#cmdset"><code>set</code></a></li>
  <li><a href="#cmdsh"><code>sh</code></a></li>
  <li><a href="#cmdoverview">Simple commands</a></li>
  <li><a href="#cmdsleep"><code>sleep</code></a></li>
  <li><a href="#startupscript">start-up script</a>
  <li><a href="#cmdtest"><code>test</code></a></li>
  <li><a href="#cmdunmount"><code>umount</code></a></li>
  <li><a href="#cmdunset"><code>unset</code></a></li>
  <li><a href="#cmdusleep"><code>usleep</code></a></li>
  <li><a href="#cmdwget"><code>wget</code></a></li>
  <li><a href="#cmdxd"><code>xd</code></a></li>
</ul></td>
</tr></table>

</body>
</html>