With Linux running on the Vybrid, you get the full Linux TCP/IP stack (kernel version 3.0.15). Userspace POSIX APIs are provided by the glibc library. Key user-space networking tools and utilities are available from the multi-call busybox utility and other Linux user-space tools. Additional tools and packages, such as for instance the OpenSSH server, can be added to the root filesystem at build time from the ELDK distribution. All in all, you have the powerful Linux TCP/IP stack at your disposal.
There is a full-functioning Ethernet device driver available in the kernel tree for the Vybrid. The device driver is linux/drivers/net/fec.c configured in the kernel using the CONFIG_FEC build time option in Device Drivers -> Network device support -> Ethernet (10 or 100Mbit):
Emcraft provides a sample Linux project called networking that demonstrates TCP/IP over Ethernet on the Vybrid SOM. In the Emcraft Linux distribution, the project can be found at projects/networking. Here is how you run that project on the Vybrid SOM.
The bootable Linux image ready to be installed to the Vybrid SOM (networking.uImage) is about 3.2 MBytes in size. It easily fits into the on-module Flash of the Vybrid SOM with plenty of room for custom enhancements. Refer to Installing Linux Images to Flash for information on how to install the image to the Vybrid SOM.
When booted to the Vybrid target, kernel performance is fast (331 BogoMIPS) and boot time to the shell is about 2.5 seconds from power-on / reset. In other words, in 2.5 seconds from power-on you have your unit running shell with the TCP/IP stack and Ethernet interface fully configured and connected to the network:
U-Boot 2011.12-vf6-1.14.0 (Apr 28 2015 - 20:54:55)
CPU: Freescale VyBrid 600 family rev1.3 at 498 MHz
Board: VF6-SOM Rev 3.a, www.emcraft.com
DDR controller is initialized
DRAM: 512 MiB
NAND: 1024 MiB
MMC: FSL_SDHC: 0
...
Linux version 3.0.15-1.14.0 (dk@ocean.emcraft.com) (gcc version 4.7.2 (GCC) ) #1659 Wed May 13 19:41:09 MSD 2015
CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c53c7d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: Emcraft Vybrid SOM Board
...
Calibrating delay loop... 331.77 BogoMIPS (lpj=1658880)
...
NET: Registered protocol family 2
IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
TCP established hash table entries: 16384 (order: 5, 131072 bytes)
TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 16384 bind 16384)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
...
FEC Ethernet Driver
fec_enet_mii_bus: probed
...
Freeing init memory: 3416K
init started: BusyBox v1.17.0 (2015-05-13 18:21:58 MSD)
eth0: Freescale FEC PHY driver [Micrel KS8081] (mii_bus:phy_addr=1:01, irq=-1)
... ~ #
Let's test the TCP/IP stack on the Vybrid.
From a development host validate that the Vybrid is visible using ping:
-bash-3.2$ ping 172.17.44.46
PING 172.17.44.46 (172.17.44.46) 56(84) bytes of data.
64 bytes from 172.17.44.46: icmp_seq=1 ttl=64 time=1.04 ms
64 bytes from 172.17.44.46: icmp_seq=2 ttl=64 time=0.262 ms
64 bytes from 172.17.44.46: icmp_seq=3 ttl=64 time=0.270 ms
64 bytes from 172.17.44.46: icmp_seq=4 ttl=64 time=0.257 ms
^C
--- 172.17.44.46 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3388ms
rtt min/avg/max/mdev = 0.257/0.458/1.046/0.340 ms
-bash-3.2$
Ping the development host from the Vybrid:
~ # ping 172.17.0.1
PING 172.17.0.1 (172.17.0.1): 56 data bytes
64 bytes from 172.17.0.1: seq=0 ttl=64 time=0.745 ms
64 bytes from 172.17.0.1: seq=1 ttl=64 time=0.384 ms
64 bytes from 172.17.0.1: seq=2 ttl=64 time=0.360 ms
64 bytes from 172.17.0.1: seq=3 ttl=64 time=0.357 ms
64 bytes from 172.17.0.1: seq=4 ttl=64 time=0.361 ms
^C
--- 172.17.0.1 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.357/0.441/0.745 ms
~ #
On the target, start the telnetd daemon to allow connections to the Vybrid:
~ # telnetd
~ # ps
PID USER VSZ STAT COMMAND
PID USER VSZ STAT COMMAND
1 root 2172 S init
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
4 root 0 SW [kworker/0:0]
5 root 0 SW [kworker/u:0]
6 root 0 SW [rcu_kthread]
7 root 0 SW [khelper]
8 root 0 SW [usb_wakeup:0]
9 root 0 SW [usb_wakeup:1]
10 root 0 SW [sync_supers]
11 root 0 SW [bdi-default]
12 root 0 SW< [kblockd]
13 root 0 SW [khubd]
14 root 0 SW [rpciod]
15 root 0 SW [kworker/0:1]
16 root 0 SW [kswapd0]
17 root 0 SWN [ksmd]
18 root 0 SW [nfsiod]
19 root 0 SW [crypto]
26 root 0 SW [mtdblock0]
27 root 0 SW [mtdblock1]
28 root 0 SW [mtdblock2]
29 root 0 SW< [mvf-qspi.0]
30 root 0 SW [kworker/u:1]
31 root 0 SW [mtdblock3]
32 root 0 SW [mtdblock4]
33 root 0 SW [mtdblock5]
62 root 2352 S /bin/hush -i
64 root 0 SW [kworker/0:2
67 root 2172 S telnetd
68 root 2352 R ps
~ #
Connect to the target from the development host using telnet. The target is configured to accept an empty password for root so just hit Enter when asked for password:
-bash-3.2$ telnet 172.17.44.46
Trying 172.17.44.46...
Connected to 172.17.44.46.
Escape character is '^]'.
(none) login: root
Password:
~ # ls
app cmsis_example.bin httpd mnt root start-mqx.sh var
bin dev init mqxboot sample.ko sys
cmsis-demo etc lib proc sbin usr
~ # exit
Connection closed by foreign host.
-bash-3.2$
On the target, configure a default gateway and a name resolver. Note how the sample configuration below makes use of the public name server provided by Google. Note also use of vi to edit target files on the target:
~ # route add default gw 172.17.0.1
~ # vi /etc/resolv.conf
nameserver 8.8.8.8
~
Use ntpd to synchronize the time on the target with the time provided by a public server:
~ # date
Thu Jan 1 00:52:09 UTC 1970
~ # ntpd -p 0.fedora.pool.ntp.org
~ # sleep 5
~ # date
Fri May 15 15:59:39 UTC 2015
~ #
Use wget to download a file from a remote server:
~ # wget ftp://ftp.gnu.org/README
Connecting to ftp.gnu.org (208.118.235.20:21)
README 100% |*******************************| 1962 --:--:-- ETA
~ # cat README
This is ftp.gnu.org, the FTP server of the the GNU project.
...
Mount a directory exported by a development host over NFS:
~ # mount -o nolock,rsize=1024 172.17.0.1:/home/vlad /mnt
~ # ls /mnt
...
dot.forward update1.0.0.sh
~ #
Start the HTTP daemon:
~ # httpd -h /httpd/html/
~ #
From a local host, open a Web browser to the Vybrid and watch the demo web page provided by the target. The Vybrid shows the current time and date as well as the list of the currently running processes:
Note: Support for the second Ethernet interface is not available using the Release 1.14.0 kernel baseline. Apply this patch to the kernel source tree if you require support for the second Ethernet.
The patch needs to be applied as follows:
[psl@ocean linux-vf6-1.14.0]$ cd linux
[psl@ocean linux]$ patch -p1 < linux-vf6-som-2eth.patch
patching file drivers/net/fec.c
[psl@ocean linux]$
Installing the stock 1.14.0 images to these modules should be fine.