Filesystem demo 1.0
File system test

Code size:6 Kb Author:yrt
Source files included:yes Version:1.0
Use circleOS:yes (4.6) Creation date:2013-07-26 15:52:21
Hardware modification:no Modification date:2013-07-26 16:33:17
Based on the STM32 Primer:All
Downloads:2355 Views:32866
Average ratings:0/5 (0 rates)

Download: (18 KB)



Filesystem demonstration

Introduction :

This application shows how to implement the new CircleOS API to manage files with the new FatFS file sytem :

  • copy files,
  • compares files,
  • gest the file size,
  • cheks the end of file,
  • gets strings....

The application also shows how to use the "UTIL_SaveScreenBMP" API function, in order to create screenshots on the SD Card in BMP format file.


The project contains one application by platform, sharing the same source file (application.c), that allows to program and debug all corresponding platforms:

  • Primer2,
  • EvoPrimer STM32E,
  • EvoPrimer STM32G,
  • EvoPrimer STM32C,
  • EvoPrimer STM32L,
  • EvoPrimer STM3240G.

Select your platform by clicking on the corresponding application in the project tree, then clik on mouse right button and choose "Set as Startup application".



The application calls alternatively two procedures : CopyTest (copy file), and ReadWriteTest (write read and display infos).

Copy files :

The application copies periodically a file, displays the size of the destination file, thanks to the API functions :

  • FS_FileCopy(),
  • FS_FileCmp(),
  • FS_OpenFile(),
  • FS_Size(),
  • FS_Close().


 Default values : source file = "Original.txt", destination file = "Copy.bak", size : 362 bytes.

Read and write file:

The application writes and reads periodically into a file:

  • writes a block of 100 characters into the file,
  • tests the end of the file,
  • reads back the block,
  • compares the read block versus the written block,
  • moves to the precedent block in the file,
  • reads a string,
  • moves to the next block,
  • repeats for 100 blocks,
  • finally displays the size of the file.

This is done thanks to the API functions :

  • FS_OpenFile(),
  • FS_Close(),
  • FS_WriteFile(),
  • FS_Tell(),
  • FS_Seek(),
  • FS_Eof(),
  • FS_ReadFile(),
  • FS_Gets(),
  • FS_Size().

Default configuration :  Default values :  "FileTest.txt", size : 10000 bytes.

Push the button to stop.

  Notes :  

  • The "Evo_Circle_STM32x.elf", "FAT.elf" and "FAT_OP4.elf" files location depends on your Ride installation; delete them from the projet and add it back before building the project.
  • This example runs on all platforms that have an SD Card port : Primer2 and EvoPrimer.
  • The screenshots have been made thanks to the "UTIL_SaveScreenBMP" API function.
  • For more information about the FS API's, see :   Circle OS Conception document

Version V1.0

  • First release