You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+185
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,27 @@ UFFAF allows firmware modification as an efficient operation with scriptable app
6
6
7
7
These reference scripts provides several capabilities including but not limited to:
8
8
>- Parsing Information of UEFI BIOS Firmware as per [Platform Initialization Specification](https://uefi.org/specs/PI/1.8/)
9
+
>- Programming/Reading BIOS knobs with CLI and GUI
10
+
>- Fetching Platform XML from target
11
+
>- System information
12
+
>- CommandLine and web based GUI support for get and set NVAR (UEFI NVRAM variable)
9
13
>- Context Menu Integration for Windows
10
14
15
+
These scripts are generic and platform/program independent (as long as BIOS on SUT BIOS supports XML CLI interface).
11
16
12
17
---
13
18
14
19
## User Guidelines for usage
15
20
21
+
These scripts are provided as reference scripts and requires to have bios driver enabled in order to use the functionality.
22
+
23
+
As scripts require to read/write memory of the target device/system, valid access interface would be required which can be configured at [config file](src/xmlcli/xmlcli.config).
24
+
16
25
For Offline Binary modification, these scripts provide easier way to interpret and update the data bytes of binary.
17
26
Irrespective of these scripts, changing undesired data in binary could be result to unexpected behavior hence, it is individual's responsibility to make sure to use valid configuration.
18
27
28
+
As Accessing target SUT is only possible at **Elevated Privilege**, we recommend proceeding with caution if service API of these scripts are exposed over network.
29
+
19
30
## Supported Interface Types
20
31
21
32
Interface means the way to access memory and I/O of target system.
@@ -24,13 +35,15 @@ These interface works only when running with elevated privileges are available.
24
35
It is responsibility of user to make sure to act with caution before making modification to avoid
25
36
corrupting memory/registers with unwanted data.
26
37
38
+
27
39
- Windows
28
40
- LINUX
29
41
- Offline mode (or stub mode, to enable BIOS/IFWI Editing)
30
42
31
43
## Prerequisites
32
44
33
45
-[Python](https://www.python.org/downloads/) software version 3.6 or above
46
+
- If running on Online mode; **elevated privileges** are required to execute commands as it involves accessing hardware memory resource.
34
47
- For Interface setup please refer README document within interface folder itself.
Refer [Installation-Steps](docs/user_guide/installation.md) for more alternate installation instruction.
51
64
65
+
66
+
## Setting Interface Type
67
+
68
+
Need to select the interface to indicate the scripts on which access method to use (depending on which environment we expect the script to operate in).
69
+
70
+
```python
71
+
from xmlcli import XmlCli as cli
72
+
cli.clb._setCliAccess("<access-method>")
73
+
```
74
+
75
+
Below are listed valid `<access-method>`:
76
+
77
+
| Access Method | Remarks |
78
+
| --- | --- |
79
+
|`linux`| For using linux as interface, need to open Python Prompt in root permissions. |
80
+
|`winrwe`| For using `RW.exe` as Windows interface (**slow**, least recommended). For more details refer [winrwe/README.md](src/xmlcli/access/winrwe/README.md)|
81
+
82
+
83
+
## Running popular commands
84
+
85
+
After initializing the desired interface, the use may run following commands.
86
+
87
+
If the commands `return 0`, it means the operation was `successful`, else there was an error.
88
+
89
+
### Standard import steps
90
+
91
+
```python
92
+
from xmlcli import XmlCli as cli
93
+
cli.clb._setCliAccess("linux") # Set desired Interface (for example `linux` if using on `linux` SUT)
94
+
```
95
+
96
+
### Step to check XmlCli capability on current System
97
+
98
+
```python
99
+
from xmlcli import XmlCli as cli
100
+
cli.clb.ConfXmlCli() # Check if XmlCli is supported &/ Enabled on the current system.
101
+
```
102
+
103
+
| Return value of `cli.clb.ConfXmlCli`| Meaning |
104
+
| --- | --- |
105
+
| 0 | XmlCli is already **supported & enabled**. |
106
+
| 1 | XmlCli is **not supported** on the current BIOS or the System BIOS has not completed Boot. |
107
+
| 2 | XmlCli is **supported** but was **not enabled**, the script has now enabled it and **SUT needs reboot** to make use of XmlCli. |
108
+
109
+
### To Save Target XML file
110
+
111
+
```python
112
+
from xmlcli import XmlCli as cli
113
+
# For Online
114
+
# Run common import steps and make sure `cli.clb.ConfXmlCli()` returns `0`
115
+
cli.savexml() # Save Target XML as `<Path_To_XmlCliRefScripts>/out/PlatformConfig.xml` file.
116
+
cli.savexml(r"path/to/file.xml") # Save Target XML as absolute file location for `path/to/file.xml`.
117
+
118
+
# For Offline
119
+
cli.savexml(0, r"path/to/ifwi-or-bios.bin") # Extract the XML data from desired BIOS or IFWI binary. Will Save Target XML in `<Path_To_XmlCliRefScripts>/out/` folder.
120
+
cli.savexml(r"path/to/file.xml", r"path/to/ifwi-or-bios.bin") # Extract the XML data from desired BIOS or IFWI binary. Will Save Target XML as `path/to/file.xml`.
121
+
```
122
+
123
+
### To Read BIOS settings
124
+
125
+
> For **Online** command to run successfully, the target must complete BIOS boot.
126
+
> For **Offline** mode, you need to pass the link to BIOS or IFWI binary.
127
+
128
+
-`Knob_A` & `Knob_B` in the below examples are the knob names taken from the `name` attribute from the `<biosknobs>` section in the XML, it is **case sensitive**.
129
+
130
+
```python
131
+
from xmlcli import XmlCli as cli
132
+
cli.CvReadKnobs("Knob_A=Val_1, Knobs_B=Val_2") # Reads the desired Knob_A & Knob_B settings from the SUT and verifies them against Val_1 & Val_2 respectively.
133
+
cli.CvReadKnobs() # same as above, just that the Knob entries will be read from the default cfg file (`<Path_To_XmlCliRefScripts>/cfg/BiosKnobs.ini`).
134
+
# For Offline
135
+
cli.CvReadKnobs("Knob_A=Val_1, Knobs_B=Val_2", r"path/to/ifwi-or-bios.bin") # Reads & verifies the desired knob settings from the given BIOS or IFWI binary.
136
+
cli.CvReadKnobs(0, r"path/to/ifwi-or-bios.bin") # same as above, just that the Knob entries will be read from the `cli.clb.KnobsIniFile` cfg file instead.
137
+
138
+
# the default cfg file pointer can be programed to desired cfg file via following command.
139
+
cli.clb.KnobsIniFile =r"path/to/bios-config.ini"
140
+
```
141
+
142
+
### To Program BIOS settings
143
+
144
+
> For **Online** command to run successfully, the target must complete BIOS boot.
145
+
> For **Offline** mode, you need to pass the link to BIOS or IFWI binary.
146
+
147
+
-`Knob_A` & `Knob_B` in the below examples are the knob names taken from the `name` attribute from the `<biosknobs>` section in the XML, it is **case sensitive**.
148
+
149
+
```python
150
+
from xmlcli import XmlCli as cli
151
+
cli.CvProgKnobs("Knob_A=Val_1, Knobs_B=Val_2") # Programs the desired Knob_A & Knob_B settings on the SUT and verifies them against Val_1 & Val_2 respectively.
152
+
cli.CvProgKnobs() # same as above, just that the Knob entries will be Programed from the default cfg file (<Path_To_XmlCliRefScripts>\cfg\BiosKnobs.ini).
153
+
# For Offline
154
+
cli.CvProgKnobs("Knob_A=Val_1, Knobs_B=Val_2", r"path/to/ifwi-or-bios.bin") # Program the desired knob settings as new default value, operates on BIOS or IFWI binary, new BIOS or IFWI binary will be generated with desired settings.
155
+
cli.CvProgKnobs(0, r"path/to/ifwi-or-bios.bin") # same as above, just that the Knob entries will be Programed from the cli.clb.KnobsIniFile cfg file instead.
156
+
157
+
# the default cfg file pointer can be programed to desired cfg file via following command.
158
+
cli.clb.KnobsIniFile =r"path/to/bios-config.ini"
159
+
160
+
# To Load Default BIOS settings on the SUT. Offline mode not supported or not Applicable.
161
+
cli.CvLoadDefaults() # Loads/Restores the default value back on the system, also shows which values were restored back to its default Value.
162
+
```
163
+
164
+
### To Program only desired BIOS settings and reverting rest all settings back to its default value
165
+
166
+
> **Offline** mode not supported or not Applicable.
167
+
168
+
-`Knob_A` & `Knob_B` in the below examples are the knob names taken from the `name` attribute from the `<biosknobs>` section in the XML, it is **case sensitive**.
169
+
170
+
```python
171
+
from xmlcli import XmlCli as cli
172
+
cli.CvRestoreModifyKnobs("Knob_A=Val_1, Knobs_B=Val_2") # Programs the desired Knob_A & Knob_B settings and restores everything else back to its default value.
173
+
cli.CvRestoreModifyKnobs() # same as above, just that the Knob entries will be Programed from the cli.clb.KnobsIniFile cfg file instead.
174
+
# the default cfg file pointer can be programed to desired cfg file via following command.
175
+
cli.clb.KnobsIniFile =r"path/to/bios-config.ini"
176
+
```
177
+
178
+
> Offline editing of BIOS will update FV_BB section of BIOS.
179
+
> This is an expected to produce boot issue with Secure Boot profiles (i.e. Secure Profile images)
180
+
181
+
To make sure offline Edited BIOSes for Knob changes boot fine with Secure Profile IFWI's,
182
+
user need to supply the re-signing script/pkg. This is user's full responsibility to manage an executable script
cli.fwp.SecureProfileEditing =True# if not set to True, Re-Signing Process will be skipped
193
+
cli.fwp.ReSigningFile =r'path/to/resigning/executable/ResignIbbForBtG.bat'# by default this variable is empty, please populate this variable with Re-Signing Script File Ptr
0 commit comments