Skip to content

Commit fa448f5

Browse files
committed
App version support added
1 parent a70555b commit fa448f5

File tree

5 files changed

+59
-24
lines changed

5 files changed

+59
-24
lines changed

Bus-Updater/src/boot_descriptor_block.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "boot_descriptor_block.h"
99
#include "crc.h"
1010

11-
#if 0
11+
#if 1
1212
unsigned int checkVectorTable (unsigned int start)
1313
{
1414
unsigned int i;
@@ -39,4 +39,8 @@ unsigned int checkApplication (AppDescriptionBlock * block)
3939
return 0;
4040
}
4141

42+
inline unsigned char * getAppVersion(AppDescriptionBlock * block)
43+
{
44+
return (unsigned char *) (block->appVersionAddress);
45+
}
4246

Bus-Updater/src/boot_descriptor_block.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ typedef struct
2222
unsigned int startAddress;
2323
unsigned int endAddress;
2424
unsigned int crc;
25+
unsigned int appVersionAddress;
2526
} AppDescriptionBlock;
2627

2728
unsigned int checkApplication (AppDescriptionBlock * block);
2829

30+
unsigned char * getAppVersion(AppDescriptionBlock * block);
31+
2932
#ifdef __cplusplus
3033
}
3134
#endif

Bus-Updater/src/update.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ enum
8383
, UPD_UNLOCK_DEVICE = 30
8484
, UPD_REQUEST_UID = 31
8585
, UPD_RESPONSE_UID = 32
86+
, UPD_APP_VERSION_REQUEST = 33
87+
, UPD_APP_VERSION_RESPONSE = 34
8688
, UPD_SET_EMULATION = 100
8789
};
8890

