![]() |
Synergy Software Package User's Manual
|
The File Transfer Protocol (FTP) is a protocol designed for file transfers. FTP utilizes reliable Transmission Control Protocol (TCP) services to perform its file transfer function. The actual FTP file transfer is performed on a dedicated FTP connection.
Unsupported Features
Passive transfer mode has not been tested for NetX in this version of SSP.
The NetX FTP Server defines APIs for creating, deleting, starting and stopping service. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
NetX/NetX Duo FTP Server Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| nx_ftp_server_create | nx_ftp_server_create(&my_server, "My Server Name", &ip_0, &ram_disk, stack_ptr, stack_size, &pool_0, my_login, my_logout);Create FTP Server with IPv4 support only. |
| **nxd_ftp_server_create | nxd_ftp_server_create(&my_server, "My Server Name", &ip_0, &ram_disk, stack_ptr, stack_size, &pool_0, my_duo_login, my_duo_logout);Create FTP Server with IPv4 and IPv6 support. |
| nx_ftp_server_delete | nx_ftp_server_delete(&my_server);Delete FTP Server. |
| nx_ftp_server_start | nx_ftp_server_start(&my_server);Start FTP Server. |
| nx_ftp_server_stop | nx_ftp_server_stop(&my_server);Stop FTP Server. |
**This API is only available in NetX Duo FTP Client. For definitions of of NetX Duo specific data types, see the NetX Duo User Guide for the Renesas Synergy™ Platform.
Status Return Values
| Name | Description |
|---|---|
| NX_SUCCESS | Successful FTP server function. |
| NX_PTR_ERROR | Invalid FTP pointer. |
| NX_CALLER_ERROR | Invalid caller of this service. |
Because FTP Client and Server operations are so closely linked, the following descriptions cover key elements of both Client and Server operations.
FTP Requirements
The NetX FTP package requires NetX or NetX Duo for proper operation. The host application must create an IP instance for running NetX services and periodic tasks. If running the FTP host application over an IPv6 network, IPv6, and ICMPv6 must be enabled on the IP task. TCP must be also enabled for either IPv6 or IPv4 networks. The IPv6 host application must set its linklocal and global IPv6 address using the IPv6 API and/or DHCPv6.
The FTP Server and Client are also designed to work with the FileX embedded file system. If FileX is not available, the host developer can implement or substitute their own file system along the guidelines suggested in filex_stub.h by defining each of the services listed in that file. This is discussed in later sections of this guide.
The FTP Client portion of the NetX FTP package has no further requirements.
The FTP Server portion of the NetX FTP package has several additional requirements. It requires complete access to TCP well-known port 21 for handling all Client FTP command requests and well-known port 20 for handling all Client FTP data transfers.
FTP File Names
FTP file names should be in the format of the target file system, usually FileX. They should be NULL terminated ASCII strings, with full path information if necessary. There is no specified limit for the size of FTP file names in the NetX FTP implementation. The packet pool payload size should be able to accommodate the maximum path and/or file name.
FTP Client Commands
The FTP has a simple mechanism for opening connections and performing file and directory operations. There is a set of standard FTP commands that are issued by the Client after a connection has been successfully established on the TCP well-known port 21. The following table shows some of the basic FTP commands. Note that the only difference when FTP runs over IPv6 is that the PORT command is replaced with the EPRT command:
FTP Server Commands
| FTP Command | Meaning |
|---|---|
| CWD path | Change working directory |
| DELE filename | Delete specified file name |
| EPRT ip_address, port | Provide IPv6 address and Client data port |
| LIST directory | Get directory listing |
| MKD directory | Make new directory |
| NLST directory | Get directory listing |
| NOOP | No operation, returns success |
| PASS password | Provide password for login |
| PORT ip_address,port | Provide IP address and Client data port |
| PWD path | Pickup current directory path |
| QUIT | Terminate Client connection |
| RETR filename | Read specified file |
| RMD directory | Delete specified directory |
| RNFR oldfilename | Specify file to rename |
| RNTO newfilename | Rename file to supplied file name |
| STOR filename | Write specified file |
| TYPE I | Select binary file image |
| USER username | Provide username for login |
These ASCII commands are used internally by the NetX FTP Client software to perform FTP operations with the FTP Server.
FTP Server Responses
Once the FTP Server processes the Client request, it returns a 3-digit coded response in ASCII followed by optional ASCII text. The numeric response is used by the FTP Client software to determine whether the operation succeeded or failed. The following list shows various FTP Server responses to Client requests:
First Numeric Field
| First Numeric Field | Meaning |
|---|---|
| 1xx | Positive preliminary status – another reply coming. |
| 2xx | Positive completion status. |
| 3xx | Positive preliminary status – another command must be sent. |
| 4xx | Temporary error condition. |
| 5xx | Error condition. |
Second Numeric Field
| Second Numeric Field | Meaning |
|---|---|
| x0x | Syntax error in command. |
| x1x | Informational message. |
| x2x | Connection related. |
| x3x | Authentication related. |
| x4x | Unspecified. |
| x5x | File system related. |
For example, a Client request to disconnect a FTP connection with the QUIT command will typically be responded with a 221 code from the Server – if the disconnect is successful.
FTP Communication
The FTP Server utilizes the well-known TCP port 21 to field Client requests. FTP Clients may use any available TCP port. The general sequence of FTP events are as follows. As mentioned previous, the only difference with FTP running over IPv6 is the PORT command is replaced with the EPRT command:
FTP Read File Requests:
FTP Write Requests:
FTP Authentication
Whenever a FTP connection takes place, the Client must provide the Server with a username and password. Some FTP sites allow what is called Anonymous FTP, which allows FTP access without a specific username and password. For this type of connection, anonymous should be supplied for username and the password should be a complete e-mail address.
You are responsible for supplying NetX FTP with login and logout authentication routines. These are supplied during the nxd_ftp_server_create and nx_ftp_server_create services and called from the password processing. The difference between the two is the nxd_ftp_server_create input function pointers to login and logout authenticate functions expect the NetX Duo address type NXD_ADDRESS. This data type holds both IPv4 or IPv6 address formats, making this function the duo service supporting both IPv4 and IPv6 networks. The nx_ftp_server_create input function pointers to login and logout authenticate functions expect ULONG IP address type. This function is limited to IPv4 networks. You are encouraged to use the duo service whenever possible.
If the login function returns NX_SUCCESS, the connection is authenticated and FTP operations are allowed. Otherwise, if the login function returns something other than NX_SUCCESS, the connection attempt is rejected.
FTP Multi-Thread Support
RFCs
FTP Constraints
The FTP standard has many options regarding the representation of file data. NetX FTP does not implement switch options like ls – al. The NetX FTP Server and the NetX Duo FTP Server expect to receive requests and their arguments in a single packet rather than consecutive packets.
Like UNIX implementations, NetX FTP assumes the following file format constraints:
This section describes how to include either or both the NetX and NetX Duo FTP Server module in an application using the SSP configurator.
To add the NetX/NetX Duo FTP Server module to an application, simply add it to a thread using the stacks selection sequence given in the following table.
NetX/NetX Duo FTP Server Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_dns0 NetX FTPServer | Threads | New Stack> X-Ware> NetX> Protocols> NetX FTPServer |
| g_dns0 NetX Duo FTPServer | Threads | New Stack> X-Ware> NetX Duo> Protocols> NetX Duo FTP Server |
When the NetX and/or NetX Duo FTP Server module is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
In the stack above, the NetX Network Driver (or NetX Duo Network Driver in a NetX Duo stack) has not been populated yet. There are multiple possible selections for the Network Driver; they are not all provided so as not to needlessly complicate the figure and the following configuration tables. The available options depend on the MCU target, but some typical options include:
Additionally, in the stack above, the FileX stack has also not been populated yet. There are multiple possible selections for the FileX module; they are not all provided so as not to needlessly complicate the figure and the following configuration tables. The available options depend on the MCU target, but some typical options include:
The NetX/NetX Duo FTP Server module must be configured by the user for the desired operation. The SSP configuration window automatically identifies (by highlighting the block in red) any required configuration selections, such as interrupts or operating modes, which must be configured for lower-level modules for successful operation. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the NetX/NetX Duo FTP Server Module
| ISDE Property | Value | Description |
|---|---|---|
| Internal Thread Priority | 16 | Internal thread priority selection. |
| Internal thread time slicing interval (ticks) | 2 | Internal thread time slicing interval selection. |
| Maximum clients to serve simultaneously | 4 | Maximum number of clients allowed. |
| Control window size (bytes) | 400 | Control window size selection. |
| Data window size (bytes) | 2048 | Data window size selection. |
| Duration internal services will suspend for (seconds) | 1 | Duration internal services will suspend for selection. |
| Maxixum username length (bytes) | 20 | Maximum username length selection. |
| Maximum password length (bytes) | 20 | Maximum password length selection. |
| Duration allowed with no activity (seconds) | 240 | Duration allowed with no activity. |
| Socket retransmit timeout (seconds) | 2 | Duration for initial timeout. |
| Maximum queued transmit packets | 20 | Maximum queued transmit selection. |
| Number of socket retransmissions | 10 | Maximum retries per selection. |
| Binary left shift as multiplier for retry duration | 1 | Binary left shift as multiplier for retry duration selection. |
| Name | g_ftp_server0 | Module name. |
| Internal thread stack size (bytes) | 4096 | Internal thread stack size stacks selection. |
| Name of Login Function | ftp_login | Name of login function selection. |
| Name of Logout Function | ftp_logout | Name of logout function selection. |
| Name of generated initialization function | ftp_server_init0 | Name of generated initialization function selection. |
| Auto Initialization | Enable, Disable Default: Enable | Auto initialization selection. |
In some cases, settings other than the defaults for lower-level modules can be desirable. For example, it might be useful to select different MAC Addresses. The configurable properties for the lower-level stack modules are provided in the following sections for completeness and as a reference.
Only a small number of settings must be modified from the default for the IP layer and lower-level drivers as indicated via the red text in the thread stack block. Notice that some of the configuration properties must be set to a certain value for proper framework operation and are locked to prevent user modification. The following table identifies all the settings within the properties section for the module:
Configuration Settings for the NetX/NetX Duo IP Instance
| ISDE Property | Value | Description |
|---|---|---|
| Name | g_ip0 | Module name. |
| IPv4 Address (use commas for separation) | 192,168,0,2 | IPv4 Address selection. |
| Subnet Mask (use commas for separation) | 255,255,255,0 | Subnet Mask selection. |
| Default Gateway Address (use commas for separation) | 0,0,0,0 | Default gateway address selection. |
| **IPv6 Global Address (use commas for separation) | 0x2001, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1 | IPv6 global address selection. |
| **IPv6 Link Local Address (use commas for separation, All zeros means use MAC address) | 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 | IPv6 link local address selection. |
| IP Helper Thread Stack Size (bytes) | 2048 | IP Helper Thread Stack Size (bytes) selection. |
| IP Helper Thread Priority | 3 | IP Helper Thread Priority selection. |
| ARP | Enable | ARP selection. |
| ARP Cache Size in Bytes | 512 | ARP Cache Size in Bytes selection. |
| Reverse ARP | Enable, Disable Default: Disable | Reverse ARP selection. |
| TCP | Enable, Disable Default: Enable | TCP selection. |
| UDP | Enable, Disable Default: Enable | UDP selection. |
| ICMP | Enable, Disable Default: Enable | ICMP selection. |
| IGMP | Enable, Disable Default: Enable | IGMP selection. |
| IP fragmentation | Enable, Disable Default: Disable | IP fragmentation selection. |
| Name of generated initialization function | ip_init0 | Name of generated initialization function selection. |
| Auto Initialization | Enable, Disable Default: Enable | Auto initialization function. |
| Link status change callback | NULL | Link status change callback selection. |
** Indicates properties that are only available in NetX Duo.
Configuration Settings for the NetX/NetX Duo FTP Common Instance
| ISDE Property | Value | Description |
|---|---|---|
| FileX support | Enabled, Disabled Default: Enabled | FileX support selection. |
| Control Type of Service | Normal, Minimum delay, Maximum data, Maximum reliability, Minimum cost Default: Normal | Control type of service selection. |
| Data Type of Service | Normal, Minimum delay, Maximum data, Maximum reliability, Minimum cost Default: Normal | Data type of service selection. |
| Fragmentation option | Don't fragment, Fragment okay Default: Don't fragment | Fragment option selection. |
| Time to live | 128 | Time to live selection. |
| Duration between client inactivity check (seconds) | 60 | Duration between client inactivity check selection. |
Configuration Settings for the NetX/NetX Duo Common Instance
| ISDE Property | Value | Description |
|---|---|---|
| Name of generated initialization function | nx_common_init0 | Name of generated initialization function selection. |
| Auto Initialization | Enable, Disable Default: Enable | Auto initialization selection. |
Configuration Settings for the NetX/NetX Duo Packet Pool Instance
| ISDE Property | Value | Description |
|---|---|---|
| Name | g_packet_pool0 | Module name. |
| Packet Size in Bytes | 640 | Packet size selection. |
| Number of Packets in Pool | 16 | Number of packets in pool selection. |
| Name of generated initialization function | packet_pool_init0 | Name of generated initialization function selection. |
| Auto Initialization | Enable, Disable Default: Enable | Auto initialization selection. |
The ETHERC peripheral module uses the PCLKA as its clock source. The PCLKA frequency is set using the SSP configurator Clock tab prior to a build or by using the CGC interface at run-time.
The ETHERC peripheral module uses pins on the MCU device to communicate to external devices. I/O pins must be selected and configured by the external device as required. The following table illustrates the method for selecting the pins within the SSP configuration window and the subsequent table illustrates an example selection for the I2C pins.
Pin Selection for the ETHERC Module
| Resource | ISDE Tab | Pin Selection Sequence |
|---|---|---|
| ETHERC | Pins | Select Peripherals> Connectivity:ETHERC> ETHERC1.RMII |
Pin Configuration Settings for the ETHERC1
| Property | Value | Description |
|---|---|---|
| Operation Mode | Disabled, Custom, RMII Default: Disabled | Select RMII as the Operation Mode for ETHERC1. |
| Pin Group Selection | Mixed, _A only Default: _A only | Pin group selection. |
| REF50CK | P701 | REF50CK pin. |
| TXD0 | P700 | TXD0 pin. |
| TXD1 | P406 | TXD1 pin. |
| TXD_EN | P405 | TXD_EN pin. |
| RXD0 | P702 | RXD0 pin. |
| RXD1 | P703 | RXD1 pin. |
| RX_ER | P704 | RX_ER pin. |
| CRS_DV | P705 | CRS_DV pin. |
| MDC | P403 | MDC pin. |
| MDIO | P404 | MDIO pin. |
The steps in using the NetX/NetX Duo FTP Server module in a typical application are:
1. Create the FTP Server using the nx_ftp_server_create (or the nxd_ftp_server_create API for NetX Duo systems).
2. Start the FTP Server using the nx_ftp_server_start API.
3. Create the FTP Client using nx_ftp_client_create API.
4. Connect to the FTP Server using the nx_ftp_client_connect API.
5. Open a file using the nx_ftp_client_open API.
6. Read from a file using the nx_ftp_client_read API.
7. Close a file using the nx_ftp_client_close API.
The following figure illustrates common steps in a typical operational flow diagram: