nafilesys: File System Example Application


This application shows how to use native file system API functions to perform file
I/O.  The BSP_INCLUDE_FILESYSTEM_FOR_CLIBRARY #define constant in bsp_fs.h must be set
to TRUE to have the BSP to mount the default RAM and Flash volumes.
If you turn on this flag you must also be sure to link the filesys library
in your application makefile by adding the line 

$(NETOS_LIBPATH)/libfilesys.a

to the APP_LIBS list.

The application creates a RAM volume user thread and a Flash volume user thread.
Both user threads use the file system API as a synchronous (or blocking) interface
even though the file system API is asynchronous (or non-blocking).  The user thread
that accesses the Flash volume uses NAFSio_request_cb_status() in a polling loop to
periodically check the completion or termination status of the I/O request.  When
the I/O request is completed or terminated, the polling loop is exited.  The user
thread that accesses the RAM volume uses wrapper functions around the file system's
file I/O API functions to implement a higher level synchronous (or blocking) file
I/O interface.  This interface uses the I/O request control block's callback feature
to notify that the I/O request has been completed or terminated.

The following #define constants enable or disable the respective user threads:

#define ENABLE_RAM0
#define ENABLE_FLASH0

The #define constants in root.c can be changed to vary file system test
configurations.  For the purposes of this example, only the following #defines
should be changed to configure the number of test passes for each user thread.

#define RAM0_TEST_PASSES 
#define FLASH0_TEST_PASSES

Note: Digi Development boards are populated with Flash memory of various sizes.
For boards with smaller size flash parts, the Flash volume mounted by the BSP can
use a minimum of 2 flash sectors. such that the flash sectors can be worn out very
quickly.  To prevent excessive wear of the Flash volume sectors, do not set
FLASH0_TEST_PASSES to a large number.

The user threads use the random number generator to decide the following:

1) The directory level depth 
2) The directory path 
3) The type of file I/O to perform. 


As the application executes, it sends status and error messages of the file I/O
operations out the serial port used for standard I/O to the console.


One GNU make file is provided.  Build the target 'image' to
generate an image that can be debugged with gdb, and the file 
image.bin which can be written to flash if the bootloader is used.
Build the target 'rom.bin' to create the file rom.bin which 
can be written to ROM if the bootloader is not used.

The following files are provided in this template.

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file
root.c            contains the applicationStart() function that starts
                  a series of tests

In addition, the following files in the BSP directory are built
as part of this application.

reset.s         contains the reset code
appconf_api.c   contains code used to read settings in appconf.h


The application build file links in the following libraries.  Most of these
libraries are not actually used by the application.  They are included because
this application is meant to be used as a template for other applications that
may use these libraries.  The linker only includes the code in libraries that 
is actually used.  For example, none of the code in the email client library 
will be linked into this application since it does not call any email APIs.

The library names are listed below.

libbsp.a           contains the BSP library
libtcpip.a         contains the TCP/IP stack library
libtx.a            contains the ThreadX kernel library
libfilesys.a       contains the file system library
libposix.lib       contains the POSIX layer library
libflash.lib       contains the Flash driver library
libtelnsvr.lib     contains the Telnet server library
libdnsclnt.lib     contains the DNS client library
libpppintf.a	   contains the PPP Interface Library
libssh.a		   contains the SSH Library
libaddp.a		   contains the ADDP Library


The application uses the following files located in the
netos\src\linkerScripts directory.  These files are generated
when the BSP is built.

bootldr.dat     bootloader configuration file used to generate the
                file image.bin.  It controls the information placed
                in the bootloader header of the image.

image.ldr       GNU linker script used to build an image that can
                be debugged and used with the bootloader.
                
customize.ldr   Customizable GNU linker script
