### Class

# FwupdPlugin Firmware

since: 1.0

#### Description [src]

    class FwupdPlugin.Firmware : GObject.Object
    {
      /* No available fields */
    }

A firmware file which can have children which represent the images within.

See also: `FuDfuFirmware`, `FuIhexFirmware`, `FuSrecFirmware`

Available since: 1.0

#### Ancestors

- GObject

#### Descendants

- FuAcpiTable
- FuArchiveFirmware
- FuCabFirmware
- FuCabImage
- FuCfuOffer
- FuCfuPayload
- FuCoswidFirmware
- FuCsvEntry
- FuCsvFirmware
- FuDfuFirmware
- FuEdid
- FuEfiDevicePath
- FuEfiDevicePathList
- FuEfiFile
- FuEfiFilesystem
- FuEfiFtwStore
- FuEfiLoadOption
- FuEfiSection
- FuEfiSignature
- FuEfiSignatureList
- FuEfiVolume
- FuEfiVss2VariableStore
- FuEfiVssAuthVariable
- FuElfFirmware
- FuFdtFirmware
- FuFdtImage
- FuFmapFirmware
- FuHidDescriptor
- FuHidReport
- FuIfdFirmware
- FuIfdImage
- FuIfwiCpdFirmware
- FuIfwiFptFirmware
- FuIhexFirmware
- FuIntelThunderboltNvm
- FuJsonFirmware
- FuLinearFirmware
- FuOpromFirmware
- FuPefileFirmware
- FuPkcs7
- FuSbatlevelSection
- FuSmbios
- FuSrecFirmware
- FuUsbBosDescriptor
- FuUsbConfigDescriptor
- FuUsbDeviceDs20
- FuUsbEndpoint
- FuUsbHidDescriptor
- FuUsbInterface
- FuUswidFirmware
- FuX509Certificate

#### Constructors

###### fu_firmware_new

Creates an empty firmware object.

since: 1.3.1

###### fu_firmware_new_from_bytes

Creates a firmware object with the provided image set as default.

since: 1.3.1

###### fu_firmware_new_from_gtypes

Tries to parse the firmware with each `GType` in order.

since: 1.5.6

#### Functions

###### fu_firmware_flags_to_string

Converts an enumerated value to a string.

since: 1.0

###### fu_firmware_strparse_uint16_safe

Parses a base 16 number from a string of 4 characters in length. The returned `value` will range from 0 to 0xffff.

since: 1.5.6

###### fu_firmware_strparse_uint24_safe

Parses a base 16 number from a string of 6 characters in length. The returned `value` will range from 0 to 0xffffff.

since: 1.5.6

###### fu_firmware_strparse_uint32_safe

Parses a base 16 number from a string of 8 characters in length. The returned `value` will range from 0 to 0xffffffff.

since: 1.5.6

###### fu_firmware_strparse_uint4_safe

Parses a base 16 number from a string of 1 character in length. The returned `value` will range from 0 to 0xf.

since: 1.5.6

###### fu_firmware_strparse_uint8_safe

Parses a base 16 number from a string of 2 characters in length. The returned `value` will range from 0 to 0xff.

since: 1.5.6

#### Instance methods

###### fu_firmware_add_chunk

Adds a chunk to the image.

since: 1.6.0

###### fu_firmware_add_flag

Adds a specific firmware flag to the firmware.

since: 1.5.0

###### fu_firmware_add_image

Adds an image to the firmware. This method will fail if the number of images would be above the limit set by fu_firmware_set_images_max().

since: 1.9.3

###### fu_firmware_add_magic

Adds a possible magic signature to the image.

since: 2.0.18

###### fu_firmware_add_patch

Adds a byte patch at a specific offset. If a patch already exists at the specified address then it is replaced.

since: 1.7.4

###### fu_firmware_build

Builds a firmware from an XML manifest. The manifest would typically have the following form:

since: 1.5.0

###### fu_firmware_build_from_filename

Builds a firmware from an XML manifest.

since: 2.0.0

###### fu_firmware_build_from_xml

Builds a firmware from an XML manifest. The manifest would typically have the following form:

since: 1.6.0

###### fu_firmware_check_compatible

Check a new firmware is compatible with the existing firmware.

since: 1.8.4

###### fu_firmware_export

This allows us to build an XML object for the nested firmware.

since: 1.6.0

###### fu_firmware_export_to_xml

This allows us to build an XML object for the nested firmware.

since: 1.6.0

###### fu_firmware_get_addr

Gets the base address of the image.

since: 1.6.0

###### fu_firmware_get_alignment

Gets the alignment of the firmware.

since: 1.6.0

###### fu_firmware_get_bytes

Gets the firmware payload, which does not have any header or footer included.

since: 1.6.0

###### fu_firmware_get_bytes_with_patches

Gets the firmware payload, with any defined patches applied.

since: 1.7.4

###### fu_firmware_get_checksum

Returns a checksum of the payload data.

