summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorsave2010-05-18 14:07:39 +0000
committersave2010-05-18 14:07:39 +0000
commit1b4b38a7683a5120ff30531ee4ef42ac9abc2556 (patch)
tree933698a761f928dbd8b8ec3c20d6ffdde1de2bd4 /cleopatre
parent877e2ed56fe7214577a04ffce22b101236ce47b9 (diff)
cleo/u-boot/spiupd: add a check of version after image download, closes #1545
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7111 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/u-boot-1.1.6/net/spidupd.c29
-rw-r--r--cleopatre/u-boot-1.1.6/net/spidupd.h1
2 files changed, 24 insertions, 6 deletions
diff --git a/cleopatre/u-boot-1.1.6/net/spidupd.c b/cleopatre/u-boot-1.1.6/net/spidupd.c
index 2cf5efb4bf..a1059056db 100644
--- a/cleopatre/u-boot-1.1.6/net/spidupd.c
+++ b/cleopatre/u-boot-1.1.6/net/spidupd.c
@@ -112,6 +112,7 @@ struct update_process {
unsigned char eth_mac_addr[6];
unsigned char plc_mac_addr[6];
int use_plc_addr;
+ char wanted_version[SPIDUPD_STRING_VERSION_SIZE];
};
/** Global processus structure */
@@ -624,7 +625,6 @@ static void SpidupdTimeout(void);
static void SpidupdSend(int rsp_type)
{
int len = 0;
- int transfer_end = 0;
volatile uchar *pkt;
VSMS_MME_t *mme;
VsUpdStartCnf_t *vs_update_start_cnf;
@@ -689,7 +689,6 @@ static void SpidupdSend(int rsp_type)
/* This is the end of packet, determine length */
len = ((ulong)vs_update_end_cnf - (ulong)pkt) + sizeof(VsUpdEndCnf_t);
- transfer_end = 1;
break;
case UPD_IND:
@@ -712,9 +711,6 @@ static void SpidupdSend(int rsp_type)
/* Send packet */
NetSendPacket(pkt, len);
-
- if(transfer_end)
- printf("Transfer Done, Write image to flash...\n");
}
/**
@@ -878,6 +874,8 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
break;
}
}
+ /* Save wanted version */
+ strncpy(ctx.wanted_version, (char*)vs_update_start_req->version, SPIDUPD_STRING_VERSION_SIZE);
}
}
else
@@ -947,6 +945,8 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
if (ctx.state == STATE_UPD_TRANSFER)
{
+ ctx.state = STATE_UPD_END;
+
/* Transfer is finished so calculate MD5 */
memcpy(md5_client, vs_update_end_req->md5_sum, 16);
md5_image((md5_byte_t *)md5_server);
@@ -955,13 +955,28 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
{
/* Wrong MD5 */
printf("Error (MD5 Error).\n");
+ ctx.modem_busy = 0;
ctx.end_cnf.result = SPIDUPD_MD5_ERROR;
+ ctx.state = STATE_UPD_START;
/* Abort the update */
NetState = NETLOOP_FAIL;
}
- ctx.state = STATE_UPD_END;
+ /* Check image version with wanted version */
+ else if(strncmp(ctx.wanted_version,
+ (char*)((spidcom_image_desc_t *)place->ram_addr)->version,
+ SPIDUPD_STRING_VERSION_SIZE) != 0)
+ {
+ /* Wrong given version */
+ printf("Error (Wrong given version).\n");
+ ctx.modem_busy = 0;
+ ctx.end_cnf.result = SPIDUPD_VERSION_ERROR;
+ ctx.state = STATE_UPD_START;
+
+ /* Abort the update */
+ NetState = NETLOOP_FAIL;
+ }
}
else
{
@@ -1021,6 +1036,8 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
printf("Error writting img desc header to flash -- image will not be valid.\n");
ctx.end_ind.result = SPIDUPD_FLASH_WRITE_ERROR;
}
+ ctx.modem_busy = 0;
+ ctx.state = STATE_UPD_START;
SpidupdSend(UPD_IND);
}
}
diff --git a/cleopatre/u-boot-1.1.6/net/spidupd.h b/cleopatre/u-boot-1.1.6/net/spidupd.h
index 2fca618a8e..e09fb04048 100644
--- a/cleopatre/u-boot-1.1.6/net/spidupd.h
+++ b/cleopatre/u-boot-1.1.6/net/spidupd.h
@@ -117,6 +117,7 @@ typedef struct
/* end_cnf */
#define SPIDUPD_MD5_ERROR 0x01
+#define SPIDUPD_VERSION_ERROR 0x02
/* end_ind */
#define SPIDUPD_FLASH_WRITE_ERROR 0x01