2016-06-15 05:01:59 +08:00
|
|
|
Title: Zephyr File System Demo
|
|
|
|
|
|
|
|
Description:
|
|
|
|
|
|
|
|
Demonstrates basic file and dir operations using the Zephyr file system.
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Building and Running Project:
|
|
|
|
|
2016-08-01 07:46:54 +08:00
|
|
|
The demo will run on Arduino 101 and will use the on-board SPI flash.
|
2016-06-15 05:01:59 +08:00
|
|
|
|
2016-08-01 07:46:54 +08:00
|
|
|
make BOARD=arduino_101
|
2016-06-15 05:01:59 +08:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Troubleshooting:
|
|
|
|
|
|
|
|
Problems caused by out-dated project information can be addressed by
|
|
|
|
issuing one of the following commands then rebuilding the project:
|
|
|
|
|
|
|
|
make clean # discard results of previous builds
|
|
|
|
# but keep existing configuration info
|
|
|
|
or
|
|
|
|
make pristine # discard results of previous builds
|
|
|
|
# and restore pre-defined configuration info
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Sample Output:
|
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
***** BOOTING ZEPHYR OS v1.6.99 - BUILD: Feb 8 2017 07:33:07 *****
|
|
|
|
Running test suite fat_fs_basic_test
|
|
|
|
tc_start() - test_fat_file
|
2016-06-15 05:01:59 +08:00
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
Open tests:
|
2016-06-15 05:01:59 +08:00
|
|
|
Creating new file testfile.txt
|
|
|
|
Opened file testfile.txt
|
2017-02-08 15:14:51 +08:00
|
|
|
|
|
|
|
Write tests:
|
2016-06-15 05:01:59 +08:00
|
|
|
Data written:"hello world!"
|
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
Data successfully written!
|
|
|
|
|
|
|
|
Sync tests:
|
|
|
|
|
|
|
|
Read tests:
|
2016-06-15 05:01:59 +08:00
|
|
|
Data read:"hello world!"
|
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
Data read matches data written
|
2016-09-02 15:46:23 +08:00
|
|
|
|
|
|
|
Truncate tests:
|
2017-02-08 15:14:51 +08:00
|
|
|
|
2016-09-02 15:46:23 +08:00
|
|
|
Testing shrink to 0 size
|
|
|
|
Testing write after truncating
|
2017-02-08 15:14:51 +08:00
|
|
|
|
|
|
|
Write tests:
|
2016-09-02 15:46:23 +08:00
|
|
|
Data written:"hello world!"
|
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
Data successfully written!
|
2016-09-02 15:46:23 +08:00
|
|
|
Original size of file = 12
|
2017-02-08 15:14:51 +08:00
|
|
|
|
|
|
|
Testing shrinking
|
2016-09-02 15:46:23 +08:00
|
|
|
File size after shrinking by 5 bytes = 7
|
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
Testing expanding
|
2016-09-02 15:46:23 +08:00
|
|
|
File size after expanding by 10 bytes = 17
|
|
|
|
Testing for zeroes in expanded region
|
2017-02-08 15:14:51 +08:00
|
|
|
|
|
|
|
Close tests:
|
2016-06-15 05:01:59 +08:00
|
|
|
Closed file testfile.txt
|
2017-02-08 15:14:51 +08:00
|
|
|
|
|
|
|
Delete tests:
|
2016-06-15 05:01:59 +08:00
|
|
|
File (testfile.txt) deleted successfully!
|
2017-02-08 15:14:51 +08:00
|
|
|
===================================================================
|
|
|
|
PASS - test_fat_file.
|
|
|
|
tc_start() - test_fat_dir
|
|
|
|
|
|
|
|
mkdir tests:
|
|
|
|
Creating new dir testdir
|
|
|
|
|
|
|
|
Write tests:
|
|
|
|
Data written:"hello world!"
|
2016-06-15 05:01:59 +08:00
|
|
|
|
|
|
|
Data successfully written!
|
2017-02-08 15:14:51 +08:00
|
|
|
Created dir testdir!
|
2016-06-15 05:01:59 +08:00
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
lsdir tests:
|
2016-06-15 05:01:59 +08:00
|
|
|
|
|
|
|
Listing dir /:
|
2017-02-08 15:14:51 +08:00
|
|
|
[DIR ] FATFILE
|
|
|
|
[FILE] TEST.C (size = 10)
|
|
|
|
[DIR ] TESTDIR
|
|
|
|
[DIR ] 1
|
2016-06-15 05:01:59 +08:00
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
lsdir tests:
|
|
|
|
|
|
|
|
Listing dir testdir:
|
|
|
|
[FILE] TESTFILE.TXT (size = 12)
|
|
|
|
|
|
|
|
rmdir tests:
|
|
|
|
|
|
|
|
Removing testdir/TESTFILE.TXT
|
|
|
|
Removed dir testdir!
|
|
|
|
|
|
|
|
lsdir tests:
|
|
|
|
|
|
|
|
Listing dir /:
|
|
|
|
[DIR ] FATFILE
|
|
|
|
[FILE] TEST.C (size = 10)
|
|
|
|
[DIR ] 1
|
2016-06-15 05:01:59 +08:00
|
|
|
|
2017-02-08 15:14:51 +08:00
|
|
|
===================================================================
|
|
|
|
PASS - test_fat_dir.
|
|
|
|
tc_start() - test_fat_fs
|
2016-06-15 05:01:59 +08:00
|
|
|
|
2016-09-02 15:46:23 +08:00
|
|
|
Optimal transfer block size = 512
|
2017-02-08 15:14:51 +08:00
|
|
|
Allocation unit size = 1024
|
|
|
|
Volume size in f_frsize units = 2028
|
|
|
|
Free space in f_frsize units = 2025
|
|
|
|
===================================================================
|
|
|
|
PASS - test_fat_fs.
|
|
|
|
===================================================================
|
|
|
|
PROJECT EXECUTION SUCCESSFUL
|