since: 1.6.0

###### fu_firmware_get_chunks

Gets the optional image chunks.

since: 1.6.0

###### fu_firmware_get_depth

Gets the depth of this child image relative to the root.

since: 1.9.14

###### fu_firmware_get_filename

Gets an optional filename that represents the image source or destination.

since: 1.6.0

###### fu_firmware_get_id

Gets the image ID, typically set at construction.

since: 1.6.0

###### fu_firmware_get_idx

Gets the index of the image which is used for ordering.

since: 1.6.0

###### fu_firmware_get_image_by_checksum

Gets the firmware image using the image checksum. The checksum type is guessed based on the length of the input string.

since: 1.5.5

###### fu_firmware_get_image_by_gtype

Gets the firmware image using the image `GType`.

since: 1.9.3

###### fu_firmware_get_image_by_gtype_bytes

Gets the firmware image bytes using the image `GType`.

since: 1.9.3

###### fu_firmware_get_image_by_id

Gets the firmware image using the image ID.

since: 1.3.1

###### fu_firmware_get_image_by_id_bytes

Gets the firmware image bytes using the image ID.

since: 1.3.1

###### fu_firmware_get_image_by_id_stream

Gets the firmware image stream using the image ID.

since: 2.0.0

###### fu_firmware_get_image_by_idx

Gets the firmware image using the image index.

since: 1.3.1

###### fu_firmware_get_image_by_idx_bytes

Gets the firmware image bytes using the image index.

since: 1.3.1

###### fu_firmware_get_image_by_idx_stream

Gets the firmware image stream using the image index.

since: 2.0.0

###### fu_firmware_get_images

Returns all the images in the firmware.

since: 1.3.1

###### fu_firmware_get_images_max

Gets the maximum number of images this container can hold.

since: 1.9.3

###### fu_firmware_get_offset

Gets the base offset of the image.

since: 1.6.0

###### fu_firmware_get_parent

Gets the parent.

since: 1.8.2

###### fu_firmware_get_size

Gets the total size of the image, which is typically the same size as the data from fu_firmware_write().

since: 1.6.0

###### fu_firmware_get_size_max

Gets the maximum size of the image allowed during parsing.

since: 1.9.7

###### fu_firmware_get_stream

Gets the input stream which was used to parse the firmware.

since: 2.0.0

###### fu_firmware_get_version

Gets an optional version that represents the firmware.

since: 1.3.3

###### fu_firmware_get_version_format

Gets the version format.

since: 2.0.0

###### fu_firmware_get_version_raw

Gets an raw version that represents the firmware. This is most frequently used when building firmware with `<version_raw>0x123456</version_raw>` in a `firmware.builder.xml` file to avoid string splitting and sanity checks.

since: 1.5.7

###### fu_firmware_has_flag

Finds if the firmware has a specific firmware flag.

since: 1.5.0

###### fu_firmware_parse_bytes

Parses a firmware, typically breaking the firmware into images.

since: 2.0.1

###### fu_firmware_parse_file

Parses a firmware file, typically breaking the firmware into images.

since: 1.3.3

###### fu_firmware_parse_stream

Parses a firmware from a stream, typically breaking the firmware into images.

since: 2.0.0

###### fu_firmware_remove_image

Remove an image from the firmware.

since: 1.5.0

###### fu_firmware_remove_image_by_id

Removes the first image from the firmware matching the ID.

since: 1.5.0

###### fu_firmware_remove_image_by_idx

Removes the first image from the firmware matching the index.

since: 1.5.0

###### fu_firmware_set_addr

Sets the base address of the image.

since: 1.6.0

###### fu_firmware_set_alignment

Sets the alignment of the firmware.

since: 1.6.0

###### fu_firmware_set_bytes

Sets the contents of the image if not created with fu_firmware_new_from_bytes().

since: 1.6.0

###### fu_firmware_set_filename

Sets an optional filename that represents the image source or destination.

since: 1.6.0

###### fu_firmware_set_id

No description available.

since: 1.6.0

###### fu_firmware_set_idx

Sets the index of the image which is used for ordering.

since: 1.6.0

###### fu_firmware_set_images_max

Sets the maximum number of images this container can hold.

since: 1.9.3

###### fu_firmware_set_offset

Sets the base offset of the image.

since: 1.6.0

###### fu_firmware_set_parent

Sets the parent. Only used internally.

since: 1.8.2

###### fu_firmware_set_size

Sets the total size of the image, which should be the same size as the data from fu_firmware_write().

since: 1.6.0

###### fu_firmware_set_size_max

Sets the maximum size of the image allowed during parsing. Implementations should query `fu_firmware_get_size_max()` during parsing when adding images to ensure the limit is not exceeded.

since: 1.9.7

###### fu_firmware_set_stream

Sets the input stream.

since: 2.0.0

###### fu_firmware_set_version

Sets an optional version that represents the firmware.

since: 1.3.3

###### fu_firmware_set_version_format

Sets the version format.

