Skip to content

Commit

Permalink
App version support added
Browse files Browse the repository at this point in the history
  • Loading branch information
glueckm committed Jul 21, 2015
1 parent a70555b commit fa448f5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 24 deletions.
6 changes: 5 additions & 1 deletion Bus-Updater/src/boot_descriptor_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "boot_descriptor_block.h"
#include "crc.h"

#if 0
#if 1
unsigned int checkVectorTable (unsigned int start)
{
unsigned int i;
Expand Down Expand Up @@ -39,4 +39,8 @@ unsigned int checkApplication (AppDescriptionBlock * block)
return 0;
}

inline unsigned char * getAppVersion(AppDescriptionBlock * block)
{
return (unsigned char *) (block->appVersionAddress);
}

3 changes: 3 additions & 0 deletions Bus-Updater/src/boot_descriptor_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ typedef struct
unsigned int startAddress;
unsigned int endAddress;
unsigned int crc;
unsigned int appVersionAddress;
} AppDescriptionBlock;

unsigned int checkApplication (AppDescriptionBlock * block);

unsigned char * getAppVersion(AppDescriptionBlock * block);

#ifdef __cplusplus
}
#endif
Expand Down
23 changes: 22 additions & 1 deletion Bus-Updater/src/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ enum
, UPD_UNLOCK_DEVICE = 30
, UPD_REQUEST_UID = 31
, UPD_RESPONSE_UID = 32
, UPD_APP_VERSION_REQUEST = 33
, UPD_APP_VERSION_RESPONSE = 34
, UPD_SET_EMULATION = 100
};

