Running TCP/IP Stack in Linux Print

With uClinux running on the LPC4357, you get the full Linux TCP/IP stack (kernel version 2.6.33). Userspace POSIX APIs are provided by the uClibc library. Key user-space networking tools and utilities are available from the multi-call busybox utility. Additional tools and packages, such as for instance the SSH dropbear server, can be built specifically for uClinux. 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 LPC4357. The device driver is linux/drivers/net/arm/stm32_eth.c configured in the kernel using the CONFIG_STM32_ETHER build time option in Device Drivers -> Network device support -> Ethernet (10 or 100Mbit):

Once you have enabled CONFIG_STM32_ETHER, go to System Type -> LPC18XX I/O interfaces and enable LPC18XX Ethernet port (CONFIG_LPC187XX_MAC). This will register a platform device for the LPC4357 Ethernet controller with the Ethernet driver:

Emcraft provides a sample Linux project called networking that demonstrates TCP/IP over Ethernet on the LPC4357. In the Emcraft Linux distribution, the project can be found at projects/networking. Here is how you run that project on the LPC4357.

The bootable Linux image ready to be installed to the LPC4357 (networking.uImage) is about 1.7 MBytes in size. Refer to Installing Linux images to Flash for information on how to install the image to Flash.

Here is a snapshot of the serial console for the networking bootstrap sequence:

Starting kernel ...

Linux version 2.6.33-arm1 (vlad version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #264 Thu May 14 14:02:21 +0400 2015
CPU: ARMv7-M Processor [410fc241] revision 1 (ARMv7M)
CPU: NO data cache, NO instruction cache
Machine: NXP LPC18xx
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
blackfin-eth: found MAC at 0x40010000, irq 5
blackfin_mii_bus: probed
found PHY id 0x7c0f1 addr 1
eth0: using MII interface
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=00:01, irq=-1)
TCP cubic registered
NET: Registered protocol family 17
ARMv7-M VFP Extension supported
IP-Config: Guessing netmask
IP-Config: Complete:
device=eth0, addr=, mask=, gw=,
host=ea-lpc4357, domain=, nis-domain=(none),
bootserver=, rootserver=, rootpath=
PHY: 00:01 - Link is Up - 100/Full
Freeing init memory: 944K
init started: BusyBox v1.17.0 (2015-04-23 14:45:46 +0400)
~ #

Let's test the TCP/IP stack on the LPC4357.

From a development host validate that the LPC4357 is visible using ping:

-bash-4.2$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=4.28 ms
64 bytes from icmp_seq=2 ttl=64 time=0.473 ms
64 bytes from icmp_seq=3 ttl=64 time=0.474 ms
--- ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2714ms
rtt min/avg/max/mdev = 0.473/1.743/4.284/1.796 ms

Ping the development host from the LPC4357:

~ # ping
PING ( 56 data bytes
64 bytes from seq=0 ttl=64 time=1.388 ms
64 bytes from seq=1 ttl=64 time=1.097 ms
64 bytes from seq=2 ttl=64 time=1.098 ms
64 bytes from seq=3 ttl=64 time=1.097 ms
--- ping statistics --
- 4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 1.097/1.170/1.388 ms
~ #

On the target, start the telnetd daemon to allow connections to the LPC4357:

~ # telnetd
~ # ps
1   root 352 S init
2   root 0   SW [kthreadd]
3   root 0   SW [ksoftirqd/0]
4   root 0   SW [events/0]
5   root 0   SW [khelper]
6   root 0   SW [async/mgr]
7   root 0   SW [sync_supers]
8   root 0   SW [bdi-default]
9   root 0   SW [kblockd/0]
10  root 0   SW [khubd]
11  root 0   SW [rpciod/0]
12  root 0   SW [kswapd0]
13  root 0   SW [nfsiod]
14  root 0   SW [mtdblockd]
20  root 367 S /bin/hush -i
23  root 332 S telnetd
24  root 348 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-4.2$ telnet
Connected to
Escape character is '^]'.

ea-lpc4357 login: root
~ # ls
bin dev etc httpd init mnt proc root sys usr var
~ # exit
Connection closed by foreign host.

Start the dropbear SSH daemon to allow secure connections to the target:

~ # dropbear
~ # ps
1  root 352 S init
2  root 0   SW [kthreadd]
3  root 0   SW [ksoftirqd/0]
4  root 0   SW [events/0]
5  root 0   SW [khelper]
6  root 0   SW [async/mgr]
7  root 0   SW [sync_supers]
8  root 0   SW [bdi-default]
9  root 0   SW [kblockd/0]
10 root 0   SW [khubd]
11 root 0   SW [rpciod/0]
12 root 0   SW [kswapd0]
13 root 0   SW [nfsiod]
14 root 0   SW [mtdblockd]
20 root 367 S /bin/hush -i
23 root 340 S telnetd
28 root 292 S dropbear
29 root 348 R ps
~ #

Connect to the target from the development host using ssh. The first connection takes several seconds to establish as the LPC4357 runs computation-extensive key calculations. Again, hit Enter on the password prompt:

-bash-4.2$ ssh root@
root@'s password:
~ # ls
bin dev etc httpd init mnt proc root sys usr var
~ # exit
Connection to closed.

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
~ # vi /etc/resolv.conf


Use ntpd to synchronize the time on the target with the time provided by a public server:

~ # date
Thu Jan 1 00:07:44 UTC 1970
~ # ntpd -p
~ # sleep 5
~ # date
Thu May 14 11:44:45 UTC 2015
~ #

Use wget to download a file from a remote server:

~ # wget
Connecting to (
README 100% |*******************************| 1962 --:--:-- ETA
~ # cat README
This is, the FTP server of the the GNU project.

Mount a directory exported by a development host over NFS:

~ # mount -o nolock,rsize=1024 /mnt
~ # ls /mnt
~ #

Start the HTTP daemon:

~ # httpd -h /httpd/html/
~ #

From a local host, open a Web browser to the LPC4357 and watch the demo web page provided by the target. The LPC4357 shows the current time and date as well as the list of the currently running processes: