FNET - TCP/IP Stack

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FNET - TCP/IP Stack

56,900 Views
butok
NXP Employee
NXP Employee

FNET TCP/IP stack: Version 0.5.0 released. 
 

FNET Home page: http://fnet.sourceforge.net/

    Please, submit your feature requests and feedbacks here:

    http://sourceforge.net/tracker/?group_id=253892&atid=1126921 

    Please, submit your bug reports here:

    http://sourceforge.net/tracker/?group_id=253892&atid=1126920

 

FNET brief information:
The FNET is a free, open source software project (under GNU GPLv3) for building embedded communication software using the Freescale processors.

 

The stack provides following protocols and services:
  * Supported platforms:
     - Reindeer - MCF5282 (M5282EVB).
     - Kirin2 - MCF52235 (M2235EVB).
     - Kirin3 - MCF52259 (M2259EVB).
     - Lasko - MCF51CN128 (TWR-MCF51CN).
     - Other Freescale platforms to be supported soon.
  * Available as:
     - Stand-alone version. No underlying RTOS is required, although it can be used with it.
  * Supported Compilers:
     - Freescale CodeWarrior for ColdFire Version 7.1.
     - Freescale CodeWarrior for Microcontrollers Version 6.2.
  * BSD-style Socket layer API
  * Protocols:
     - User Datagram Protocol (UDP).
     - Transmission Control Protocol (TCP).
     - Internet Protocol (IPv4).
     - Internet Control Message Protocol (ICMP).
     - Address Resolution Protocol (ARP).
  * Network Interfaces:
     - Ethernet interface.
     - Loopback interface.
  * Services:
     - HTTP/0.9 server. Both SSI and CGI are supported.
     - DHCP client.
     - TFTP client.
     - Static File System.
     - CFM Flash driver.
  * Tools:
     - GUI File System Generation Tool.
  * Applications:
     - TFTP Bootloader.
     - Shell Application.
  * Doxygen User Documentation.

 

 Changes in 0.5.0 (since last public version):
 - Added TFTP client.
 - Added Coldfire Flash Module (CFM) driver.
 - Added FNET TFTP Bootloader.
 - Fixed DHCP client.
 - Updated Shell Demo application. Application parameters are saved in the flash.
 - Improved Shell library. Added blocking-command and multi-word parameter features.
 - A lot of other changes and fixes.

 

Best regards,

Andrey Butok

Labels (1)
Tags (2)
225 Replies

2,068 Views
bobsawyer
Contributor I

I have just downloaded FNET.  It came up and ran instantly on the 52235 Eval board - good job!

 

I now want to run this on a 52235 based board that I designed.  The serial ports are tied up by the application, so I would like to start Telnet out of reset.  There appears to be an option in fapp_user_config.h:

 

#if 1 /* To run HTTP and Telnet server on startup set to 1. */
    #define FAPP_CFG_STARTUP            (1)
    #define FAPP_CFG_STARTUP_SCRIPT     "http; telnet"
#endif

I tried setting this, but Telnet doesn't seem to start up.

 

Can you provide any help with this?

 

Thanks!

 

 

0 Kudos
Reply

2,068 Views
butok
NXP Employee
NXP Employee

Hi Bobsawyer,

 

Please rename  old name FAPP_CFG_STARTUP  to new FAPP_CFG_STARTUP_SCRIPT_ENABLED in the config. file:

 

#if 1 /* To run HTTP and Telnet server on startup set to 1. */
    #define FAPP_CFG_STARTUP_SCRIPT_ENABLED            (1)
    #define FAPP_CFG_STARTUP_SCRIPT     "http; telnet"
#endif

 

BTW: Thanks, that you have noticed it, it will be corrected in the next version (even it is commented).

 

After that, on startup you should see:

 

Parameters loaded from Flash.

 

************************************************

 FNET Shell Application