since: 2.0.0

###### fu_firmware_set_version_raw

Sets an raw version that represents the firmware.

since: 1.5.7

###### fu_firmware_to_string

This allows us to easily print the object.

since: 1.3.1

###### fu_firmware_tokenize

Tokenizes a firmware, typically breaking the firmware into records.

since: 2.0.0

###### fu_firmware_write

Writes a firmware, typically packing the images into a binary blob.

since: 1.3.1

###### fu_firmware_write_chunk

Gets a block of data from the image. If the contents of the image is smaller than the requested chunk size then the `GBytes` will be smaller than `chunk_sz_max`. Use `fu_bytes_pad()` if padding is required.

since: 1.6.0

###### fu_firmware_write_file

Writes a firmware, typically packing the images into a binary blob.

since: 1.3.3

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### FwupdPlugin.Firmware:parent

The firmware parent.

since: 1.8.2

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

since: 2.0

#### Class structure

    struct FwupdPluginFirmwareClass {
      GObjectClass parent_class;
      gboolean (* parse) (
        FuFirmware* self,
        GInputStream* stream,
        guint64 flags,
        GError** error
      );
      gboolean (* parse_full) (
        FuFirmware* self,
        GInputStream* stream,
        gsize offset,
        guint64 flags,
        GError** error
      );
      GByteArray* (* write) (
        FuFirmware* self,
        GError** error
      );
      void (* export) (
        FuFirmware* self,
        guint64 flags,
        XbBuilderNode* bn
      );
      gboolean (* tokenize) (
        FuFirmware* self,
        GInputStream* stream,
        guint64 flags,
        GError** error
      );
      gboolean (* build) (
        FuFirmware* self,
        XbNode* n,
        GError** error
      );
      gchar* (* get_checksum) (
        FuFirmware* self,
        GChecksumType csum_kind,
        GError** error
      );
      gboolean (* validate) (
        FuFirmware* self,
        GInputStream* stream,
        gsize offset,
        GError** error
      );
      gboolean (* check_compatible) (
        FuFirmware* self,
        FuFirmware* other,
        guint64 flags,
        GError** error
      );
      gchar* (* convert_version) (
        FuFirmware* self,
        guint64 version_raw
      );
      void (* add_magic) (
        FuFirmware* self
      );

    }

No description available.

###### Class members

`parent_class: GObjectClass`
  No description available.
`parse: gboolean (* parse) ( FuFirmware* self, GInputStream* stream, guint64 flags, GError** error )`
  No description available.
`parse_full: gboolean (* parse_full) ( FuFirmware* self, GInputStream* stream, gsize offset, guint64 flags, GError** error )`
  No description available.
`write: GByteArray* (* write) ( FuFirmware* self, GError** error )`
  No description available.
`export: void (* export) ( FuFirmware* self, guint64 flags, XbBuilderNode* bn )`
  No description available.
`tokenize: gboolean (* tokenize) ( FuFirmware* self, GInputStream* stream, guint64 flags, GError** error )`
  No description available.
`build: gboolean (* build) ( FuFirmware* self, XbNode* n, GError** error )`
  No description available.
`get_checksum: gchar* (* get_checksum) ( FuFirmware* self, GChecksumType csum_kind, GError** error )`
  No description available.
`validate: gboolean (* validate) ( FuFirmware* self, GInputStream* stream, gsize offset, GError** error )`
  No description available.
`check_compatible: gboolean (* check_compatible) ( FuFirmware* self, FuFirmware* other, guint64 flags, GError** error )`
  No description available.
`convert_version: gchar* (* convert_version) ( FuFirmware* self, guint64 version_raw )`
  No description available.
`add_magic: void (* add_magic) ( FuFirmware* self )`
  No description available.

#### Virtual methods

###### FwupdPlugin.FirmwareClass.add_magic

No description available.

since: 1.0

###### FwupdPlugin.FirmwareClass.build

Builds a firmware from an XML manifest. The manifest would typically have the following form:

since: 1.5.0

###### FwupdPlugin.FirmwareClass.check_compatible

Check a new firmware is compatible with the existing firmware.

since: 1.8.4

###### FwupdPlugin.FirmwareClass.convert_version

No description available.

since: 1.0

###### FwupdPlugin.FirmwareClass.export

This allows us to build an XML object for the nested firmware.

since: 1.6.0

###### FwupdPlugin.FirmwareClass.get_checksum

Returns a checksum of the payload data.

since: 1.6.0

###### FwupdPlugin.FirmwareClass.parse

No description available.

since: 1.0

###### FwupdPlugin.FirmwareClass.parse_full

No description available.

since: 1.0

###### FwupdPlugin.FirmwareClass.tokenize

Tokenizes a firmware, typically breaking the firmware into records.

since: 2.0.0

###### FwupdPlugin.FirmwareClass.validate

No description available.

since: 1.0

###### FwupdPlugin.FirmwareClass.write

No description available.

since: 1.0