Trueffs
Trueffs
Version 1.3
w w w. r a d i s y s . c o m
Revision B • July 2006
Copyright and publication information Reproduction notice
This manual reflects version 1.3 of TrueFFS for Microware OS-9. The software described in this document is intended to
Reproduction of this document, in part or whole, by any means, be used on a single computer system. RadiSys
electrical, mechanical, magnetic, optical, chemical, manual, or Corporation expressly prohibits any reproduction of the
otherwise is prohibited, without written permission from RadiSys software on tape, disk, or any other medium except for
Microware Communications Software Division, Inc. backup purposes. Distribution of this software, in part
or whole, to any other party or on any other system
Disclaimer may constitute copyright infringements and
misappropriation of trade secrets and confidential
The information contained herein is believed to be accurate as of processes which are the property of RadiSys
the date of publication. However, RadiSys Corporation will not be Corporation and/or other parties. Unauthorized
liable for any damages including indirect or consequential, from distribution of software may cause damages far in
use of the OS-9 operating system, Microware-provided software, excess of the value of the copies involved.
or reliance on the accuracy of this documentation. The
information contained herein is subject to change without notice.
July 2006
Copyright ©2006 by RadiSys Corporation
All rights reserved.
EPC and RadiSys are registered trademarks of RadiSys Corporation. ASM, Brahma, DAI, DAQ, MultiPro, SAIB, Spirit, and ValuePro are
trademarks of RadiSys Corporation.
DAVID, MAUI, OS-9, OS-9000, and SoftStax are registered trademarks of RadiSys Corporation. FasTrak, Hawk, and UpLink are
trademarks of RadiSys Corporation.
† All other trademarks, registered trademarks, service marks, and trade names are the property of their respective owners.
Contents
Chapter 1: Installing TrueFFS for OS-9®
Installing FTL on OS-9 ..................................................................................................................... 6.
Method 1: Creating a Bootfile with os9make ............................................................................. 6.
Method 2: Creating a Bootfile with the Configuration Wizard................................................... 7.
Installing FTL on OS-9 for 68K ........................................................................................................ 7.
Adding FTL to a Running System ..................................................................................................... 8.
Chapter 2: Using and Testing
TrueFFS
Formatting the Flash Device ............................................................................................................. 10.
Testing TrueFFS and the FTL ........................................................................................................... 12.
Chapter 3: Technical Overview
The OS-9 Flash File System............................................................................................................... 14.
FTL Device Driver and Descriptors................................................................................................... 14.
FTL Device Driver Limitations ................................................................................................... 16.
FTL Device Descriptors .............................................................................................................. 16.
FTL and the PC Card Program ......................................................................................................... 17.
Chapter 4: Programming Reference
System Calls...................................................................................................................................... 20.
I_SETSTAT, SS_DEFLSH ...................................................................................................................21
I_SETSTAT, SS_DEFRAG ..................................................................................................................22
I_SETSTAT, SS_DELBLK...................................................................................................................23
I_SETSTAT, SS_LLFRMT ..................................................................................................................24
Utilities ............................................................................................................................................. 26.
filltest ................................................................................................................................................27
ftcheck...............................................................................................................................................28
ftdefrag..............................................................................................................................................29
ftformat .............................................................................................................................................30
Configuration Fields ......................................................................................................................... 31.
ds_flash_base.....................................................................................................................................32
ds_flash_size ......................................................................................................................................33
ds_flash_source .................................................................................................................................34
Errors ............................................................................................................................................... 35.
Chapter 5: Porting Guide
Common Code Files ......................................................................................................................... 38.
Hardware-Specific Functions ............................................................................................................ 38.
Communication Structure................................................................................................................. 38.
Required Fields .......................................................................................................................... 39.
Optional Fields........................................................................................................................... 39.
Fields Specified in the Device Descriptor .................................................................................... 39.
Example Source Code ....................................................................................................................... 40.
3
Using TrueFFS for OS-9®
4
1 InstallingTrueFFSforOS-9®
This chapter contains installation instructions for including the TrueFFS for OS-9®
Flash Translation Layer (FTL) in an OS-9 boot image configuration or adding FTL
to an already running OS-9 system. FTL is a standard for flash file systems which
provides full disk emulation for standard flash devices. TrueFFS for OS-9 allows
programs to have disk-like access to flash memory.
The following sections are included in this chapter:
• Installing FTL on OS-9
• Installing FTL on OS-9 for 68K
• Adding FTL to a Running System
5
Using TrueFFS for OS-9®
Step 3. Rebuild the bootfile using os9make and the makefile that resides in
MWOS/OS9000/<CPU Family>/PORTS/<port>/BOOTS/SYSTEMS/PORTBOOT.
Step 4. Follow the instructions in your OS-9 for <target> Board Guide for placing the
bootfile onto the target system.
6
Chapter 1: Installing TrueFFS for OS-9®
7
Using TrueFFS for OS-9®
If space permits, uncomment the following lines in the bootlist file by removing the
leading asterisk. These utilities are optional, but help to test the installation.
../../../68000/CMDS/dcheck
../../../68000/CMDS/dir
../../../68000/CMDS/kermit
../../../68000/CMDS/mdir
../../../68000/CMDS/save
Add the following lines to the bootlist file:
CMDS/BOOTOBJS/RBFTL/rbftl
CMDS/BOOTOBJS/RBFTL/rrf0
CMDS/BOOTOBJS/RBFTL/rrf0fmt
Refer to your OS-9 for 68K Processors BLS Reference for OS-9 for 68K
installation and configuration information.
8
2 Using and Testing
TrueFFS
This chapter explains how to use and test TrueFFS and the FTL for
OS-9/OS-9 for 68K once it has been installed.
9
Using TrueFFS for OS-9®
This utility will perform a low level format of a flash volume /rrf0@
for use with the rbftl TrueFFS flash file system driver.
This formatting will destroy all file and low-level state info
including wear-leveling info, if any, stored in the flash.
10
Chapter 2: Using and Testing TrueFFS
11
Using TrueFFS for OS-9®
12
3 Technical Overview
This chapter explains how the rbftl device driver works with the OS-9 RBF and
PCF file managers to make flash memory accessible like disk devices.
The following sections are included in this chapter:
• The OS-9 Flash File System
• FTL Device Driver and Descriptors
• FTL and the PC Card Program
13
Using TrueFFS for OS-9®
Applications
Physical Hardware
including PC Cards
and flash arrays on
motherboards
14
Chapter 3: Technical Overview
FTL Algorithms
Memory Technology
MTD MTD MTD
Driver (MTD)
Device
rcf1 rrf1 pcf1 prf1
Descriptors
Physical Hardware
including PC Cards
and flash arrays on
motherboards
The rbftl driver includes a single "block manager" and set of hardware driver
routines which share a relationship similar to that of RBF and a typical device
driver.
The "block manager," shown as the FTL Algorithms in Figure 3-2., implements the
media wear-leveling intelligence.
Media wear-leveling is accomplished through a metadata structure on the media
which provides rbftl with the following:
• a block address translation map
• block wear-leveling information
• block-in-use information
The FTL algorithms use this information for block read requests and to determine a
flash block range for memory write requests.
To maintain flash memory device independence, the MTD (memory technology
driver) intelligence is not embedded into the FTL algorithms. Separate routines,
though still internal to the driver, are used by the FTL algorithms to manage flash
hardware.
The thin layer that binds the FTL algorithms to a given MTD (memory technology
driver) is a standard set of call entry points. These are:
• Write - writes a block of bytes to flash.
• Erase - erases one or more contiguous flash erasable blocks.
15
Using TrueFFS for OS-9®
16
Chapter 3: Technical Overview
The flash size does not have to span the entire flash device but must terminate on an
erase block boundary.
The flash location flag is not used. rbftl accesses both resident and PC Card-based
flash without regard for the additional considerations that removable flash
provides. For PC Card flash, this requires that another program has already ensured
the following:
• A single memory window large enough to access the entire flash array is
enabled.
• Flash accesses through this window are always word-wide.
• Flash Vcc and Vpp are always available and enabled.
• Flash is always available. The PC Card is in the slot.
The flash type identification specifier, JEDEC ID, is not used. FTL auto-detects the
flash type. If it is necessary to manually set the JEDEC ID, this number can be set to
a non-zero value.
17
Using TrueFFS for OS-9®
18
4 Programming Reference
This chapter contains the reference pages for the FTL system calls, utilities,
configuration fields, and errors.
The following sections are included in this chapter:
• System Calls
• Utilities
• Configuration Fields
• Errors
19
Using TrueFFS for OS-9®
System Calls
The following OS-9 system calls are included for TrueFFS and the FTL:
• I_SETSTAT, SS_DEFLSH
• I_SETSTAT, SS_DEFRAG
• I_SETSTAT, SS_DELBLK
• I_SETSTAT, SS_LLFRMT
20
Chapter 4: Programming Reference
I_SETSTAT, SS_DEFLSH
Function Code
I_SETSTAT, SS_DEFLSH
Syntax
#include <IO/ftlsrvcb.h>
Attributes
State: User, System, and I\O
Description
csfd calls I_SETSTAT, SS_DEFLSH to notify rbftl that the flash array in the
system is smaller than specified in the descriptor.
flash_base
is the starting memory address of the flash array.
flash_size
is the actual size of the flash array.
bus_width
specifies in bits the width of array memory accesses.
21
Using TrueFFS for OS-9®
I_SETSTAT, SS_DEFRAG
Function Code
I_SETSTAT, SS_DEFRAG
Syntax
#include <IO/ftlsrvcb.h>
Attributes
State: User, System, and I\O
Description
The ftdefrag utility calls I_SETSTAT, SS_DEFRAG to defragment a flash device.
irLength is the maximum number of free sectors to make available. Depending on
the amount of recoverable space on the device, this number may not be reached.
Possible Errors
EOS_BAD_FORMAT
EOS_BTYP
EOS_GENERAL_FAILURE
EOS_WRITE_FAULT
22
Chapter 4: Programming Reference
I_SETSTAT, SS_DELBLK
Function Code
I_SETSTAT, SS_DELBLK
Syntax
#include <IO/ftlsrvcb.h>
Attributes
State: User, System, and I\O
Description
I_SETSTAT, SS_DELBLK marks blocks of flash as deleted. This allows flash
memory to be re-used more efficiently after files have been deleted.
irSectorNo is the starting sector number of blocks to delete.
irSectorCount is number of sectors to delete.
Possible Errors
EOS_BAD_FORMAT
EOS_BTYP
EOS_GENERAL_FAILURE
EOS_SECTOR_NOT_FOUND
EOS_WRITE_FAULT
23
Using TrueFFS for OS-9®
I_SETSTAT, SS_LLFRMT
Function Code
I_SETSTAT, SS_LLFRMT
Syntax
#include <IO/ftlsrvcb.h>
Attributes
State: User, System, and I\O
Description
The ftformat utility calls I_SETSTAT, SS_LLFRMT to perform a low-level format
of the flash volume.
formatParams are a set of device parameters including:
• int32 bootImageLen;
Space to reserve for a boot-image at the start of the medium. The FLite volume
begins at the next higher erase unit boundary.
• u_int16 percentUse;
FTL performance depends on how full the flash media is. Performance slows as
the media is close to 100% full. To increase performace, format the media to
less than 100% capacity, which guarantees some free space at all times by
sacrificing some capacity.
• u_int16 noOfSpareUnits;
FTL needs at least one spare erase unit to function as a read/write media. (It is
possible to specify zero (0) to achieve WORM functionality). You can specify
more than one spare unit. This takes more media space, but if one of the flash
erase units becomes bad and un-erasable in the future, one of the spare units
needs to replace it. A second spare unit can continue read/write functionality.
Without the spare unit, the media enters read-only mode. The standard value to
use is 1.
24
Chapter 4: Programming Reference
• u_int32 vmAddressingLimit;
Part of the FTL virtual map always resides in RAM. The RAM-resident portion
is used to address the media below the VM addressing limit. Reading and
writing to this part is usually faster. The larger the limit, the more RAM size
that is required. To get the extra RAM requirement in bytes, divide the limit by
512. The minimum VM limit is 0. The standard value to use is 0x10000, the
first 64KB.
• int (*progressCallback)
( u_int16 totalUnitsToFormat,
u_int16 totalUnitsFormattedSoFar );
The progress callback routine is called if not NULL. The callback routine is
called after erasing each unit, and its parameters are the total number of erase
units to format and the number erased so far. The callback routine returns a
status value. A value of OK (0) allows formatting to continue. Any other value
will abort the formatting with the returned status code.
Possible Errors
EOS_BAD_FORMAT. SS_LLFRMT returns this code when the verify pass following the
low-level format failed, indicating a hardware failure.
EOS_<callback>. These are callback procedure errors. One field in the SS_LLFRMT
structure is for a callback procedure to take advantage of format progress status.
EOS_VOLUME_TOO_SMALL
EOS_WRITE_FAULT
25
Using TrueFFS for OS-9®
Utilities
The following FTL utilities are included:
• filltest
• ftcheck
• ftdefrag
• ftformat
26
Chapter 4: Programming Reference
filltest
Syntax
filltest [<opts>] {<path> [<opts>]}
Attributes
Operating System:OS-9 and OS-9 for 68K
Description
The filltest utility completely fills any RBF-formatted device with files that are
several blocks in length and performs the stress testing.
Examples
filltest -s=100 /rrf1
Errors
EOS_BAD_FORMAT
EOS_BTYP
EOS_GENERAL_FAILURE
EOS_UNKNOWN_MEDIA
EOS_WRITE_FAULT
27
Using TrueFFS for OS-9®
ftcheck
Syntax
ftcheck <mem addr> [size]
Attributes
Operating System:OS-9 and OS-9 for 68K
Parameters
<mem addr>
The starting address of the flash disk
[size]
The size of the flash disk
Description
The ftcheck utility checks the integrity of an FTL media by collecting the
information, such as Erase Units, Sectors/Unit, Direct Memory from it. It can also
verify erased media.
Examples
ftcheck 0xFFA00000
Errors
EOS_BTYP
EOS_GENERAL_FAILURE
EOS_UNKNOWN_MEDIA
EOS_WRITE_FAULT
28
Chapter 4: Programming Reference
ftdefrag
Syntax
ftdefrag [<opts>] {<path> [<opts>]}
Attributes
Operating System:OS-9 and OS-9 for 68K
Description
The ftdefrag utility optimizes performance of FTL media by reorganizing media
data blocks. This reorganization defragments and recycles non-writeable flash areas
to achieve optimal writing speed. This operation would typically be performed after
deleting one or more large files.
Examples
ftdefrag /rrf1@
Errors
EOS_BAD_FORMAT
EOS_BTYP
EOS_GENERAL_FAILURE
EOS_WRITE_FAULT
29
Using TrueFFS for OS-9®
ftformat
Syntax
ftformat [<opts>] {<path> [<opts>]}
Attributes
Operating System:OS-9 and OS-9 for 68K
Description
The ftformat utility performs a low-level format of a flash media device. During a
low-level format operation, the rbftl driver erases all units of the flash media and
lays down a metadata structure which is used for wear leveling and data block
location. Once the media has been low-level formatted, a high-level format can be
done by the file manager. The high-level format of the FTL media creates the
directory structure and file allocation information. The low-level format is normally
a one-time operation, unless the media becomes corrupted through an event such as
software or hardware failure.
30
Chapter 4: Programming Reference
Example
ftformat /rrf1
Errors
EOS_BAD_FORMAT
EOS_<callback>
EOS_VOLUME_TOO_SMALL
EOS_WRITE_FAULT
See Also
format in the Utilities Reference
Configuration Fields
In addition to the configuration fields included in RBF, the following FTL fields are
included:
• ds_flash_base
• ds_flash_size
• ds_flash_source
31
Using TrueFFS for OS-9®
ds_flash_base
Default Description Macro
FLASH_BASE
EditMod Labels
1-module header
2-device descriptor data definitions
4-RBF logical unit static storage
5-rbftl specific information
1-flash base address
Description
This is the base address of the flash memory.
Default Value
None
Available Values
Value ranges are hardware dependent. Refer to your OS-9 board guide to see what
types and sizes of flash your board has available.
32
Chapter 4: Programming Reference
ds_flash_size
Default Description Macro
FLASH_SIZE
EditMod Labels
1-module header
2-device descriptor data definitions
4-RBF logical unit static storage
5-rbftl specific information
2-size of flash to be used
Description
This is the size of flash to be used in bytes.
Default Value
None
Available Values
Value ranges are hardware dependent. Refer to your OS-9 board guide to see what
types and sizes of flash your board has available.
33
Using TrueFFS for OS-9®
ds_flash_source
Default Description Macro
FLASH_SOURCE
EditMod Labels
1-module header
2-device descriptor data definitions
4-RBF logical unit static storage
5-rbftl specific information
3-flash source location
Description
Use this parameter to set the flash location, on the motherboard or on a PC Card.
Default Value
None
Available Values
Available values are listed in <links>Table 4-1. ds_flash_source Available Values.
34
Chapter 4: Programming Reference
Errors
The FTL errors described in <links>Table 4-2. FTL Errors are defined in
ftlsrvcb.h.
35
Using TrueFFS for OS-9®
36
5 Porting Guide
This chapter explains how to add support for a new flash part into a rbftl flash
driver.
Rbftl drivers consists of two parts: Common code that is already written for your
driver, and hardware specific code that you write. The common code includes the
wear-balancing algorithm and RBF driver interface, and generally makes up most of
the driver. In the hardware specific code, you will need to write functions for
identifying, erasing, and writing the flash part you choose.
37
Using TrueFFS for OS-9®
Hardware-Specific Functions
The hardware-specific functions you need are for identification, erasing, and
writing the flash part. Each has a specific prototype:
error_code flash_write( u_int32 address, u_int8* buff, u_int32
length, u_int16 overwrite);
address Flash part relative address to write data. You must call
flash.map() to make this a system address.
buff Buffer containing data to write to flash part.
length Number of bytes to write to flash part.
overwrite Used to specify whether or not this area of flash has been
erased. No longer used.
error_code flash_identify();
This routine is responsible for identifying your flash device as well as filling out
fields in the global structure called flash.
Communication Structure
Communication between the hardware specific and common code happens via a
global data structure that is defined in rbftl_defs.h. This structure is declared in
the common code and is named flash. Your flash identification routine is
responsible for setting the required fields properly so that the common code can
make use of them.
38
Chapter 5: Porting Guide
Required Fields
Required fields are referenced by common code.
erasable_block_sizeNumber of bytes in an erase block.
write Function pointer to your flash write routine.
erase Function pointer to your flash erase routine.
Optional Fields
Optional fields are used by other existing hardware specific code.
type JEDEC ID of flash part.
chip_size Byes in a single chip in flash array.
num_chips Number of flash chips.
interleaving Address difference between two successive words on a chip
(for example 2 for two 8 bit parts, 1 for one 16bit part).
parallel_limit Effective flash byte bus width.
flags Not used currently.
hw_data Place you can store data.
read Function pointer that reads memory off the flash device. The
default value is memcpy. You can set this to another value if
your flash device has special access needs.
map Function that converts flash device relative addresses to real
memory addresses. Default is returning
(address+flash.flash_base).
39
Using TrueFFS for OS-9®
40
Chapter 5: Porting Guide
On an OS9 for 68k system, the base address, size, and bus width are specified in the
systype.d file.
********************
* Flash System Memory Definitions
*
* These are used to make descriptors for the flash file system.
********************
* Flash disk descriptor definitions
*
* FLASHDesc Port,Size,Source,Width,MFGID,DEVID,Driver name,MTD
name
*
FlashRRF0 macro
FLASHDesc FlashDBase,FlashDSize,0,8,0,0,rbftl,mtd
endm
41
Using TrueFFS for OS-9®
42