fwupdate.c
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #include "fwupdate.h"
66 #include "string.h"
67 #include "xbus.h"
68 
69 #ifndef LOG
70  #define LOG(...)
71 #endif
72 
73 #define XMID_FIRMWARE_UPDATE (0xF2)
74 
75 #define FWUP_DEFAULT_SLICE_SIZE (64)
76 
77 
80 #define FWUP_READY (unsigned char)0x52 //'R'
81 #define FWUP_OK (unsigned char)0x53 //'S'
82 #define FWUP_CSERROR (unsigned char)0x45 //'E'
83 #define FWUP_CRITICAL (unsigned char)0x46 //'F'
84 #define FWUP_FINISHED (unsigned char)0x46 //'F'
85 #define FWUP_PAGE (unsigned char)0x50 //'P'
86 #define FWUP_HEADER (unsigned char)0x53 //'S'
87 #define FWUP_PAGESLICE (unsigned char)0x54 //'T'
88 #define FWUP_STARTED (unsigned char)0x41 //'A'
89 #define FWUP_OTHER (unsigned char)0x4F //'O'
90 
91 
94 const char* commandToString(uint8_t command)
95 {
96  switch (command)
97  {
98  case FWUP_READY:
99  return ("FWUP_READY");
100  case FWUP_HEADER:
101  return ("FWUP_HEADER");
102  case FWUP_FINISHED:
103  return ("FWUP_FINISHED");
104  case FWUP_PAGE:
105  return ("FWUP_PAGE");
106  case FWUP_PAGESLICE:
107  return ("FWUP_PAGESLICE");
108  case FWUP_STARTED:
109  return ("FWUP_STARTED");
110  case FWUP_OTHER:
111  return ("FWUP_OTHER");
112  default:
113  return ("unknown");
114  }
115 }
116 
117 
120 const char* ackToString(uint8_t command)
121 {
122  switch (command)
123  {
124  case FWUP_READY:
125  return "FWUP_READY";
126  case FWUP_OK:
127  return "FWUP_OK";
128  case FWUP_CSERROR:
129  return "FWUP_CSERROR";
130  case FWUP_CRITICAL:
131  return "FWUP_CRITICAL";
132  case FWUP_PAGE:
133  return "FWUP_PAGE";
134  case FWUP_PAGESLICE:
135  return "FWUP_PAGESLICE";
136  case FWUP_STARTED:
137  return "FWUP_STARTED";
138  case FWUP_OTHER:
139  return "FWUP_OTHER";
140  default:
141  return "unknown";
142  }
143 }
144 
145 
149 {
150  uint32_t result;
151  uint8_t buffer[4];
152  uint32_t n = thisPtr->m_readXffData(buffer, thisPtr->m_readIndex, 4);
153  thisPtr->m_readIndex += n;
154  if (n == 4)
155  result = (uint32_t)buffer[0] << 24 | (uint32_t)buffer[1] << 16 | (uint32_t)buffer[2] << 8 | buffer[3];
156  else
157  {
158  thisPtr->m_endOfFile = 1;
159  result = 0;
160  }
161  return result;
162 }
163 
164 
167 uint16_t readUint16(FwUpdate* thisPtr)
168 {
169  uint32_t result;
170  uint8_t buffer[2];
171  uint32_t n = thisPtr->m_readXffData(buffer, thisPtr->m_readIndex, 2);
172  thisPtr->m_readIndex += n;
173  if (n == 2)
174  result = (uint32_t)buffer[0] << 8 | buffer[1];
175  else
176  {
177  thisPtr->m_endOfFile = 1;
178  result = 0;
179  }
180  return (uint16_t)result;
181 }
182 
183 
186 uint8_t readUint8(FwUpdate* thisPtr)
187 {
188  uint8_t result;
189  uint8_t buffer[1];
190  uint32_t n = thisPtr->m_readXffData(buffer, thisPtr->m_readIndex, 1);
191  thisPtr->m_readIndex += n;
192  if (n == 1)
193  result = buffer[0];
194  else
195  {
196  thisPtr->m_endOfFile = 1;
197  result = 0;
198  }
199  return result;
200 }
201 
202 
205 static void readXffHeader(FwUpdate* thisPtr)
206 {
207  LOG("Fwu: readXffHeader()\n");
208 
209  uint32_t globalIdTemp = readUint32(thisPtr);
210  if (globalIdTemp != 0)
211  {
212  thisPtr->m_xffHeader.m_globalId = globalIdTemp;
213  thisPtr->m_xffHeader.m_sectionSize = readUint32(thisPtr);
214  thisPtr->m_xffHeader.m_firmwareRevision[0] = readUint8(thisPtr);
215  thisPtr->m_xffHeader.m_firmwareRevision[1] = readUint8(thisPtr);
216  thisPtr->m_xffHeader.m_firmwareRevision[2] = readUint8(thisPtr);
217  thisPtr->m_xffHeader.m_xffVersion[0] = readUint8(thisPtr);
218  thisPtr->m_xffHeader.m_xffVersion[1] = readUint8(thisPtr);
219  thisPtr->m_xffHeader.m_chipId = readUint8(thisPtr);
220  thisPtr->m_xffHeader.m_numberOfSections = readUint8(thisPtr);
221  thisPtr->m_xffHeader.m_addressLength = readUint8(thisPtr);
222  thisPtr->m_xffHeader.m_pageSize = readUint16(thisPtr);
223  if (thisPtr->m_xffHeader.m_xffVersion[0] >= 2)
224  thisPtr->m_xffHeader.m_sliceSize = readUint16(thisPtr);
225  else
227  }
228  else
229  {
230  (void) readUint32(thisPtr); // headerSize
231  thisPtr->m_xffHeader.m_globalId = readUint32(thisPtr);
232  thisPtr->m_xffHeader.m_sectionSize = readUint32(thisPtr);
233  thisPtr->m_xffHeader.m_firmwareRevision[0] = readUint8(thisPtr);
234  thisPtr->m_xffHeader.m_firmwareRevision[1] = readUint8(thisPtr);
235  thisPtr->m_xffHeader.m_firmwareRevision[2] = readUint8(thisPtr);
236  thisPtr->m_xffHeader.m_xffVersion[0] = readUint8(thisPtr);
237  thisPtr->m_xffHeader.m_xffVersion[1] = readUint8(thisPtr);
238  thisPtr->m_xffHeader.m_chipId = readUint8(thisPtr);
239  thisPtr->m_xffHeader.m_numberOfSections = readUint8(thisPtr);
240  thisPtr->m_xffHeader.m_addressLength = readUint8(thisPtr);
241  thisPtr->m_xffHeader.m_pageSize = readUint16(thisPtr);
242  thisPtr->m_xffHeader.m_sliceSize = readUint16(thisPtr);
243  thisPtr->m_xffHeader.m_hardwareVersion[0] = readUint8(thisPtr);
244  thisPtr->m_xffHeader.m_hardwareVersion[1] = readUint8(thisPtr);
245  if (thisPtr->m_xffHeader.m_xffVersion[0] >= 4)
246  {
247  for (int n = 0; n < 20; n++)
248  thisPtr->m_xffHeader.m_productCode[n] = (char) readUint8(thisPtr);
249  thisPtr->m_xffHeader.m_productVariant = readUint32(thisPtr);
250  }
251  }
252 }
253 
254 
257 static void sendReady(FwUpdate* thisPtr)
258 {
259  Xbus_message(thisPtr->m_txBuffer, 0xFF, XMID_FIRMWARE_UPDATE, 1);
262  thisPtr->m_sendXbusMessage(thisPtr->m_txBuffer);
263 }
264 
265 
268 static void sendHeader(FwUpdate* thisPtr)
269 {
270  uint32_t n;
271  Xbus_message(thisPtr->m_txBuffer, 0xFF, XMID_FIRMWARE_UPDATE, 1 + thisPtr->m_xffHeader.m_addressLength + 2);
272  uint8_t* payload = Xbus_getPointerToPayload(thisPtr->m_txBuffer);
273  payload[0] = FWUP_HEADER;
274  n = thisPtr->m_readXffData(&payload[1], thisPtr->m_readIndex, thisPtr->m_xffHeader.m_addressLength);
275  thisPtr->m_readIndex += n;
276  if (n == thisPtr->m_xffHeader.m_addressLength)
277  {
278  memcpy(&payload[1 + thisPtr->m_xffHeader.m_addressLength], (uint8_t*)&thisPtr->m_nofSlicesPerPage, 2);
280  thisPtr->m_sendXbusMessage(thisPtr->m_txBuffer);
281  }
282  else
283  thisPtr->m_endOfFile = 1;
284 }
285 
286 
289 static void sendSlice(FwUpdate* thisPtr)
290 {
291  uint32_t n;
292 
293  Xbus_message(thisPtr->m_txBuffer, 0xFF, XMID_FIRMWARE_UPDATE, 1 + thisPtr->m_xffHeader.m_sliceSize);
294  uint8_t* payload = Xbus_getPointerToPayload(thisPtr->m_txBuffer);
295 
296  payload[0] = FWUP_PAGESLICE;
297  n = thisPtr->m_readXffData(&payload[1], thisPtr->m_readIndex, thisPtr->m_xffHeader.m_sliceSize);
298  thisPtr->m_readIndex += n;
299  if (n == thisPtr->m_xffHeader.m_sliceSize)
300  {
302  thisPtr->m_sendXbusMessage(thisPtr->m_txBuffer);
303  }
304  else
305  thisPtr->m_endOfFile = 1;
306 }
307 
308 
311 static void sendOther(FwUpdate* thisPtr)
312 {
313  Xbus_message(thisPtr->m_txBuffer, 0xFF, XMID_FIRMWARE_UPDATE, 2);
314  uint8_t* payload = Xbus_getPointerToPayload(thisPtr->m_txBuffer);
315  payload[0] = FWUP_OTHER;
316  payload[1] = thisPtr->m_xffHeader.m_chipId;
317  LOG("Fwu: Send FWUP_OTHER\n");
319  thisPtr->m_sendXbusMessage(thisPtr->m_txBuffer);
320 }
321 
322 
325 static void sendFinished(FwUpdate* thisPtr)
326 {
327  Xbus_message(thisPtr->m_txBuffer, 0xFF, XMID_FIRMWARE_UPDATE, 1);
328  uint8_t* payload = Xbus_getPointerToPayload(thisPtr->m_txBuffer);
329  payload[0] = FWUP_FINISHED;
330  LOG("Fwu: Send FWUP_FINISHED\n");
332  thisPtr->m_sendXbusMessage(thisPtr->m_txBuffer);
333 }
334 
335 
338 static void enterNewSection(FwUpdate* thisPtr)
339 {
340  LOG("\nFwu: enterNewSection()\n");
341  readXffHeader(thisPtr);
343  thisPtr->m_nofSlicesPerPage = thisPtr->m_xffHeader.m_pageSize / thisPtr->m_xffHeader.m_sliceSize;
344  thisPtr->m_pageCounter = 0;
345  thisPtr->m_sliceCounter = 0;
346  sendOther(thisPtr);
347 }
348 
349 
352 void FwUpdate_init(FwUpdate* thisPtr)
353 {
354  LOG("Fwu: init()\n");
355  thisPtr->m_state = STATE_Idle;
356 }
357 
358 
361 void FwUpdate_start(FwUpdate* thisPtr)
362 {
363  if (thisPtr->m_state == STATE_Idle)
364  {
365  LOG("Fwu: start() --> Send FWUP_READY\n");
366  thisPtr->m_readIndex = 0;
367  thisPtr->m_endOfFile = 0;
368  thisPtr->m_state = STATE_Start;
369  sendReady(thisPtr);
370  }
371  else
372  {
373  thisPtr->m_readyHandler(FWU_Failed);
374  LOG("Fwu: start() failed\n");
375  }
376 }
377 
378 
382 void FwUpdate_handleXbus(FwUpdate* thisPtr, uint8_t const* xbusMessage)
383 {
384  uint8_t ack;
385 
386  if (Xbus_getMessageId(xbusMessage) != XMID_FIRMWARE_UPDATE)
387  {
388  LOG("Fwu: Got unhandled xbus message 0x%02X (ignored)\n", Xbus_getMessageId(xbusMessage));
389  return;
390  }
391 
392  ack = Xbus_getConstPointerToPayload(xbusMessage)[0];
393 
394  switch (thisPtr->m_state)
395  {
396  case STATE_Idle:
397  {
398  LOG("Fwu: Got %s in STATE_Idle (ignored)\n", ackToString(ack));
399  break;
400  }
401 
402  case STATE_Start:
403  {
404  if (ack == FWUP_READY)
405  {
406  LOG("Fwu: FWUP_READY in STATE_Start --> Enter new section\n");
407  enterNewSection(thisPtr);
408  thisPtr->m_state = STATE_WaitReady;
409  }
410  else
411  LOG("Fwu: Got %s in STATE_Start (ignored)\n", ackToString(ack));
412  break;
413  }
414 
415  case STATE_WaitReady:
416  {
417  if (ack == FWUP_READY)
418  {
419  LOG("Fwu: FWUP_READY in STATE_WaitReady --> Send header\n");
420  sendHeader(thisPtr);
421  thisPtr->m_state = STATE_WaitHeaderResult;
422  }
423  else
424  {
425  LOG("Fwu: Got %s in STATE_WaitReady --> Failed\n", ackToString(ack));
426  thisPtr->m_readyHandler(FWU_Failed);
427  thisPtr->m_state = STATE_Idle;
428  }
429  break;
430  }
431 
433  {
434  if (ack == FWUP_READY)
435  {
436  LOG("Fwu: FWUP_READY in STATE_WaitHeaderResult --> Send first slice\n");
437  sendSlice(thisPtr);
438  thisPtr->m_sliceCounter = 1;
439  thisPtr->m_state = STATE_WaitSliceReady;
440  }
441  else
442  {
443  LOG("Fwu: Got %s in STATE_WaitHeaderResult --> Failed\n", ackToString(ack));
444  thisPtr->m_readyHandler(FWU_Failed);
445  thisPtr->m_state = STATE_Idle;
446  }
447  break;
448  }
449 
451  {
452  if (ack == FWUP_READY)
453  {
454  if (thisPtr->m_sliceCounter < thisPtr->m_nofSlicesPerPage)
455  {
456  LOG("Fwu: FWUP_READY in STATE_WaitSliceReady --> Send slice %d\n", thisPtr->m_sliceCounter);
457  sendSlice(thisPtr);
458  thisPtr->m_sliceCounter++;
459  }
460  else
461  {
462  LOG("Fwu: All slices sent --> STATE_WaitPageOk\n");
463  thisPtr->m_state = STATE_WaitPageOk;
464  }
465  }
466  else
467  {
468  LOG("Fwu: Got %s in STATE_WaitSliceReady --> Failed\n", ackToString(ack));
469  thisPtr->m_readyHandler(FWU_Failed);
470  thisPtr->m_state = STATE_Idle;
471  }
472  break;
473  }
474 
475  case STATE_WaitPageOk:
476  {
477  if (ack == FWUP_OK)
478  {
479  LOG("Fwu: FWUP_OK in STATE_WaitPageOk --> STATE_WaitPageReady\n");
480  thisPtr->m_state = STATE_WaitPageReady;
481  }
482  else
483  {
484  LOG("Fwu: Got %s in STATE_WaitPageOk --> Failed\n", ackToString(ack));
485  thisPtr->m_readyHandler(FWU_Failed);
486  thisPtr->m_state = STATE_Idle;
487  }
488  break;
489  }
490 
491  case STATE_WaitPageReady:
492  {
493  if (ack == FWUP_READY)
494  {
495  thisPtr->m_pageCounter++;
496  if (thisPtr->m_nofPages != 0 && thisPtr->m_pageCounter == thisPtr->m_nofPages)
497  {
498  LOG("Fwu: All pages sent --> Enter new section\n");
499  enterNewSection(thisPtr);
500  thisPtr->m_state = STATE_WaitReady;
501  }
502  else
503  {
504  sendHeader(thisPtr);
505  if (thisPtr->m_endOfFile)
506  {
507  LOG("Fwu: End of file --> Firmware update done\n");
508  sendFinished(thisPtr);
509  thisPtr->m_readyHandler(FWU_Success);
510  thisPtr->m_state = STATE_Idle;
511  }
512  else
513  {
514  LOG("Fwu: FWUP_READY in STATE_WaitPageReady --> Send header\n");
515  thisPtr->m_state = STATE_WaitHeaderResult;
516  }
517  }
518  }
519  else
520  {
521  LOG("Fwu: Got %s in STATE_WaitPageReady --> Failed\n", ackToString(ack));
522  thisPtr->m_readyHandler(FWU_Failed);
523  thisPtr->m_state = STATE_Idle;
524  }
525  break;
526  }
527 
528  default:
529  break;
530  }
531 }
FWUP_OTHER
#define FWUP_OTHER
Definition: fwupdate.c:89
XffHeader::m_firmwareRevision
uint8_t m_firmwareRevision[3]
Definition: fwupdate.h:91
FwUpdate_start
void FwUpdate_start(FwUpdate *thisPtr)
Start a firmware update.
Definition: fwupdate.c:361
FwUpdate::m_nofSlicesPerPage
uint32_t m_nofSlicesPerPage
Definition: fwupdate.h:152
FwUpdate::m_endOfFile
uint8_t m_endOfFile
Definition: fwupdate.h:156
XffHeader::m_addressLength
uint8_t m_addressLength
Definition: fwupdate.h:95
FWUP_PAGE
#define FWUP_PAGE
Definition: fwupdate.c:85
FWUP_HEADER
#define FWUP_HEADER
Definition: fwupdate.c:86
FwUpdate::m_readyHandler
void(* m_readyHandler)(FWU_Result result)
Callback function by which FwUpdate notifies the host that a firmware update has finished.
Definition: fwupdate.h:141
readUint16
uint16_t readUint16(FwUpdate *thisPtr)
Read a uint16_t from the current position in the xff.
Definition: fwupdate.c:167
fwupdate.h
command
ROSLIB_DECL std::string command(const std::string &cmd)
FwUpdate::m_readXffData
uint32_t(* m_readXffData)(uint8_t *buffer, uint32_t offset, uint32_t length)
Callback function by which FwUpdate requests for xff data.
Definition: fwupdate.h:131
STATE_WaitPageReady
@ STATE_WaitPageReady
Definition: fwupdate.h:114
XffHeader::m_productVariant
uint32_t m_productVariant
Definition: fwupdate.h:100
enterNewSection
static void enterNewSection(FwUpdate *thisPtr)
Enter the next section of the xff file.
Definition: fwupdate.c:338
FWUP_FINISHED
#define FWUP_FINISHED
Definition: fwupdate.c:84
FwUpdate
FwUpdate object definition.
Definition: fwupdate.h:121
XffHeader::m_sectionSize
uint32_t m_sectionSize
Definition: fwupdate.h:90
XffHeader::m_sliceSize
uint16_t m_sliceSize
Definition: fwupdate.h:97
XffHeader::m_numberOfSections
uint8_t m_numberOfSections
Definition: fwupdate.h:94
STATE_WaitSliceReady
@ STATE_WaitSliceReady
Definition: fwupdate.h:112
XffHeader::m_chipId
uint8_t m_chipId
Definition: fwupdate.h:93
xbus.h
STATE_Start
@ STATE_Start
Definition: fwupdate.h:109
FWUP_OK
#define FWUP_OK
Definition: fwupdate.c:81
XffHeader::m_hardwareVersion
uint8_t m_hardwareVersion[2]
Definition: fwupdate.h:98
readXffHeader
static void readXffHeader(FwUpdate *thisPtr)
Read an Xff header from the current position in the xff.
Definition: fwupdate.c:205
FwUpdate_init
void FwUpdate_init(FwUpdate *thisPtr)
Initialize a FwUpdate instance.
Definition: fwupdate.c:352
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
STATE_Idle
@ STATE_Idle
Definition: fwupdate.h:108
commandToString
const char * commandToString(uint8_t command)
Helper function for converting a firmware updater command to a string.
Definition: fwupdate.c:94
FwUpdate::m_state
FWU_State m_state
Definition: fwupdate.h:149
FwUpdate::m_pageCounter
uint32_t m_pageCounter
Definition: fwupdate.h:153
FWUP_DEFAULT_SLICE_SIZE
#define FWUP_DEFAULT_SLICE_SIZE
Definition: fwupdate.c:75
FwUpdate::m_readIndex
uint32_t m_readIndex
Definition: fwupdate.h:155
STATE_WaitHeaderResult
@ STATE_WaitHeaderResult
Definition: fwupdate.h:111
sendSlice
static void sendSlice(FwUpdate *thisPtr)
Send a page slice.
Definition: fwupdate.c:289
FwUpdate::m_nofPages
uint32_t m_nofPages
Definition: fwupdate.h:151
Xbus_insertChecksum
void Xbus_insertChecksum(uint8_t *xbusMessage)
Inserts the correct checksum in xbus message.
Definition: xbus.c:175
FwUpdate::m_sendXbusMessage
void(* m_sendXbusMessage)(uint8_t const *xbusMessage)
Callback function via which FwUpdate can send xbus messages to the module.
Definition: fwupdate.h:136
Xbus_getConstPointerToPayload
uint8_t const * Xbus_getConstPointerToPayload(uint8_t const *xbusMessage)
Returns a const pointer to payload of an xbus message.
Definition: xbus.c:167
FWUP_CSERROR
#define FWUP_CSERROR
Definition: fwupdate.c:82
FWUP_STARTED
#define FWUP_STARTED
Definition: fwupdate.c:88
XffHeader::m_productCode
char m_productCode[20]
Definition: fwupdate.h:99
STATE_WaitReady
@ STATE_WaitReady
Definition: fwupdate.h:110
FWUP_CRITICAL
#define FWUP_CRITICAL
Definition: fwupdate.c:83
FWUP_READY
#define FWUP_READY
Firmware updater commands.
Definition: fwupdate.c:80
sendReady
static void sendReady(FwUpdate *thisPtr)
Send a FWUP_READY command.
Definition: fwupdate.c:257
FWU_Success
@ FWU_Success
Definition: fwupdate.h:80
sendOther
static void sendOther(FwUpdate *thisPtr)
Send a FWUP_OTHER command.
Definition: fwupdate.c:311
XMID_FIRMWARE_UPDATE
#define XMID_FIRMWARE_UPDATE
Definition: fwupdate.c:73
XffHeader::m_xffVersion
uint8_t m_xffVersion[2]
Definition: fwupdate.h:92
FwUpdate::m_sliceCounter
uint32_t m_sliceCounter
Definition: fwupdate.h:154
FwUpdate::m_txBuffer
uint8_t * m_txBuffer
Memory needed by the FwUpdate. Host must allocate a block of memory of size FWU_REQUIRED_TXBUFFER_SIZ...
Definition: fwupdate.h:146
XffHeader::m_globalId
uint32_t m_globalId
Definition: fwupdate.h:89
Xbus_message
void Xbus_message(uint8_t *xbusMessage, uint8_t bid, uint8_t mid, uint16_t len)
Initialize a xbus message with BID, MID and Length.
Definition: xbus.c:134
sendHeader
static void sendHeader(FwUpdate *thisPtr)
Send a FWUP_HEADER command.
Definition: fwupdate.c:268
readUint32
uint32_t readUint32(FwUpdate *thisPtr)
Read a uint32_t from the current position in the xff.
Definition: fwupdate.c:148
readUint8
uint8_t readUint8(FwUpdate *thisPtr)
Read a uint8_t from the current position in the xff.
Definition: fwupdate.c:186
LOG
#define LOG(...)
Definition: fwupdate.c:70
ackToString
const char * ackToString(uint8_t command)
Helper function for converting a firmware updater command acknowledge to a string.
Definition: fwupdate.c:120
FWUP_PAGESLICE
#define FWUP_PAGESLICE
Definition: fwupdate.c:87
Xbus_getPointerToPayload
uint8_t * Xbus_getPointerToPayload(uint8_t *xbusMessage)
Returns pointer to payload of an xbus message.
Definition: xbus.c:157
sendFinished
static void sendFinished(FwUpdate *thisPtr)
Send a FWUP_FINISHED command.
Definition: fwupdate.c:325
STATE_WaitPageOk
@ STATE_WaitPageOk
Definition: fwupdate.h:113
FwUpdate::m_xffHeader
XffHeader m_xffHeader
Definition: fwupdate.h:150
Xbus_getMessageId
int Xbus_getMessageId(const uint8_t *xbusMessage)
Returns xbus Message identifier.
Definition: xbus.c:91
XffHeader::m_pageSize
uint16_t m_pageSize
Definition: fwupdate.h:96
FwUpdate_handleXbus
void FwUpdate_handleXbus(FwUpdate *thisPtr, uint8_t const *xbusMessage)
Handle xbus message coming from the module.
Definition: fwupdate.c:382
FWU_Failed
@ FWU_Failed
Definition: fwupdate.h:81


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20