NRAFS

From PaparazziUAV
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Not Really a File System

Criteria

  • Should be usable on flash memory: don't overwrite the same blocks over and over.
  • Fast
  • Should miss at most one block of data when a write operation is interrupted. (For example when a logger without dedicated battery is disconnected.)
  • Table-like logging: a table header and a rows with data, separated in columns.

Overview

NrafsOverview.png

First block of disk, the "partition table"

The first block (512 Bytes) of the disk only has to be written once. It has an 8-bytes header which indicates that the disk is 'formatted' in NRAFS format. The remaining 504 Bytes are reserved for future use, and will store usage information about the SD-card's blocks.

First block of log, the "table header"

The first block of a log can be seen as a table header. It consists off:

  • A 16-byte header to indicate the block type.
  • 16 bytes containing the airframe's MD5 sum.
  • 1 byte containing the airframe ID.
  • 5 bytes describing the reference (start) time of the log: 4 bytes descibe the time in seconds since Unix Epoch, and 1 byte indicates the 1/255th seconds.

(total 38 bytes)

And per field:

  • 6 bytes describing the name of the field in ASCII.
  • 1 byte describing the data type: 2 bits indicate the size of the field (8/16/24/32 bits); another bit indicates if it is a float or an interger; a fourth bit indicates if it is a signed or unsigned type.
  • 1 byte containing the XOR checksum of this field description.

(total 8 bytes per field description)

When 59 fields are used, this would take 59*8=472 Bytes. As 38 Bytes are used for the header, there are still 512-472-38=2 Bytes available for a CRC checksum of this block.

A data block

A data block simply consists of concatenated rows of binary data.

 FieldA FieldB FieldC FieldD FieldA FieldB FieldC FieldD

No row seperator characters are used. We have to see how well that turns out. We could easily add a CRC per block as the STM32F10x and STM32F4 have hardware CRC-checksum generation.

Where to start a new log?

Blocks are read starting from the second block of the SD card, until a block is found which does not start with the 16-byte "start of log" header. A NrafsFindFreeLogSpace.png