fwpkg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

README

firmware-packaging-go

A go library to read firmware packages. Initially created for io4edge firmware packages.

A firmware package is a tar file containing a manifest and the firmware binary:

$ tar tvf testdata/t1.fwpkg
drwx------ root/root         0 2021-09-07 14:24 ./
-rw-r--r-- root/root    155688 2021-09-05 13:01 ./fw_varA_1_1_0.json
-rw-r--r-- root/root       179 2021-09-07 14:24 ./manifest.json

where manifest.json describes the firmware binary:

{
  "name": "cpu01-tty_accdl",
  "version": "1.1.0",
  "file": "fw_varA_1_1_0.json",
  "compatibility": {
    "hw": "s101-cpu01",
    "major_revs": [
      1,
      2
    ]
  }
}

Example usage of the library:

    import fwpkg "github.com/ci4rail/firmware-packaging-go"

	pkg, err := fwpkg.NewFirmwarePackageConsumerFromFile("t1.fwpkg")
	if err != nil {
		...
	}
	manifest := pkg.Manifest()
    fmt.Printf("manifest: %v\n", manifest)

    // load fw file into memory
    fwFile := new(bytes.Buffer)
	err = pkg.File(fwFile)
	if err != nil {
		...
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FirmwarePackageConsumer

type FirmwarePackageConsumer struct {
	// contains filtered or unexported fields
}

FirmwarePackageConsumer is a handle to consume firmware package archive files

func NewFirmwarePackageConsumerFromFile

func NewFirmwarePackageConsumerFromFile(fileName string) (*FirmwarePackageConsumer, error)

NewFirmwarePackageConsumerFromFile creates an object to work with the firmware package in fileName The file is opened and the manifest is parsed and checed for validity. If not valid, an error is returned

func (*FirmwarePackageConsumer) File

File extracts the firmware binary file from the firmware package and writes it to w

func (*FirmwarePackageConsumer) Manifest

func (p *FirmwarePackageConsumer) Manifest() (manifest *FwManifest)

Manifest returns the parsed manifest as ago struct

type FwManifest

type FwManifest struct {
	Name          string
	Version       string
	File          string
	Compatibility struct {
		HW        string
		MajorRevs []int `json:"major_revs"`
	}
}

FwManifest contains the fields from the manifest file within the firmware package

Jump to

Keyboard shortcuts

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