<< Previous | Next >>

fs_format (FS1)

int fs_format( long reserveblocks, int num_blocks, unsigned long wearlevel );

Description

Initializes the internal data structures and file system. All blocks in the file system are erased.

Parameters

reserveblocks
Starting address of the flash file system. When FS_FLASH is defined this value should be 0 or a multiple of the block size. When FS_RAM is defined this parameter is ignored.

num_blocks
The number of blocks to allocate for the file system. With a default block size of 4096 bytes and a 256K flash memory, this value might be 64.

wearlevel
This value should be 1 on a new flash memory, and some higher value on an unformatted used flash memory. If you are reformatting a flash memory you can set wearlevel to 0 to keep the old wear leveling.

Return value

0: Success.
1: Failure.

Library

FILESYSTEM.LIB

Example

This program can be found in samples/filesystem/format.c.


#define FS_FLASH
#use "filesystem.lib"
#define RESERVE 0
#define BLOCKS 64
#define WEAR 1

main() {
if(fs_format(RESERVE,BLOCKS,WEAR)) {
printf("error formatting flash\n");
} else {
printf("flash successfully formatted\n");
}
}


Dynamic C Functions << Previous | Next >> rabbit.com