nafileio: File IO Example Application

This application shows how to use c library file system functions to perform file I/O.
The application demostrate how to use mkdir(), open(), close(), write(), read(), fopen(), fclose(), fread(),
fwrite(), fseek() and remove().

The compile flag FLASH_TEST is defined or undefined in root.c in order
to select whether the test is run against the flash (NAND or NOR, depending on
which is configured) or RAM volume. If the board has no flash, this flag must
be undefined.

This example should work on all development boards.

Note:

1. the file IO functions are implemented as block only.

2. In function mkdir(dirname, mode) implementation, the mode is ignored since creating
directory in NETOS6's native filesystem requires group id and group access mode. 
group id and group access mode is hardcoded in the filesystem configuration and can be 
changed in platforms\your_board\startfilesystem.c.

3. In function open(filename, mode), the mode is implemented to be consistent with
fopen(filename, fmode) as the following table:
                                             r    w    a    r+    w+    a+  
      File must exist before open            *              *
      Old file truncated to zero length           *               *
      File can be read                       *              *     *     *
      File can be written                         *    *    *     *     *
      File can be wriiten only at end                  *                *

for example, 
open(filename, mode) will fail if mode = O_RDONLY. file must exist before it is readable.

4. In function fopen(filename, mode), the opened file will be binary only.
fopen(filename, "r"), fopen(filename, "rb"), fopen(filename, "rt") will open the same 
                                                   type of binary file.

5. Only the following C lib functions are implemented with NETOS filesystem module. For other
functionalities, please use the native filesystem API provided in NETOS6:

mkdir()
rename()
remove()
open()
close()
read()
write()
fopen()
fclose()
fread()
fwrite()
fseek()

6. This test assumes that flash is ENABLED (No jumper on J1). When using a debugger, such as the majic,
to successfully download, flash must be DISABLED (Jumper on J1). To do this you must do 
the following:

Begin the download process. Set a breakpoint at netosStartup. When the debugger
hits the breakpoint, remove the jumper from J1 (enable flash). Then continue
execution of your application. 

After your test is complete, you will want to replace the jumper onto J1, asssuming
you will want to download additional test applications through your debugger.

7. By default, the c library entries to the file system are NOT included
in the bsp. In this case, when you run this application, you will see
the following error message in your terminal emulator window:
"current BSP does not include file system for CLIB". In order to 
rectify this you must do the following:
    a) Update file src\bsp\platforms\ns9750_a\bsp_fs.h in the following
      manner:
        I) find the #define for constant BSP_INCLUDE_FILESYSTEM_FOR_CLIBRARY 
        II) change its definition, which by default is FALSE to TRUE
    b) When complete, rebuild the bsp
    c) When complete, rebuild and rerun your application, after insuring that the
		filesys library is linked in via the Makefile

End note

As the application executes, it sends status and error messages out \com\0 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 application.

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file
root.c            contains applicationStart() function


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.

libbsp.a           contains the BSP code
libtcpip.a         contains the Net+Works TCP/IP stack
libtx.a            contains the ThreadX kernel
libfilesys.a       contains the file system libraries
libposix.lib       contains the POSIX layer libraries
libflash.lib       contains the Flash driver API library
libsnmpd.lib       contains the SNMP daemon 
libmanapi.lib      contains the management API library
libftpclnt.lib     contains the FTP client library
libftpsvr.lib      contains the FTP server library
libemailc.lib      contains the Email client library
libtelnsvr.lib     contains the Telnet server library
libdnsclnt.lib     contains the DNS client 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


