FwupdPlugin.Firmware
Description: Reference for FwupdPlugin.Firmware

### Class

# FwupdPluginFirmware

#### Description [src]

    class FwupdPlugin.Firmware : GObject.Object {
      parent_instance: GObject
    }

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

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

#### Hierarchy

#### Ancestors

- GObject

#### Descendants

- FuArchiveFirmware
- FuCfuOffer
- FuCfuPayload
- FuCoswidFirmware
- FuDfuFirmware
- FuEfiFirmwareFile
- FuEfiFirmwareFilesystem
- FuEfiFirmwareSection
- FuEfiFirmwareVolume
- FuEfiSignature
- FuEfiSignatureList
- FuFdtFirmware
- FuFdtImage
- FuFmapFirmware
- FuIfdFirmware
- FuIfdImage
- FuIfwiCpdFirmware
- FuIfwiFptFirmware
- FuIhexFirmware
- FuIntelThunderboltNvm
- FuLinearFirmware
- FuOpromFirmware
- FuSmbios
- FuSrecFirmware
- FuUsbDeviceDs20
- FuUswidFirmware

#### Constructors

###### fu_firmware_new

Creates an empty firmware object.

Available since: 1.3.1

###### fu_firmware_new_from_bytes

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

Available since: 1.3.1

###### fu_firmware_new_from_gtypes

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

Available since: 1.5.6

#### Functions

###### fu_firmware_flag_from_string

Converts a string to a `FuFirmwareFlags`.

Available since: 1.5.0

###### fu_firmware_flag_to_string

Converts a `FuFirmwareFlags` to a string.

Available since: 1.5.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 from 0 to 0xffff.

Available 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 from 0 to 0xffffff.

Available 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 from 0 to 0xffffffff.

Available 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 from 0 to 0xf.

Available 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 from 0 to 0xff.

Available since: 1.5.6

#### Instance methods

###### fu_firmware_add_chunk

Adds a chunk to the image.

Available since: 1.6.0

###### fu_firmware_add_flag

Adds a specific firmware flag to the firmware.

Available since: 1.5.0

###### fu_firmware_add_image

Adds an image to the firmware.

Available since: 1.3.1

###### 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.

Available since: 1.7.4

###### fu_firmware_build

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

Available since: 1.5.0

###### fu_firmware_build_from_xml

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

Available since: 1.6.0

###### fu_firmware_check_compatible

Check a new firmware is compatible with the existing firmware.

Available since: 1.8.4

###### fu_firmware_export

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

Available since: 1.6.0

###### fu_firmware_export_to_xml

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

Available since: 1.6.0

###### fu_firmware_get_addr

Gets the base address of the image.

Available since: 1.6.0

###### fu_firmware_get_alignment

Gets the alignment of the firmware.

Available since: 1.6.0

###### fu_firmware_get_bytes

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

Available since: 1.6.0

###### fu_firmware_get_bytes_with_patches

Gets the firmware payload, with any defined patches applied.

Available since: 1.7.4

###### fu_firmware_get_checksum

Returns a checksum of the payload data.

Available since: 1.6.0

###### fu_firmware_get_chunks

Gets the optional image chunks.

Available since: 1.6.0

###### fu_firmware_get_filename

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

Available since: 1.6.0

###### fu_firmware_get_id

Gets the image ID, typically set at construction.

Available since: 1.6.0

###### fu_firmware_get_idx

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

Available 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.

Available since: 1.5.5

###### fu_firmware_get_image_by_id

Gets the firmware image using the image ID.

Available since: 1.3.1

###### fu_firmware_get_image_by_id_bytes

Gets the firmware image bytes using the image ID.

Available since: 1.3.1

###### fu_firmware_get_image_by_idx

Gets the firmware image using the image index.

Available since: 1.3.1

###### fu_firmware_get_image_by_idx_bytes

Gets the firmware image bytes using the image index.

Available since: 1.3.1

###### fu_firmware_get_images

Returns all the images in the firmware.

Available since: 1.3.1

###### fu_firmware_get_offset

Gets the base offset of the image.

Available since: 1.6.0

###### fu_firmware_get_parent

Gets the parent.

Available 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().

Available since: 1.6.0

###### fu_firmware_get_version

Gets an optional version that represents the firmware.

Available since: 1.3.3

###### 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.

Available since: 1.5.7

###### fu_firmware_has_flag

Finds if the firmware has a specific firmware flag.

Available since: 1.5.0

###### fu_firmware_parse

Parses a firmware, typically breaking the firmware into images.

Available since: 1.3.1

###### fu_firmware_parse_file

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

Available since: 1.3.3

###### fu_firmware_parse_full

Parses a firmware, typically breaking the firmware into images.

