NetBurner 3.5.6
PDF Version
Simple FTP Server (FTPD)

Simple FTP Server (FTPD) - Trivial Implementation

Overview

This is a lightweight FTP server implementation designed for NetBurner embedded systems. Unlike traditional FTP servers that rely on file systems, this trivial implementation uses callback functions to handle FTP operations, making it ideal for downloading system information and uploading configuration data without requiring persistent storage.

Note
For FTP and SFTP using the EFFS file systesms, refer to examples in the \nburn\examples\EFFS folder

Features

  • No File System Required: Operates entirely through callback functions
  • Lightweight Design: Minimal memory footprint suitable for embedded systems
  • Debug Output: Status messages and data are sent to the debug serial port
  • Fixed File Operations:
    • Download: Single file named ReadFile.txt with customizable content
    • Upload: Accepts ASCII text files named WriteFile.txt (displayed via serial port)

Technical Details

Application Configuration

  • Application Name: FTPD Trivial
  • FTP Port: 21 (standard FTP port)
  • Priority: MAIN_PRIO - 1

Supported Operations

File Download

  • Available File: ReadFile.txt
  • Content: Fixed string "This will be the contents of ReadFile.txt"
  • Customization: Content can be modified to include dynamic system information

File Upload

  • Accepted File: WriteFile.txt (ASCII text only)
  • Storage: File content is not stored in memory
  • Output: Uploaded content is displayed on the debug serial port

Directory Operations

  • Listing: Returns single file entry for ReadFile.txt
  • Permissions: Simulated as rw-rw-rw-
  • Timestamps: Fixed to "Jan 01 00:00"

Authentication

  • Method: Basic callback-based authentication
  • Default Behavior: Accepts any username/password combination
  • Customization: Authentication logic can be modified in FTPDSessionStart()

Code Structure

Main Functions

Helper Functions

  • getdirstring(): Formats directory listing entries
  • ShowFileContents(): Displays uploaded file content to serial port

Unsupported Operations

The following FTP operations return FTPD_FAIL:

  • Directory creation/deletion
  • File deletion
  • File renaming
  • File size queries
  • Subdirectory operations

Usage

Compilation and Deployment

  1. Include required NetBurner headers: ftpd.h, init.h, iosys.h, nbrtos.h
  2. Compile with NetBurner development tools
  3. Deploy to NetBurner device

Testing

  1. Connect FTP client to device IP address on port 21
  2. Use any username/password (authentication passes by default)
  3. Test operations:
    • ls or dir: Lists ReadFile.txt
    • get ReadFile.txt: Downloads the fixed content file
    • put WriteFile.txt: Uploads file (content displayed on serial port)

Serial Port Monitoring

Use a terminal application like mttty to monitor:

  • Server startup messages
  • File upload content
  • Debug information

Customization

Dynamic Content

Modify the READ_FILEDATA constant or the FTPD_SendFileToClient() function to provide dynamic system information such as:

  • Device status
  • Sensor readings
  • Configuration parameters
  • Log data

Authentication

Enhance the FTPDSessionStart() function to implement:

  • User validation against stored credentials
  • IP address filtering
  • Session logging

File Operations

Extend functionality by:

  • Supporting multiple downloadable files
  • Implementing file storage for uploads
  • Adding configuration file handling

Dependencies

  • NetBurner RTOS
  • NetBurner FTP daemon library
  • Standard C library functions

Notes

  • This implementation is designed for development and lightweight applications
  • Remove EnableSystemDiagnostics() call for production deployment
  • For file system-based FTP implementations, refer to examples in the \nburn\examples\EFFS folder
  • All FTP operations are logged to the debug serial port for monitoring and troubleshooting

Related Examples

For more advanced FTP server implementations using the EFFS file system, see the NetBurner examples in the EFFS folder which provide full file system integration and persistent storage capabilities.