Expand Down Expand Up @@ -186,6 +188,7 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
if (!((BcuUpdate *) bcu)->progPinStatus())
{ // the operator has physical access to the device -> we unlock it
deviceLocked = DEVICE_UNLOCKED;
lastError = IAP_SUCCESS;
}
else
{ // we need to ensure that only authorized operators can
Expand All @@ -206,6 +209,7 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
if (lastError != UPD_UID_MISSMATCH)
{
deviceLocked = DEVICE_UNLOCKED;
lastError = IAP_SUCCESS;
}
}
break;
Expand All @@ -230,6 +234,24 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
else
lastError = UPD_DEVICE_LOCKED;
break;
case UPD_APP_VERSION_REQUEST:
unsigned char * appversion;
appversion = getAppVersion
( (AppDescriptionBlock *)
(FIRST_SECTOR - (1 + data[3]) * BOOT_BLOCK_SIZE)
);
if (((unsigned int) appversion) < 0x50000)
{
* sendTel = _prepareReturnTelegram(12, UPD_APP_VERSION_RESPONSE);
memcpy( bcu->sendTelegram +10
, appversion
, 12
);
lastError = IAP_SUCCESS;
}
else
lastError = UPD_APPLICATION_NOT_STARTABLE;
break;
case UPD_ERASE_SECTOR:
#ifdef SERIAL_DEBUG
if (emulation & 0xF0)
Expand Down Expand Up @@ -339,7 +361,6 @@ unsigned char handleMemoryRequests(int apciCmd, bool * sendTel, unsigned char *
#endif
if (crc == streamToUIn32(data + 3))
{
address = FIRST_SECTOR - (1 + data[7]) * BOOT_BLOCK_SIZE; // start address of the descriptor block
if (checkApplication ((AppDescriptionBlock *) ramBuffer))
{
lastError = RUN_OR_EMULATE
Expand Down
8 changes: 8 additions & 0 deletions Memory-Layouts/LPC1115-App-With-Bootloader.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<info flash_driver='LPC11_12_13_64K_8K.cfx'>
<chip>
<memory id='Flash' type='Flash' is_ro='true' can_program='true'></memory>
<memory id='RAM' type='RAM'></memory>
<memoryInstance id='MFlash64' derived_from='Flash' location='0x2000' size='0xe000' edited='true' />
<memoryInstance id='RamLoc8' derived_from='RAM' location='0x10000100' size='0x1f00' edited='true' />
</chip>
</info>
43 changes: 21 additions & 22 deletions examples/example-busmon-for-bootloader/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -361,28 +361,27 @@
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;&#13;
&lt;memory id="RAM" type="RAM"/&gt;&#13;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;&#13;
&lt;memoryInstance derived_from="Flash" edited="true" id="MFlash32" location="0x2000" size="0x6000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" edited="true" id="RamLoc8" location="0x10000100" size="0x1f00"/&gt;&#13;
&lt;peripheralInstance derived_from="V6M_NVIC" id="NVIC" location="0xe000e000"/&gt;&#13;
&lt;peripheralInstance derived_from="V6M_DCR" id="DCR" location="0xe000edf0"/&gt;&#13;
&lt;peripheralInstance derived_from="I2C" id="I2C" location="0x40000000"/&gt;&#13;
&lt;peripheralInstance derived_from="WWDT" id="WWDT" location="0x40004000"/&gt;&#13;
&lt;peripheralInstance derived_from="UART" id="UART" location="0x40008000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT16B0" id="CT16B0" location="0x4000c000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT16B1" id="CT16B1" location="0x40010000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT32B0" id="CT32B0" location="0x40014000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT32B1" id="CT32B1" location="0x40018000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC" id="ADC" location="0x4001c000"/&gt;&#13;
&lt;peripheralInstance derived_from="PMU" id="PMU" location="0x40038000"/&gt;&#13;
&lt;peripheralInstance derived_from="FLASHCTRL" id="FLASHCTRL" location="0x4003c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI0" id="SPI0" location="0x40040000"/&gt;&#13;
&lt;peripheralInstance derived_from="IOCON" id="IOCON" location="0x40044000"/&gt;&#13;
&lt;peripheralInstance derived_from="SYSCON" id="SYSCON" location="0x40048000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI1" id="SPI1" location="0x40058000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO0" id="GPIO0" location="0x50000000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO1" id="GPIO1" location="0x50010000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO2" id="GPIO2" location="0x50020000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO3" id="GPIO3" location="0x50030000"/&gt;&#13;
&lt;memoryInstance derived_from="Flash" id="MFlash32" location="0x0" size="0x8000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/&gt;&#13;
&lt;peripheralInstance derived_from="V6M_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/&gt;&#13;
&lt;peripheralInstance derived_from="V6M_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/&gt;&#13;
&lt;peripheralInstance derived_from="I2C" determined="infoFile" id="I2C" location="0x40000000"/&gt;&#13;
&lt;peripheralInstance derived_from="WWDT" determined="infoFile" id="WWDT" location="0x40004000"/&gt;&#13;
&lt;peripheralInstance derived_from="UART" determined="infoFile" id="UART" location="0x40008000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT16B0" determined="infoFile" id="CT16B0" location="0x4000c000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT16B1" determined="infoFile" id="CT16B1" location="0x40010000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT32B0" determined="infoFile" id="CT32B0" location="0x40014000"/&gt;&#13;
&lt;peripheralInstance derived_from="CT32B1" determined="infoFile" id="CT32B1" location="0x40018000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC" determined="infoFile" id="ADC" location="0x4001c000"/&gt;&#13;
&lt;peripheralInstance derived_from="PMU" determined="infoFile" id="PMU" location="0x40038000"/&gt;&#13;
&lt;peripheralInstance derived_from="FLASHCTRL" determined="infoFile" id="FLASHCTRL" location="0x4003c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI0" determined="infoFile" id="SPI0" location="0x40040000"/&gt;&#13;
&lt;peripheralInstance derived_from="IOCON" determined="infoFile" id="IOCON" location="0x40044000"/&gt;&#13;
&lt;peripheralInstance derived_from="SYSCON" determined="infoFile" id="SYSCON" location="0x40048000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO0" determined="infoFile" id="GPIO0" location="0x50000000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO1" determined="infoFile" id="GPIO1" location="0x50010000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO2" determined="infoFile" id="GPIO2" location="0x50020000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO3" determined="infoFile" id="GPIO3" location="0x50030000"/&gt;&#13;
&lt;/chip&gt;&#13;
&lt;processor&gt;&lt;name gcc_name="cortex-m0"&gt;Cortex-M0&lt;/name&gt;&#13;
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;
Expand Down

0 comments on commit fa448f5

Please sign in to comment.