Available since: 1.8.2

###### fu_firmware_remove_image

Remove an image from the firmware.

Available since: 1.5.0

###### fu_firmware_remove_image_by_id

Removes the first image from the firmware matching the ID.

Available since: 1.5.0

###### fu_firmware_remove_image_by_idx

Removes the first image from the firmware matching the index.

Available since: 1.5.0

###### fu_firmware_set_addr

Sets the base address of the image.

Available since: 1.6.0

###### fu_firmware_set_alignment

Sets the alignment of the firmware.

Available since: 1.6.0

###### fu_firmware_set_bytes

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

Available since: 1.6.0

###### fu_firmware_set_filename

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

Available since: 1.6.0

###### fu_firmware_set_id

No description available.

Available since: 1.6.0

###### fu_firmware_set_idx

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

Available since: 1.6.0

###### fu_firmware_set_offset

Sets the base offset of the image.

Available since: 1.6.0

###### fu_firmware_set_parent

Sets the parent. Only used internally.

Available 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().

Available since: 1.6.0

###### fu_firmware_set_version

Sets an optional version that represents the firmware.

Available since: 1.3.3

###### fu_firmware_set_version_raw

Sets an raw version that represents the firmware.

Available since: 1.5.7

###### fu_firmware_to_string

This allows us to easily print the object.

Available since: 1.3.1

###### fu_firmware_tokenize

Tokenizes a firmware, typically breaking the firmware into records.

Available since: 1.3.2

###### fu_firmware_write

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

Available 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.

Available since: 1.6.0

###### fu_firmware_write_file

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

Available 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.

Available since: 1.8.2

#### Signals

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

###### GObject.Object::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.

#### Class structure

    struct FwupdPluginFirmwareClass {
      GObjectClass parent_class;
      gboolean (* parse) (
        FuFirmware* self,
        GBytes* fw,
        gsize offset,
        FwupdInstallFlags flags,
        GError** error
      );
      GBytes* (* write) (
        FuFirmware* self,
        GError** error
      );
      void (* export) (
        FuFirmware* self,
        FuFirmwareExportFlags flags,
        XbBuilderNode* bn
      );
      gboolean (* tokenize) (
        FuFirmware* self,
        GBytes* fw,
        FwupdInstallFlags flags,
        GError** error
      );
      gboolean (* build) (
        FuFirmware* self,
        XbNode* n,
        GError** error
      );
      gchar* (* get_checksum) (
        FuFirmware* self,
        GChecksumType csum_kind,
        GError** error
      );
      gboolean (* check_magic) (
        FuFirmware* self,
        GBytes* fw,
        gsize offset,
        GError** error
      );
      gboolean (* check_compatible) (
        FuFirmware* self,
        FuFirmware* other,
        FwupdInstallFlags flags,
        GError** error
      );

    }

###### Class members

`parent_class` |
    GObjectClass
| No description available.
`parse` |
    gboolean (* parse) (
        FuFirmware* self,
        GBytes* fw,
        gsize offset,
        FwupdInstallFlags flags,
        GError** error
      )
| No description available.
`write` |
    GBytes* (* write) (
        FuFirmware* self,
        GError** error
      )
| No description available.
`export` |
    void (* export) (
        FuFirmware* self,
        FuFirmwareExportFlags flags,
        XbBuilderNode* bn
      )
| No description available.
`tokenize` |
    gboolean (* tokenize) (
        FuFirmware* self,
        GBytes* fw,
        FwupdInstallFlags 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.
`check_magic` |
    gboolean (* check_magic) (
        FuFirmware* self,
        GBytes* fw,
        gsize offset,
        GError** error
      )
| No description available.
`check_compatible` |
    gboolean (* check_compatible) (
        FuFirmware* self,
        FuFirmware* other,
        FwupdInstallFlags flags,
        GError** error
      )
| No description available.

#### Virtual methods

###### FwupdPlugin.FirmwareClass.build

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

Available since: 1.5.0

###### FwupdPlugin.FirmwareClass.check_compatible

Check a new firmware is compatible with the existing firmware.

Available since: 1.8.4

###### FwupdPlugin.FirmwareClass.check_magic

No description available.

###### FwupdPlugin.FirmwareClass.export

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

Available since: 1.6.0

###### FwupdPlugin.FirmwareClass.get_checksum

Returns a checksum of the payload data.

Available since: 1.6.0

###### FwupdPlugin.FirmwareClass.parse

No description available.

###### FwupdPlugin.FirmwareClass.tokenize

Tokenizes a firmware, typically breaking the firmware into records.

Available since: 1.3.2

###### FwupdPlugin.FirmwareClass.write

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

Available since: 1.3.1