437
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
Formatting is performed using the
method. This method accepts, as
arguments, two parameters: total number of sectors occupied by the disk, and the
maximum number of files that you wish to be able to store on the disk.
The total number of sectors cannot exceed the size of the
. That is, the
maximum "gross" disk size is
sectors. The flash disk
needs several sectors for internal housekeeping reasons, so actual useful capacity
of the disk will be less.
topic explains how to find out
current disk capacity, as well as get other useful info. There is also a minimum
limit that will be accepted for the total disk size. The minimum exists because the
number of sectors occupied by the disk must at least be enough for the
"housekeeping" data.
When debugging your application, use less space for the disk than
actually available -- this way the disk will not get corrupted each time
your application size increases. When debugging is done, you can use
maximum possible size, unless you want to leave some space for
.
The fd. object stores up to 64 files on the disk, in a single "root" directory. You can
choose to have less files if you don't need so many. This will reduce the number of
"housekeeing" sectors required for the disk. The economy is not dramatic, but you
can still save some space. Each file record occupies 64 bytes, so one sector of the
FRT table can store 4 file records. For this reason, the number of files you specify
will always be adjusted to be the multiple of 4. For example:
'format a disk to occupy 3/4th of available space and store at least 10
files
If
fd.format((fd.availableflashspace/4)*3,10)<>PL_FD_STATUS_OK
Then
'some problem...
End
If
'actual maximum number of files will be 12 (adjusted up from 10 to be a
multiple of 4)
After the formatting the disk will be in the dismounted state and will need to be
before any disk-related activity can be successfully performed.
This topic provides details on the internal structure of the flash disk.
The flash disk has a number of areas. Each area includes one or more flash
sectors. Each sector has a physical size of 264 bytes. Of those, only 256 bytes are
used to store the data. Two more bytes are for the
. Six remaining
bytes are mostly left unused, except in the FRT/FAT areas (see below), where they
do serve a useful function.
The flash disk has the following areas:
BOOT sector, always at logical sector #0 (so it is the topmost physical sector of
the flash -- this was explained in
Sharing Flash Between Your Application and
). The boot sector contains the information about the sizes of other areas
of the disk.
File record table (FRT) area.
File allocation table (FAT) area.
Data area -- actual data sectors of files.
467
434
457
441
454
439
450
434