Staging:CC3120 File Operations (Texas Instruments NDA restrictions applicable)

= Overview = The purpose of this sample application is to demonstrate how to exercise certain capabilities/features of 'CC3120 SimpleLinkTM Wi-Fi Network Processor' device. Details of the features that are exercised in this application are listed in subsequent sections.

Application Details
The application supports 9 commands which are divided in 3 groups as shown below: These commands are used to showcase below capabilities of the device:
 * 1) File-System (fs) - fscreate, fswrite, fsread, fsdel, fsinfo and fslist
 * 2) Console - clear, exit
 * 3) Others - help
 * 1) File System
 * 2) * Creating non-secure, secure or secure-authenticated files on sFLASH
 * 3) * Writing/reading contents to/from a file on sFLASH
 * 4) * Deleting a specific file on sFLASH
 * 5) * Getting the information of a file
 * 6) * Listing all files that exist on the sFLASH

Source files briefly explained
= Usage =
 * main.c - Initializes the device in default configuration and creates a task 'fileSystemTask'
 * file_system_common.c - Common functions that are used by all other files.
 * cmd_fs.c - Implementation to exercise all File-system (fs) commands
 * cmd_console.c - Implementation to exercise all console related command
 * str.c	- Defines all command option and message strings

Prerequisite
Note: This application is supported on other platforms as well - Check the release notes for the list of supported platforms
 * 1x CC3120BOOST
 * 1x MSP432P401R
 * 2x Micro-USB cables

General Guidelines
Note: This project is dependent on OS - Ensure 'ti_rtos_config' and 'osi_lib' are included in the workspace and built prior to compiling the application Note: Section:'Build and Execution Process' of 'CC3120 Programmers' Guide' has detailed build instructions
 * Mount CC3120BOOST on a compatible MCU LaunchPad from TI, and connect the board to a Windows-PC - Refer 'CC3120 Getting Started Guide' for detailed instructions
 * Connect a terminal-program running on Windows w/ the target - This is required for seeing the application logs. 'CC3120 Getting Started Guide' for detailed instructions for configuring the terminal-program
 * Open the application project @ '\platform\msp432p401r\example_project_ccs\file_operations' in CCS.
 * Build and run the project
 * A prompt will appear on the terminal where commands can be entered as described below:

Commands
1. help usage: help

Description: To know more about &lt;command name&gt;

Example: help fslist 2. fslist Usage: fslist [-help] [-l[h]]

Description: To list the files on sFLASH.

Options: -help	: To display help for fslist command [Optional] -l     List files with details in single column -lh    Show files with human readable sizes

Example: fslist -lh 3. fscreate Usage: fscreate [-help] -f <"file name"> [-s ] [-c ] [-p ] [-pr] [-pw] [-t] [-fs]

Description: To create a file in the sFLASH.

Options: -f     File name. -c     Max file size in bytes. -s     File security option : <1 - Non-secure> <2 - Encrypted> <3 - Authenticated & Encrypted> -fs    Create file in Fail Safe mode. -p     Token/Password to access file, if any. -t     Set if you want to send the file over term during file creation. -pw    Set if you want to allow write access to your secure file without password. -pr    Set if you want to allow users to read your secure file without password. -help  Display this help.

Example: fscreate -f "/tmp/test.txt" -c 4096 -s 1 [Creates a non-secure file] fscreate -f "/tmp/test.txt" -c 4096 -s 2 -p " " [Creates a secure file] Note: If password is not entered, the device generates a random password fscreate -f "/tmp/test.txt" -c 4096 -s 3 -p " " [Creates a secure and authenticated file] Note: If password is not entered, the device generates a random password fscreate -f "/tmp/test.txt" -c 4096 -s 2 -p " " -pr [Creates a secure file with public read enabled] Note: If password is not entered, the device generates a random password. Public read option enables user to read the file without password. 4. fsinfo Usage: fsinfo [-help] -f <"filename"> [-p ]

Description: To get information on a particular file.

Options: -f     File name. -p     Token/Password to access file, if any. -help  Display this help.

Example: fsinfo -f "/tmp/test.txt" fsinfo -f "/tmp/test.txt" -p " " Note: Password is required for secure files. 5. fswrite Usage: fswrite [-help] -f <"file name"> [-p ] [-t]