@@ -186,6 +188,7 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
186188
if (!((BcuUpdate *) bcu)->progPinStatus())
187189
{ // the operator has physical access to the device -> we unlock it
188190
deviceLocked = DEVICE_UNLOCKED;
191+
lastError = IAP_SUCCESS;
189192
}
190193
else
191194
{ // we need to ensure that only authorized operators can
@@ -206,6 +209,7 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
206209
if (lastError != UPD_UID_MISSMATCH)
207210
{
208211
deviceLocked = DEVICE_UNLOCKED;
212+
lastError = IAP_SUCCESS;
209213
}
210214
}
211215
break;
@@ -230,6 +234,24 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
230234
else
231235
lastError = UPD_DEVICE_LOCKED;
232236
break;
237+
case UPD_APP_VERSION_REQUEST:
238+
unsigned char * appversion;
239+
appversion = getAppVersion
240+
( (AppDescriptionBlock *)
241+
(FIRST_SECTOR - (1 + data[3]) * BOOT_BLOCK_SIZE)
242+
);
243+
if (((unsigned int) appversion) < 0x50000)
244+
{
245+
* sendTel = _prepareReturnTelegram(12, UPD_APP_VERSION_RESPONSE);
246+
memcpy( bcu->sendTelegram +10
247+
, appversion
248+
, 12
249+
);
250+
lastError = IAP_SUCCESS;
251+
}
252+
else
253+
lastError = UPD_APPLICATION_NOT_STARTABLE;
254+
break;
233255
case UPD_ERASE_SECTOR:
234256
#ifdef SERIAL_DEBUG
235257
if (emulation & 0xF0)
@@ -339,7 +361,6 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
339361
#endif
340362
if (crc == streamToUIn32(data + 3))
341363
{
342-
address = FIRST_SECTOR - (1 + data[7]) * BOOT_BLOCK_SIZE; // start address of the descriptor block
343364
if (checkApplication ((AppDescriptionBlock *) ramBuffer))
344365
{
345366
lastError = RUN_OR_EMULATE
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<info flash_driver='LPC11_12_13_64K_8K.cfx'>
2+
<chip>
3+
<memory id='Flash' type='Flash' is_ro='true' can_program='true'></memory>
4+
<memory id='RAM' type='RAM'></memory>
5+
<memoryInstance id='MFlash64' derived_from='Flash' location='0x2000' size='0xe000' edited='true' />
6+
<memoryInstance id='RamLoc8' derived_from='RAM' location='0x10000100' size='0x1f00' edited='true' />
7+
</chip>
8+
</info>

examples/example-busmon-for-bootloader/.cproject

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -361,28 +361,27 @@
361361
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;&#13;
362362
&lt;memory id="RAM" type="RAM"/&gt;&#13;
363363
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;&#13;
364-
&lt;memoryInstance derived_from="Flash" edited="true" id="MFlash32" location="0x2000" size="0x6000"/&gt;&#13;
365-
&lt;memoryInstance derived_from="RAM" edited="true" id="RamLoc8" location="0x10000100" size="0x1f00"/&gt;&#13;
366-
&lt;peripheralInstance derived_from="V6M_NVIC" id="NVIC" location="0xe000e000"/&gt;&#13;
367-
&lt;peripheralInstance derived_from="V6M_DCR" id="DCR" location="0xe000edf0"/&gt;&#13;
368-
&lt;peripheralInstance derived_from="I2C" id="I2C" location="0x40000000"/&gt;&#13;
369-
&lt;peripheralInstance derived_from="WWDT" id="WWDT" location="0x40004000"/&gt;&#13;
370-
&lt;peripheralInstance derived_from="UART" id="UART" location="0x40008000"/&gt;&#13;
371-
&lt;peripheralInstance derived_from="CT16B0" id="CT16B0" location="0x4000c000"/&gt;&#13;
372-
&lt;peripheralInstance derived_from="CT16B1" id="CT16B1" location="0x40010000"/&gt;&#13;
373-
&lt;peripheralInstance derived_from="CT32B0" id="CT32B0" location="0x40014000"/&gt;&#13;
374-
&lt;peripheralInstance derived_from="CT32B1" id="CT32B1" location="0x40018000"/&gt;&#13;
375-
&lt;peripheralInstance derived_from="ADC" id="ADC" location="0x4001c000"/&gt;&#13;
376-
&lt;peripheralInstance derived_from="PMU" id="PMU" location="0x40038000"/&gt;&#13;
377-
&lt;peripheralInstance derived_from="FLASHCTRL" id="FLASHCTRL" location="0x4003c000"/&gt;&#13;
378-
&lt;peripheralInstance derived_from="SPI0" id="SPI0" location="0x40040000"/&gt;&#13;
379-
&lt;peripheralInstance derived_from="IOCON" id="IOCON" location="0x40044000"/&gt;&#13;
380-
&lt;peripheralInstance derived_from="SYSCON" id="SYSCON" location="0x40048000"/&gt;&#13;
381-
&lt;peripheralInstance derived_from="SPI1" id="SPI1" location="0x40058000"/&gt;&#13;
382-
&lt;peripheralInstance derived_from="GPIO0" id="GPIO0" location="0x50000000"/&gt;&#13;
383-
&lt;peripheralInstance derived_from="GPIO1" id="GPIO1" location="0x50010000"/&gt;&#13;
384-
&lt;peripheralInstance derived_from="GPIO2" id="GPIO2" location="0x50020000"/&gt;&#13;
385-
&lt;peripheralInstance derived_from="GPIO3" id="GPIO3" location="0x50030000"/&gt;&#13;
364+
&lt;memoryInstance derived_from="Flash" id="MFlash32" location="0x0" size="0x8000"/&gt;&#13;
365+
&lt;memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/&gt;&#13;
366+
&lt;peripheralInstance derived_from="V6M_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/&gt;&#13;
367+
&lt;peripheralInstance derived_from="V6M_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/&gt;&#13;
368+
&lt;peripheralInstance derived_from="I2C" determined="infoFile" id="I2C" location="0x40000000"/&gt;&#13;
369+
&lt;peripheralInstance derived_from="WWDT" determined="infoFile" id="WWDT" location="0x40004000"/&gt;&#13;
370+
&lt;peripheralInstance derived_from="UART" determined="infoFile" id="UART" location="0x40008000"/&gt;&#13;
371+
&lt;peripheralInstance derived_from="CT16B0" determined="infoFile" id="CT16B0" location="0x4000c000"/&gt;&#13;
372+
&lt;peripheralInstance derived_from="CT16B1" determined="infoFile" id="CT16B1" location="0x40010000"/&gt;&#13;
373+
&lt;peripheralInstance derived_from="CT32B0" determined="infoFile" id="CT32B0" location="0x40014000"/&gt;&#13;
374+
&lt;peripheralInstance derived_from="CT32B1" determined="infoFile" id="CT32B1" location="0x40018000"/&gt;&#13;
375+
&lt;peripheralInstance derived_from="ADC" determined="infoFile" id="ADC" location="0x4001c000"/&gt;&#13;
376+
&lt;peripheralInstance derived_from="PMU" determined="infoFile" id="PMU" location="0x40038000"/&gt;&#13;
377+
&lt;peripheralInstance derived_from="FLASHCTRL" determined="infoFile" id="FLASHCTRL" location="0x4003c000"/&gt;&#13;
378+
&lt;peripheralInstance derived_from="SPI0" determined="infoFile" id="SPI0" location="0x40040000"/&gt;&#13;
379+
&lt;peripheralInstance derived_from="IOCON" determined="infoFile" id="IOCON" location="0x40044000"/&gt;&#13;
380+
&lt;peripheralInstance derived_from="SYSCON" determined="infoFile" id="SYSCON" location="0x40048000"/&gt;&#13;
381+
&lt;peripheralInstance derived_from="GPIO0" determined="infoFile" id="GPIO0" location="0x50000000"/&gt;&#13;
382+
&lt;peripheralInstance derived_from="GPIO1" determined="infoFile" id="GPIO1" location="0x50010000"/&gt;&#13;
383+
&lt;peripheralInstance derived_from="GPIO2" determined="infoFile" id="GPIO2" location="0x50020000"/&gt;&#13;
384+
&lt;peripheralInstance derived_from="GPIO3" determined="infoFile" id="GPIO3" location="0x50030000"/&gt;&#13;
386385
&lt;/chip&gt;&#13;
387386
&lt;processor&gt;&lt;name gcc_name="cortex-m0"&gt;Cortex-M0&lt;/name&gt;&#13;
388387
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;

0 commit comments

Comments
 (0)