programmer-core 1.0.29__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- programmer_core/__init__.py +22 -0
- programmer_core/activate_device.py +246 -0
- programmer_core/adapters.py +23 -0
- programmer_core/constants.py +50 -0
- programmer_core/debug_device.py +278 -0
- programmer_core/detect_flash_type.py +316 -0
- programmer_core/enter_rma.py +264 -0
- programmer_core/factory_program_device.py +667 -0
- programmer_core/full_flash_erase.py +268 -0
- programmer_core/get_fuse_data.py +277 -0
- programmer_core/memory_validation_test.py +357 -0
- programmer_core/partial_fuse_programming.py +342 -0
- programmer_core/program_device.py +775 -0
- programmer_core/query_device.py +274 -0
- programmer_core/report.py +921 -0
- programmer_core/utility.py +1822 -0
- programmer_core-1.0.29.dist-info/METADATA +146 -0
- programmer_core-1.0.29.dist-info/RECORD +20 -0
- programmer_core-1.0.29.dist-info/WHEEL +5 -0
- programmer_core-1.0.29.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
from os.path import join, isfile
|
|
2
|
+
import logging
|
|
3
|
+
import json
|
|
4
|
+
import pathlib
|
|
5
|
+
|
|
6
|
+
from flash_images_builder_core import (
|
|
7
|
+
PsramOption,
|
|
8
|
+
FIBUtility,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
from utility import (
|
|
13
|
+
ProgrammerUtility,
|
|
14
|
+
AUTHENTICATION_BYPASS_FILES_FOLDER_NAME,
|
|
15
|
+
ACTION_PARAMS,
|
|
16
|
+
)
|
|
17
|
+
from program_device import ProgramDevice
|
|
18
|
+
except ImportError:
|
|
19
|
+
from .utility import (
|
|
20
|
+
ProgrammerUtility,
|
|
21
|
+
AUTHENTICATION_BYPASS_FILES_FOLDER_NAME,
|
|
22
|
+
ACTION_PARAMS,
|
|
23
|
+
)
|
|
24
|
+
from .program_device import ProgramDevice
|
|
25
|
+
|
|
26
|
+
FULL_FLASH_ERASE_LOGGER = logging.getLogger("full-flash-erase")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class FullFlashErase:
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
interface_type,
|
|
33
|
+
serial_number,
|
|
34
|
+
flash_type,
|
|
35
|
+
activation_type,
|
|
36
|
+
signing_module,
|
|
37
|
+
device_type,
|
|
38
|
+
verbose,
|
|
39
|
+
programmer_artifacts_path,
|
|
40
|
+
fib_artifacts_path,
|
|
41
|
+
psram_type=PsramOption.NO_PSRAM.name,
|
|
42
|
+
enable_ota=False,
|
|
43
|
+
nvs_size=None,
|
|
44
|
+
key_storage_size=None,
|
|
45
|
+
vendor_specific_size=None,
|
|
46
|
+
bl2_size=None,
|
|
47
|
+
wsoc_size=None,
|
|
48
|
+
tclk_delay=4,
|
|
49
|
+
chunk_size=1085,
|
|
50
|
+
):
|
|
51
|
+
self.device_type = device_type
|
|
52
|
+
self.interface_type = interface_type
|
|
53
|
+
self.serial_number = serial_number
|
|
54
|
+
self.flash_type = flash_type
|
|
55
|
+
self.verbose = verbose
|
|
56
|
+
self.enable_ota = enable_ota
|
|
57
|
+
self.psram_type = psram_type
|
|
58
|
+
self.activation_type = activation_type
|
|
59
|
+
self.signing_module = signing_module
|
|
60
|
+
|
|
61
|
+
self.tclk_delay = tclk_delay
|
|
62
|
+
self.chunk_size = chunk_size
|
|
63
|
+
|
|
64
|
+
self.nvs_size = nvs_size
|
|
65
|
+
self.key_storage_size = key_storage_size
|
|
66
|
+
self.vendor_specific_size = vendor_specific_size
|
|
67
|
+
self.bl2_size = bl2_size
|
|
68
|
+
self.wsoc_size = wsoc_size
|
|
69
|
+
|
|
70
|
+
self.prog_dir = programmer_artifacts_path
|
|
71
|
+
self.fib_dir = fib_artifacts_path
|
|
72
|
+
self.prog_utility = ProgrammerUtility(self.prog_dir, self.fib_dir)
|
|
73
|
+
self.fib_utility = FIBUtility(self.fib_dir)
|
|
74
|
+
self.tmp_folder = self.prog_utility.get_programming_tmp_folder()
|
|
75
|
+
self.jsons_dir_path = self.prog_utility.get_config_folder()
|
|
76
|
+
self.tool_settings_json_template = (
|
|
77
|
+
self.prog_utility.get_tool_settings_template()
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
self.updated_tool_settings_json = join(self.tmp_folder, "tool_settings.json")
|
|
81
|
+
|
|
82
|
+
self.action_request_json_template = (
|
|
83
|
+
self.prog_utility.get_action_params_template()
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
self.updated_action_request_json = join(self.tmp_folder, ACTION_PARAMS)
|
|
87
|
+
|
|
88
|
+
# Get limits for default values
|
|
89
|
+
limits = self.fib_utility.get_limits_by_flash_device_name(
|
|
90
|
+
self.flash_type, self.enable_ota
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
if self.nvs_size is None:
|
|
94
|
+
self.nvs_size = limits["protected_storage"]["nvsSize"]["default"]
|
|
95
|
+
if self.key_storage_size is None:
|
|
96
|
+
self.key_storage_size = limits["protected_storage"]["keyStorageSize"][
|
|
97
|
+
"default"
|
|
98
|
+
]
|
|
99
|
+
if self.vendor_specific_size is None:
|
|
100
|
+
self.vendor_specific_size = limits["protected_storage"]["vendorSize"]["default"]
|
|
101
|
+
if self.bl2_size is None:
|
|
102
|
+
self.bl2_size = limits["ti_components"]["bl2_size"]["default"]
|
|
103
|
+
if self.wsoc_size is None:
|
|
104
|
+
self.wsoc_size = limits["ti_components"]["wsoc_size"]["default"]
|
|
105
|
+
|
|
106
|
+
ext_flash_dir_path = self.fib_utility.get_ext_flash_dir_path()
|
|
107
|
+
# move flash jsons files to tmp folder
|
|
108
|
+
self.xspi_json, self.otfde_json, self.ext_mem_json = (
|
|
109
|
+
self.prog_utility.move_flash_json_files(
|
|
110
|
+
flash_type_files_folder=ext_flash_dir_path,
|
|
111
|
+
flash_device=self.flash_type,
|
|
112
|
+
enable_ota=self.enable_ota,
|
|
113
|
+
)
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if (
|
|
117
|
+
not isfile(self.xspi_json)
|
|
118
|
+
or not isfile(self.otfde_json)
|
|
119
|
+
or not isfile(self.ext_mem_json)
|
|
120
|
+
):
|
|
121
|
+
raise Exception(f"Some JSONs are missing for Flash Device {flash_type}")
|
|
122
|
+
|
|
123
|
+
# modify jsons by user parameters
|
|
124
|
+
self.ext_mem_json, self.otfde_json, self.xspi_json = (
|
|
125
|
+
self.fib_utility.update_flash_configuration_files(
|
|
126
|
+
ext_mem_json_path=self.ext_mem_json,
|
|
127
|
+
otfde_json_path=self.otfde_json,
|
|
128
|
+
xspi_json_path=self.xspi_json,
|
|
129
|
+
nvs_size_kb=self.nvs_size,
|
|
130
|
+
ks_size_kb=self.key_storage_size,
|
|
131
|
+
vs_size_kb=self.vendor_specific_size,
|
|
132
|
+
bl2_size_kb=self.bl2_size,
|
|
133
|
+
wsoc_size_kb=self.wsoc_size,
|
|
134
|
+
device_type=self.device_type,
|
|
135
|
+
psram_type=self.psram_type,
|
|
136
|
+
ota_enabled=self.enable_ota,
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
if (
|
|
140
|
+
not isfile(self.xspi_json)
|
|
141
|
+
or not isfile(self.otfde_json)
|
|
142
|
+
or not isfile(self.ext_mem_json)
|
|
143
|
+
):
|
|
144
|
+
raise Exception(f"Some Modify JSONs are missing")
|
|
145
|
+
|
|
146
|
+
fuse_json_name = self.prog_utility.get_fuse_json_name(self.device_type)
|
|
147
|
+
self.fuse_conf_json = join(
|
|
148
|
+
self.jsons_dir_path,
|
|
149
|
+
AUTHENTICATION_BYPASS_FILES_FOLDER_NAME,
|
|
150
|
+
fuse_json_name,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
def _build_action_request_image(self):
|
|
154
|
+
with open(self.action_request_json_template, "r") as f:
|
|
155
|
+
action_params = json.load(f)
|
|
156
|
+
|
|
157
|
+
action_params_prog_req_content = action_params["programming"]["payload_param"][
|
|
158
|
+
"payload"
|
|
159
|
+
]["prog_req_content"]
|
|
160
|
+
|
|
161
|
+
action_params_prog_req_content["flash_factory_reset"] = True
|
|
162
|
+
action_params_prog_req_content["boot_sector"] = False
|
|
163
|
+
action_params_prog_req_content["primary_tbl"] = False
|
|
164
|
+
action_params_prog_req_content["secondary_tbl"] = False
|
|
165
|
+
action_params_prog_req_content["primary_vendor_image"] = False
|
|
166
|
+
action_params_prog_req_content["secondary_vendor_image"] = False
|
|
167
|
+
action_params_prog_req_content["secondary_ti_wsoc"] = False
|
|
168
|
+
action_params_prog_req_content["primary_ti_wsoc"] = False
|
|
169
|
+
action_params_prog_req_content["protected_storage"] = False
|
|
170
|
+
|
|
171
|
+
with open(self.updated_action_request_json, "w") as f:
|
|
172
|
+
json.dump(action_params, f, indent=4)
|
|
173
|
+
|
|
174
|
+
# Build action params
|
|
175
|
+
action_req_out_path, action_req_to_sign_out_path = (
|
|
176
|
+
self.prog_utility.build_action_request_image(
|
|
177
|
+
params_json=self.updated_action_request_json,
|
|
178
|
+
type="programming",
|
|
179
|
+
dir_out_path=self.tmp_folder,
|
|
180
|
+
device=self.device_type,
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
signed_action_req_out_path = self.prog_utility.sign_action_request_image(
|
|
185
|
+
unsign_request=action_req_out_path,
|
|
186
|
+
forsign_request=action_req_to_sign_out_path,
|
|
187
|
+
activation_type=self.activation_type,
|
|
188
|
+
signing_module=self.signing_module,
|
|
189
|
+
dir_out_path=self.tmp_folder,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
return signed_action_req_out_path
|
|
193
|
+
|
|
194
|
+
def _build_programming_inst_image(self):
|
|
195
|
+
programming_unsign_image_path, programming_forsign_image_path = (
|
|
196
|
+
self.prog_utility.build_programming_image(
|
|
197
|
+
version="0.0.1.0",
|
|
198
|
+
pub_key_path=None,
|
|
199
|
+
activation_type=self.activation_type,
|
|
200
|
+
dir_out_path=self.tmp_folder,
|
|
201
|
+
fuses_programming_instructions=self.fuse_conf_json,
|
|
202
|
+
flash_discovery_config_xspi=self.xspi_json,
|
|
203
|
+
flash_discovery_config_otfde=self.otfde_json,
|
|
204
|
+
flash_discovery_config_ext_mem=self.ext_mem_json,
|
|
205
|
+
device=self.device_type,
|
|
206
|
+
)
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
signed_programming_image_path = self.prog_utility.sign_programming_image(
|
|
210
|
+
programming_unsign_image=programming_unsign_image_path,
|
|
211
|
+
programming_forsign_image=programming_forsign_image_path,
|
|
212
|
+
activation_type=self.activation_type,
|
|
213
|
+
signing_module=self.signing_module,
|
|
214
|
+
dir_out_path=self.tmp_folder,
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
return signed_programming_image_path
|
|
218
|
+
|
|
219
|
+
def _update_tool_settings(self, action_req_path, programming_instructions_path):
|
|
220
|
+
tool_settings = json.load(open(self.tool_settings_json_template, "r"))
|
|
221
|
+
programming_debug_and_ota_signed_components = tool_settings[
|
|
222
|
+
"programming_debug_and_ota_signed_components"
|
|
223
|
+
]
|
|
224
|
+
|
|
225
|
+
# Update paths in tool_settings
|
|
226
|
+
programming_debug_and_ota_signed_components["actions_req_paths"][
|
|
227
|
+
"programming"
|
|
228
|
+
] = str(action_req_path)
|
|
229
|
+
programming_debug_and_ota_signed_components["programming_instructions"] = str(
|
|
230
|
+
programming_instructions_path
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
with open(self.updated_tool_settings_json, "w") as f:
|
|
234
|
+
json.dump(tool_settings, f, indent=4)
|
|
235
|
+
|
|
236
|
+
def erase_flash(self):
|
|
237
|
+
# Build action request and programming instructions images
|
|
238
|
+
signed_action_req_out_path = self._build_action_request_image()
|
|
239
|
+
programming_instructions_path = self._build_programming_inst_image()
|
|
240
|
+
|
|
241
|
+
# Create tool_settings
|
|
242
|
+
self._update_tool_settings(
|
|
243
|
+
action_req_path=signed_action_req_out_path,
|
|
244
|
+
programming_instructions_path=programming_instructions_path,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
# Program the device with the created tool_settings
|
|
248
|
+
programmer = ProgramDevice(
|
|
249
|
+
interface_type=self.interface_type,
|
|
250
|
+
serial_number=self.serial_number,
|
|
251
|
+
tool_settings=self.updated_tool_settings_json,
|
|
252
|
+
device_type=self.device_type,
|
|
253
|
+
report_file_path=(
|
|
254
|
+
pathlib.Path(self.tmp_folder) / "erase_programming_report.txt"
|
|
255
|
+
),
|
|
256
|
+
programmer_artifacts_path=self.prog_dir,
|
|
257
|
+
fib_artifacts_path=self.fib_dir,
|
|
258
|
+
verbose=self.verbose,
|
|
259
|
+
tclk_delay=self.tclk_delay,
|
|
260
|
+
chunk_size=self.chunk_size,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
if not programmer.program():
|
|
264
|
+
FULL_FLASH_ERASE_LOGGER.info("Full flash erase failed")
|
|
265
|
+
return False
|
|
266
|
+
else:
|
|
267
|
+
FULL_FLASH_ERASE_LOGGER.info("Full flash erase ended successfully")
|
|
268
|
+
return True
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
from os.path import join, isfile
|
|
2
|
+
import logging
|
|
3
|
+
import json
|
|
4
|
+
import pathlib
|
|
5
|
+
|
|
6
|
+
from flash_images_builder_core import (
|
|
7
|
+
PsramOption,
|
|
8
|
+
FIBUtility,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
from utility import (
|
|
13
|
+
ProgrammerUtility,
|
|
14
|
+
FUSE_PROG_NAME_CC35XXE,
|
|
15
|
+
AUTHENTICATION_BYPASS_FILES_FOLDER_NAME,
|
|
16
|
+
ACTION_PARAMS,
|
|
17
|
+
)
|
|
18
|
+
from program_device import ProgramDevice
|
|
19
|
+
except ImportError:
|
|
20
|
+
from .utility import (
|
|
21
|
+
ProgrammerUtility,
|
|
22
|
+
FUSE_PROG_NAME_CC35XXE,
|
|
23
|
+
AUTHENTICATION_BYPASS_FILES_FOLDER_NAME,
|
|
24
|
+
ACTION_PARAMS,
|
|
25
|
+
)
|
|
26
|
+
from .program_device import ProgramDevice
|
|
27
|
+
|
|
28
|
+
GET_FUSE_DATA_LOGGER = logging.getLogger("get-fuse-data")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class GetFuseData:
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
interface_type,
|
|
35
|
+
serial_number,
|
|
36
|
+
flash_type,
|
|
37
|
+
activation_type,
|
|
38
|
+
signing_module,
|
|
39
|
+
device_type,
|
|
40
|
+
verbose,
|
|
41
|
+
programmer_artifacts_path,
|
|
42
|
+
fib_artifacts_path,
|
|
43
|
+
psram_type=PsramOption.NO_PSRAM.name,
|
|
44
|
+
enable_ota=False,
|
|
45
|
+
nvs_size=None,
|
|
46
|
+
key_storage_size=None,
|
|
47
|
+
vendor_specific_size=None,
|
|
48
|
+
bl2_size=None,
|
|
49
|
+
wsoc_size=None,
|
|
50
|
+
tclk_delay=4,
|
|
51
|
+
chunk_size=1085,
|
|
52
|
+
):
|
|
53
|
+
self.device_type = device_type
|
|
54
|
+
self.interface_type = interface_type
|
|
55
|
+
self.serial_number = serial_number
|
|
56
|
+
self.flash_type = flash_type
|
|
57
|
+
self.verbose = verbose
|
|
58
|
+
self.enable_ota = enable_ota
|
|
59
|
+
self.psram_type = psram_type
|
|
60
|
+
self.activation_type = activation_type
|
|
61
|
+
self.signing_module = signing_module
|
|
62
|
+
|
|
63
|
+
self.tclk_delay = tclk_delay
|
|
64
|
+
self.chunk_size = chunk_size
|
|
65
|
+
|
|
66
|
+
self.nvs_size = nvs_size
|
|
67
|
+
self.key_storage_size = key_storage_size
|
|
68
|
+
self.vendor_specific_size = vendor_specific_size
|
|
69
|
+
self.bl2_size = bl2_size
|
|
70
|
+
self.wsoc_size = wsoc_size
|
|
71
|
+
|
|
72
|
+
self.prog_dir = programmer_artifacts_path
|
|
73
|
+
self.fib_dir = fib_artifacts_path
|
|
74
|
+
self.prog_utility = ProgrammerUtility(self.prog_dir, self.fib_dir)
|
|
75
|
+
self.fib_utility = FIBUtility(self.fib_dir)
|
|
76
|
+
self.tmp_folder = self.prog_utility.get_programming_tmp_folder()
|
|
77
|
+
self.jsons_dir_path = self.prog_utility.get_config_folder()
|
|
78
|
+
self.tool_settings_json_template = (
|
|
79
|
+
self.prog_utility.get_tool_settings_template()
|
|
80
|
+
)
|
|
81
|
+
self.report_path = (
|
|
82
|
+
pathlib.Path(self.tmp_folder) / "get_fuse_programming_report.txt"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
self.updated_tool_settings_json = join(self.tmp_folder, "tool_settings.json")
|
|
86
|
+
|
|
87
|
+
self.action_request_json_template = (
|
|
88
|
+
self.prog_utility.get_action_params_template()
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
self.updated_action_request_json = join(self.tmp_folder, ACTION_PARAMS)
|
|
92
|
+
|
|
93
|
+
# Get limits for default values
|
|
94
|
+
limits = self.fib_utility.get_limits_by_flash_device_name(
|
|
95
|
+
self.flash_type, self.enable_ota
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if self.nvs_size is None:
|
|
99
|
+
self.nvs_size = limits["protected_storage"]["nvsSize"]["default"]
|
|
100
|
+
if self.key_storage_size is None:
|
|
101
|
+
self.key_storage_size = limits["protected_storage"]["keyStorageSize"][
|
|
102
|
+
"default"
|
|
103
|
+
]
|
|
104
|
+
if self.vendor_specific_size is None:
|
|
105
|
+
self.vendor_specific_size = limits["protected_storage"]["vendorSize"]["default"]
|
|
106
|
+
if self.bl2_size is None:
|
|
107
|
+
self.bl2_size = limits["ti_components"]["bl2_size"]["default"]
|
|
108
|
+
if self.wsoc_size is None:
|
|
109
|
+
self.wsoc_size = limits["ti_components"]["wsoc_size"]["default"]
|
|
110
|
+
|
|
111
|
+
ext_flash_dir_path = self.fib_utility.get_ext_flash_dir_path()
|
|
112
|
+
# move flash jsons files to tmp folder
|
|
113
|
+
self.xspi_json, self.otfde_json, self.ext_mem_json = (
|
|
114
|
+
self.prog_utility.move_flash_json_files(
|
|
115
|
+
flash_type_files_folder=ext_flash_dir_path,
|
|
116
|
+
flash_device=self.flash_type,
|
|
117
|
+
enable_ota=self.enable_ota,
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
not isfile(self.xspi_json)
|
|
123
|
+
or not isfile(self.otfde_json)
|
|
124
|
+
or not isfile(self.ext_mem_json)
|
|
125
|
+
):
|
|
126
|
+
raise Exception(f"Some JSONs are missing for Flash Device {flash_type}")
|
|
127
|
+
|
|
128
|
+
# modify jsons by user parameters
|
|
129
|
+
self.ext_mem_json, self.otfde_json, self.xspi_json = (
|
|
130
|
+
self.fib_utility.update_flash_configuration_files(
|
|
131
|
+
ext_mem_json_path=self.ext_mem_json,
|
|
132
|
+
otfde_json_path=self.otfde_json,
|
|
133
|
+
xspi_json_path=self.xspi_json,
|
|
134
|
+
nvs_size_kb=self.nvs_size,
|
|
135
|
+
ks_size_kb=self.key_storage_size,
|
|
136
|
+
vs_size_kb=self.vendor_specific_size,
|
|
137
|
+
bl2_size_kb=self.bl2_size,
|
|
138
|
+
wsoc_size_kb=self.wsoc_size,
|
|
139
|
+
device_type=self.device_type,
|
|
140
|
+
psram_type=self.psram_type,
|
|
141
|
+
ota_enabled=self.enable_ota,
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
if (
|
|
145
|
+
not isfile(self.xspi_json)
|
|
146
|
+
or not isfile(self.otfde_json)
|
|
147
|
+
or not isfile(self.ext_mem_json)
|
|
148
|
+
):
|
|
149
|
+
raise Exception(f"Some Modify JSONs are missing")
|
|
150
|
+
|
|
151
|
+
self.fuse_conf_json = join(
|
|
152
|
+
self.jsons_dir_path,
|
|
153
|
+
AUTHENTICATION_BYPASS_FILES_FOLDER_NAME,
|
|
154
|
+
FUSE_PROG_NAME_CC35XXE,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
def _build_action_request_image(self):
|
|
158
|
+
with open(self.action_request_json_template, "r") as f:
|
|
159
|
+
action_params = json.load(f)
|
|
160
|
+
|
|
161
|
+
action_params_prog_req_content = action_params["programming"]["payload_param"][
|
|
162
|
+
"payload"
|
|
163
|
+
]["prog_req_content"]
|
|
164
|
+
|
|
165
|
+
action_params_prog_req_content["flash_factory_reset"] = False
|
|
166
|
+
action_params_prog_req_content["boot_sector"] = False
|
|
167
|
+
action_params_prog_req_content["primary_tbl"] = False
|
|
168
|
+
action_params_prog_req_content["secondary_tbl"] = False
|
|
169
|
+
action_params_prog_req_content["primary_vendor_image"] = False
|
|
170
|
+
action_params_prog_req_content["secondary_vendor_image"] = False
|
|
171
|
+
action_params_prog_req_content["secondary_ti_wsoc"] = False
|
|
172
|
+
action_params_prog_req_content["primary_ti_wsoc"] = False
|
|
173
|
+
action_params_prog_req_content["protected_storage"] = False
|
|
174
|
+
|
|
175
|
+
with open(self.updated_action_request_json, "w") as f:
|
|
176
|
+
json.dump(action_params, f, indent=4)
|
|
177
|
+
|
|
178
|
+
# Build action params
|
|
179
|
+
action_req_out_path, action_req_to_sign_out_path = (
|
|
180
|
+
self.prog_utility.build_action_request_image(
|
|
181
|
+
params_json=self.updated_action_request_json,
|
|
182
|
+
type="programming",
|
|
183
|
+
dir_out_path=self.tmp_folder,
|
|
184
|
+
device=self.device_type,
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
signed_action_req_out_path = self.prog_utility.sign_action_request_image(
|
|
189
|
+
unsign_request=action_req_out_path,
|
|
190
|
+
forsign_request=action_req_to_sign_out_path,
|
|
191
|
+
activation_type=self.activation_type,
|
|
192
|
+
signing_module=self.signing_module,
|
|
193
|
+
dir_out_path=self.tmp_folder,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
return signed_action_req_out_path
|
|
197
|
+
|
|
198
|
+
def _build_programming_inst_image(self):
|
|
199
|
+
programming_unsign_image_path, programming_forsign_image_path = (
|
|
200
|
+
self.prog_utility.build_programming_image(
|
|
201
|
+
version="0.0.1.0",
|
|
202
|
+
pub_key_path=None,
|
|
203
|
+
activation_type=self.activation_type,
|
|
204
|
+
dir_out_path=self.tmp_folder,
|
|
205
|
+
fuses_programming_instructions=self.fuse_conf_json,
|
|
206
|
+
flash_discovery_config_xspi=self.xspi_json,
|
|
207
|
+
flash_discovery_config_otfde=self.otfde_json,
|
|
208
|
+
flash_discovery_config_ext_mem=self.ext_mem_json,
|
|
209
|
+
device=self.device_type,
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
signed_programming_image_path = self.prog_utility.sign_programming_image(
|
|
214
|
+
programming_unsign_image=programming_unsign_image_path,
|
|
215
|
+
programming_forsign_image=programming_forsign_image_path,
|
|
216
|
+
activation_type=self.activation_type,
|
|
217
|
+
signing_module=self.signing_module,
|
|
218
|
+
dir_out_path=self.tmp_folder,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
return signed_programming_image_path
|
|
222
|
+
|
|
223
|
+
def _update_tool_settings(self, action_req_path, programming_instructions_path):
|
|
224
|
+
tool_settings = json.load(open(self.tool_settings_json_template, "r"))
|
|
225
|
+
programming_debug_and_ota_signed_components = tool_settings[
|
|
226
|
+
"programming_debug_and_ota_signed_components"
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
# Update paths in tool_settings
|
|
230
|
+
programming_debug_and_ota_signed_components["actions_req_paths"][
|
|
231
|
+
"programming"
|
|
232
|
+
] = str(action_req_path)
|
|
233
|
+
programming_debug_and_ota_signed_components["programming_instructions"] = str(
|
|
234
|
+
programming_instructions_path
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
with open(self.updated_tool_settings_json, "w") as f:
|
|
238
|
+
json.dump(tool_settings, f, indent=4)
|
|
239
|
+
|
|
240
|
+
def get_fuse_data(self):
|
|
241
|
+
# Build action request and programming instructions images
|
|
242
|
+
signed_action_req_out_path = self._build_action_request_image()
|
|
243
|
+
programming_instructions_path = self._build_programming_inst_image()
|
|
244
|
+
|
|
245
|
+
# Create tool_settings
|
|
246
|
+
self._update_tool_settings(
|
|
247
|
+
action_req_path=signed_action_req_out_path,
|
|
248
|
+
programming_instructions_path=programming_instructions_path,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
# Program the device with the created tool_settings
|
|
252
|
+
programmer = ProgramDevice(
|
|
253
|
+
interface_type=self.interface_type,
|
|
254
|
+
serial_number=self.serial_number,
|
|
255
|
+
tool_settings=self.updated_tool_settings_json,
|
|
256
|
+
device_type=self.device_type,
|
|
257
|
+
report_file_path=self.report_path,
|
|
258
|
+
programmer_artifacts_path=self.prog_dir,
|
|
259
|
+
fib_artifacts_path=self.fib_dir,
|
|
260
|
+
verbose=self.verbose,
|
|
261
|
+
tclk_delay=self.tclk_delay,
|
|
262
|
+
chunk_size=self.chunk_size,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
if not programmer.program():
|
|
266
|
+
GET_FUSE_DATA_LOGGER.info("Get fuse data failed")
|
|
267
|
+
return None
|
|
268
|
+
else:
|
|
269
|
+
GET_FUSE_DATA_LOGGER.info("Get fuse data ended successfully")
|
|
270
|
+
|
|
271
|
+
data = programmer.report_generator.report_container.vendor_fuse_report
|
|
272
|
+
fuse_data_table = self.prog_utility.create_table_from_json(data)
|
|
273
|
+
|
|
274
|
+
GET_FUSE_DATA_LOGGER.info("FUSES DATA:")
|
|
275
|
+
GET_FUSE_DATA_LOGGER.info(fuse_data_table)
|
|
276
|
+
|
|
277
|
+
return data
|