Description: To read data from console and write into the mentioned file.

Options: -f     File name -p     Token/Password to access file, if any -t     Set if you want to send the file over console (teraterm) during write. -help  Display this help.

Example: fswrite -f "/tmp/test.txt" [Write on non secure file] fswrite -f "/tmp/test.txt" -p " " [Write on a secure file] Note: The application accepts the contents from the console and write to the file 6. fsread Usage: fsread [-help] -f <"file name"> [-o ] [-l ] [-p ] [-x]

Description: To read data from mentioned file and print on console

Options: -f     File name -o     Offset (in bytes) from where to read. Default from beginning of file -l     Number of bytes to read. Default complete file -p     Token/Password to access file, if any -x     Print data on console in hex format -help  Display this help. Example: fsread -f "/tmp/test.txt" [Reads contents of a non-secure file] fsread -f "/tmp/test.txt" -p " " [Reads contents of a secure file] Note: The application reads the file and displays the content on the console 7. fsdel Usage: fsdel [-help] -f <"file name"> [-p ]

Description: To delete mentioned file from file system.

Options:

-f     File name -p     Token/Password to access file, if any -help  Display this help.

Example: fsdel -f "/tmp/test.txt" [Deletes a non-secure file] fsdel -f "/tmp/test.txt" -p " " [Deletes a secure file] 8. clear Usage: clear

Description: To clear console screen.

Example: clear 9. exit Usage: exit

Description: To exit from command prompt.

Example: exit

Working with secured and authenticated files
OpenSSL> dgst -binary -sha1 -sign "\playground.cert-good-key.pem" –out "\test.sig" "\test.txt" Above files are available @ '\examples\file_operations\CertificateStore\Playground\ Above files are available @ '\examples\file_operations\CertificateStore\Playground\ Refer to 'CC3x20 Programmer Utility' section of 'cc3120 programmers guide' for instructions on flashing. command>>:fscreate -f "/tmp/test.txt" -c 4096 -s 3 -p " " On success, a secure and authenticated file gets created command>>:fsread -f "/tmp/test.txt" -p " "
 * Create a 'test.txt' on Windows PC and add contents to it
 * Use 'OpenSSL' and sign the file with 'playground.cert-good-key.pem' available @ '\examples\file_operations\CertificateStore\Playground\pem'. OpenSSL command to sign the file is given below:
 * Open 'SimpleLink Image Creator' tool
 * In ‘User Files’ tab:
 * click on 'Add' button - Choose ‘playground.ca.der’ for 'Source File' and 'ca_in_cert_store' for 'Target File' and click on 'Done'
 * click on 'Add' button - Choose ‘playground.cert-good.der’ for 'Source File' and 'cert_good' for 'Target File' and click on 'Done'
 * In 'Flash' tab:
 * In 'Device Settings' section, uncheck 'Use default Certificate Store'
 * Choose ‘playground.certstore.150630.lst’ for ‘Certificate Store Source File’
 * Choose ‘playground.certstore.150630.sign’ for ‘Certificate Store Signature Source File’
 * In 'Service Pack' section, choose ‘service pack’
 * Click on 'Create Image' and then on 'Program Image' for creating the image and programming it on the target respectively.
 * Now run the application, and on console:
 * Ensure ‘Setup’ --> ‘Terminal’ --> Receive and Transmit for ‘New Line’ is CR
 * Enter command to create a secure and authenticated file
 * When prompted for ‘Send the user file...’, go to File --> Send File (Ensure ‘Binary’ is checked) --> Choose the *.txt file that was created at step #1
 * When prompted for ‘Please type the name of the certificate that authenticates your secure file.’, enter ‘cert_good’
 * When prompted for ‘Send the signature file for the user file in binary format.’, go to File --> Send File (Ensure ‘Binary’ is checked) --> Choose the *.sig file that was created at step #2
 * To read back the contents:

= Limitations/Known Issues = = Note = = Links =
 * Maximum file size which can transferred over the console is 32K limited by the buffer used by the application. User can modify macro 'MAX_TEXT_PAD_SIZE' defined in 'file_system_common.h' to change the buffer size.
 * Set receive new-line as AUTO or CR in terminal