summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/FirmwareStorageFormat
AgeCommit message (Collapse)AuthorFilesLines
4 daysBaseTools/FirmwareStorageFormat: Fix FV ext entry struct factory functionsMichael D Kinney1-2/+2
The Refine_FV_EXT_ENTRY_OEM_TYPE_Header() and Refine_FV_EXT_ENTRY_GUID_TYPE_Header() functions incorrectly return an instantiation attempt of the local class with `Structure` as an argument (e.g., `return ClassName(Structure)`) instead of returning the class itself (e.g., `return ClassName`). This causes FMMT to fail with: "expected EFI_FIRMWARE_VOLUME_EXT_ENTRY instance, got _ctypes.PyCStructType" When processing FVs that contain ext header entries of type 0x01 (OEM Type) or type 0x02 (GUID Type, used for FV UI Name when FvNameString = TRUE). Fix by returning the class directly, matching the pattern used by Refine_FV_Header() which correctly returns the class for subsequent .from_buffer_copy() calls. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-11-24BaseTools: Enable FMMT Rebase functionYuwei Chen4-0/+954
This patch adds and improves the rebase functionality for firmware images (PE/COFF/TE) in the FMMT tool. Key features include: 1.Automatically rebases PE/COFF/TE images within FFS files when the firmware volume (FV) layout is adjusted or FFS files are moved, ensuring correct loading and execution at new addresses. 2.Implements recursive rebase logic for nested sections, guaranteeing all relevant images are properly relocated. 3.Adds support for rebasing subsequent FFS files within the same FV, enhancing compatibility and stability during firmware layout changes. 4.Core code changes are mainly in FvHandler.py, BiosTreeNode.py, and BinaryFactoryProduct.py, covering rebase flag detection, address calculation, and actual relocation operations. 5.This feature improves the flexibility of firmware space management and enhances the automation and reliability of the FMMT tool. Co-Auther: Ashraf Ali S <ashraf.ali.s@intel.com> Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
2025-10-21BaseTools:Remove deprecated ast.Str import for Python 3.14 compatibilityAshraf Ali S1-1/+0
- Str is not being used in FvHeader.py - Removed import of ast.Str as it was removed in Python 3.14. - Ensures compatibility with Python 3.14 and later. - https://docs.python.org/3/whatsnew/3.14.html#id9 This addresses ImportError caused by removal of deprecated AST classes including ast.Str. Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
2023-12-11BaseTools: FMMT support ELF UPLD parserYuwei Chen1-0/+244
FMMT add new function to support the .elf file parsing. Using '-v' option, the UPLD info will be printed out. ''' - UNIVERSAL_PAYLOAD_INFO - 4 bytes align (BOOLEAN) - Identifier - SpecRevision - Attribute - Revision - Capability - ProducerId - ImageId UPLD Buffer ''' Cc: Rebecca Cran <rebecca@bsdio.com> Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Yuwei Chen <yuwei.chen@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
2022-05-06BaseTools: Add FMMT Python ToolChen, Christine5-0/+379
The FMMT python tool is used for firmware files operation, which has the Fv/FFs-based 'View'&'Add'&'Delete'&'Replace' operation function: 1.Parse a FD(Firmware Device) / FV(Firmware Volume) / FFS(Firmware Files) 2.Add a new FFS into a FV file (both included in a FD file or not) 3.Replace an FFS in a FV file with a new FFS file 4.Delete an FFS in a FV file (both included in a FD file or not) 5.Extract the FFS from a FV file (both included in a FD file or not) This version of FMMT Python tool does not support PEIM rebase feature, this feature will be added in future update. Currently the FMMT C tool is saved in edk2-staging repo, but its quality and coding style can't meet the Edk2 quality, which is hard to maintain (Hard/Duplicate Code; Regression bugs; Restrict usage). The new Python version keeps same functions with origin C version. It has higher quality and better coding style, and it is much easier to extend new functions and to maintain. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1847 RFC Link: https://edk2.groups.io/g/devel/message/82877 Staging Link: https://github.com/tianocore/edk2-staging/tree/PyFMMT Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Yuwei Chen <yuwei.chen@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com> Acked-by: Liming Gao <gaoliming@byosoft.com.cn>