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
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
|
<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: July 18, 2013</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="#cmdbase64dec">2.2 Base64 Decode (base64dec)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdbase64enc">2.3 Base64 Encode (base64enc)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdcat">2.4 Concatenate Files (cat)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdcd">2.5 Change Current Working Directory (cd)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdcmp">2.6 Compare Files (cmp)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdcp">2.7 Copy Files (cp)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmddate">2.8 Show or set the date and time (date)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmddd">2.9 Copy and Convert Files (dd)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmddf">2.10 Show volume status (df)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdecho">2.11 Echo Strings and Variables (echo)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdexec">2.12 Execute User Code (exec)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdexit">2.13 Exit NSH (exit)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdfree">2.14 Show Memory Manager Status (free)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdget">2.15 Get File Via TFTP (get)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdhelp">2.16 Show Usage Command Usage (help)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdhexdump">2.17 Hexadecimal Dump of File or Device (hexdump)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdifconfig">2.18 Manage Network Configuration (ifconfig)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdifdown">2.19 Take a network down (ifdown)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdifup">2.20 Bring a network up (ifup)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdkill">2.21 Send a signal to a task (kill)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdlosetup">2.22 Setup/teardown the Loop Device (losetup)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdls">2.23 List Directory Contents (ls)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmd5">2.24 Calculate MD5 (md5)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmbhw">2.25 Access Memory (mb, mh, and mw)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdps">2.26 Show Current Tasks and Threads (ps)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmkdir">2.27 Create a Directory (mkdir)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmkfatfs">2.28 Create a FAT Filesystem (mkfatfs)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmkfifo">2.29 Create a FIFO (mkfifo)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmkrd">2.30 Create a RAMDISK (mkrd)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmount">2.31 Mount a File System (mount)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdmv">2.32 Rename a File (mv)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdnfsmount">2.33 Mount an NFS file system (nfsmount)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdping">2.34 Check Network Peer (ping)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdput">2.35 Send File Via TFTP (put)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdpwd">2.36 Show Current Working Directory (pwd)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdrm">2.37 Remove a File (rm)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdrmdir">2.38 Remove a Directory (rmdir)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdset">2.39 Set an Environment Variable (set)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdsh">2.40 Execute an NSH Script (sh)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdsleep">2.41 Wait for Seconds (sleep)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdunmount">2.42 Unmount a File System (umount)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdunset">2.43 Unset an Environment Variable (unset)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdurldec">2.44 URL Decode (urldecode)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdurlencode">2.45 URL Encode (urlencode)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdusleep">2.46 Wait for Microseconds (usleep)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdwget">2.47 Get File Via HTTP (wget)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#cmdxd">2.48 Hexadecimal Dump of Memory (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="#customizingnsh">4.0 Customimizing the NuttShell</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#custonshlib">4.1 The NSH Library and NSH Initialization</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#custoncmds">4.2 NSH Commands</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#custapps">4.3 NSH "Built-In" Applications</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
<a href="#custinit">4.4 Customizing NSH Initialization</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>
</pre></ul>
<code>nsh></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><cmd></code></td>
</tr>
<tr>
<td>Command with re-directed output:</td>
<td><code>
<cmd> > <file><br>
<cmd> >> <file>
</code></td>
</tr>
<tr>
<td>Background command:</td>
<td><code><cmd> &</code></td>
</tr>
<tr>
<td>Re-directed background command:</td>
<td><code>
<cmd> > <file> &<br>
<cmd> >> <file> &
</code></td>
</tr>
</table></ul>
<p>Where:</p>
<ul><table>
<tr>
<td><code><cmd></code></td>
<td>
is any one of the simple commands listed later.
</td>
</tr>
<tr>
<td><code><file></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 <niceness>>]] <cmd> [> <file>|>> <file>] [&]
</code></ul>
<p>
Where <code><niceness></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 <cmd>
then
[sequence of <cmd>]
else
[sequence of <cmd>]
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> > 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/<board>/include</code> will be used.
NOTE when the OS is configured, <code>include/arch/board</code> will be linked to <code>configs/<board>/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>
<p>
<b>Further Information</b>.
See the section on <a href="#customizingnsh">Customimizing the NuttShell</a> for additional, more detailed information about the NSH start-up script and how to modify it.
</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>
[ <expression> ]
test <expression>
</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="cmdbase64dec"><h2>2.2 Base64 Decode (base64dec)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
base64dec [-w] [-f] <string or filepath>
</pre></ul>
<p>
<b>Synopsis</b>.
<i>To be provided.</i>
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdbase64enc"><h2>2.3 Base64 Encode (base64enc)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
base64enc [-w] [-f] <string or filepath>
</pre></ul>
<p>
<b>Synopsis</b>.
<i>To be provided.</i>
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdcat"><h2>2.4 Concatenate Files (cat)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
cat <code><path></code> [<code><path></code> [<code><path></code> ...]]
</pre></ul>
<p>
<b>Synopsis</b>.
This command copies and concatentates all of the files at <code><path></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.5 Change Current Working Directory (cd)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
cd [<dir-path>|-|~|..]
</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 <dir-path></code></b></td>
<td>sets the current working directory to <code><dir-path></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="cmdcmp"><h2>2.6 Compare Files (cmp)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
cmp <path1> <path2>
</pre></ul>
<p>
<b>Synopsis</b>.
Compare of the contents of the file at <code><path1></code> with the contents of the file at <code><path2></code>. Returns an indication only if the files differ.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdcp"><h2>2.7 Copy Files (cp)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
cp <source-path> <dest-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Copy of the contents of the file at <code><source-path></code> to the location
in the filesystem indicated by <code><dest-path></code>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmddate"><h2>2.8 Show or set the date and time (date)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
date [-s "MMM DD HH:MM:SS YYYY"]
</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 "Sep 1 11:30:00 2011"
</pre></ul>
</p>
<p>
24-hour time is used.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmddd"><h2>2.9 Copy and Convert Files (dd)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
dd if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>]
</pre></ul>
<p>
<b>Synopsis</b>.
Copy blocks from <infile> to <outfile>.
<infile> or <outfile> 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> ls -l /dev
/dev:
crw-rw-rw- 0 zero
nsh> dd if=/dev/zero of=/tmp/zeros bs=64 count=16
nsh> 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> ls -l /dev
/dev:
brw-rw-rw- 0 ram0
crw-rw-rw- 0 zero
nsh> 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> ls -l /dev
/dev:
crw-rw-rw- 0 null
brw-rw-rw- 0 ram0
nsh> dd if=/dev/ram0 of=/dev/null
</pre></ul>
</li>
</ol>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmddf"><h2>2.10 Show Volument Status (df)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
df [-h]
</pre></ul>
<p>
<b>Synopsis</b>.
Show the state of each mounted volume.
As an example:
</p>
<ul><pre>
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>
</pre></ul>
<p>
If <code>CONFIG_NSH_CMDOPT_DF_H</code> is defined in the NuttX configuration, the the <code>df</code> will also support an option <code>-h</code> which may be used to show the the volume information in <i>human readable</i> format.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdecho"><h2>2.11 Echo Strings and Variables (echo)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
echo [<string|$name> [<string|$name>...]]
</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.12 Execute User Code (exec)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
exec <hex-address>
</pre></ul>
<p>
<b>Synopsis</b>.
Execute the user logic at address <code><hex-address></code>. NSH will pause
until the execution unless the user logic is executed in background
via <code><a href="#cmdexec">exec</a> <hex-address> &</code>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdexit"><h2>2.13 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.14 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> free
total used free largest
Mem: 4194288 1591552 2602736 2601584
nsh>
</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.15 Get File Via TFTP (get)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Copy the file at <code><remote-address></code> from the host whose IP address is
identified by <code><ip-address></code>.
</p>
<p><b>Other options:</b></p>
<ul><table>
<tr>
<td><b><code>-f <local-path></code></b></td>
<td>
The file will be saved relative to the current working directory
unless <code><local-path></code> is provided.
</td>
</tr>
<tr>
<td><b><code>-b|-n</code></b></td>
<td>
Selects either binary ("octect") or test ("netascii") transfer
mode. Default: text.
</td>
</tr>
</table></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdhelp"><h2>2.16 Show Usage Command Usage (help)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
help [-v] [<cmd>]
</pre></ul>
<p>
<b>Synopsis</b>.
Presents summary information about NSH commands to console.
</p>
<p><b>Options:</b></p>
<ul><table>
<tr>
<td><b><code>-v</code></b></td>
<td>
how verbose output will full command usage.
</td>
</tr>
<tr>
<td><b><code><cmd></code></b></td>
<td>
Show full command usage only for this command.
</td>
</tr>
</table></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdhexdump"><h2>2.17 Hexadecimal Dump of File or Device (hexdump)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
hexdump <file or device>
</pre></ul>
<p>
<b>Synopsis</b>.
Dump data in hexadecimal format from a file or character device.
</p>
<tr>
<td><br></td>
<td>
<a href="#"></a>
</td>
</tr>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdifconfig"><h2>2.18 Manage Network Configuration (ifconfig)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
ifconfig [nic_name [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]]
</pre></ul>
<p>
<b>Synopsis</b>.
Multiple 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> 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>
<li>
Other forms <i>to be provided</i>
</li>
</ol>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdifdown"><h2>2.19 Take a network down (ifdown)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
ifdown <nic-name>
</pre></ul>
<p>
<b>Synopsis</b>.
Take down the interface identified by the name <nic-name>.
</p>
<p>
<b>Example:</b>
</p>
<ul><pre>
ifdown eth0
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdifup"><h2>2.20 Bring a network up (ifup)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
ifup <nic-name>
</pre></ul>
<p>
<b>Synopsis</b>.
Bring up down the interface identified by the name <nic-name>.
</p>
<p>
<b>Example:</b>
</p>
<ul><pre>
ifup eth0
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdkill"><h2>2.21 Send a signal to a task (kill)</h2></a>
</td>
</tr>
</table>
<ul><pre>
kill -<signal> <pid>
</pre></ul>
<p>
<b>Synopsis</b>.
Send the <signal> to the task identified by <pid>.
</p>
<ul><pre>
nsh> mkfifo /dev/fifo
nsh> cat /dev/fifo &
cat [2:128]
nsh> 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> kill -9 2
nsh: cat: open failed: 4
nsh> ps
PID PRI SCHD TYPE NP STATE NAME
0 0 FIFO TASK READY Idle Task()
1 128 FIFO TASK RUNNING init()
nsh>
</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.22 Setup/teardown the Loop Device (losetup)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax 1:</b></p>
<ul><pre>
losetup [-o <offset>] [-r] <dev-path> <file-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Setup the loop device at <dev-path> to access the file at <file-path> as a block device.
In the following example a 256K 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> 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>
</pre></ul>
</p>
<p><b>Command Syntax 2:</b></p>
<ul><pre>
losetup d <dev-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Teardown the setup for the loop device at <dev-path>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdls"><h2>2.23 List Directory Contents (ls)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
ls [-lRs] <dir-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Show the contents of the directory at <code><dir-path></code>. NOTE:
<code><dir-path></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="cmdmd5"><h2>2.24 Calculate MD5 (md5)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
md5 [-f] <string or filepath>
</pre></ul>
<p>
<b>Synopsis</b>.
<i>To be provided.</i>
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdmbhw"><h2>2.25 Access Memory (mb, mh, and mw)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mb <hex-address>[=<hex-value>][ <hex-byte-count>]
mh <hex-address>[=<hex-value>][ <hex-byte-count>]
mw <hex-address>[=<hex-value>][ <hex-byte-count>]
</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><hex-address></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><hex-address>=<hex-value></code>.</td>
<td>Read the value, then write <code><hex-value></code>
to the location.
</tr>
<tr>
<td><code><hex-byte-count></code>.</td>
<td>Perform the mb, mh, or mw operation on a total
of <code><hex-byte-count></code> bytes, increment the <code><hex-address></code> appropriately
after each access
</tr>
</table></ul>
<p><b>Example:</b><p>
<ul><pre>
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>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdps"><h2>2.26 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> 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 <pthread>(21)
nsh>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdmkdir"><h2>2.27 Create a Directory (mkdir)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mkdir <path>
</pre></ul>
<p>
<b>Synopsis</b>.
Create the directory at <code><path></code>.
All components of of <code><path></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.28 Create a FAT Filesystem (mkfatfs)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mkfatfs <path>
</pre></ul>
<p>
<b>Synopsis</b>.
Format a fat file system on the block device specified by <code><path></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.29 Create a FIFO (mkfifo)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mkfifo <path>
</pre></ul>
<p>
<b>Synopsis</b>.
Creates a FIFO character device anywhere in the pseudo file system, creating
whatever pseudo directories that may be needed to complete the <code><path></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.30 Create a RAMDISK (mkrd)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mkrd [-m <minor>] [-s <sector-size>] <nsectors>
</pre></ul>
<p>
<b>Synopsis</b>.
Create a ramdisk consisting of <code><nsectors></code>, each of size
<code><sector-size></code> (or 512 bytes if <code><sector-size></code> is not specified.
The ramdisk will be registered as <code>/dev/ram<n></code> (if <code><n></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> ls /dev
/dev:
console
null
ttyS0
ttyS1
nsh> mkrd 1024
nsh> ls /dev
/dev:
console
null
ram0
ttyS0
ttyS1
nsh>
</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> mkrd 1024
nsh> mkfatfs /dev/ram0
nsh> mount -t vfat /dev/ram0 /tmp
nsh> ls /tmp
/tmp:
nsh>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdmount"><h2>2.31 Mount a File System (mount)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mount -t <fstype> <block-device> <code><dir-path></code>
</pre></ul>
<p>
<b>Synopsis</b>.
The <code>mount</code> command performs one of two different operations.
If no paramters are provided on the command line after the <code>mount</code> command, then the <code>mount</code> command will enumerate all of the current mountpoints on the console.
</p>
<p>
If the mount parameters are provied on the command after the <code>mount</code> command, then the <code>mount</code> command will mount a file system in the NuttX pseudo-file system.
<code>mount</code>' performs a three way association, binding:
</p>
<ol>
<li><b>File system.</b>
The '-t <code><fstype></code>' option identifies the type of
file system that has been formatted on the <code><block-device></code>.
As of this writing, <code>vfat</code> is the only supported value for <code><fstype></code>
</li>
<li><b>Block Device.</b>
The <code><block-device></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><block-device></code> must have been previously formatted with the same file system
type as specified by <code><fstype></code>
</li>
<li><b>Mount Point.</b>
The mount point, <code><dir-path></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 pseudo 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>Examples</b>:</p>
<p>Using <code>mount</code> to mount a file system:</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>
<p>Using <code>mount</code> to enumerate mounts:</p>
<ul><pre>
nsh> mount
/etc type romfs
/mnt/fs type vfat
/tmp type vfat
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdmv"><h2>2.32 Rename a File (mv)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
mv <old-path> <new-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Rename the file object at <code><old-path></code> to <code><new-path></code>.
Both paths must reside in the same mounted filesystem.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdnfsmount"><h2>2.33 Mount an NFS file system (nfsmount)</h2></a>
</td>
</tr>
</table>
<a href="#"></a>
<p><b>Command Syntax:</b></p>
<ul><pre>
nfsmount <server-address> <mount-point> <remote-path>
</pre></ul>
<p>
<b>Synopsis</b>.
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.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdping"><h2>2.34 Check Network Peer (ping)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
ping [-c <count>] [-i <interval>] <ip-address>
</pre></ul>
<p>
<b>Synopsis</b>.
Test the network communication with a remote peer. Example,
</p>
<ul><pre>
nsh> 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>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdput"><h2>2.35 Send File Via TFTP (put)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Copy the file at <code><local-address></code> to the host whose IP address is
identified by <code><ip-address></code>.
</p>
<p><b>Other options:</b></p>
<ul><table>
<tr>
<td><b><code>-f <remote-path></code></b></td>
<td>
The file will be saved relative with the same name on the host
unless <code><remote-path></code> is provided.
</td>
</tr>
<tr>
<td><b><code>-b|-n</code></b></td>
<td>
Selects either binary ("octect") or test ("netascii") transfer
mode. Default: text.
</td>
</tr>
</table></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdpwd"><h2>2.36 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> cd /dev
nsh> pwd
/dev
nsh>
</pre></ul>
<p>Same as <code><a href="#cmdecho">echo</a> <a href="#environvars">$PWD</a></code>.</p>
<ul><pre>
nsh> echo $PWD
/dev
nsh>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdrm"><h2>2.37 Remove a File (rm)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
rm <file-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Remove the specified <code><file-path></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.38 Remove a Directory (rmdir)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
rmdir <dir-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Remove the specified <code><dir-path></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.39 Set an Environment Variable (set)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
set <name> <value>
</pre></ul>
<p>
<b>Synopsis</b>.
Set the environment variable <code><name></code> to the string <code><value></code>.
For example,
</p>
<ul><pre>
nsh> echo $foobar
nsh> set foobar foovalue
nsh> echo $foobar
foovalue
nsh>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdsh"><h2>2.40 Execute an NSH Script (sh)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
sh <script-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Execute the sequence of NSH commands in the file referred
to by <code><script-path></code>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdsleep"><h2>2.41 Wait for Seconds (sleep)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
sleep <sec>
</pre></ul>
<p>
<b>Synopsis</b>.
Pause execution (sleep) for <code><sec></code> seconds.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdunmount"><h2>2.42 Unmount a File System (umount)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
umount <dir-path>
</pre></ul>
<p>
<b>Synopsis</b>.
Un-mount the file system at mount point <code><dir-path></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.43 Unset an Environment Variable (unset)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
unset <name>
</pre></ul>
<p>
<b>Synopsis</b>.
Remove the value associated with the environment variable
<code><name></code>. Example:
</p>
<ul><pre>
nsh> echo $foobar
foovalue
nsh> unset foobar
nsh> echo $foobar
nsh>
</pre></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdurldec"><h2>2.44 URL Decode (urldecode)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
urldecode [-f] <string or filepath>
</pre></ul>
<p>
<b>Synopsis</b>.
<i>To be provided.</i>
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdurlencode"><h2>2.45 URL Encode (urlencode)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
urlencode [-f] <string or filepath>
</pre></ul>
<p>
<b>Synopsis</b>.
<i>To be provided.</i>
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdusleep"><h2>2.46 Wait for Microseconds (usleep)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
usleep <usec>
</pre></ul>
<p>
<b>Synopsis</b>.
Pause execution (sleep) of <code><usec></code> microseconds.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdwget">2.47 Get File Via HTTP (wget)</a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
wget [-o <local-path>] <url>
</pre></ul>
<p>
<b>Synopsis</b>.
Use HTTP to copy the file at <code><url></code> to the current directory.
</p>
<p><b>Options:</b></p>
<ul><table>
<tr>
<td><b><code>-o <local-path></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><local-path></code> is provided.
</td>
</tr>
</table></ul>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="cmdxd"><h2>2.48 Hexadecimal Dump of Memory (xd)</h2></a>
</td>
</tr>
</table>
<p><b>Command Syntax:</b></p>
<ul><pre>
xd <hex-address> <byte-count>
</pre></ul>
<p>
<b>Synopsis</b>.
Dump <code><byte-count></code> bytes of data from address <code><hex-address></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>base64dec</code></b></td>
<td><code>CONFIG_NETUTILS_CODECS</code> && <code>CONFIG_CODECS_BASE64</code></td>
<td><code>CONFIG_NSH_DISABLE_BASE64DEC</code></td>
</tr>
<tr>
<td><b><code>base64enc</code></b></td>
<td><code>CONFIG_NETUTILS_CODECS</code> && <code>CONFIG_CODECS_BASE64</code></td>
<td><code>CONFIG_NSH_DISABLE_BASE64ENC</code></td>
</tr>
<tr>
<td><b><code>cat</code></b></td>
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
<td><code>CONFIG_NSH_DISABLE_CD</code></td>
</tr>
<tr>
<td><b><code>cmp</code></b></td>
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
<td><code>CONFIG_NSH_DISABLE_CMP</code></td>
</tr>
<tr>
<td><b><code>cp</code></b></td>
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 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> && <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> > 0</td>
<td><code>CONFIG_NSH_DISABLE_DD</code></td>
</tr>
<tr>
<td><b><code>df</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_READABLE</code><sup>3</sup></td>
<td><code>CONFIG_NSH_DISABLE_DF</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> && <code>CONFIG_NET_UDP</code> &&
<code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_NET_BUFSIZE</code> >= 558<sup>1</sup></td>
<td><code>CONFIG_NSH_DISABLE_GET</code></td>
</tr>
<tr>
<td><b><code>help</code></b><sup>5</sup></td>
<td><br></td>
<td><code>CONFIG_NSH_DISABLE_HELP</code></td>
</tr>
<tr>
<td><b><code>hexdump</code></b></td>
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
<td><code>CONFIG_NSH_DISABLE_HEXDUMP</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>ifdown</code></b></td>
<td><code>CONFIG_NET</code></td>
<td><code>CONFIG_NSH_DISABLE_IFUPDOWN</code></td>
</tr>
<tr>
<td><b><code>ifup</code></b></td>
<td><code>CONFIG_NET</code></td>
<td><code>CONFIG_NSH_DISABLE_IFUPDOWN</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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 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> > 0</td>
<td><code>CONFIG_NSH_DISABLE_LS</code></td>
</tr>
<tr>
<td><b><code>md5</code></b></td>
<td><code>CONFIG_NETUTILS_CODECS</code> && <code>CONFIG_CODECS_HASH_MD5</code></td>
<td><code>CONFIG_NSH_DISABLE_MD5</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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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> > 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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_WRITABLE</code><sup>3</sup></td>
<td><code>CONFIG_NSH_DISABLE_MV</code></td>
</tr>
<tr>
<td><b><code>nfsmount</code></b></td>
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_NET</code> && <code>CONFIG_NFS</code></td>
<td><code>CONFIG_NSH_DISABLE_NFSMOUNT</code></td>
</tr>
<tr>
<td><b><code>ping</code></b></td>
<td><code>CONFIG_NET</code> && <code>CONFIG_NET_ICMP</code> &&
<code>CONFIG_NET_ICMP_PING</code> && !<code>CONFIG_DISABLE_CLOCK</code> &&
!<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> && <code>CONFIG_NET_UDP</code> &&
<code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_NET_BUFSIZE</code> >= 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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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 > 0 && <code>CONFIG_NFILE_STREAMS > 0 && !<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> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <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>urldecode</code></b></td>
<td>!<code>CONFIG_NETUTILS_CODECS</code> && <code>CONFIG_CODECS_URLCODE</code>
<td><code>CONFIG_NSH_DISABLE_URLDECODE</code></td>
</tr>
<tr>
<td><b><code>urlencode</code></b></td>
<td>!<code>CONFIG_NETUTILS_CODECS</code> && <code>CONFIG_CODECS_URLCODE</code>
<td><code>CONFIG_NSH_DISABLE_URLENCODE</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> && <code>CONFIG_NET_TCP</code> &&
<code>CONFIG_NFILE_DESCRIPTORS</code> > 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>
<sup>5</sup><small>
Verbose help output can be suppressed by defining <code>CONFIG_NSH_HELP_TERSE</code>.
In that case, the help command is still available but will be slightly smaller.
</small>
</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/<board-name>/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, "builtin" applications that can be
executed from the NSH command line (see apps/README.txt for
more information).
This required <code>CONFIG_BUILTIN</code> to enable NuttX support for
"builtin" applications.
</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>
<code>strerror(errno)</code> makes more readable output but <code>strerror()</code> is
very large and will not be used unless this setting is <i>y</i>.
This setting depends upon the <code>strerror()</code> having been enabled with <code>CONFIG_LIBC_STRERROR</code>.
</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>&</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="/dev/ttyS1"</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 "<code>/dev/console</code>")
<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>
<tr>
<td valign="top"><b><code>CONFIG_NSH_MAX_ROUNDTRIP</code></b></td>
<td>
This is the maximum round trip for a response to a ICMP ECHO request.
It is in units of deciseconds. The default is 20 (2 seconds).
</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/<board>/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>"/etc"</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>"init.d/rcS"</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="customizingnsh"><h1>4.0 Customimizing the NuttShell</h1></a>
</td>
</tr>
</table>
<p>
<b>Overview.</b>
The NuttShell (NSH) is a simple shell application that may be used with NuttX.
It supports a variety of commands and is (very) loosely based on the bash shell and the common utilities used in Unix shell programming.
The paragraphs in this appendix will focus on customizing NSH: Adding new commands, changing the initialization sequence, etc.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="custonshlib"><h2>4.1 The NSH Library and NSH Initialization</h2></a>
</td>
</tr>
</table>
<p>
<b>Overview.</b>
NSH is implemented as a library that can be found at <code>apps/nshlib</code>.
As a library, it can be custom built into any application that follows the NSH initialization sequence described below.
As an example, the code at <code>apps/examples/nsh/nsh_main.c</code> illustrates how to start NSH and the logic there was intended to be incorporated into your own custom code.
Although code was generated simply as an example, in the end most people just use this example code as their application <code>main()</code> function.
That initialization performed by that example is discussed in the following paragraphs.
</p>
<h3>4.1.1 NSH Initialization sequence</h3>
<p>
The NSH start-up sequence is very simple.
As an example, the code at <code>apps/examples/nsh/nsh_main.c</code> illustrates how to start NSH.
It simple does the following:
</p>
<ol>
<li>
<p>
If you have C++ static initializers, it will call your implementation of <code>up_cxxinitialize()</code> which will, in turn, call those static initializers.
For the case of the STM3240G-EVAL board, the implementation of <code>up_cxxinitialize()</code> can be found at <code>nuttx/configs/stm3240g-eval/src/up_cxxinitialize.c</code>.
</p>
<li>
<p>
This function then calls <code>nsh_initialize()</code> which initializes the NSH library.
<code>nsh_initialize()</code> is described in more detail below.
</p>
<li>
<p>
If the Telnetconsole is enabled, it calls <code>nsh_telnetstart()</code> which resides in the NSH library.
<code>nsh_telnetstart()</code> will start the Telnet daemon that will listen for Telnet connections and start remote NSH sessions.
</p>
<li>
<p>
If a local console is enabled (probably on a serial port), then <code>nsh_consolemain()</code> is called.
<code>nsh_consolemain()</code> also resides in the NSH library.
<code>nsh_consolemain()</code> does not return so that finished the entire NSH initialization sequence.
</p>
</ol>
<h3>4.1.2 <code>nsh_initialize()</code></h3>
<p>
The NSH initialization function, <code>nsh_initialize()</code>, be found in <code>apps/nshlib/nsh_init.c</code>.
It does only three things:
</p>
<ol>
<li>
<p>
<code>nsh_romfsetc()</code>:
If so configured, it executes an NSH start-up script that can be found at <code>/etc/init.d/rcS</code> in the target file system.
The <code>nsh_romfsetc()</code> function can be found in <code>apps/nshlib/nsh_romfsetc.c</code>.
This function will (1) register a ROMFS file system, then (2) mount the ROMFS file system.
<code>/etc</code> is the default location where a read-only, ROMFS file system is mounted by <code>nsh_romfsetc()</code>.
</p>
<p>
The ROMFS image is, itself, just built into the firmware.
By default, this <code>rcS</code> start-up script contains the following logic:
</p>
<ul><pre>
# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX
mkrd -m XXXMKRDMINORXXX -s XXMKRDSECTORSIZEXXX XXMKRDBLOCKSXXX
mkfatfs /dev/ramXXXMKRDMINORXXX
mount -t vfat /dev/ramXXXMKRDMINORXXX XXXRDMOUNTPOUNTXXX
</pre></ul>
<p>
Where the <code>XXXX*XXXX</code> strings get replaced in the template when the ROMFS image is created:
</p>
<ul>
<li>
<p>
<code>XXXMKRDMINORXXX</code> will become the RAM device minor number.
Default: 0
</p>
<li>
<p>
<code>XXMKRDSECTORSIZEXXX</code> will become the RAM device sector size
</p>
<li>
<p>
<code>XXMKRDBLOCKSXXX</code> will become the number of sectors in the device.
</p>
<li>
<p>
<code>XXXRDMOUNTPOUNTXXX</code> will become the configured mount point.
Default: <code>/etc</code>
</p>
</ul>
<p>
By default, the substituted values would yield an <code>rcS</code> file like:
</p>
<ul><pre>
# Create a RAMDISK and mount it at /tmp
mkrd -m 1 -s 512 1024
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /tmp
</pre></ul>
<p>
This script will, then:
</p>
<ul>
<li>
<p>
Create a RAMDISK of size 512*1024 bytes at <code>/dev/ram1</code>,
</p>
<li>
<p>
Format a FAT file system on the RAM disk at <code>/dev/ram1</code>, and then
</p>
<li>
<p>
Mount the FAT filesystem at a configured mountpoint, <code>/tmp</code>.
</p>
</ul>
<p>
This <code>rcS</code> template file can be found at <code>apps/nshlib/rcS.template</code>.
The resulting ROMFS file system can be found in <code>apps/nshlib/nsh_romfsimg.h</code>.
</p>
<li>
<p>
<code>nsh_archinitialize()</code>:
Next any architecture-specific NSH initialization will be performed (if any).
For the STM3240G-EVAL, this architecture specific initialization can be found at <code>configs/stm3240g-eval/src/up_nsh.c</code>.
This it does things like: (1) Initialize SPI devices, (2) Initialize SDIO, and (3) mount any SD cards that may be inserted.
</p>
<li>
<p>
<code>nsh_netinit()</code>:
The <code>nsh_netinit()</code> function can be found in <code>apps/nshlib/nsh_netinit.c</code>.
</p>
</ol>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="custoncmds"><h2>4.2 NSH Commands</h2></a>
</td>
</tr>
</table>
<p>
<b>Overview.</b>
NSH supports a variety of commands as part of the NSH program.
All of the NSH commands are listed in the NSH documentation <a href="#cmdoverview">above</a>.
Not all of these commands may be available at any time, however.
Many commands depend upon certain NuttX configuration options.
You can enter the help command at the NSH prompt to see the commands actual available:
</p>
<ul><pre>
nsh> help
</pre></ul>
<p>
For example, if network support is disabled, then all network-related commands will be missing from the list of commands presented by '<code>nsh> help</code>'.
You can see the specific command dependencies in the table <a href="#cmddependencies">above</a>.
</p>
<h3>4.2.1 Adding New NSH Commands</h3>
<p>
New commands can be added to the NSH very easily.
You simply need to add two things:
</p>
<ol>
<li>
<p>
The implementation of your command, and
</p>
<li>
<p>
A new entry in the NSH command table
</p>
</ol>
<p>
<b>Implementation of Your Command.</b>
For example, if you want to add a new a new command called <code>mycmd</code> to NSH, you would first implement the <code>mycmd</code> code in a function with this prototype:
</p>
<ul></pre>
int cmd_mycmd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
</pre></ul>
<p>
The <code>argc</code> and <code>argv</code> are used to pass command line arguments to the NSH command.
Command line parameters are passed in a very standard way: <code>argv[0]</code> will be the name of the command, and <code>argv[1]</code> through <code>argv[argc-1]</code> are the additional arguments provided on the NSH command line.
</p>
<p>
The first parameter, <code>vtbl</code>, is special.
This is a pointer to session-specific state information.
You don't need to know the contents of the state information, but you do need to pass this <code>vtbl</code> argument when you interact with the NSH logic.
The only use you will need to make of the <code>vtbl</code> argument will be for outputting data to the console.
You don't use <code>printf()</code> within NSH commands.
Instead you would use:
</p>
<ul><pre>
void nsh_output(FAR struct nsh_vtbl_s *vtbl, const char *fmt, …);
</pre></ul>
<p>
So if you only wanted to output "Hello, World!" on the console, then your whole command implementation might be:
</p>
<ul><pre>
int cmd_mycmd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
nsh_output(vtbl, "e;Hello, World!"e;);
return 0;
}
</pre></ul>
<p>
The prototype for the new command should be placed in <code>apps/examples/nshlib/nsh.h></code>.
</p>
<p>
<b>Adding You Command to the NSH Command Table</b>.
All of the commands support by NSH appear in a single table called:
</p>
<ul><pre>
const struct cmdmap_s g_cmdmap[]
</pre></ul>
<p>
That table can be found in the file <code>apps/examples/nshlib/nsh_parse.c</code>.
The structure <code>cmdmap_s</code> is also defined in <code>apps/nshlib/nsh_parse.c</code>:
</p>
<ul><pre>
struct cmdmap_s
{
const char *cmd; /* Name of the command */
cmd_t handler; /* Function that handles the command */
uint8_t minargs; /* Minimum number of arguments (including command) */
uint8_t maxargs; /* Maximum number of arguments (including command) */
const char *usage; /* Usage instructions for 'help' command */
};
</pre></ul>
<p>
This structure provides everything that you need to describe your command:
Its name (<code>cmd</code>), the function that handles the command (<code>cmd_mycmd()</code>), the minimum and maximum number of arguments needed by the command,
and a string describing the command line arguments.
That last string is what is printed when enter "<code>nsh> help</code>".
</p>
<p>
So, for you sample commnd, you would add the following the to the <code>g_cmdmap[]</code> table:
</p>
<ul><pre>
{ "mycmd", cmd_mycmd, 1, 1, NULL },
</pre></ul>
<p>
This entry is particularly simply because <code>mycmd</code> is so simple.
Look at the other commands in <code>g_cmdmap[]</code> for more complex examples.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="custapps"><h2>4.3 NSH "Built-In" Applications</h2></a>
</td>
</tr>
</table>
<p>
<b>Overview.</b>
In addition to these commands that are a part of NSH, external programs can also be executed as NSH commands.
These external programs are called "Built-In" Applications for historic reasons.
That terminology is somewhat confusing because the actual NSH commands as described above are truly "built-into" NSH whereas these applications are really external to NuttX.
</p>
<p>
These applications are built-into NSH in the sense that they can be executed by simply typing the name of the application at the NSH prompt.
Built-in application support is enabled with these configuration option:
</p>
<ul>
<li>
<code>CONFIG_BUILTIN</code>:
Enable NuttX support for builtin applications.
</li>
<li>
<code>CONFIG_NSH_BUILTIN_APPS</code>:
Enable NSH support for builtin applications.
</li>
</ul>
<p>
When these configuration options are set, you will also be able to see the built-in applications if you enter "nsh> help".
They will appear at the bottom of the list of NSH commands under:
</p>
<ul><pre>
Builtin Apps:
</pre></ul>
<p>
Note that no detailed help information beyond the name of the built-in application is provided.
</p>
<h3>4.3.1 Built-In Applications</h3>
<p>
<b>Overview.</b>
The underlying logic that supports the NSH built-in applications is called "Built-In Applications".
The builtin application logic can be found at <code>apps/builtin</code>.
This logic simply does the following:
</p>
<ol>
<li>
<p>
It supports registration mechanism so that builtin applications can dynamically register themselves at build time, and
</p>
<li>
<p>
Utility functions to look up, list, and execute the builtin applications.
</p>
</ol>
<p>
<b>Built-In Application Utility Functions</b>.
The utility functions exported by the builtin application logic are prototyped in <code>nuttx/include/nuttx/binfmt/builtin.h</code> and <code>apps/include/builtin.h</code>.
These utility functions include:
</p>
<ul>
<li>
<p>
<code>int builtin_isavail(FAR const char *appname);</code>
Checks for availability of application registered as <code>appname</code> during build time.
</p>
<li>
<p>
<code>const char *builtin_getname(int index);</code>
Returns a pointer to a name of built-in application pointed by the <code>index</code>.
This is the utility function that is used by NSH in order to list the available built-in applications when "<code>nsh> help</code>" is entered.
</p>
<li>
<p>
<code>int exec_builtin(FAR const char *appname, FAR const char **argv);</code>
Executes built-in builtin application registered during compile time.
This is the utility function used by NSH to execute the built-in application.
</p>
</ul>
<p>
<b>Autogenerated Header Files</b>.
Application entry points with their requirements are gathered together in two files when NuttX is first built:
</p>
<ol>
<li>
<p>
<code>apps/builtin/builtin_proto.h</code>:
Prototypes of application task entry points.
</p>
<li>
<p>
<code>apps/builtin/builtin_list.h</code>:
Application specific information and start-up requirements
</p>
</ol>
<p>
<b>Registration of Built-In Applications</b>.
The NuttX build occurs in several phases as different build targets are executed:
(1) <i>context</i> when the configuration is established,
(2) <i>depend </i>when target dependencies are generated, and
(3) <i>default</i> (<code>all</code>) when the normal compilation and link operations are performed.
Built-in application information is collected during the make <i>context</i> build phase.
</p>
<p>
An example application that can be "built-in" is be found in the <code>apps/examples/hello directory</code>.
Let's walk through this specific cause to illustrate the general way that built-in applications are created and how they register themselves so that they can be used from NSH.
</p>
<p>
<code><b>apps/examples/hello</code></b>.
The main routine for apps/examples/hello can be found in <code>apps/examples/hello/main.c</code>.
The main routine is:
</p>
<ul><pre>
int hello_main(int argc, char *argv[])
{
printf("Hello, World!!\n");
return 0;
}
</pre></ul>
<p>
This is the built in function that will be registered during the <i>context</i> build phase of the NuttX build.
That registration is performed by logic in <code>apps/examples/hello/Makefile</code>.
But the build system gets to that logic through a rather tortuous path:
</p>
<ol>
<li>
<p>
The top-level context make target is in <code>nuttx/Makefile</code>.
All build targets depend upon the <i>context</i> build target.
For the <code>apps/</code> directory, this build target will execute the <i>context</i> target in the <code>apps/Makefile</code>.
</p>
<li>
<p>
The <code>apps/Makefile</code> will, in turn, execute the <i>context</i> targets in all of the configured sub-directories.
In our case will include the <code>Makefile</code> in <code>apps/examples</code>.
</p>
<li>
<p>
And finally, the <code>apps/examples/Makefile</code> will execute the <i>context</i> target in all configured <code>example</code>sub-directores, getting us finally to <code>apps/examples/Makefile</code> which is covered below.</p>
</ol>
<p>
<b>NOTE</b>:
Since this context build phase can only be executed one time, any subsequent configuration changes that you make will, then, not be reflected in the build sequence.
That is a common area of confusion.
Before you can instantiate the new configuration, you have to first get rid of the old configuration.
The most drastic way to this is:
</p>
<ul><pre>
make distclean
</pre></ul>
<p>
But then you will have to re-configuration NuttX from scratch.
But if you only want to re-build the configuration in the <code>apps/</code> sub-directory, then there is a less labor-intensive way to do that.
The following NuttX make command will remove the configuration only from the <code>apps/</code> directory and will let you continue without re-configuring everything:
</p>
<ul><pre>
make apps_distclean
</pre></ul>
<p>
Logic for the <code>context</code> target in <code>apps/examples/hello/Makefile</code> registers the <code>hello_main()</code> application in the <code>builtin</code>'s <code>builtin_proto.h</code>and <code>builtin_list.h</code> files.
That logic that does that in <code>apps/examples/hello/Makefile</code> is abstracted below:
</p>
<ol>
<li>
<p>
First, the <code>Makefile</code> includes <code>apps/Make.defs</code>:
</p>
<ul><pre>
include $(APPDIR)/Make.defs
</pre></ul>
<p>
This defines a macro called <code>REGISTER</code> that adds data to the <i>builtin</i> header files:
</p>
<ul><pre>
define REGISTER
@echo "Register: $1"
@echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/builtin/builtin_list.h"
@echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/builtin/builtin_proto.h"
endef
</pre></ul>
<p>
When this macro runs, you will see the output in the build "<code>Register: hello</code>", that is a sure sign that the registration was successful.
</p>
<li>
<p>
The make file then defines the application name (<code>hello</code>), the task priority (default), and the stack size that will be allocated in the task runs (2K).
</p>
<ul><pre>
APPNAME = hello
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
</pre></ul>
<li>
<p>
And finally, the <code>Makefile</code> invokes the <code>REGISTER</code> macro to added the <code>hello_main()</code> builtin application.
Then, when the system build completes, the <code>hello</code> command can be executed from the NSH command line.
When the <code>hello</code> command is executed, it will start the task with entry point <code>hello_main()</code> with the default priority and with a stack size of 2K.
</p>
<ul><pre>
context:
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
</pre></ul>
</ol>
<p>
<b>Other Uses of Built-In Application.</b>
The primary purpose of builtin applications is to support command line execution of applications from NSH.
However, there is one other use of builtin applications that should be mentioned.
</p>
<ol>
<li>
<p><b><i>binfs</i></b>.
<i>binfs</i> is a tiny file system located at <code>apps/builtin/binfs.c</code>.
This provides an alternative what of visualizing installed builtin applications.
Without <i>binfs</i>, you can see the installed builtin applications using the NSH help command.
<i>binfs</i> will create a tiny pseudo-file system mounted at <code>/bin</code>.
Using <i>binfs</i>, you can see the available builtin applications by listing the contents of <code>/bin</code> directory.
This gives some superficial Unix compatibility, but does not really add any new functionality.
</p>
</li>
</ol>
<h3>4.3.2 Synchronous Built-In Applications</h3>
<p>
By default, built-in commands started from the NSH command line will run asynchronously with NSH.
If you want to force NSH to execute commands then wait for the command to execute, you can enable that feature by adding the following to the NuttX configuration file:
</p>
<ul><pre>
CONFIG_SCHED_WAITPID=y
</pre></ul>
<p>
This configuration option enables support for the standard <code>waitpid()</code> RTOS interface.
When that interface is enabled, NSH will use it to wait, sleeping until the built-in application executes to completion.
</p>
<p>
Of course, even with <code>CONFIG_SCHED_WAITPID=y</code> defined, specific applications can still be forced to run asynchronously by adding the ampersand (&) after the NSH command.
</p>
<h3>4.3.3 Application Configuration File</h3>
<p>
<b>The appconfig File</b>.
A special configuration file is used to configure which applications are to be included in the build.
The source for this file is saved at <code>configs/<board>/<configuration>/appconfig</code>.
The existence of the <code>appconfig</code> file in the board configuration directory is sufficient to enable building of applications.
</p>
<p>
The <code>appconfig</code> file is copied into the <code>apps/</code> directory as <code>.config</code> when NuttX is configured.
<code>.config</code> is included by the top-level <code>apps/Makefile</code>.
As a minimum, this configuration file must define files to add to the <code>CONFIGURED_APPS</code> list like:
</p>
<ul><pre>
CONFIGURED_APPS += examples/hello
</pre></ul>
<p>
<b>Changes in the Works</b>.
There are changes in the works that will obsolete the <code>appconfig</code> file.
These changes will implement an automated configuration system for NuttX.
One consequence of this new configuration system is that the <code>appconfig</code> file will become obsolete and will be replaced by a new mechanism for selecting applications.
This new mechanism is not yet available, but is dicussed here: <a href="http://tech.groups.yahoo.com/group/nuttx/message/1604">http://tech.groups.yahoo.com/group/nuttx/message/1604</a>.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="custinit"><h2>4.4 Customizing NSH Initialization</h2></a>
</td>
</tr>
</table>
<p>
<b>Ways to Customize NSH Initialization</b>.
There are three ways to customize the NSH start-up behavior.
Here they are presented in order of increasing difficulty:
</p>
<ol>
<li>
<p>
You can extend the initialization logic in <code>configs/stm3240g-eval/src/up_nsh.c</code>.
The logic there is called each time that NSH is started and is good place in particular for any device-related initialization.
</p>
<li>
<p>
You replace the sample code at <code>apps/examples/nsh/nsh_main.c</code> with whatever start-up logic that you want.
NSH is a library at <code>apps/nshlib</code>.
<code>apps.examplex/nsh</code> is just a tiny, example start-up function (<code>CONFIG_USER_ENTRYPOINT</code>()) that that runs immediately and illustrates how to start NSH
If you want something else to run immediately then you can write your write your own custom <code>CONFIG_USER_ENTRYPOINT</code>() function and then start other tasks from your custom <code>CONFIG_USER_ENTRYPOINT</code>().
</p>
<li>
<p>
NSH also supports a start-up script that executed when NSH first runs.
This mechanism has the advantage that the start-up script can contain any NSH commands and so can do a lot of work with very little coding.
The disadvantage is that is is considerably more complex to create the start-up script.
It is sufficiently complex that is deserves its own paragraph
</p>
</ol>
<h3>4.4.1 NuttShell Start up Scripts</h3>
<p>
First of all you should look at <a href="#startupscript">NSH Start-Up Script</a> paragraph.
Most everything you need to know can be found there.
That information will be repeated and extended here for completeness.
</p>
<p>
<b>NSH Start-Up Script</b>.
NSH supports options to provide a start up script for NSH.
The start-up script contains any command support by NSH (i.e., that you see when you enter 'nsh> help').
In general this capability is enabled with <code>CONFIG_NSH_ROMFSETC=y</code>, but has several other related configuration options as described with the <a href="#nshconfiguration">NSH-specific configuration settings</a> paragraph.
This capability also depends on:
</p>
<ul>
<li>
<p>
<code>CONFIG_DISABLE_MOUNTPOINT=n</code>.
If mount point support is disabled, then you cannot mount <i>any</i> file systems.
</p>
<li>
<p>
<code>CONFIG_NFILE_DESCRIPTORS > 4</code>.
Of course you have to have file descriptions to use any thing in the file system.
</p>
<li>
<p>
<code>CONFIG_FS_ROMFS</code> enabled.
This option enables ROMFS file system support.
</p>
</ul>
<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 start-up time:
</p>
<ul>
<li>
<p>
NSH will create a read-only RAM disk (a ROM disk), containing a tiny ROMFS filesystem containing the following:
</p>
<ul><pre>
`--init.d/
`-- rcS
</pre></ul>
<p>
Where <code>rcS</code> is the NSH start-up script.
</p>
<li>
<p>
NSH will then mount the ROMFS filesystem at <code>/etc</code>, resulting in:
</p>
<ul><pre>
|--dev/
| `-- ram0
`--etc/
`--init.d/
`-- rcS</PRE>
</pre></ul>
<li>
<p>
By default, the contents of <code>rcS</code> script are:
</p>
<ul><pre>
# Create a RAMDISK and mount it at /tmp
mkrd -m 1 -s 512 1024
mkfatfs /dev/ram1
mount -t vfat /dev/ram1 /tmp
</pre></ul>
<li>
<p>
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:
</p>
<ul><pre>
|--dev/
| |-- ram0
| `-- ram1
|--etc/
| `--init.d/
| `-- rcS
`--tmp/
</pre></ul>
</ul>
<p>
<b>Example Configurations</b>.
Here are some configurations that have <code>CONFIG_NSH_ROMFSETC=y</code> in the NuttX configuration file.
They might provide useful examples:
</p>
<ul>
<code>configs/hymini-stm32v/nsh2<br>
configs/ntosd-dm320/nsh<br>
configs/sim/nsh<br>
configs/sim/nsh2<br>
configs/sim/nx<br>
configs/sim/nx11<br>
configs/sim/touchscreen<br>
configs/vsn/nsh</code>
</ul>
<p>
In most of these cases, the configuration sets up the <i>default</i> <code>/etc/init.d/rcS</code> script.
The default script is here: <code>apps/nshlib/rcS.template</code>.
(The funny values in the template like <code>XXXMKRDMINORXXX</code> get replaced via <code>sed</code> at build time).
This default configuration creates a ramdisk and mounts it at <code>/tmp</code> as discussed above.
</p>
<p>
If that default behavior is not what you want, then you can provide your own custom <code>rcS</code> script by defining <code>CONFIG_NSH_ARCHROMFS=y</code> in the configuration file.
The only example that uses a custom /<code>etc/init.d/rcS</code> file in the NuttX source tree is this one: <code>configs/vsn/nsh</code>.
The <code>configs/vsn/nsh/defconfig</code> file also has this definition:
</p>
<ul><code>CONFIG_NSH_ARCHROMFS=y</code> -- Support an architecture specific ROMFS file.</ul>
<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:
</p>
<ol>
<li>
<p>
<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>.
</p>
<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 several things:
</p>
<ol>
<li>
<p>
The configuration settings then installed configuration.
</p>
<li>
<p>
The <code>genromfs</code> tool(available from <a href="http://romfs.sourceforge.net/">http://romfs.sourceforge.net</a>) or included within the NuttX buildroot toolchain.
There is a snapshot here: <code>misc/tools/genromfs-0.5.2.tar.gz</code>.
</p>
<li>
<p>
The <code>xxd</code> tool that is used to generate the C header files (xxd is a normal part of a complete Linux or Cygwin installation, usually as part of the <code>vi</code> package).
</p>
<li>
<p>
The file <code>apps/nshlib/rcS.template</code> (OR, if <code>CONFIG_NSH_ARCHROMFS</code> is defined <code>include/arch/board/rcs.template</code>.
</p>
</ol>
<li>
<p>
<code><b>rcS.template</b></code>.
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.
</p>
</ol>
<p>
<b><code>rcS.template</code></b>.
The default <code>rcS.template</code>, </code><code>apps/nshlib/rcS.template</code>, generates the standard, default <code>apps/nshlib/nsh_romfsimg.h</code> file.
</p>
<p>
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/<board>/include</code>will be used.
NOTE when the OS is configured, <code>include/arch/board</code> will be linked to <code>configs/<board>/include</code>.
</p>
<p>
As mention above, the only example that uses a custom <code>/etc/init.d/rcS</code> file in the NuttX source tree is this one: <code>configs/vsn/nsh</code>.
The custom script for the <code>configs/vsn</code> case is located at <code>configs/vsn/include/rcS.template</code>.
</p>
<p>
All of the startup-behavior is contained in <code>rcS.template</code>.
The role of <code>mkromfsimg.sh</code> script 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.
To do this, <code>mkromfsimg.sh</code> uses two tools that must be installed in your system:
</p>
<ol>
<li>
<p>
The <code>genromfs</code> tool that is used to generate the ROMFS file system image.</code>
</p>
<li>
<p>
The <code>xxd</code> tool that is used to create the C header file.
</p>
</ol>
<p>
You can find the generated ROMFS file system for the <code>configs/vsn</code> case here: <code>configs/vsn/include/rcS.template</code>
</p>
<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="#custoncmds">Adding NSH commands</a></li>
<li><a href="#custapps"><code>appconfig</code></a></li>
<li><a href="#custapps">Application configuration file (<code>appconfig</code>)</a></li>
<li><a href="#custapps">Autogenerated header files</a></li>
<li><a href="#cmdoverview">Background commands</a></li>
<li><a href="#cmdoverview">Background command priority</a></li>
<li><a href="#custapps"><code>binfs</code></a></li>
<li><a href="#custapps">Built-In applications</a></li>
<li><a href="#custapps">Built-In application start-up <code>main()</code></a></li>
<li><a href="#builtinvars">Built-in variables</a></li>
<li><a href="#custapps"><code>builtin_getname()</code></a></li>
<li><a href="#custapps"><code>builtin_isavail()</code></a></li>
<li><a href="#custapps"><code>builtin_list.h</code></a></li>
<li><a href="#custapps"><code>builtin_proto.h</code></a></li>
<li><a href="#cmdbase64dec"><code>base64dec</code></a></li>
<li><a href="#cmdbase64enc"><code>base64enc</code></a></li>
<li><a href="#cmdcat"><code>cat</code></a></li>
<li><a href="#cmdcd"><code>cd</code></a></li>
<li><a href="#cmdcmp"><code>cmp</code></a></li>
<li><a href="#commands">Command summaries</a></li>
<li><a href="#custoncmds">Command table</a></li>
<li><a href="#conditional">Conditional command execution</a></li>
<li><a href="#custinit"><code>CONFIG_DISABLE_MOUNTPOINT</code></a></li>
<li><a href="#custinit"><code>CONFIG_FS_ROMFS</code></a></li>
<li><a href="#custinit"><code>CONFIG_NFILE_DESCRIPTORS</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_ARCHINIT</code></a></li>
<li><a href="#custinit"><code>CONFIG_NSH_ARCHROMFS</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_BUILTIN_APPS</code></a></li>
<li><a href="#custapps"><code>CONFIG_NSH_BUILTIN_APPS</code></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_MAX_ROUNDTRIP</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="#custinit"><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="#nshconfiguration"><code>CONFIG_NSH_USBCONDEV</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_USBCONSOLE</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_UBSDEV_MINOR</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_USBDEV_TRACECLASS</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_USBDEV_TRACECONTROLLER</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_USBDEV_TRACEINIT</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_USBDEV_TRACEINTERRUPTS</code></a></li>
<li><a href="#nshconfiguration"><code>CONFIG_NSH_USBDEV_TRACETRANSFERS</code></a></li>
<li><a href="#custapps"><code>CONFIG_SCHED_WAITPID</code></a></li>
<li><a href="#custapps"><code>CONFIGURED_APPS</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="#customizingnsh">Customizing NSH</a></li>
<li><a href="#custinit">Customizing NSH initialization</a></li>
<li><a href="#cmddate"><code>date</code></a></li>
<li><a href="#cmddd"><code>dd</code></a></li>
<li><a href="#cmddf"><code>df</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="#custapps"><code>exec_builtin()</code></a></li>
<li><a href="#cmdexit"><code>exit</code></a></li>
<li><a href="#cmdfree"><code>free</code></a></li>
<li><a href="#custoncmds"><code>g_cmdmap</code></a></li>
<li><a href="#custinit"><code>genromfs</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="#cmdhexdump"><code>hexdump</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="#cmdifdown"><code>ifdown</code></a></li>
<li><a href="#cmdifup"><code>ifup</code></a></li>
<li><a href="#custonshlib">Initialization sequence</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="#cmdmd5">md5</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="#custinit"><code>mkromfsimg.sh</code></a></li>
<li><a href="#cmdmount"><code>mount</code></a></li>
<li><a href="#cmdmv"><code>mv</code></a></li>
<li><a href="#cmdnfsmount"><code>nfsmount</code></a></li>
<li><a href="#cmdoverview"><code>nice</code></a></li>
<li><a href="#custonshlib">NSH library (<code>nshlib</code>)</a></li>
<li><a href="#custonshlib"><code>nsh_archinitialize()</code></a></li>
<li><a href="#custonshlib"><code>nsh_consolemain()</code></a></li>
<li><a href="#custonshlib"><code>nsh_initialize()</code></a></li>
<li><a href="#custonshlib"><code>nsh_main()</code></a></li>
<li><a href="#custinit"><code>nsh_main.c</code></a></li>
<li><a href="#custonshlib"><code>nsh_netinit()</code></a></li>
<li><a href="#custoncmds"><code>nsh_output()</code></a></li>
<li><a href="#custonshlib"><code>nsh_romfsetc()</code></a></li>
<li><a href="#custonshlib"><code>nsh_telnetstart()</code></a></li>
<li><a href="#custonshlib"><code>nshlib</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="#custinit"><code>rcS.template</code></a></li>
<li><a href="#cmdoverview">Re-directed commands</a></li>
<li><a href="#custapps">Registration of builtin applications</a></li>
<li><a href="#cmdrm"><code>rm</code></a></li>
<li><a href="#cmdrmdir"><code>rmdir</code></a></li>
<li><a href="#custinit">ROMFS, Modifying the ROMFS image</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="#custinit">Start-up, Default behavior</a></li>
<li><a href="#startupscript">Start-up script</a>
<li><a href="#custinit">Start-up script</a></li>
<li><a href="#custapps">Synchronous built-in applications</a></li>
<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="#custonshlib"><code>up_cxxinitialize()</code></a></li>
<li><a href="#custinit"><code>up_nsh.c</code></a></li>
<li><a href="#cmdurldec"><code>urldecode</code></a></li>
<li><a href="#cmdurlencode"><code>urlencode</code></a></li>
<li><a href="#cmdusleep"><code>usleep</code></a></li>
<li><a href="#custapps"><code>waitpid()</code></a></li>
<li><a href="#cmdwget"><code>wget</code></a></li>
<li><a href="#cmdxd"><code>xd</code></a></li>
<li><a href="#custinit"><code>xxd</code></a></li>
</ul></td>
</tr></table>
</body>
</html>
|