Embedded TCP/IP stack  4.7.0
FNET Shell Demo Quick Start

Requirements

Tools used during this quick start:

Step by step

Follow these steps to run the FNET Shell demo application:

  • Prepare your evaluation board according to your board User Manual.
  • Use USB or RS-232 male/female DB-9 serial cable to connect your PC (through COM port) to the evaluation board.
  • Connect the evaluation board to an Ethernet network.
  • Power the board up.
  • Invoke the terminal program on the PC to which the evaluation board is connected and configure it to:
    • Bits per second: 115200.
    • Data bits: 8.
    • Parity: none.
    • Stop bits: 1.
    • Flow control: None.
  • Launch IDE.
  • Open the project:
    • Baremetal:
      fnet\fnet_demos\build\<board_name>\shell\bm\<compiler_name>\
    • FreeRTOS:
      fnet\fnet_demos\build\<board_name>\shell\freertos\<compiler_name>\
      This FreeRTOS application has absolutely the same features and behaviour as the baremetal one.
      In addition, the application:
      • runs in FreeRTOS task.
      • polls application protocol with a period.
      • has additional application parameters:
        • FAPP_CFG_FREERTOS_TASK_PRIORITY - FreeRTOS task priority.
        • FAPP_CFG_FREERTOS_TASK_STACK_SIZE - FreeRTOS task stack size.
        • FAPP_CFG_FREERTOS_TASK_POLL_PERIOD_MS - Polling period for calling the fnet_poll_service() function.
      • The application project includes FreeRTOS. Its source code is located in fnet/third_party/freertos-x.x.x/.
      • FreeRTOS FNET application configuration parameters are in the FreeRTOSConfig.h file.
  • In the IDE, choose a project target you want to compile.
  • Compile, load (or flash) the application to the board and run the project.
  • In your terminal program window you should see the FNET application Shell welcome message:
    ************************************************
     FNET Shell Application
    ************************************************
     FNET TCP/IP Stack for MK64FN1
     Version 4.0.0
     Built Oct 26 2017 at 13:14:08 by IAR
    
     Enter '?' for command list.
    ************************************************
    [FAPP] Application parameters loaded from Flash.
    SHELL>
    
  • The Shell application monitors the network interface connection status using the Link-Detection service (enabled by FNET_CFG_LINK). Whenever a network interface indicates that it has been connected, the application begins the auto-configuration process using DHCPv4. If the DHCPv4 server has not been discovered on local network, the application starts the Auto-IP service. Whenever the network interface indicates that it has been disconnected, the application disables all bound protocols on this interface.
    Note
    On connect/disconnect scripts are defined by FAPP_CFG_LINK_CONNECT_SCRIPT and FAPP_CFG_LINK_DISCONNECT_SCRIPT in fapp_user_config.h
    So if network cable is connected, in your terminal program window you should see:
    [LINK] eth0: connected => Script: dhcpc autoip -n eth0; mdns -n eth0; llmnr -n eth0;
    ************************************************
     DHCPv4 Client started.
     Interface            : eth0
    ************************************************
    Press [Ctr+C] to cancel.
    [DHCP] Discovering...
    
    ************************************************
     IPv4 parameters updated :
    ************************************************
    Ethernet Interface <default>:
     Name                 : eth0
     ScopeID              : 1
     Media State          : connected
     IPv4 Address         : 192.168.0.102 <dhcp>
     IPv6 Address         : fe80::211:22ff:fe33:4455 <autoconfigurable>
     IPv4 Subnet mask     : 255.255.255.0
     IPv4 Gateway         : 192.168.0.1
     IPv4 DNS             : 192.168.0.1
     DHCP Client          : on
     DHCP Server Address  : 192.168.0.1
     AUTOIP Service       : off
     LLMNR Server         : off
     MDNS Server          : off
    
    ************************************************
     mDNS server started.
     Interface            : eth0
     Host Name            : fnet
    ************************************************
    ************************************************
     LLMNR server started.
     Interface            : eth0
     Host Name            : fnet
    ************************************************
    SHELL>
    
  • There is an additional possibility to start any other service (http, telnet etc.) automatically during power-up by setting the FAPP_CFG_STARTUP_SCRIPT parameter to a command line string.
  • You may start the mDNS server (if not started already during start-up), which allows the name resolution for hosts on the same local link. It is natively supported by Apple OSs and named "Bonjour".
    If HTTP server is enabled, the application registers the "_http._tcp.local" service in mDNS server. So the HTTP server can be discoverable in MacOS Safari browser using Bonjour.
    SHELL> mdns
    ************************************************
     mDNS server started.
     Interface            : eth0
     Host Name            : fnet
    ************************************************
    
  • You may start LLMNR server (if not started already during start-up), which allows the name resolution for hosts on the same local link. It is natively supported by Windows OSs.
    SHELL> llmnr
    ************************************************
     LLMNR server started.
     Interface            : eth0
     Host Name            : fnet
    ************************************************
    
    So you can use the host name "fnet" instead of an IP address to find this node on the local network.
  • The Main Shell is now ready to accept user commands. Try ? command to display a list of all the commands available within the shell:
    >         ?                                    - Display this help message
    >       set [<parameter> <value>]              - Set parameter
    >       get [<parameter>]                      - Get parameters
    >      bind [-n <if name>] <IP6 address>       - Bind IPv6 Address
    >    unbind [-n <if name>] <IP6 address>       - Unbind IPv6 Address
    >      info [-n <if name>]                     - Show interface info
    >      stat [-n <if name>]                     - Show interface statistics
    >     dhcpc [-n <if name>] [release|autoip]    - Start DHCPv4 client
    >    autoip [-n <if name>] [release]           - Start Auto-IP service
    >      http [release]                          - Start HTTP server
    >       exp                                    - File Explorer submenu...
    >    telnet [release]                          - Start Telnet server
    >       dns [-n <if name>] [-s <server ip>] [4|6] <host name> - Resolve IPv4|6 address of <host name>
    >     llmnr [-n <if name>] [release]           - Start LLMNR server
    >      mdns [-n <if name>] [release]           - Start MDNS server
    >      sntp [<server name|ip>]                 - Resolve time over SNTP
    >      save                                    - Save parameters to the FLASH
    >     reset                                    - Reset the board
    >      ping [-c <count>][-i <seconds>]
                    [-p <pattern>][-s <size>]
                    [-h <hoplimit/ttl>] <ip>        - Send ICMP ECHO requests
    SHELL>
  • All computers, connected to an Ethernet network running the IPv4 protocol, need several network-specific parameters:
    • IPv4 address for the system;
    • IPv4 address of the Gateway for non-local traffic;
    • IPv4 network mask (netmask) for the system to distinguish between local or non-local traffic;
  • You are able to change the default network parameters manually:
    • By using Shell commands:
      set address <default-if IPv4 address>
      set gateway <default-if IPv4 gateway address>
      set netmask <default-if IPv4 netmask address>
      set mac <default-if Ethernet address>
      
    • By changing the default values in the fapp_user_config.h source file.
      Your local system administrator is able to assign a unique IPv4 address for the board, and also provide you with the IPv4 addresses of the gateway and the netmask.
  • You may start the DHCP IPv4 client (if not started already during start-up) to obtain the address parameters automatically from your network DHCPv4 server:
    SHELL> dhcpc
    ************************************************
     DHCPv4 Client started.
     Interface            : eth0
    ************************************************
    Press [Ctr+C] to cancel.
    [DHCP] Discovering...
    
    ************************************************
     IPv4 parameters updated :
    ************************************************
    Ethernet Interface <default>:
     Name                 : eth0
     ScopeID              : 1
     Media State          : connected
     IPv4 Address         : 192.168.0.102 <dhcp>
     IPv6 Address         : fe80::211:22ff:fe33:4455 <autoconfigurable>
     IPv4 Subnet mask     : 255.255.255.0
     IPv4 Gateway         : 192.168.0.1
     IPv4 DNS             : 192.168.0.1
     DHCP Client          : on
     DHCP Server Address  : 192.168.0.1
     AUTOIP Service       : off
     LLMNR Server         : off
     MDNS Server          : off
     
    SHELL>
    
  • You may also start (if not started during start-up) the Auto-IP service to obtain automatically the IPv4 link-local address within the 169.254/16 prefix that is valid for communication with other devices connected to the same physical (or logical) link:
    SHELL> autoip
    ************************************************
     Auto-IPv4 service started.
     Interface            : eth0
    ************************************************
    Press [Ctr+C] to cancel.
    [AUTOIP] Probing...
    [AUTOIP] Probing...
    [AUTOIP] Probing...
    
    ************************************************
     IPv4 parameters updated :
    ************************************************
    Ethernet Interface <default>:
     Name                 : eth0
     ScopeID              : 1
     Media State          : connected
     IPv4 Address         : 169.254.67.77 <autoconfigurable>
     IPv6 Address         : fe80::211:22ff:fe33:4455 <autoconfigurable>
     IPv4 Subnet mask     : 255.255.0.0
     IPv4 Gateway         : 192.168.0.1
     IPv4 DNS             : 192.168.0.1
     DHCP Client          : off
     AUTOIP Service       : on
     LLMNR Server         : on
     MDNS Server          : on
    
    SHELL>
    
    Note
    You may start Auto-IP service automatically, if no DHCPv4 server was discovered, by adding the autoip parameter to the dhcpc command. DHCP client will continue its DHCP server discovering, while Auto-IP is active. The DHCP discovery period defined by FAPP_CFG_DHCPC_CMD_RESPONSE_TIMEOUT_AUTOIP_MS.
  • You may enter the save command to save the all run-time parameters to non-volatile memory (it is located in the last erase page of the on-chip flash memory).
    SHELL> save
    Application parameters saved
    SHELL>
    
    Note
    The save command does not save the ip parameter in case it was allocated by a DHCP server to avoid IPv4 address conflict during the system startup.
  • You may get an information about all initialized network interfaces by typing the info command into your terminal program window.
    In your terminal program window you should see:
    SHELL> info
    Ethernet Interface <default>:
     Name                 : eth0
     ScopeID              : 1
     Media State          : connected
     IPv4 Address         : 192.168.0.102 <dhcp>
     IPv6 Address         : fe80::211:22ff:fe33:4455 <autoconfigurable>
     IPv4 Subnet mask     : 255.255.255.0
     IPv4 Gateway         : 192.168.0.1
     IPv4 DNS             : 192.168.0.1
     DHCP Client          : on
     DHCP Server Address  : 192.168.0.1
     AUTOIP Service       : off
     LLMNR Server         : on
     MDNS Server          : on
    
    Services:
     HTTP Server          : off
     HTTPS Server         : off
     TELNET Server        : off
    SHELL>
    
  • You should now be able to "ping" the board from one of your workstations. The ping program is a very useful diagnostic tool used to check that the board`s IP information is properly configured.
  • The ping tool can be used from the command-line environment on the host PC:
    ping <your_board_IP_adress> 
    By default the ping routine will send a test ICMP frame to the board four times and will write a summary message on the screen. If everything works as expected, you should see an output similar to this:
    C:\Temp>ping 192.168.0.22
    
    Pinging 192.168.0.22 with 32 bytes of data:
    Reply from 192.168.0.22: bytes=32 time=10ms TTL=64
    Reply from 192.168.0.22: bytes=32 time<1ms TTL=64
    Reply from 192.168.0.22: bytes=32 time<1ms TTL=64
    Reply from 192.168.0.22: bytes=32 time<1ms TTL=64
    
    Ping statistics for 192.168.0.22:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 10ms, Average = 2ms
    
    C:\Temp>ping fe80::204:9fff:fe12:4938%19
    
    Pinging fe80::204:9fff:fe12:4938%19 with 32 bytes of data:
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    
    Ping statistics for fe80::204:9fff:fe12:4938%19:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
  • The PING application can be started also from the board, by typing the command ping into your terminal program window.
    In your terminal program window you should see:
    SHELL> ping 192.168.0.1
    ************************************************
     PING
    ************************************************
     Remote IP addr       : 192.168.0.1
     Message Size         : 63
     Num. of messages     : 4
     Pattern              : 0
     Hoplimit (TTL)       : 64
    Press [Ctr+C] to cancel.
    ************************************************
    Reply from 192.168.0.1
    Reply from 192.168.0.1
    Reply from 192.168.0.1
    Reply from 192.168.0.1
    SHELL>
    
  • In the next step, you can run the HTTP Server on the board, by typing the command http into your terminal program window.
    In your terminal program window you should see:
    SHELL> http
    ************************************************
     HTTP server started.
     IPv4 Address     : 192.168.0.22
     IPv6 Address     : fe80::204:9fff:fe12:4938
    ************************************************
    SHELL>
    
  • Then run your Web browser and navigate to the server address (the address you have assigned to the system or obtained from the DHCP server):
    http:// 192.168.0.22
    
    or
    http:// [fe80::204:9fff:fe12:4938]
    
  • You should see a Web page served by the FNET HTTP server:


    fnet_quick_start_web.png
    Demo Web Page
  • Also you can run the Telnet Server on the board, by typing the command telnet into your terminal program window.
    In your terminal program window you should see:
    SHELL> telnet
    ************************************************
     Telnet server started.
     IPv4 Address     : 192.168.0.22
     IPv6 Address     : fe80::204:9fff:fe12:4938
    ************************************************
    SHELL>
    
  • Then run your Telnet client. Start PuTTYtel application and enter the Telnet server IP address (the address you have assigned to the system or obtained from the DHCP server):

    fnet_telnet_config.jpg
    PuTTYtel Configuration
  • Press [Open] to open a telnet session. In your telnet program window you should see the FNET application Shell welcome message:

    fnet_telnet_session.jpg
    Telnet session
  • If you need to get know an IP address of the domain/host name (like www.google.com or others), you may use DNS client/resolver, by typing the command dns <host_name> 4|6 into the command shell window.
    For example, if you want to get know the IPv4 address of www.google.com, enter dns www.google.com 4 in your terminal program window:
    SHELL> dns 4 www.google.com
    ************************************************
     Resolving            : www.google.com
     DNS Server           : 192.168.0.1
    Press [Ctr+C] to cancel.
    ************************************************
     Resolved address     : 172.217.19.68    TTL=2147483648
     Resolved address     : 216.239.32.10    TTL=2013724672
     Resolved address     : 216.239.34.10    TTL=2013724672
     Resolved address     : 216.239.36.10    TTL=2013724672
     Resolved address     : 216.239.38.10    TTL=2013724672
    
    For example, if you want to get know the IPv6 address of www.google.com, enter dns www.google.com 6 in your terminal program window:
    SHELL> dns 6 www.google.com
    ************************************************
     Resolving            : www.google.com
     DNS Server           : 192.168.0.1
    Press [Ctr+C] to cancel.
    ************************************************
     Resolved address     : 2a00:1450:4005:803::2004         TTL=604045312
     Resolved address     : 2001:4860:4802:32::a     TTL=2653487104
     Resolved address     : 2001:4860:4802:34::a     TTL=2653487104
     Resolved address     : 2001:4860:4802:36::a     TTL=2653487104
     Resolved address     : 2001:4860:4802:38::a     TTL=2653487104
    
    Note
    Be sure that the dns parameter is set to correct IP address of the DNS server on your network. It can be set manually by the set command or can be obtained automatically by the DHCP IPv4 client service.
  • If you need to get know the current date and time, you may use SNTP client, by typing the command sntp [<server name|ip>] into the command shell window.
    For example, you may use public pool of NTP servers addressed by "pool.ntp.org".
    SHELL> sntp pool.ntp.org
    ************************************************
     Resolving            : pool.ntp.org
     DNS Server           : 192.168.0.1
    Press [Ctr+C] to cancel.
    ************************************************
     Resolved address     : 31.31.74.35      TTL=486539264
     Resolved address     : 147.251.48.140   TTL=486539264
     Resolved address     : 212.96.160.147   TTL=486539264
     Resolved address     : 37.187.104.44    TTL=486539264
     Resolved address     : 207.171.17.42    TTL=1209337600
     Resolved address     : 185.120.22.23    TTL=348913664
     Resolved address     : 185.121.173.155  TTL=348913664
     Resolved address     : 212.25.19.23     TTL=348913664
     Resolved address     : 174.127.124.192  TTL=348913664
     Resolved address     : 85.214.25.217    TTL=348913664
     Resolved address     : 185.82.172.118   TTL=348913664
     Resolved address     : 199.249.224.53   TTL=348913664
     Resolved address     : 178.63.120.205   TTL=348913664
    ************************************************
     SNTP Resolving
     SNTP Server          : 31.31.74.35
    Press [Ctr+C] to cancel.
    ************************************************
    ************************************************
     SNTP Resolving
     SNTP Server          : 147.251.48.140
    Press [Ctr+C] to cancel.
    ************************************************
     UTC: 2018-6-19 7:48:28.134
    SHELL>
    
    Note
  • If you do not have access to public NTP servers, for testing you may use a local SNTP server provided by the http://tftpd32.jounin.net/ application.
  • The pool.ntp.org server provides time service on a volunteer basis and with no guarantee of accuracy or availability.
  • It's recommended to orange own NTP server.

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net