naflash: Flash Memory Example Application

This application shows how to use the Flash API to access and manage flash memory.

This example will work on the NET+Works NS7520 and NET+50 development boards.
It may not work on DigiConnect development boards because some flash sectors
on these boards are locked.  

Running this example on any development board will erase the bootloader,
application image, backup image (if present), and the file system.  This
means that the board will no longer boot from flash after this application 
completes.  You will have to restore the bootloader and the application image
to get the board to boot from flash again.

The "naflash" application is a single thread application that tests flash 
memory erase / write / read reliability.  The test performs the following:

1) Automatically changes the MASK bits of the chip select 0 option register 
   (CS0_OR) to allow accessing the amount of flash memory configured.
2) Executes a suite of flash memory erase, write, read and verify tests. The C 
   library rand() function is used to generate random numbers to fill the write 
   buffer, so that write data for each write test is unique.   Printf() messages
   of the test status are sent out the serial port.  These tests are described as
   follows:
   a) Write the entire flash memory with a single NAFlashWrite() call.
   b) Verify flash memory data with write buffer data and erase sectors as needed.
   c) Write the entire flash memory with multiple NAFlashWrite() calls one sector 
      at a time.
   d) Verify flash memory data with write buffer data and erase sectors as needed.
   e) Write the entire flash memory with multiple NAFlashWrite() calls with write
      byte sizes of up to 32767 bytes without crossing sectors.  Write byte sizes
      exceeding sector boundaries are adjusted such that the NAFlashWrite() call 
      writes up to the last byte of the sector.  Note that 32767 is the maximum
      number generated by the C library rand() function.
   f) Verify flash memory data with write buffer data and erase sectors as needed.
   g) Write the entire flash memory with multiple NAFlashWrite() calls with write 
      byte sizes of up to 32767 bytes crossing sectors.  This test allows writing
      various combinations of partial and full sector writes.  Note that 32767 is
      the maximum number generated by the C library call rand().
   h) Verify flash memory data with write buffer data and erase sectors as needed.

Prior to running the application, Flash memory must be hardware enabled.

FLASH size and RAM size are set in customize.lx and customize.ldr files for GHS
and GNU respectively. This application takes these values and calculate the best
test cases given the size of the RAM. This application also assumes 1 Meg of RAM
is used by the application to execute. So keep the network heap, APP_NET_HEAP_SIZE,
as low as possible (current value is set to 0x20000).  

The following files are provided with 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 library
libaddp.a			   contains the ADDP Library
libtcpip.a             contains the TCP/IP stack library
libpppintf.a		   contains the PPP Interface Library
libtx.a                contains the ThreadX kernel
libfilesys.a           contains the Native File System library
libposix.a             contains the POSIX layer library
libflash.a             contains the Flash driver API library
libssh.a			   contains the SSH Library
libtelnsvr.a           contains the Telnet Server library
libdnsclnt.a           contains the DNS Client library
libfat32.a             contains the FAT32 library

The application uses the following files located in the
netos\src\linkerScripts directory.

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

Note: Make sure the flash size defined in customize.ldr (GNU) matches the
actual flash peice on the board. 

Otherwise the program will exit after printing WARNING message on the console.

