-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Driver to existing Binary of specified GUID #12
base: main
Are you sure you want to change the base?
Conversation
1. Functions Introduction Functions: 1. Parse the input FV file into a origin binary tree. Currently, we just support FV level replacement operation, so we define two different types of tree nodes - FV/ FFS. 2. Given a new FFS file , parse the new FFS file into a new binary tree and get the new FFS Node from the new binary tree. 3. Find target FFS node from the origin binary tree with new FFS's driver guid. 4. Replace the target FFS node with New FFS node in the binary tree. 5. Encapsulate binary with replaced FFS. Design thoughts: A binary tree will be created for binary file to include all the info. The whole binary file will be seen as a Root Node of the tree. When parse the binary, the FV and FFS part will be seen as the FVNode/FFSNode which is the Child of the ROOT/FVNode. With the tree, both the structure and data of ROOT/FV/FFS... can be saved which can be used for function extensions. 2. Use method Method 1: Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs" (The file name can not be changed) into the XmlCli repo root folder. Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py". Then the expected output binary file "replaced_image.bin" will be generated into the root folder. Method 2: Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs"( with your own file name )into the XmlCli repo root folder. Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py -r $(input_binary_file) $(target_driver_ffs).ffs $(output_binary_file)". Then the expected output binary file $(output_binary_file) will be generated into the root folder. 3. Known Issue 3.1 Only support replace the first find driver ffs. 3.2 Only support replace the same guid driver ffs file. 3.3 The entry extension in xmlcli_registry_listener.py does not been complemented. 4. Extension direction 4.1 All the Known Issues can be enhanced with more details requirements descriptions. 4.2 The binary tree can be extended to save all level's FV and FFS and Section Node through binary parsing. 4.3 The existed binary Tree can be used to extend more functions like "Add a new driver / Delete a driver...". Signed-off-by: Yuwei Chen <[email protected]> Signed-off-by: Yuting Yang <[email protected]>
Update the Descriptions:
|
import json | ||
import shutil | ||
from collections import namedtuple | ||
|
||
sys.path.append(".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this method be working when installed module as Python package on system?
# -*- coding: utf-8 -*- | ||
|
||
# Built-in imports | ||
from collections import namedtuple |
Check notice
Code scanning / CodeQL
Unused import Note
) | ||
|
||
# parse bios image into a binary_tree | ||
bios_output_dict = uefi_parser.parse_binary() |
Check notice
Code scanning / CodeQL
Unused local variable Note test
bios_output_dict = uefi_parser.parse_binary() | ||
|
||
# parse driver ffs image into a binary tree node | ||
ffs_output_dict = newffs_parser.parse_binary() |
Check notice
Code scanning / CodeQL
Unused local variable Note test
) | ||
|
||
# parse bios image into a binary_tree | ||
bios_output_dict = uefi_parser.parse_binary() |
Check notice
Code scanning / CodeQL
Unused global variable Note
bios_output_dict = uefi_parser.parse_binary() | ||
|
||
# parse driver ffs image into a binary tree node | ||
ffs_output_dict = newffs_parser.parse_binary() |
Check notice
Code scanning / CodeQL
Unused global variable Note
log.result(self.stored_guids) | ||
return self.output | ||
|
||
def parse_firmware_volume(self, buffer, buffer_pointer, end_point, nesting_level=0, is_compressed=False, **kwargs): | ||
def parse_firmware_volume(self, buffer, buffer_pointer, end_point, par_tree_node=None, nesting_level=0, is_compressed=False, is_root_level=False, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to add new argument as suffix of function to maintain API function argument order
@@ -282,22 +297,30 @@ def parse_firmware_volume(self, buffer, buffer_pointer, end_point, nesting_level | |||
firmware_volume_header = fv.read_from(buffer) # read header structure from buffer | |||
log.debug("FV parsed...") | |||
|
|||
if (firmware_volume_header.HeaderLength - 56) // 8 != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is logic with numbers 56
and 8
?
@@ -19,8 +19,8 @@ | |||
from collections import OrderedDict | |||
|
|||
# Custom imports | |||
from .logger import log | |||
from .configurations import XMLCLI_CONFIG, ENCODING, XMLCLI_DIR, OUT_DIR, PY3, STATUS_CODE_RECORD_FILE | |||
from logger import log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it work when installed as python site package module?
@@ -0,0 +1,131 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file breaks PEP-8 naming convention guideline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to ensure below before merging changes:
- Follows naming convention as per PEP:8 guideline
- Should work when installed as pip module
- Can it be convenient if it can have modular API calls for operation of delete followed by update? so that same code flow be used as 2 features.
- In case need of command line implementation, entry point https://github.com/intel/xml-cli/blob/main/setup.cfg#L35 can be used
This Updates Driver with GUID from another binary to fulfil usecase where:
TODO:
|
Functions Introduction Functions:
Design thoughts:
A binary tree will be created for binary file to include all the info.
The whole binary file will be seen as a Root Node of the tree. When parse the binary, the FV and FFS part will be seen as the FVNode/FFSNode which is the Child of the ROOT/FVNode.
With the tree, both the structure and data of ROOT/FV/FFS... can be saved which can be used for function extensions.
Use method Method 1:$(input_binary_file) $ (target_driver_ffs).ffs $(output_binary_file)".
Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs" (The file name can not be changed) into the XmlCli repo root folder.
Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py".
Then the expected output binary file "replaced_image.bin" will be generated into the root folder.
Method 2:
Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs"( with your own file name )into the XmlCli repo root folder.
Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py -r
Then the expected output binary file $(output_binary_file) will be generated into the root folder.
Known Issue 3.1 Only support replace the first find driver ffs. 3.2 Only support replace the same guid driver ffs file. 3.3 The entry extension in xmlcli_registry_listener.py does not been complemented.
Extension direction 4.1 All the Known Issues can be enhanced with more details requirements descriptions. 4.2 The binary tree can be extended to save all level's FV and FFS and Section Node through binary parsing. 4.3 The existed binary Tree can be used to extend more functions like "Add a new driver / Delete a driver...".