help で準備されているコマンドの一覧を見ることができます。
nsh> help help usage: help [-v] [<cmd>] . dd ifdown mv source [ delroute ifup mw test ? df irqinfo nslookup time addroute dmesg kill pidof timedatectl alias echo losetup printf true unalias env ln ps truncate arp exec ls pwd uname basename exit mb readlink umount break expr mkdir reboot unset cat false mkfatfs resetcause uptime cd fdinfo mkfifo rm usleep cp free mkrd rmdir xd cmp help mksmartfs route dirname hexdump mh set date ifconfig mount sleep Builtin Apps: adc iptables nsh telnet calib_udelay lm75 ping telnetd cu lte_ctrl pppd timeout dumpstack mobile_watch_nx rtcwake ftpc netcat sh i2c netdb shutdown nsh>
“Builtin Apps:”
より上に列挙されているものは NuttShell のビルトインコマンドです。
help commandName で使用方法を見ることができます。
nsh> help cd cd usage: cd [<dir-path>|-|~|..] nsh> help timedatectl timedatectl usage: timedatectl [set-timezone TZ]
/dev や /proc など、Linux のようなファイルシステムがいくつか mount されています。
nsh> ls -l / /: drwxrwxrwx 0 dev/ dr-xr-xr-x 0 etc/ dr--r--r-- 0 proc/ drwxrwxrwx 0 tmp/ drwxrwxrwx 40 var/ nsh> ls -l /var/ /var: drwxrwxrwx 0 run/ drwxrwxrwx 0 ftok/ drwxrwxrwx 0 mqueue/ drwxrwxrwx 0 sem/ drwxrwxrwx 8 log/ nsh> ls -l /var/log /var/log: -rwxrwxrwx 2780 syslog nsh>
nsh> ls -l /dev /dev: crw-rw-rw- 0 DI0 crw-rw-rw- 0 DI1 crw-rw-rw- 0 DI2 crw-rw-rw- 0 DI3 crw-rw-rw- 0 DO0 crw-rw-rw- 0 DO1 crw-rw-rw- 0 LED_Power_R crw-rw-rw- 0 LED_Stat1_G crw-rw-rw- 0 LED_Stat1_R crw-rw-rw- 0 LED_Stat2_G crw-rw-rw- 0 LED_Stat2_R crw-rw-rw- 0 LED_Stat3_G crw-rw-rw- 0 LED_Stat3_R cr--r--r-- 0 adc0 crw-rw-rw- 0 console crw-rw-rw- 0 eeprom crw-rw-rw- 0 i2c1 crw-rw-rw- 0 kmsg c-w--w--w- 0 log crw-rw-rw- 0 loop brw-rw-rw- 5150605312 mmcblk0 brw-rw-rw- 629145600 mmcblk0p1 brw-rw-rw- 4520411136 mmcblk0p2 brw-rw-rw- 0 mmcblk1 crw-rw-rw- 0 null crw-rw-rw- 0 ptmx brw-rw-rw- 1024 ram0 crw-rw-rw- 0 rtc0 crw-rw-rw- 0 telnet crw-rw-rw- 0 ttyACM0 crw-rw-rw- 0 ttyACM1 crw-rw-rw- 0 ttyACM2 crw-rw-rw- 0 ttyFC0 crw-rw-rw- 0 ttyFC1 crw-rw-rw- 0 ttyS0 crw-rw-rw- 0 tun cr--r--r-- 0 urandom crw-rw-rw- 0 userleds crw-rw-rw- 0 watchdog0 crw-rw-rw- 0 zero nsh>
syslog を見ることができます。
nsh> cat /var/log/syslog [ 0.067000] [ 9] nsh_main: /var/sem created. [ 0.067000] [ 9] nsh_main: /var/mqueue created. [ 0.067000] [ 9] nsh_main: /var/ftok created. [ 0.067000] [ 9] nsh_main: /var/run created. [ 0.067000] [ 9] nsh_main: board_userled_initialize: PowerLED initialized. [ 0.067000] [ 9] nsh_main: sam_settimeout: WDT: Disabled, clear WDDIS bit on MR. [ 0.083000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Power_R. [ 0.084000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Stat1_R. [ 0.085000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Stat2_R. [ 0.086000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Stat3_R. [ 0.087000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Stat1_G. [ 0.088000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Stat2_G. [ 0.089000] [ 9] nsh_main: tca6507_pincfg: Register LED LED_Stat3_G. [ 0.090000] [ 9] nsh_main: lte_pio_initialize: LTE GPIOs initialized. [ 0.090000] [ 9] nsh_main: sam_emac0_setmac: MAC: 00:80:6d:01:23:45 [ 0.096000] [ 9] nsh_main: get_rtc_type: RTC DS324SR detected. [ 0.098000] [ 9] nsh_main: get_rtc_type: SEL Register updated to 30s. [ 1.104000] [ 9] nsh_main: register_blockdriver: /dev/mmcblk0 registered. [ 1.104000] [ 9] nsh_main: parse_block_partition: blocksize: 512, nblocks: 10059776 [ 1.104000] [ 9] nsh_main: register_blockdriver: /dev/mmcblk0p1 registered. [ 1.104000] [ 9] nsh_main: parse_block_partition: blocksize: 512, nblocks: 1228800 [ 1.105000] [ 9] nsh_main: register_blockdriver: /dev/mmcblk0p2 registered. [ 1.105000] [ 9] nsh_main: parse_block_partition: blocksize: 512, nblocks: 8828928 [ 1.106000] [ 9] nsh_main: parse_mbr_partition: cannot found MBR magic(0x55, 0xaa) [ 1.106000] [ 9] nsh_main: register_blockdriver: /dev/mmcblk1 registered. [ 1.106000] [ 9] nsh_main: parse_block_partition: /dev/mmcblk1: get geometry() failed with -19 [ 1.157000] [ 9] nsh_main: sam_ehci_initialize: g_qhpool: addr: 0x3fe00000, size: 0x00001000 [ 1.157000] [ 9] nsh_main: sam_ehci_initialize: g_qtdpool: addr: 0x3fe01000, size: 0x00000800 [ 1.157000] [ 9] nsh_main: sam_ehci_initialize: g_framelist: addr: 0x3fe02000, size: 0x00001000 [ 1.157000] [ 9] nsh_main: sam_ehci_initialize: DMA allocator: 0x3fe03000 [ 1.208000] [ 9] nsh_main: mas1xx_xio_initialize: mas1xx_xio_initialize: XIO_ID: 0x01... [ 1.208000] [ 9] nsh_main: sam_netinitialize: Configuring 00c00049 [ 1.209000] [13] mobile_watch_nx: watch_event: Monitoring started. [ 12.759000] [12] EHCI_Monitor: usbhost_connect: Register device: /dev/ttyACM0 [ 12.762000] [12] EHCI_Monitor: usbhost_connect: Register device: /dev/ttyACM1 [ 12.765000] [12] EHCI_Monitor: usbhost_connect: Register device: /dev/ttyACM2 nsh>
ifconfig
コマンドで設定/状態の確認ができます。
nsh> help ifconfig ifconfig usage: ifconfig [interface [mtu <len>]|[address_family] [[add|del] <ip-address>|dhcp]][dr|gw|gateway <dr-address>] [netmask <net-mask>|prefixlen <len>] [dns <dns-address>] [hw <hw-mac>] nsh> ifconfig eth0 Link encap:Ethernet HWaddr 00:80:6d:01:23:45 at DOWN mtu 1500 inet addr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0 RX: Received Fragment Errors 00000000 00000000 00000000 IPv4 ARP Dropped 00000000 00000000 00000000 TX: Queued Sent Errors Timeouts 00000000 00000000 00000000 00000000 Total Errors: 00000000 lo Link encap:Local Loopback at RUNNING mtu 1518 inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0 RX: Received Fragment Errors 00000000 00000000 00000000 IPv4 ARP Dropped 00000000 00000000 00000000 TX: Queued Sent Errors Timeouts 00000000 00000000 00000000 00000000 Total Errors: 00000000 IPv4 TCP UDP ICMP Received 0000 0000 0000 0000 Dropped 0000 0000 0000 0000 IPv4 VHL: 0000 Frg: 0000 Checksum 0000 0000 0000 ---- TCP ACK: 0000 SYN: 0000 RST: 0000 0000 Type 0000 ---- ---- 0000 Sent 0000 0000 0000 0000 Rexmit ---- 0000 ---- ---- nsh>
IP Address / DNS Server / Default Gateway など設定して通信をしてみます。
nsh> ifup eth0 ifup eth0...OK nsh> ifconfig eth0 172.16.1.16 netmask 255.255.255.0 dns 172.16.1.60 gw 172.16.1.60 nsh> ping -c 3 www.centurysys.jp PING 133.242.204.151 56 bytes of data 56 bytes from 133.242.204.151: icmp_seq=0 time=22.0 ms 56 bytes from 133.242.204.151: icmp_seq=1 time=22.0 ms 56 bytes from 133.242.204.151: icmp_seq=2 time=22.0 ms 3 packets transmitted, 3 received, 0% packet loss, time 3003 ms rtt min/avg/max/mdev = 22.000/22.000/22.000/0.000 ms nsh>
nsh> nslookup www.centurysys.co.jp Host: www.centurysys.co.jp Addr: 203.142.213.55 nsh>