************************************************

 FNET TCP/IP Stack for MCF52235

 Version 1.1.1

 Built Aug 15 2011 at 09:17:12 by CW

 Copyright 2005-2011 by Freescale Semiconductor

 GNU LGPLv3

************************************************

 Interface        : eth0

 IP address       : 192.168.0.22 (set manually)

 Subnet mask      : 255.255.255.0

 Gateway          : 10.171.88.254

 DNS              : 192.168.1.5

 MAC address      : 00:04:9F:09:17:08

 Link status      : unconnected

 TX Packets       : 2

 RX Packets       : 0

 Free Heap        : 15096

 HTTP server      : disabled

 DHCP client      : disabled

 TELNET server    : disabled

 

 Enter 'help' for command list.

************************************************

 

Startup script: http; telnet

************************************************

  HTTP server started.

  Use: http://192.168.0.22

************************************************

************************************************

  Telnet server started.

  Use: telnet 192.168.0.22

************************************************

SHELL>

 

Thank you,

Andrey Butok

0 Kudos
Reply

2,068 Views
BobS
Contributor III

Thanks so much for the help!  It is working now.

 

I'm having a bit of trouble trying to add a new socket for Modbus IP.  I have looked at Telnet, and HTTP, but can't seem to make the socket I am adding work correctly.  Is there an example of adding a simple socket somewhere?

 

I hacked up a copy of the telnet files and have the Modbus socket start up after reset.  I can see the remote device trying to connect, but have no luck trying to retreive the data packet.  I am just looking to add a socket to allow my board to be a Modbus slave device. 

 

Any help with this would be appreciated.

 

Thanks!

0 Kudos
Reply

2,068 Views
butok
NXP Employee
NXP Employee

Hi Bob,

 

I do not have examples of Modbus IP. But as examples how to use sockets you can looks at the code that comes with FNET:

 

TCP server:

HTTP server, Telnet server, TCP RX Benchmark

TCP client:

TFTP client, TCP TX Benchmark

UDP server:

TFTP server, UDP RX Benchmark

UDP client:

DHCP client, DNS client, UDP TX Benchmark

 

I guess that as the simplest examples you can use the Benchmark application in (fapp_bench.c/h).

 

BTW:

I suggest putting FNET technical specific questions to sourceforge FNET-dedicated forum here:

http://sourceforge.net/projects/fnet/forums/forum/920346

It can be useful for other FNET user and they can found it without digging inside this 7-page thread, which is used mainly for general announcement.

 

Thank you,

Andrey Butok

0 Kudos
Reply

2,068 Views
BobS
Contributor III

Got it!  The benchmark code helped me out.  Thanks!

 

I have a simple modbus slave up and running.

 

I don't know the code very well yet, but I have a question.  I am using the stack on our company network for production test equipment.  We use fixed IP addresses, so I went into fnet_user_config.h and set the DHCP option to zero.  When I do this, I get a compile error from the fapp_dns.c file:

 

* DESCRIPTION: Start DNS client/resolver.
************************************************************************/
void fapp_dns_cmd( fnet_shell_desc_t desc, int argc, char ** argv )
{
   
    struct fnet_dns_params dns_params;
    fnet_netif_desc_t netif = fapp_default_netif;
    char ip_str[16];
   
    FNET_COMP_UNUSED_ARG(argc);
   
    /* Set DNS client/resolver parameters.*/
    fnet_memset(&dns_params, 0, sizeof(struct fnet_dhcp_params));
                                                                                    ^^^^^^^^^^^^^^^^^^^^^

 

The compiler can't find "fnet_dhcp_params".  Should this be "fnet_dns_params" ?

 

I will use the sourceforge forum in the future.

 

I appreciate your help!

0 Kudos
Reply

2,068 Views
butok
NXP Employee
NXP Employee

Hi Bob,

 

1)

There are two configuration files,

fnet_user_config.h – FNET stack configuration file and fapp_user_config.h – user/demo-application configuration file.

