Running TCP/IP Stack in Linux Print

 

With uClinux running on the i.MX RT1060, you get the full Linux TCP/IP stack (kernel version 4.5.0). Userspace POSIX APIs are provided by the uClibc library. Key user-space networking tools and utilities are available from the multi-call busybox. 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 i.MX RT1060. The device driver is linux/drivers/net/ethernet/freescale/fec.c configured in the kernel using the CONFIG_FEC build time option in Device Drivers -> Network device support -> Ethernet driver support -> Freescale devices -> FEC ethernet controller (of ColdFire and some i.MX CPUs).

For the run-time configuration of the kernel, Ethernet is enabled in rootfs.dts.IMXRT106X_NXPEVK in projects/rootfs as follows:

  &fec { phy-mode = "rmii"; phy-handle = <&ethphy0>; status = "ok"; mdio { #address-cells = <1>; #size-cells = <0>; ethphy0: ethernet-phy@0 { reg = <2>; clocks = <&rmii_clk>; clock-names = "rmii-ref"; }; }; };

This will register a platform device for the i.MX RT1060 Ethernet controller with the Ethernet driver.

The Linux project provided by Emcraft in the distribution (refer to projects/rootfs) and installed on each shipping module and kit includes the TCP/IP stack and various network related capabilities. The following snapshot shows the full Linux bootsrap sequence from power-on to the Linux shell:

  U-Boot 2017.09-imxrt-2.5.2 (Nov 22 2018 - 01:47:42 +0300) CPU: i.MX RT106x at 600MHz Model: NXP i.RT1060 EVK DRAM: 32 MiB MMC: FSL_SDHC: 0 reading uboot.env Video: 480x272x24 In: serial@40184000 Out: serial@40184000 Err: serial@40184000 Net: eth0: ethernet@402D8000 reading splash-rt1050-series_24.bmp 391736 bytes read in 109 ms (3.4 MiB/s) reading mxrt106x-evk.ini 102 bytes read in 12 ms (7.8 KiB/s) fatexec: 'setenv ipaddr 192.168.1.141' fatexec: 'setenv netmask 255.255.255.0' Hit any key to stop autoboot: 0 reading rootfs.uImage 7749634 bytes read in 1773 ms (4.2 MiB/s) ## Booting kernel from Legacy Image at 80007fc0 ... Image Name: Linux-4.5.0 Image Type: ARM Linux Multi-File Image (uncompressed) Data Size: 7749570 Bytes = 7.4 MiB Load Address: 80008000 Entry Point: 80008001 Contents: Image 0: 7739904 Bytes = 7.4 MiB Image 1: 9654 Bytes = 9.4 KiB Verifying Checksum ... OK ## Flattened Device Tree from multi component Image at 80007FC0 Booting using the fdt at 0x80769a0c Loading Multi-File Image ... OK Loading Device Tree to 81e77000, end 81e7c5b5 ... OK Starting kernel ... Booting Linux on physical CPU 0x0 Linux version 4.5.0 (ovm@ubuntu) (gcc version 4.7.4 20130508 (prerelease) (20170818-165657- build on build.emcraft by build) ) #2 Tue Oct 17 18:29:14 FET 2017 CPU: ARMv7-M [411fc271] revision 1 (ARMv7M), cr=00000000 CPU: WBA data cache, WBA instruction cache Machine model: NXP IMXRT1060 board debug: ignoring loglevel setting. On node 0 totalpages: 8192 free_area_init_node: node 0, pgdat 80769320, node_mem_map 81ec0000 Normal zone: 64 pages used for memmap Normal zone: 0 pages reserved Normal zone: 8192 pages, LIFO batch:0 pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 pcpu-alloc: [0] 0 Built 1 zonelists in Zone order, mobility grouping off. Total pages: 8128 Kernel command line: console=ttyLP0,115200 consoleblank=0 ignore_loglevel ip=192.168.1.141:192.168.1.65::255.255.255.0::eth0:off PID hash table entries: 128 (order: -3, 512 bytes) Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) Memory: 23728K/32768K available (2188K kernel code, 118K rwdata, 360K rodata, 4888K init, 95K bss, 9040K reserved, 0K cma-reserved) Virtual kernel memory layout: vector : 0x00000000 - 0x00001000 ( 4 kB) fixmap : 0xffc00000 - 0xfff00000 (3072 kB) vmalloc : 0x00000000 - 0xffffffff (4095 MB) lowmem : 0x80000000 - 0x82000000 ( 32 MB) .text : 0x80008000 - 0x8028531c (2549 kB) .init : 0x80286000 - 0x8074c000 (4888 kB) .data : 0x8074c000 - 0x80769a00 ( 119 kB) .bss : 0x80769a00 - 0x807819f8 ( 96 kB) NR_IRQS:16 nr_irqs:16 16 sched_clock: 32 bits at 75MHz, resolution 13ns, wraps every 28633115129ns clocksource: vf-pit: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 25483472618 ns Calibrating delay loop... 1196.85 BogoMIPS (lpj=5984256) pid_max: default: 4096 minimum: 301 Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) devtmpfs: initialized clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns pinctrl core: initialized pinctrl subsystem NET: Registered protocol family 16 mxs_phy 400d9000.usbphy: Invalid GPIO: -2 mxs_phy 400da000.usbphy: Invalid GPIO: -2 imxrt105x-pinctrl 401f8000.iomuxc: initialized IMX pinctrl driver SCSI subsystem initialized usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb pps_core: LinuxPPS API ver. 1 registered pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti < This e-mail address is being protected from spambots. You need JavaScript enabled to view it > PTP clock support registered clocksource: Switched to clocksource vf-pit NET: Registered protocol family 2 TCP established hash table entries: 1024 (order: 0, 4096 bytes) TCP bind hash table entries: 1024 (order: 0, 4096 bytes) TCP: Hash tables configured (established 1024 bind 1024) UDP hash table entries: 256 (order: 0, 4096 bytes) UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) 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. futex hash table entries: 16 (order: -5, 192 bytes) fuse init (API version 7.24) Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) io scheduler noop registered io scheduler cfq registered (default) mxsfb 402b8000.lcdif: initialized 40184000.serial: ttyLP0 at MMIO 0x40184000 (irq = 44, base_baud = 375000) is a FSL_LPUART console [ttyLP0] enabled Serial: VF610 driver libphy: fec_enet_mii_bus: probed ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ehci-mxc: Freescale On-Chip EHCI Host driver usbcore: registered new interface driver uas usbcore: registered new interface driver usb-storage ci_hdrc ci_hdrc.1: EHCI Host Controller ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1 ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected g_serial gadget: Gadget Serial v2.4 g_serial gadget: g_serial ready i2c /dev entries driver ft5x0x_ts 0-0038: resolution: 479x271 ft5x0x_ts 0-0038: Operating withoug nReset pin (-2) input: ft5x0x_ts as /devices/virtual/input/input0 [FTS] Firmware version = 0x12 [FTS] report rate is 90Hz. [FTS] touch threshold is 92. i2c i2c-0: LPI2C adapter registered sdhci: Secure Digital Host Controller Interface driver sdhci: Copyright(c) Pierre Ossman sdhci-pltfm: SDHCI platform and OF driver helper sdhci-esdhc-imx 402c0000.esdhc: could not get default state /soc/aips-bus@40000000/esdhc@402c0000: voltage-ranges unspecified mmc0: SDHCI controller on 402c0000.esdhc [402c0000.esdhc] using DMA usbcore: registered new interface driver usbhid usbhid: USB HID core driver NET: Registered protocol family 10 sit: IPv6 over IPv4 tunneling driver input: gpio-keys as /devices/platform/gpio-keys/input/input1 Freeing unused kernel memory: 4888K (80286000 - 8074c000) init started: BusyBox v1.24.2 (2017-10-17 17:57:51 FET) mmc0: host does not support reading read-only switch, assuming write-enable mmc0: new high speed SD card at address b368 mmcblk0: mmc0:b368 00000 1.86 GiB mmcblk0: p1 FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. random: dropbear urandom read with 5 bits of entropy available / # Micrel KSZ8081 or KSZ8091 402d8000.etherne:02: attached PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=402d8000.etherne:02, irq=-1) IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready fec 402d8000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready / #

Let's test the TCP/IP stack on the i.MX RT1060.

From the development host validate that the i.MX RT1060 is visible using ping:

-bash-3.2$ ping 192.168.1.141 -c 10
PING 192.168.1.141 (192.168.1.141) 56(84) bytes of data.
64 bytes from 192.168.1.141: icmp_seq=1 ttl=64 time=0.697 ms
64 bytes from 192.168.1.141: icmp_seq=2 ttl=64 time=0.637 ms
64 bytes from 192.168.1.141: icmp_seq=3 ttl=64 time=0.645 ms
64 bytes from 192.168.1.141: icmp_seq=4 ttl=64 time=0.587 ms
64 bytes from 192.168.1.141: icmp_seq=5 ttl=64 time=0.575 ms
64 bytes from 192.168.1.141: icmp_seq=6 ttl=64 time=0.646 ms
64 bytes from 192.168.1.141: icmp_seq=7 ttl=64 time=0.683 ms
64 bytes from 192.168.1.141: icmp_seq=8 ttl=64 time=0.706 ms
64 bytes from 192.168.1.141: icmp_seq=9 ttl=64 time=0.619 ms
64 bytes from 192.168.1.141: icmp_seq=10 ttl=64 time=0.665 ms

--- 192.168.1.141 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9018ms
rtt min/avg/max/mdev = 0.575/0.646/0.706/0.041 ms

ping the development host from the i.MX RT1060:

/ # ping 192.168.1.65 -c 10
PING 192.168.1.65 (192.168.1.65): 56 data bytes
64 bytes from 192.168.1.65: seq=0 ttl=128 time=1.168 ms
64 bytes from 192.168.1.65: seq=1 ttl=128 time=0.989 ms
64 bytes from 192.168.1.65: seq=2 ttl=128 time=0.858 ms
64 bytes from 192.168.1.65: seq=3 ttl=128 time=0.934 ms
64 bytes from 192.168.1.65: seq=4 ttl=128 time=0.941 ms
64 bytes from 192.168.1.65: seq=5 ttl=128 time=0.961 ms
64 bytes from 192.168.1.65: seq=6 ttl=128 time=0.783 ms
64 bytes from 192.168.1.65: seq=7 ttl=128 time=0.740 ms
64 bytes from 192.168.1.65: seq=8 ttl=128 time=7.953 ms
64 bytes from 192.168.1.65: seq=9 ttl=128 time=2.382 ms

--- 192.168.1.65 ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 0.740/1.770/7.953 ms

On the target, start the telnetd daemon to allow connections to the i.MX RT1060:

 / # ps | grep telnetd 96 root 388 S {busybox} telnetd 101 root 388 S grep telnetd / #

Connect to the target from the development host using telnet. The target is configured to accept the 123 password for root

-bash-3.2$ telnet 192.168.1.141 Trying 192.168.1.141... Connected to 192.168.1.141. Escape character is '^]'. (none) login: root Password: / # ls bin dev httpd lib proc sbin tmp var crankdemo etc init mnt root sys usr / # exit Connection closed by foreign host. -bash-3.2$

The dropbear SSH daemon is running automatically if the U-Boot environment variable ssh is set to yes. Verify that dropbear is really running, and allow secure connections to the target:

/ # ps | grep dropbear
74 root 404 S dropbear
105 root 388 S grep dropbear
/ #

Connect to the target from the development host using ssh. The first connection takes several seconds to establish as the i.MX RT1060 runs computation-extensive key calculations. Again, enter 123 on the password prompt:

-bash-3.2$ ssh This e-mail address is being protected from spambots. You need JavaScript enabled to view it
The authenticity of host '192.168.1.141 (192.168.1.141)' can't be established.
DSA key fingerprint is d2:d1:5f:dd:84:65:1d:2f:ee:69:0c:85:d0:22:0c:87.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.141' (DSA) to the list of known hosts.
This e-mail address is being protected from spambots. You need JavaScript enabled to view it 's password:
/ # ls
bin dev httpd lib proc sbin tmp var
crankdemo etc init mnt root sys usr
/ # exit
Connection to 192.168.1.141 closed.
-bash-3.2$

On the target, enable access to the Internet by configuring a default gateway. Note also that the system makes use of the public name server provided by Google:

/ # route add default gw 192.168.1.1 / # cat /etc/resolv.conf # This configuration makes use of the Google public DNS server. # If you would like to use something else, replace with the IP # of your DNS server 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:09:27 UTC 1970
/ # ntpd -p 0.fedora.pool.ntp.org
/ # sleep 5
/ # date
Tue Oct 17 15:40:13 UTC 2017

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% |*******************************| 2509 0:00:00 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 192.168.1.99:/srv/nfs /mnt/nfs / # ls /mnt/nfs/ SimpleClass linux-dp test / # cp /bin/busybox /mnt/nfs / # cp /mnt/nfs/busybox /tmp / # md5sum /bin/busybox /tmp/busybox bb39cf3470150200a35c41bd6f78ef92 /bin/busybox bb39cf3470150200a35c41bd6f78ef92 /tmp/busybox

Start the HTTP daemon:

/ # httpd -h /httpd/html/

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