1 /*
2 * UpdateManagerFet.cpp
3 *
4 * Functionality for updating eZ-FET & MSP-FET debugger
5 *
6 * Copyright (C) 2007 - 2011 Texas Instruments Incorporated - http://www.ti.com/
7 *
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the
19 * distribution.
20 *
21 * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #include <pch.h>
39
40 #include <BSL430_DLL/Connections/MSPBSL_Connection5xxUSB.h>
41 #include <BSL430_DLL/MSPBSL_Factory.h>
42 #include <BSL430_DLL/Utility_Classes/MSPBSL_CRCEngine.h>
43
44 #include "UpdateManagerFet.h"
45 #include "VersionInfo.h"
46 #include "FetHandle.h"
47 #include "FetHandleManager.h"
48 #include "ConfigManager.h"
49 #include "DeviceInfo.h"
50 #include "HalExecCommand.h"
51 #include "FetControl.h"
52 #include "WatchdogControl.h"
53 #include "DeviceHandleMSP430.h"
54 #include "HidUpdateManager.h"
55
56 #include "Record.h"
57 #include "MemoryContent.h"
58 #include "FileReader.h"
59
60 #include "../../../../Bios/include/eZ_FetDcdc.h"
61 #include "../../../../Bios/include/eZ_FetHal.h"
62 #include "../../../../Bios/include/eZ_FetHil.h"
63 #include "../../../../Bios/include/eZ_FetCore.h"
64 #include "../../../../Bios/include/eZ_FetComChannel.h"
65 #include "../../../../Bios/include/eZ_FetDcdcController.h"
66 #include "../../../../Bios/include/eZ_FetDcdcControllerV2x.h"
67
68
69 #include "../../../../Bios/include/MSP_FetDcdc.h"
70 #include "../../../../Bios/include/MSP_FetHal.h"
71 #include "../../../../Bios/include/MSP_FetHil.h"
72 #include "../../../../Bios/include/MSP_FetCore.h"
73 #include "../../../../Bios/include/MSP_FetComChannel.h"
74 #include "../../../../Bios/include/MSP_FetDcdcController.h"
75 #include "../../../../Bios/include/MSP_FetDcdcControllerV2x.h"
76
77 //Removed due to license limitations
78 //#define FPGA_UPDATE
79
80 #ifdef FPGA_UPDATE
81 #include "../../../../Bios/include/MSP_FetFpgaHal.h"
82 #endif
83
84 #include "../../../../Bios/include/ConfigureParameters.h"
85
86 using namespace TI::DLL430;
87 using namespace std;
88
89
90 static string UpdateLog;
91
UpdateManagerFet(FetHandle * fetHandle,ConfigManager * configManagerV3,FetHandleManager * fhManager)92 UpdateManagerFet::UpdateManagerFet(FetHandle* fetHandle, ConfigManager* configManagerV3, FetHandleManager* fhManager)
93 : fetHandle(fetHandle)
94 , configManagerV3(configManagerV3)
95 , fetHandleManager(fhManager)
96 , requiredUpdates(0)
97 , percent(0)
98 , intCallback(nullptr)
99 {
100 }
101
102
updateCore(MemoryContent & firmware)103 bool UpdateManagerFet::updateCore(MemoryContent &firmware)
104 {
105 double requiredCoreUpdates = 4.0 + firmware.segments.size();
106 double percentCore = 100.0 / requiredCoreUpdates;
107
108 try
109 {
110 int currentPid = 0;
111 string currentDevice;
112 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
113 {
114 currentPid = MSPBSL_MSP_FET_USB_PID;
115 currentDevice = "MSP430F6638";
116 }
117 else
118 {
119 currentPid = MSPBSL_EZ_FET_USB_PID;
120 currentDevice = "MSP430F5528";
121 }
122
123 UpdateLog.append("----TRACE---------------eZ_FET start BSL update------------------------------;\n");
124
125 // erase reset vector of core
126 upCoreErase();
127
128 if (intCallback)
129 {
130 --requiredCoreUpdates;
131 intCallback(BL_DATA_BLOCK_PROGRAMMED, (uint32_t)(100 - (requiredCoreUpdates)*percentCore), 0);
132 }
133
134 this_thread::sleep_for(chrono::seconds(4));
135
136 fetHandle->shutdown();
137
138 if (intCallback)
139 {
140 --requiredCoreUpdates;
141 intCallback(BL_DATA_BLOCK_PROGRAMMED, (uint32_t)(100 - (requiredCoreUpdates)*percentCore), 0);
142 }
143
144 uint32_t countedHidDevices = 0, timeout = 50;
145 do
146 {
147 this_thread::sleep_for(chrono::seconds(1));
148 countedHidDevices = HidUpdateManager::countHidDevices(currentPid);
149
150 if (intCallback)
151 {
152 intCallback(BL_DATA_BLOCK_PROGRAMMED, (uint32_t)(100 - (requiredCoreUpdates)*percentCore), 0);
153 }
154 }
155 while (!countedHidDevices && timeout--);
156
157 if (!countedHidDevices)
158 {
159 UpdateLog.append("----TRACE--- Did not find any HIDs\n");
160 }
161
162 if (intCallback)
163 {
164 --requiredCoreUpdates;
165 intCallback(BL_DATA_BLOCK_PROGRAMMED, (uint32_t)(100 - (requiredCoreUpdates)*percentCore), 0);
166 }
167
168 UpdateLog.append("----TRACE----fetHandle->shutdown()\n");
169 unique_ptr<MSPBSL_Connection5xxUSB> eZ_FET(dynamic_cast<MSPBSL_Connection5xxUSB*>(MSPBSL_Factory::getMSPBSL_Connection("DEVICE:" + currentDevice + " VID:0x2047 PID:0x"+ convertPid(currentPid) +"")));
170
171 if (eZ_FET.get() == nullptr)
172 {
173 UpdateLog.append("----TRACE----MSPBSL_Factory::getMSPBSL_Connection()\n");
174 return false;
175 }
176
177 UpdateLog.append("----TRACE----unique_ptr<MSPBSL_Connection5xxUSB> eZ_FET\n");
178
179 if (eZ_FET->loadRAM_BSL(currentPid) != 0)
180 {
181 //Reset FET
182 eZ_FET->closeBslconnection();
183 UpdateLog.append("----TRACE----eZ_FET->loadRAM_BSL() != 0 \n");
184 return false;
185 }
186
187 string verString = "";
188 eZ_FET->TX_BSL_Version(verString);
189 UpdateLog.append("----TRACE----eZ_FET->TX_BSL_Version(verString);\n");
190
191 eZ_FET->massErase();
192 UpdateLog.append("----TRACE----eZ_FET->massErase();\n");
193
194 if (firmware.segments.empty())
195 {
196 UpdateLog.append("----TRACE----firmware.segments.empty()\n");
197 return false;
198 }
199
200 for (size_t i = 0; i < firmware.segments.size(); i++)
201 {
202 const DataSegment& seg = firmware.segments[i];
203
204 vector<uint8_t> Buffer(seg.data.size());
205
206 MSPBSL_CRCEngine crcEngine("5xx_CRC");
207 crcEngine.initEngine(0xFFFF);
208
209 for (uint32_t n=0; n < seg.data.size(); n++)
210 {
211 Buffer[n]= (seg.data[n] & 0xff);
212 crcEngine.addByte(seg.data[n] & 0xff);
213 }
214
215 eZ_FET->RX_DataBlockFast(&Buffer[0], (uint32_t)seg.startAddress&0xfffffffe, (uint16_t)seg.data.size());
216
217 uint16_t currentCoreCRC[1] = {0};
218 eZ_FET->CRC_Check(currentCoreCRC, (uint32_t)seg.startAddress & 0xfffffffe, static_cast<uint16_t>(seg.data.size()));
219
220 uint32_t expectedCoreCRC = static_cast<uint32_t>(crcEngine.getHighByte()) << 8;
221 expectedCoreCRC |= (static_cast<uint32_t> (crcEngine.getLowByte()) & 0x0000FFFF);
222
223 if (expectedCoreCRC != currentCoreCRC[0])
224 {
225 if (i != 0)// just debug exeption
226 {
227 eZ_FET->closeBslconnection();
228 UpdateLog.append("----TRACE----eZ_FET end BSL update faild\n");
229 return false;
230 }
231 }
232 if (intCallback)
233 {
234 --requiredCoreUpdates;
235 intCallback(BL_DATA_BLOCK_PROGRAMMED, (uint32_t)(100 - (requiredCoreUpdates)*percentCore), 0);
236 }
237 }
238 UpdateLog.append("----TRACE---------------eZ_FET end BSL update------------------------------;\n");
239 eZ_FET->closeBslconnection();
240 }
241 catch (...)
242 {
243 UpdateLog.append("----TRACE----eZ_FET end BSL update failed\n");
244 return false;
245 }
246
247 if (intCallback)
248 {
249 --requiredCoreUpdates;
250 intCallback(BL_DATA_BLOCK_PROGRAMMED, (uint32_t)(100 - (requiredCoreUpdates)*percentCore), 0);
251 }
252 return true;
253 }
254
255
isUpdateRequired(TARGET_ARCHITECTURE_t arch) const256 bool UpdateManagerFet::isUpdateRequired(TARGET_ARCHITECTURE_t arch) const
257 {
258 bool isUpdateRequired = false;
259 if (checkHalVersion() != 0)
260 {
261 isUpdateRequired = true;
262 }
263 if (checkCoreVersion() != 0)
264 {
265 isUpdateRequired = true;
266 }
267 if (checkDcdcLayerVersion() != 0)
268 {
269 isUpdateRequired = true;
270 }
271 if (checkDcdcSubMcuVersion() != 0)
272 {
273 isUpdateRequired = true;
274 }
275 if (checkHilVersion() != 0)
276 {
277 isUpdateRequired = true;
278 }
279 if (checkFpgaVersion() != 0)
280 {
281 isUpdateRequired = true;
282 }
283 if (checkUartVersion() != 0)
284 {
285 isUpdateRequired = true;
286 }
287 return isUpdateRequired;
288 }
289
290
checkHilVersion() const291 uint16_t UpdateManagerFet::checkHilVersion() const
292 {
293 //get current hil version from FET
294 const uint16_t currentHilVersion = fetHandle->getControl()->getHilVersion();
295 //get hil CRC from FET
296 const uint16_t currentHilCrc = fetHandle->getControl()->getFetHilCrc();
297
298 uint16_t expectedHilVersion = 0;
299 uint16_t expectedHilCrc = 0;
300
301 Record *image = 0;
302 uint16_t retVal = 0;
303
304 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
305 {
306 image = new Record(MSP_FetHilImage, MSP_FetHilImage_address, MSP_FetHilImage_length_of_sections, MSP_FetHilImage_sections);
307 }
308 else
309 {
310 image = new Record(eZ_FetHilImage, eZ_FetHilImage_address, eZ_FetHilImage_length_of_sections, eZ_FetHilImage_sections);
311 }
312
313 //if hil versions or CRC's do not match, update hil
314 if (image && image->getWordAtAdr(0x18F6, &expectedHilVersion) && image->getWordAtAdr(0x18FA, &expectedHilCrc))
315 {
316 if ((expectedHilVersion != currentHilVersion) || (expectedHilCrc != currentHilCrc))
317 {
318 retVal = 1;
319 }
320 }
321
322 delete image;
323
324 return retVal;
325 }
326
checkUartVersion() const327 uint16_t UpdateManagerFet::checkUartVersion() const
328 {
329 uint16_t retVal = 0;
330
331 const uint16_t currentUartVersion = fetHandle->getControl()->getFetComChannelVersion();
332 const uint16_t currentFetComChannelCrc= fetHandle->getControl()->getFetComChannelCrc();
333
334 uint16_t expectedUartVersion = 0;
335 uint16_t expectedFetComChannelCRC = 0;
336
337 Record *image = 0;
338
339 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
340 {
341 image = new Record(MSP_FetComChannelImage, MSP_FetComChannelImage_address, MSP_FetComChannelImage_length_of_sections, MSP_FetComChannelImage_sections);
342 }
343 else
344 {
345 image = new Record(eZ_FetComChannelImage, eZ_FetComChannelImage_address, eZ_FetComChannelImage_length_of_sections, eZ_FetComChannelImage_sections);
346 }
347
348 if (image && image->getWordAtAdr(0x1984, &expectedUartVersion) && image->getWordAtAdr(0x19FA, &expectedFetComChannelCRC))
349 {
350 if ((expectedUartVersion != currentUartVersion) || (expectedFetComChannelCRC != currentFetComChannelCrc))
351 {
352 retVal = 1;
353 }
354 }
355
356 delete image;
357
358 return retVal;
359 }
360
checkFpgaVersion() const361 uint16_t UpdateManagerFet::checkFpgaVersion() const
362 {
363 uint16_t retVal = 0;
364
365 #ifdef FPGA_UPDATE
366 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
367 {
368 const uint16_t currentFpgaVersion = fetHandle->getControl()->getFetFpgaVersion();
369 uint16_t expectedFpgaVersion;
370
371 Record fpgaVersion(MSP_FetFpgaHalImage, MSP_FetFpgaHalImage_address, MSP_FetFpgaHalImage_length_of_sections, MSP_FetFpgaHalImage_sections);
372
373 if (fpgaVersion.getWordAtAdr(0x1978, &expectedFpgaVersion))
374 {
375 if (expectedFpgaVersion > currentFpgaVersion)
376 {
377 retVal = 1;
378 }
379 }
380 }
381 #endif
382
383 return retVal;
384 }
385
checkDcdcLayerVersion() const386 uint16_t UpdateManagerFet::checkDcdcLayerVersion() const
387 {
388 //get current dcdc layer version from FET
389 const uint32_t currentDcdcLayerVersion = fetHandle->getControl()->getDcdcLayerVersion();
390 //get dcdc layer CRC from FET
391 const uint16_t currentDcdcCrc= fetHandle->getControl()->getFetDcdcCrc();
392
393 uint16_t expectedDcdcCrc = 0;
394 uint16_t expectedDcdcLayerVersion = 0;
395
396 Record *image = 0;
397 uint16_t retVal = 0;
398
399 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
400 {
401 image = new Record(MSP_FetDcdcImage, MSP_FetDcdcImage_address, MSP_FetDcdcImage_length_of_sections, MSP_FetDcdcImage_sections);
402 }
403 else
404 {
405 image = new Record(eZ_FetDcdcImage, eZ_FetDcdcImage_address, eZ_FetDcdcImage_length_of_sections, eZ_FetDcdcImage_sections);
406 }
407
408 //if hil versions or CRC's do not match, update hil
409 if (image && image->getWordAtAdr(0x1804, &expectedDcdcLayerVersion) && image->getWordAtAdr(0x187A, &expectedDcdcCrc))
410 {
411 if ((expectedDcdcLayerVersion != currentDcdcLayerVersion) || (expectedDcdcCrc != currentDcdcCrc))
412 {
413 retVal = 1;
414 }
415 }
416
417 delete image;
418
419 return retVal;
420 }
421
checkDcdcSubMcuVersion() const422 uint16_t UpdateManagerFet::checkDcdcSubMcuVersion() const
423 {
424 const uint32_t currentDcdcSubMcuVersion = fetHandle->getControl()->getDcdcSubMcuVersion();
425 uint16_t expectedDcdcSubMcuVersion = 0;
426
427 Record *image = 0;
428 uint16_t retVal = 0;
429
430 if (fetHandle->getControl()->getFetToolId() == eZ_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == eZ_FET_WITH_DCDC_NO_FLOWCT)
431 {
432 image = new Record(eZ_FetDcdcControllerImage, eZ_FetDcdcControllerImage_address, eZ_FetDcdcControllerImage_length_of_sections, eZ_FetDcdcControllerImage_sections);
433 }
434 else if (fetHandle->getControl()->getFetToolId() == eZ_FET_WITH_DCDC_V2x)
435 {
436 image = new Record(eZ_FetDcdcControllerV2xImage, eZ_FetDcdcControllerV2xImage_address, eZ_FetDcdcControllerV2xImage_length_of_sections, eZ_FetDcdcControllerV2xImage_sections);
437 }
438 else if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC)
439 {
440 image = new Record(MSP_FetDcdcControllerImage, MSP_FetDcdcControllerImage_address, MSP_FetDcdcControllerImage_length_of_sections, MSP_FetDcdcControllerImage_sections);
441 }
442 else if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
443 {
444 image = new Record(MSP_FetDcdcControllerV2xImage, MSP_FetDcdcControllerV2xImage_address, MSP_FetDcdcControllerV2xImage_length_of_sections, MSP_FetDcdcControllerV2xImage_sections);
445 }
446
447 if (image && image->getWordAtAdr(0x1000, &expectedDcdcSubMcuVersion))
448 {
449 //if dcdc sub-mcu versions do not match, update sub-mcu
450 if (currentDcdcSubMcuVersion != expectedDcdcSubMcuVersion)
451 {
452 retVal = 1;
453 }
454 }
455
456 delete image;
457
458 return retVal;
459 }
460
checkHalVersion() const461 uint16_t UpdateManagerFet::checkHalVersion() const
462 {
463 //get hal CRC from FET
464 const uint16_t currentHalCrc = fetHandle->getControl()->getFetHalCrc();
465 uint16_t expectedHalCrc = 0;
466
467 Record *image;
468 uint16_t retVal = 0;
469
470 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
471 {
472 image = new Record(MSP_FetHalImage, MSP_FetHalImage_address, MSP_FetHalImage_length_of_sections, MSP_FetHalImage_sections);
473 }
474 else
475 {
476 image = new Record(eZ_FetHalImage, eZ_FetHalImage_address, eZ_FetHalImage_length_of_sections, eZ_FetHalImage_sections);
477 }
478
479 if (image->getWordAtAdr(0x197A, &expectedHalCrc))
480 {
481 if (expectedHalCrc != currentHalCrc)
482 {
483 retVal = 1;
484 }
485 }
486
487 delete image;
488
489 return retVal;
490 }
491
492
checkCoreVersion() const493 uint16_t UpdateManagerFet::checkCoreVersion() const
494 {
495 //get current core version from FET
496 const uint16_t actualFetCoreVersion = fetHandle->getControl()->getFetCoreVersion();
497 //get core CRC from FET
498 const uint16_t currentCoreCrc= fetHandle->getControl()->getFetCoreCrc();
499
500 uint16_t expectedFetCoreVersion = 0;
501 uint16_t expectedCoreCrc = 0;
502
503 uint16_t versionLocation = 0;
504 uint16_t crcLocation = 0;
505
506 Record *image;
507 uint16_t retVal = 0;
508
509 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
510 {
511 image = new Record(MSP_FetCoreImage, MSP_FetCoreImage_address, MSP_FetCoreImage_length_of_sections, MSP_FetCoreImage_sections);
512 versionLocation = 0x8004;
513 crcLocation = 0x8002;
514 }
515 else
516 {
517 image = new Record(eZ_FetCoreImage, eZ_FetCoreImage_address, eZ_FetCoreImage_length_of_sections, eZ_FetCoreImage_sections);
518 versionLocation = 0x4404;
519 crcLocation = 0x4402;
520 }
521
522 if (image->getWordAtAdr(versionLocation, &expectedFetCoreVersion) && image->getWordAtAdr(crcLocation, &expectedCoreCrc))
523 {
524 //if core versions or CRC's do not match, update core
525 if ((expectedFetCoreVersion != actualFetCoreVersion) || (currentCoreCrc != expectedCoreCrc))
526 {
527 retVal = 1;
528 }
529 }
530
531 delete image;
532
533 return retVal;
534 }
535
getHalVersion() const536 VersionInfo UpdateManagerFet::getHalVersion() const
537 {
538 const std::vector<uint8_t>* sw_info = this->fetHandle->getSwVersion();
539 const uint16_t currentHalCrc = fetHandle->getControl()->getFetHalCrc();
540 uint16_t expectedHalCrc = 0;
541
542 Record *image;
543
544 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
545 {
546 image = new Record(MSP_FetHalImage, MSP_FetHalImage_address, MSP_FetHalImage_length_of_sections, MSP_FetHalImage_sections);
547 }
548 else
549 {
550 image = new Record(eZ_FetHalImage, eZ_FetHalImage_address, eZ_FetHalImage_length_of_sections, eZ_FetHalImage_sections);
551 }
552
553 if (image->getWordAtAdr(0x197A, &expectedHalCrc))
554 {
555 if (expectedHalCrc != currentHalCrc)
556 {
557 delete image;
558 return VersionInfo(1, 0, 0, 0);
559 }
560 }
561
562 delete image;
563
564 if (sw_info==nullptr)
565 {
566 return VersionInfo(0, 0, 0, 0);
567 }
568 if (sw_info->size()<4)
569 {
570 return VersionInfo(0, 0, 0, 0);
571 }
572
573 unsigned char major = sw_info->at(1);
574
575 return VersionInfo((((major&0xC0)>>6)+1), (major&0x3f), sw_info->at(0),
576 (sw_info->at(3)<<8)+sw_info->at(2));
577 }
578
updateHal()579 bool UpdateManagerFet::updateHal()
580 {
581 bool returnValue = false;
582 MemoryContent firmware;
583
584 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
585 {
586 firmware.fromSRec(MSP_FetHalImage, MSP_FetHalImage_address, MSP_FetHalImage_length_of_sections, MSP_FetHalImage_sections);
587 }
588 else
589 {
590 firmware.fromSRec(eZ_FetHalImage, eZ_FetHalImage_address, eZ_FetHalImage_length_of_sections, eZ_FetHalImage_sections);
591 }
592 returnValue = updateFirmware(firmware);
593 if (!returnValue)
594 {
595 UpdateLog.append("----TRACE----HalLayer update failed\n");
596 }
597
598 return returnValue;
599 }
600
updateHil()601 bool UpdateManagerFet::updateHil()
602 {
603 bool returnValue = false;
604 MemoryContent firmware;
605
606 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
607 {
608 firmware.fromSRec(MSP_FetHilImage, MSP_FetHilImage_address, MSP_FetHilImage_length_of_sections, MSP_FetHilImage_sections);
609 }
610 else
611 {
612 firmware.fromSRec(eZ_FetHilImage, eZ_FetHilImage_address, eZ_FetHilImage_length_of_sections, eZ_FetHilImage_sections);
613 }
614
615 returnValue = updateFirmware(firmware);
616 if (!returnValue)
617 {
618 UpdateLog.append("----TRACE----HilLayer update failed\n");
619 }
620
621 return returnValue;
622 }
623
updateFpga()624 bool UpdateManagerFet::updateFpga()
625 {
626 bool returnValue = true;
627 MemoryContent firmware;
628 #ifdef FPGA_UPDATE
629
630 firmware.fromSRec(MSP_FetFpgaHalImage, MSP_FetFpgaHalImage_address, MSP_FetFpgaHalImage_length_of_sections, MSP_FetFpgaHalImage_sections);
631
632 if (firmware.segments.empty())
633 {
634 return false;
635 }
636
637 this->upInit(1);
638
639 if (returnValue && !this->upErase(firmware))
640 {
641 returnValue = false;
642 }
643 if (returnValue && !this->upWrite(firmware))
644 {
645 returnValue = false;
646 }
647
648 // Start the FPGA update
649 this->upInit(3);
650
651 this_thread::sleep_for(chrono::seconds(1));
652
653 // Restore the normal HAL module
654 if (returnValue && !updateHal())
655 {
656 returnValue = false;
657 }
658
659 if (!returnValue)
660 {
661 UpdateLog.append("----TRACE----FPGA update failed\n");
662 }
663 #endif
664 return returnValue;
665 }
666
updateDcdcLayer()667 bool UpdateManagerFet::updateDcdcLayer()
668 {
669 bool returnValue = false;
670 MemoryContent firmware;
671
672 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
673 {
674 firmware.fromSRec(MSP_FetDcdcImage, MSP_FetDcdcImage_address, MSP_FetDcdcImage_length_of_sections, MSP_FetDcdcImage_sections);
675 }
676 else
677 {
678 firmware.fromSRec(eZ_FetDcdcImage, eZ_FetDcdcImage_address, eZ_FetDcdcImage_length_of_sections, eZ_FetDcdcImage_sections);
679 }
680 returnValue = updateFirmware(firmware);
681 if (!returnValue)
682 {
683 UpdateLog.append("----TRACE----DcdcLayer update failed \n");
684 }
685
686 return returnValue;
687 }
688
updateSubMcu()689 bool UpdateManagerFet::updateSubMcu()
690 {
691 bool returnValue = true;
692 MemoryContent firmware;
693
694 IDeviceHandleManager* dhm = this->fetHandle->getDeviceHandleManager();
695
696 // Now programm the Sub MCU
697 this->upInit(2);
698
699 //-----------------------------------------
700 configManagerV3->setJtagMode(SPYBIWIRE_DCDC);
701 if (!configManagerV3->start())
702 {
703 UpdateLog.append("----TRACE---- configManagerV3->start() \n");
704 }
705
706 // save the device handle to work with
707 IDeviceHandle* singleDevice = dhm->createDeviceHandle(0, SPYBIWIRE_IF);
708
709 if (singleDevice == nullptr)
710 {
711 configManagerV3->stop();
712 UpdateLog.append("----TRACE---- singleDevice==NULL \n");
713 return false;
714 }
715
716 if (singleDevice->getJtagId() != 0x89)
717 {
718 returnValue = false;
719 UpdateLog.append("----TRACE---- singleDevice->getJtagId() != 0x89 \n");
720 }
721
722 if (returnValue)
723 {
724 const long setId = singleDevice->identifyDevice(0, false);
725 if (setId == -5555)
726 {
727 returnValue = false;
728 UpdateLog.append("----TRACE---- Fuse Blown\n");
729 }
730 else if (setId < 0)
731 {
732 returnValue = false;
733 UpdateLog.append("----TRACE----No device detected\n");
734 }
735 }
736
737 if (returnValue)
738 {
739 returnValue = this->programmSubMcu(singleDevice);
740 if (!returnValue)
741 {
742 UpdateLog.append("----TRACE----programm the Sub MCU update failed \n");
743 }
744
745 this->upInit(0);
746
747 if (!configManagerV3->stop())
748 {
749 UpdateLog.append("----TRACE----Stop JTAG done failed \n");
750 }
751 }
752
753
754 // destroy device handle
755 dhm->destroyDeviceHandle(singleDevice);
756
757 return returnValue;
758 }
759
updateComChannel()760 bool UpdateManagerFet::updateComChannel()
761 {
762 MemoryContent firmware;
763
764 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
765 {
766 firmware.fromSRec(MSP_FetComChannelImage, MSP_FetComChannelImage_address, MSP_FetComChannelImage_length_of_sections, MSP_FetComChannelImage_sections);
767 }
768 else
769 {
770 firmware.fromSRec(eZ_FetComChannelImage, eZ_FetComChannelImage_address, eZ_FetComChannelImage_length_of_sections, eZ_FetComChannelImage_sections);
771 }
772
773 bool returnValue = updateFirmware(firmware);
774 if (!returnValue)
775 {
776 UpdateLog.append("----TRACE----Uart Layer update failed \n");
777 }
778
779 return returnValue;
780 }
781
firmWareUpdate(const char * fname,UpdateNotifyCallback callback,bool * coreUpdate)782 bool UpdateManagerFet::firmWareUpdate(const char* fname, UpdateNotifyCallback callback, bool* coreUpdate)
783 {
784 FetControl* control = this->fetHandle->getControl();
785 intCallback = nullptr;
786 if (control == nullptr)
787 {
788 return false;
789 }
790 if (callback)
791 {
792 intCallback = callback;
793 }
794 bool returnValue = true;
795
796 UpdateLog.clear();
797 UpdateLog.append("\n\n\n ------------------------Start Firmware update--------------------------- \n");
798
799 if (intCallback)
800 {
801 intCallback(BL_INIT, 0, 0);
802 intCallback(BL_PROGRAM_FIRMWARE, 0, 0);
803 }
804
805 if (checkCoreVersion() != 0)
806 {
807 *coreUpdate = true;
808 MemoryContent firmware;
809 if (control->getFetToolId() == MSP_FET_WITH_DCDC || control->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
810 {
811 firmware.fromSRec(MSP_FetCoreImage, MSP_FetCoreImage_address, MSP_FetCoreImage_length_of_sections, MSP_FetCoreImage_sections);
812 }
813 else
814 {
815 firmware.fromSRec(eZ_FetCoreImage, eZ_FetCoreImage_address, eZ_FetCoreImage_length_of_sections, eZ_FetCoreImage_sections);
816 }
817 UpdateLog.append("----TRACE----call updateCore(firmware)\n");
818 bool retval = updateCore(firmware);
819
820 if (intCallback)
821 {
822 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100, 0);
823 }
824
825 if (!retval)
826 {
827 #if defined(_WIN32) || defined(_WIN64)
828 char binaryPath[256] = { 0 };
829 uint32_t pathLength = 0;
830
831 pathLength = GetModuleFileName(0, binaryPath, sizeof(binaryPath));
832 while (pathLength > 0 && binaryPath[pathLength - 1] != '\\')
833 {
834 --pathLength;
835 }
836 string logfile = string(binaryPath, pathLength) + "Update.log";
837 #else
838 string logfile = "Update.log";
839 #endif
840 UpdateLog.append("\n---------------------Firmware upate end--------------------------\n");
841
842 std::ofstream(logfile.c_str(), ios::app | ios::out) << UpdateLog;
843 }
844
845 return retval;
846 }
847
848 // just for core update test do not call during normal debug
849 if (fname && string(fname).find("CORE_RST_VECTOR_ERASE") != string::npos)
850 {
851 upCoreErase();
852 if (intCallback)
853 {
854 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100, 0);
855 intCallback(BL_UPDATE_DONE, 0, 0);
856 intCallback(BL_EXIT, 0, 0);
857 }
858 UpdateLog.append("----TRACE----CORE_RST_VECTOR_ERASE done\n");
859 return true;
860 }
861 else if (fname)
862 {
863 MemoryContent firmware;
864 try
865 {
866 FileReader::create(fname)->read(&firmware);
867 }
868 catch (const std::runtime_error&)
869 {
870 UpdateLog.append("----TRACE--- firmware.readFirmware(fname)failed\n");
871 return false;
872 }
873 if (intCallback)
874 {
875 intCallback(BL_DATA_BLOCK_PROGRAMMED, 0, 0);
876 }
877 returnValue = updateFirmware(firmware);
878 if (!returnValue)
879 {
880 UpdateLog.append("----TRACE--- returnValue = updateFirmware(firmware) failed\n");
881 }
882
883 if (intCallback)
884 {
885 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100, 0);
886 intCallback(BL_UPDATE_DONE, 0, 0);
887 intCallback(BL_EXIT, 0, 0);
888 }
889 }
890 else
891 {
892 requiredUpdates = 1;
893 requiredUpdates += numStepsHalFirmware();
894 requiredUpdates += numStepsHilFirmware();
895 requiredUpdates += numStepsFpgaFirmware();
896 requiredUpdates += numStepsDcdcLayerFirmware();
897 requiredUpdates += numStepsSubMcuLayerFirmware();
898 requiredUpdates += numStepsComChannelFirmware();
899
900 percent = 100 / requiredUpdates;
901 this->upInit(4);// stop vcc supervision
902 if (intCallback)
903 {
904 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(requiredUpdates)*percent, 0);
905 }
906 //--------------------------------------HalUpdate-----------------------------------------------------
907 if (isHalUpdateRequired())
908 {
909 returnValue = updateHal(); control->resetCommunication();
910 }
911 else
912 {
913 requiredUpdates -= numStepsHalFirmware();
914 }
915
916 if (intCallback)
917 {
918 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(requiredUpdates)*percent, 0);
919 }
920 //--------------------------------------HilUpdate-----------------------------------------------------
921 if (returnValue && isHilUpdateRequired())
922 {
923 returnValue = updateHil();
924
925 control->resetCommunication();
926 }
927 else
928 {
929 requiredUpdates -= numStepsHilFirmware();
930 }
931
932 if (intCallback)
933 {
934 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(requiredUpdates)*percent, 0);
935 }
936
937 //--------------------------------------FpgaUpdate-----------------------------------------------------
938 if (returnValue && isFpgaUpdateRequired())
939 {
940 returnValue = updateFpga();
941
942 control->resetCommunication();
943 }
944 else
945 {
946 requiredUpdates -= numStepsFpgaFirmware();
947 }
948
949 if (intCallback)
950 {
951 intCallback(BL_DATA_BLOCK_PROGRAMMED, (100-(requiredUpdates)*percent), 0);
952 }
953
954 //--------------------------------------DcdcLayerUpdate-----------------------------------------------------
955 if (returnValue && isDcdcLayerUpdateRequired())
956 {
957 returnValue = updateDcdcLayer();
958
959 control->resetCommunication();
960 }
961 else
962 {
963 requiredUpdates -= numStepsDcdcLayerFirmware();
964 }
965
966 if (intCallback)
967 {
968 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(requiredUpdates)*percent, 0);
969 }
970
971 //--------------------------------------SubMcuUpdate-----------------------------------------------------
972 if (returnValue && isSubMcuLayerUpdateRequired())
973 {
974 returnValue = updateSubMcu();
975
976 control->resetCommunication();
977 }
978 else
979 {
980 requiredUpdates -= numStepsSubMcuLayerFirmware();
981 }
982
983 if (intCallback)
984 {
985 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(requiredUpdates)*percent, 0);
986 }
987
988 //--------------------------------------ComChannelUpdate-----------------------------------------------------
989 if (returnValue && isComChannelUpdateRequired())
990 {
991 returnValue = updateComChannel();
992
993 control->resetCommunication();
994 }
995 this->upInit(5);// start vcc supervision
996
997 if (intCallback)
998 {
999 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100, 0);
1000 intCallback(BL_UPDATE_DONE, 0, 0);
1001 intCallback(BL_EXIT, 0, 0);
1002 }
1003 }
1004
1005
1006 if (!returnValue)
1007 {
1008 #if defined(_WIN32) || defined(_WIN64)
1009 char binaryPath[256] = { 0 };
1010 uint32_t pathLength = 0;
1011
1012 pathLength = GetModuleFileName(0, binaryPath, sizeof(binaryPath));
1013 while (pathLength > 0 && binaryPath[pathLength - 1] != '\\')
1014 {
1015 --pathLength;
1016 }
1017 string logfile = string(binaryPath, pathLength) + "Update.log";
1018 #else
1019 string logfile = "Update.log";
1020 #endif
1021 UpdateLog.append("\n---------------------Firmware upate end--------------------------\n");
1022
1023 std::ofstream(logfile.c_str(), ios::app | ios::out) << UpdateLog;
1024 }
1025 return returnValue;
1026 }
1027
programmSubMcu(IDeviceHandle * singleDevice)1028 bool UpdateManagerFet::programmSubMcu(IDeviceHandle * singleDevice)
1029 {
1030 MemoryContent firmware;
1031
1032 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC)
1033 {
1034 firmware.fromSRec(MSP_FetDcdcControllerImage, MSP_FetDcdcControllerImage_address, MSP_FetDcdcControllerImage_length_of_sections, MSP_FetDcdcControllerImage_sections);
1035 }
1036 else if ( fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
1037 {
1038 firmware.fromSRec(MSP_FetDcdcControllerV2xImage, MSP_FetDcdcControllerV2xImage_address, MSP_FetDcdcControllerV2xImage_length_of_sections, MSP_FetDcdcControllerV2xImage_sections);
1039 }
1040 else if (fetHandle->getControl()->getFetToolId() == eZ_FET_WITH_DCDC_V2x)
1041 {
1042 firmware.fromSRec(eZ_FetDcdcControllerV2xImage, eZ_FetDcdcControllerV2xImage_address, eZ_FetDcdcControllerV2xImage_length_of_sections, eZ_FetDcdcControllerV2xImage_sections);
1043 }
1044 else
1045 {
1046 firmware.fromSRec(eZ_FetDcdcControllerImage, eZ_FetDcdcControllerImage_address, eZ_FetDcdcControllerImage_length_of_sections, eZ_FetDcdcControllerImage_sections);
1047 }
1048
1049 if (firmware.segments.empty())
1050 {
1051 return false;
1052 }
1053 if (!singleDevice)
1054 {
1055 UpdateLog.append("----TRACE---- SUB mcu !singleDevice\n");
1056 return false;
1057 }
1058 IMemoryManager* mm = singleDevice->getMemoryManager();
1059
1060 if (!mm)
1061 {
1062 UpdateLog.append("----TRACE---- SUB mcu !mm\n");
1063 return false;
1064 }
1065 MemoryArea* main = mm->getMemoryArea(MemoryArea::Main);
1066
1067 singleDevice->reset();
1068
1069 if (intCallback)
1070 {
1071 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(requiredUpdates)*percent, 0);
1072 }
1073
1074 //erase sub MCU.
1075 bool eraseSubMcuMain = main->erase();
1076 if (!eraseSubMcuMain)
1077 {
1078 UpdateLog.append("----TRACE---- SUB mcu !eraseSubMcuMain\n");
1079 return false;
1080 }
1081
1082 MemoryArea* info = mm->getMemoryArea(MemoryArea::Info);
1083 singleDevice->reset();
1084
1085 //erase sub MCU.
1086 bool eraseSubMcuinfo = info->erase();
1087 if (!eraseSubMcuinfo)
1088 {
1089 UpdateLog.append("----TRACE---- SUB mcu !eraseSubMcuinfo\n");
1090 return false;
1091 }
1092
1093 if (intCallback)
1094 {
1095 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(--requiredUpdates)*percent, 0);
1096 }
1097
1098 singleDevice->reset();
1099
1100 bool writeSubMcu = true;
1101 for (DataSegment& segment : firmware.segments)
1102 {
1103 if (!mm->write(segment.startAddress, segment.data.data(), segment.data.size()) || !mm->sync())
1104 {
1105 UpdateLog.append("----TRACE---- SUB mcu !writeSubMcu\n");
1106 writeSubMcu = false;
1107 break;
1108 }
1109 if (intCallback)
1110 {
1111 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100 - (--requiredUpdates)*percent, 0);
1112 }
1113 }
1114 return writeSubMcu;
1115 }
1116
updateFirmware(const MemoryContent & firmware)1117 bool UpdateManagerFet::updateFirmware(const MemoryContent &firmware)
1118 {
1119 if (firmware.segments.empty())
1120 {
1121 return false;
1122 }
1123 // start HAL update routine
1124 this->upInit(1);
1125
1126 if (!this->upErase(firmware))
1127 {
1128 return false;
1129 }
1130 if (!this->upWrite(firmware))
1131 {
1132 return false;
1133 }
1134 this->upInit(0);
1135
1136 // give the firmware time to execute initialisation
1137 this_thread::sleep_for(chrono::seconds(1));
1138 return true;
1139 }
1140
upInit(unsigned char level)1141 void UpdateManagerFet::upInit(unsigned char level)
1142 {
1143 HalExecCommand updateCmd;
1144 updateCmd.setTimeout(10000);
1145 HalExecElement* el = new HalExecElement(ID_Zero, UpInit);
1146 el->setAddrFlag(false);
1147 el->appendInputData8(level);
1148
1149 updateCmd.elements.emplace_back(el);
1150 this->fetHandle->send(updateCmd);
1151 }
1152
upErase(const MemoryContent & firmware)1153 bool UpdateManagerFet::upErase(const MemoryContent& firmware)
1154 {
1155 for (size_t i = 0; i < firmware.segments.size(); ++i)
1156 {
1157 const DataSegment& seg = firmware.segments[i];
1158
1159 HalExecElement* el = new HalExecElement(ID_Zero, UpErase);
1160 el->setAddrFlag(false);
1161
1162 el->appendInputData32(seg.startAddress & 0xfffffffe);
1163 el->appendInputData32(static_cast<uint32_t>(seg.data.size()));
1164
1165 HalExecCommand updateCmd;
1166 updateCmd.setTimeout(40000);
1167 updateCmd.elements.emplace_back(el);
1168 if (this->fetHandle->send(updateCmd)==false)
1169 {
1170 return false;
1171 }
1172 if (intCallback)
1173 {
1174 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(--requiredUpdates)*percent, 0);
1175 }
1176 }
1177 return true;
1178 }
1179
upWrite(const MemoryContent & firmware)1180 bool UpdateManagerFet::upWrite(const MemoryContent& firmware)
1181 {
1182 for (size_t i = firmware.segments.size(); i > 0; i--)
1183 {
1184 const DataSegment& seg = firmware.segments[i-1];
1185
1186 // create Core telegram -> update write
1187 HalExecElement* el = new HalExecElement(ID_Zero, UpWrite);
1188 // no HAL id needed for update
1189 el->setAddrFlag(false);
1190
1191 const uint32_t padding = seg.data.size() % 2;
1192 const uint32_t data2send = static_cast<uint32_t>(seg.data.size()) + padding;
1193
1194 // add address data
1195 el->appendInputData32(seg.startAddress&0xfffffffe);
1196 el->appendInputData32(data2send);
1197
1198 // add update data
1199 for (size_t n = 0; n < seg.data.size(); n++)
1200 {
1201 el->appendInputData8(seg.data[n] & 0xff);
1202 }
1203 for (uint32_t p = 0; p < padding; p++)
1204 {
1205 el->appendInputData8(0xff);
1206 }
1207
1208 HalExecCommand updateCmd;
1209 updateCmd.setTimeout(45000);
1210 updateCmd.elements.emplace_back(el);
1211 if (this->fetHandle->send(updateCmd)==false)
1212 {
1213 return false;
1214 }
1215 if (intCallback)
1216 {
1217 intCallback(BL_DATA_BLOCK_PROGRAMMED, 100-(--requiredUpdates)*percent, 0);
1218 }
1219 }
1220 return true;
1221 }
1222
upCoreErase()1223 bool UpdateManagerFet::upCoreErase()
1224 {
1225 FetControl * control=this->fetHandle->getControl();
1226 // create 0x55 command erase signature
1227 // command forces safecore to search for new core on reset
1228 std::vector<uint8_t> data_55;
1229 data_55.push_back(0x03);
1230 data_55.push_back(0x55);
1231 uint8_t id = control->createResponseId();
1232 data_55.push_back(id);
1233 data_55.push_back(0x00);
1234
1235 control->sendData(data_55);
1236 control->clearResponse();
1237 return true;
1238 }
1239
upCoreWrite()1240 bool UpdateManagerFet::upCoreWrite()
1241 {
1242 return true;
1243 }
1244
1245 //reads back flashed core data and compares it to data in core image
1246 //returns: true, if data on FET and core image are equal
upCoreRead()1247 bool UpdateManagerFet::upCoreRead()
1248 {
1249 return true;
1250 }
1251
isHalUpdateRequired()1252 bool UpdateManagerFet::isHalUpdateRequired()
1253 {
1254 return (getHalVersion().get() == 10000000);
1255 }
1256
isHilUpdateRequired()1257 bool UpdateManagerFet::isHilUpdateRequired()
1258 {
1259 return (checkHilVersion() != 0);
1260 }
1261
isFpgaUpdateRequired()1262 bool UpdateManagerFet::isFpgaUpdateRequired()
1263 {
1264 return (checkFpgaVersion() != 0);
1265 }
1266
isDcdcLayerUpdateRequired()1267 bool UpdateManagerFet::isDcdcLayerUpdateRequired()
1268 {
1269 return (checkDcdcLayerVersion() != 0);
1270 }
1271
isSubMcuLayerUpdateRequired()1272 bool UpdateManagerFet::isSubMcuLayerUpdateRequired()
1273 {
1274 return (checkDcdcSubMcuVersion() != 0);
1275 }
1276
isComChannelUpdateRequired()1277 bool UpdateManagerFet::isComChannelUpdateRequired()
1278 {
1279 return (checkUartVersion() != 0);
1280 }
1281
numStepsHalFirmware()1282 uint32_t UpdateManagerFet::numStepsHalFirmware()
1283 {
1284 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
1285 {
1286 return MSP_FetHalImage_sections * 2;
1287 }
1288 else
1289 {
1290 return eZ_FetHalImage_sections * 2;
1291 }
1292 }
1293
numStepsHilFirmware()1294 uint32_t UpdateManagerFet::numStepsHilFirmware()
1295 {
1296 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
1297 {
1298 return MSP_FetHilImage_sections * 2;
1299 }
1300 else
1301 {
1302 return eZ_FetHilImage_sections * 2;
1303 }
1304 }
1305
numStepsFpgaFirmware()1306 uint32_t UpdateManagerFet::numStepsFpgaFirmware()
1307 {
1308 #ifdef FPGA_UPDATE
1309 return MSP_FetFpgaHalImage_sections * 2;
1310 #else
1311 return 1;
1312 #endif
1313 }
1314
numStepsDcdcLayerFirmware()1315 uint32_t UpdateManagerFet::numStepsDcdcLayerFirmware()
1316 {
1317 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
1318 {
1319 return MSP_FetDcdcImage_sections * 2;
1320 }
1321 else
1322 {
1323 return eZ_FetDcdcImage_sections * 2;
1324 }
1325 }
1326
numStepsSubMcuLayerFirmware()1327 uint32_t UpdateManagerFet::numStepsSubMcuLayerFirmware()
1328 {
1329 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC)
1330 {
1331 return MSP_FetDcdcControllerImage_sections + 1;
1332 }
1333 else if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
1334 {
1335 return MSP_FetDcdcControllerV2xImage_sections + 1;
1336 }
1337 else
1338 {
1339 return eZ_FetDcdcControllerImage_sections + 1;
1340 }
1341 }
1342
numStepsComChannelFirmware()1343 uint32_t UpdateManagerFet::numStepsComChannelFirmware()
1344 {
1345 if (fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC || fetHandle->getControl()->getFetToolId() == MSP_FET_WITH_DCDC_V2x)
1346 {
1347 return MSP_FetComChannelImage_sections * 2;
1348 }
1349 else
1350 {
1351 return eZ_FetComChannelImage_sections * 2;
1352 }
1353 }
1354
1355 /*EOF*/
1356