Be sure that DHCP feature was disabled in both files (the DHCP client and the DHCP shell-command using it).

#define FNET_CFG_DHCP               (0)      // fnet_user_config.h

#define FAPP_CFG_DHCP_CMD               (0) // fapp_user_config.h

 

2)

fapp_dns.c:

fnet_memset(&dns_params, 0, sizeof(struct fnet_dhcp_params));

replace with

fnet_memset(&dns_params, 0, sizeof(struct fnet_dns_params));

This is copy-paste mistake. Thank you very much.

So now it should be compliable.

P.S. I guess I should do new minor release to apply all collected minor fixes :smileywink:

 

Thank you,

Andrey Butok

0 Kudos
Reply

2,068 Views
TomE
Specialist II

Andrey, I've sent some possible bugs in FNET to your Mailbox in case you haven't read it.


I ran gcc over some of the code and here's one example of something it complained about that your other compilers haven't spotted:

 

fnet_eth.c: In function ‘fnet_str_to_mac’:fnet_eth.c:137: warning: array subscript is above array bounds    typedef unsigned char fnet_mac_addr_t[6];
   
    int fnet_str_to_mac( char *str_mac, fnet_mac_addr_t addr )
    {
        unsigned long octet[6];        ...        for (i = 0; i <= 6; i++)            addr[i] = (unsigned char)octet[i];

 

That's reading from one beyond the end of octet[] to one beyond the end of addr[].

 

Tom

 

0 Kudos
Reply

2,068 Views
butok
NXP Employee
NXP Employee

Hi Tom,

 

You are right. Thank you.

Unfortunately I do not have/use clever GCC :smileywink:

 

Please replace

for (i = 0; i <= 6; i++)

by

for (i = 0; i < 6; i++)

 

It will be applied to the nearest version of FNET.

  

BTW:

I did not receive any e-mail from you. Please resend them to Andrey.Butok@freescale.com

 

Thank you very much,

Andrey Butok

0 Kudos
Reply

2,064 Views
butok
NXP Employee
NXP Employee

 FNET version 0.8.0 released (http://fnet.sourceforge.net):
- HTTP Server:
     - Added support of the HTTP/1.0 response.
     - Added support of the Basic Access Authentication according to RFC2617.
     - Added support of the HTTP POST method.
     - Added the "cookie" parameter to the POST, SSI and CGI callback functions, which can be used to associate custom information with a connection instance.
- Added the HTTP POST and Access Authentication demos to the Shell demo application.
- Added fnet_snprintf() function. The save version of fnet_sprintf() that does not suffer from buffer overrun.
- Updated GUI File System generation tool:
     - Added additional generation parameters (image name and #if condition).
     - Fixed issue occurred during saving/loading of project files for images that have directories.
- Eliminated using of the CodeWarrior #pragma overload.
- Used
http://www.installjammer.com tool for creation of the FNET Installer and Uninstaller.
- Other minor changes/fixes.

 

Best regards,

Andrey Butok

0 Kudos
Reply

2,064 Views
satinderKhera
Contributor I

Dear Andrey,

I am facing a problem that whenever I am connecting my board to the LAN my processor is getting reset due to watchdog time-out. I have initialized my watchdog with a time out of around 3.3secs. Without connecting my board to LAN everything is working very fine (no processor crash is observed for 3 days), however as soon as I connect it to the network it crashes very frequently. I have disabled all the Ethernet activities from my ground loop, it means that only my FNET stack is initialized during power up and no application is running in the ground loop.

I am unable to find any problem can you suggest some of the areas in stack which I should look or something that I need to take care.

It is certain that processor crash is occurring only due to watchdog time out. Is there any ISR which may take long enough time to cause the watchdog timeout?

 

Regards,

Satinder

0 Kudos
Reply

2,064 Views
butok
NXP Employee
NXP Employee

Hi Satinder,

 

>>Is there any ISR which may take long enough time to cause the watchdog timeout?

FNET uses only two ISRs: one for Ethernet and one for Timer. But it should take micro seconds to handle it. 

For example it can stuck by wrong PHY initialization (in case you have own non-standard EVB), but in this case you do not have any Ethernet traffic.

No real ideas what can take seconds. Please write me back if you find the real reason. 

 

Thanks,

Andrey

 

0 Kudos
Reply

2,064 Views
satinderKhera
Contributor I

Dear Andrey,

 

I could find only one ISR i.e. asm void fnet_isr(void); can tell me which one is the other ISR and which one of these is for timer and which is for Ethernet?

 

Regards,

Satinder

0 Kudos
Reply

2,064 Views
butok
NXP Employee
NXP Employee

The ISR handlers (called by general fnet_isr()) are split into two parts (“bottom-half” and “top-half”) :

Eth:     fnet_eth_isr_rx_handler_top()

            fnet_eth_isr_rx_handler_bottom()

Timer: fnet_timer_handler_top()

             fnet_timer_handler_bottom()

0 Kudos
Reply

2,064 Views
butok
NXP Employee
NXP Employee

FNET version 0.9.0 released (http://fnet.sourceforge.net):
- Added support of the IAR Embedded Workbench for ColdFire Version 1.22.
- Added support of the IAR compiler to the demo applications for the M52259EVB board.
- Added the FNET_CFG_COMP_compiler_type set of user-configuration options that define a currently used compiler.
- Added GPL linking exception to the FNET license (based on
http://en.wikipedia.org/wiki/GPL_linking_exception), to allow static linking to proprietary applications.
- Fixed several issues in the Telnet server, which caused stuck situations.
- Fixed assembler version of the checksum calculation.
- Added the compiler directory where are placed compiler-specific files.
- All inline assembler functions were rewritten to separate ASM files, to make it more portable.
- All standard_abi assembler functions were rewritten to follow register_abi.
- Increased general throughput performance, based on benchmark results.
- Fixed CFM driver initialization.
- Fixed MSS issue, it was set to the lowest value for all cases.
- Added the FNET_CFG_SOCKET_TCP_MSS user-configuration option that defines the default value of the TCP_MSS socket option. By default the selection of the MSS is automatic and is based on the MTU of the outgoing interface. It is done to assist in avoiding of IP fragmentation at the endpoints of the TCP connection.
- Added the FNET_CFG_SHELL_HELP_FORMAT user-configuration option that defines the format of the command-shell help message, that is used by the fnet_shell_help() function.
- Added the FNET_CFG_TELNET_SHELL_ECHO user-configuration option that defines the Echo in the Telnet shell.
- Updated structure of the application parameters, used by the FNET demo applications.
- Updated the FNET ROM file-system image structure and the "FNET File System Generation Tool", to make the file-system image file more portable between different compilers.
- The "fnet.h" header file gives full access to the whole FNET user-API, including the services API.
- Other minor changes/fixes.

Special thanks to Jon Elliot and Obi Okafor for contribution.

 

Best regards,

Andrey Butok

0 Kudos
Reply

2,064 Views
satinderKhera
Contributor I

Dear Mr. Butok,

 

 I am writting an application using FNET stack and my hardware is acting as a server for this application. Whenever a client tries to connect to this application through the socket, I need to check certain things and want to send error codes to client if the connection is not allowed. Can you please suggest how can I send these error codes to client.

Though some errors are already being checked in

 

SOCKET accept( SOCKET s, struct sockaddr *addr, int *addrlen )

But I need to check some more exceptions based on my application.

Do I need to use send( ) and recv( ) functions for this or I can simply set the errors using  fnet_error_set(error); please suggest what is required.

 

Regards,

Satinder Singh

0 Kudos
Reply

2,064 Views
butok
NXP Employee
NXP Employee

Hi Satinder Singh

 

The simplest solution is just to close() connection on the server side.
After that any calling of send() or recv() on client side should return error.

If you need to send different types of errors and others (for example string error description) you should implement own protocol.

 

>> or I can simply set the errors using  fnet_error_set(error)
Its just only set/reset global error code (and nothing more). It does not have any influence on the socket communication.

 

Best regards,

Andrey Butok

0 Kudos
Reply

2,064 Views
satinderKhera
Contributor I

Dear Andrey,

 

Thanks for replying, right now I am doing the same thing, that is I am sipmly closing the connection. I just wanted to know that whether this is acceptable as it will show the establishment of connetion and then the graceful closing of the connection.

 

Thaniks,

Satinder Singh

0 Kudos
Reply

2,064 Views
satinderKhera
Contributor I

Dear Andrey,

 One more thing that I would like to know is that form where in the stack I can change the KEEPALIVE timeout?

Regards,

0 Kudos
Reply

2,064 Views
TomE
Specialist II

> KEEPALIVE


TCP Keepalives have always been contentious. If you think that Keepalives can solve a problem you have, then there's usually a better solution to that problem. That's one reason why the default Keepalive time is TWO HOURS. That's not a mistake. That's a deliberate message from the designers that you should be doing this some other way.

I suggest you read through:

Keepalive - Wikipedia, the free encyclopedia

That refers to:

RFC 1122 - Requirements for Internet Hosts - Communication Layers

I recommend the "DISCUSSION:" section there.

I note you already asked:

> Can you please suggest how can I send these error codes to client.

That's not a function of TCP. It provides a single data stream for you to send your data through. If you want to send both data and come form of "control information", then you have to encode that WITHIN the data stream, by using escale codes or your own packet-based formatting. There's also the complicated approach used by FTP which opens two separate TCP connections - one for the control messages and one for the data, but that causes other complications.

Tom

0 Kudos
Reply

2,064 Views
butok
NXP Employee
NXP Employee

Hi Satinder Singh,

 

There are several options that control keep-alive probes.

 

- SO_KEEPALIVE:

http://fnet.sourceforge.net/manual/group__fnet__socket_ga989481a2cee0291e70f9076a091eddf1.html#gga98...

 

- TCP_KEEPIDLE , TCP_KEEPINTVL, TCP_KEEPCNT :

http://fnet.sourceforge.net/manual/group__fnet__socket_ga19bc4a3a913399993d98a180df3bc447.html#ga19b...

 

The source code example you can find in the fnet_telnet.c:

/* Enable keepalive_option option. */

        (setsockopt (telnet_if->socket_listen, SOL_SOCKET, SO_KEEPALIVE, (char *)&keepalive_option, sizeof(keepalive_option)) == SOCKET_ERROR) ||

        /* Keepalive probe retransmit limit. */

        (setsockopt (telnet_if->socket_listen, IPPROTO_TCP, TCP_KEEPCNT, (char *)&keepcnt_option, sizeof(keepcnt_option)) == SOCKET_ERROR) ||

        /* Keepalive retransmit interval.*/

        (setsockopt (telnet_if->socket_listen, IPPROTO_TCP, TCP_KEEPINTVL, (char *)&keepintvl_option, sizeof(keepintvl_option)) == SOCKET_ERROR) ||

        /* Time between keepalive probes.*/

        (setsockopt (telnet_if->socket_listen, IPPROTO_TCP, TCP_KEEPIDLE, (char *)&keepidle_option, sizeof(keepidle_option)) == SOCKET_ERROR)

 

Best regards,

Andrey Butok

0 Kudos
Reply

2,064 Views
mjbcswitzerland
Specialist V

Hi Satinder

 

I can't help with FNET but there is a complete, fully documented and proven MODBUS serial/TCP module for the M522XX available at  http://www.utasker.com/modbus.html

 

Regards

 

Mark

 

0 Kudos
Reply