firmware

package
v0.0.0-...-e9c722b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2016 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendCRC

func AppendCRC(filename string) error

AppendCRC calculates the CRC for any given file and appends it to the end

Types

type CRCMode

type CRCMode int64

CRCMode represent whether or not CRC is present at the end of the firmware

const (
	// NoCRC = CRC is not present
	NoCRC CRCMode = iota
	// CRCPresent = CRC is present
	CRCPresent
)

func (CRCMode) String

func (i CRCMode) String() string

type FileEntry

type FileEntry struct {
	Path        string
	StartSector int64
	Size        int64
}

FileEntry contains the complete file path, file start in sector, file size in bytes

type Firmware

type Firmware struct {
	File   *os.File
	Reader *bufio.Reader
	Path   string
	Header Structure
	Files  []FileEntry
}

Firmware represent the firmware file

func (*Firmware) FileList

func (f *Firmware) FileList()

FileList return a FileEntry array

func (*Firmware) ReadHeader

func (f *Firmware) ReadHeader(fwPath string) error

ReadHeader takes in input the path of a Fiio firmware file and reads header information into a Structure struct.

This function will return the reader initialized, with the seek pointer already pointing at the file list.

func (*Firmware) Unpack

func (f *Firmware) Unpack(dest string)

Unpack unpack the firmware in the destination directory

type Structure

type Structure struct {
	HeaderStartToken     string    // offset 0x0, length 4 - confirmed
	FilesystemSectors    int64     // offset 0x4, length 4 - unsure
	HeaderSize           int64     // offset 0x8, length 4 - unsure
	CreationTime         time.Time // offset 0x10, length 12 - confirmed
	NumberOfFiles        int64     // offset 0x1c, length 4 - confirmed
	CRC                  CRCMode   // offset 0x20, length 4 - confirmed but always true
	MachineString        string    // offset 0x30, length 8 - confirmed
	FilesystemSizeBytes  int64     // not sure
	FilesystemSectorSize int64     // confirmed, always 512
}

Structure represents the firmware header

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL