summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6
diff options
context:
space:
mode:
authorsave2010-05-19 11:55:11 +0000
committersave2010-05-19 11:55:11 +0000
commit2bf9707a081ad7b02ef44139e0303112f1cdfed6 (patch)
treeba4d6a852f24fa63d4c86c596616e6e794d043e1 /cleopatre/u-boot-1.1.6
parentd54f13c252dcb7fb0aaa5110542fd018ef075c86 (diff)
cleo/u-boot.spidupd: check same version only with running one, closes #1479
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7116 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre/u-boot-1.1.6')
-rw-r--r--cleopatre/u-boot-1.1.6/net/spidupd.c81
1 files changed, 8 insertions, 73 deletions
diff --git a/cleopatre/u-boot-1.1.6/net/spidupd.c b/cleopatre/u-boot-1.1.6/net/spidupd.c
index e5ad4d077e..a2cf1f2042 100644
--- a/cleopatre/u-boot-1.1.6/net/spidupd.c
+++ b/cleopatre/u-boot-1.1.6/net/spidupd.c
@@ -88,7 +88,7 @@ struct update_place {
ulong correct_img_exist;
ulong correct_type;
ulong correct_archi;
- char versions[MAX_IMG][SPIDUPD_STRING_VERSION_SIZE];
+ char current_version[SPIDUPD_STRING_VERSION_SIZE];
};
/** Informations about image to update */
@@ -327,8 +327,7 @@ static int select_image(int img_nb, ulong img_0_addr, ulong img_max_size, struct
place->correct_img_exist = 0;
/* Clear previous stored version */
- for(i=0 ; i<MAX_IMG ; i++)
- place->versions[i][0] = '\0';
+ place->current_version[0] = '\0';
for(i=0 ; i<img_nb ; i++)
{
@@ -357,14 +356,14 @@ static int select_image(int img_nb, ulong img_0_addr, ulong img_max_size, struct
if (desc->index > max_index)
{
max_index = desc->index;
+ /* Store the version */
+ strncpy(place->current_version, desc->version, SPIDUPD_STRING_VERSION_SIZE);
+ place->current_version[SPIDUPD_STRING_VERSION_SIZE] = '\0';
}
/* Precise type and archi allowed */
place->correct_img_exist = 1;
place->correct_type = desc->type;
place->correct_archi = desc->arch;
- /* Store the version */
- strncpy(place->versions[i], desc->version, SPIDUPD_STRING_VERSION_SIZE);
- place->versions[i][SPIDUPD_STRING_VERSION_SIZE] = '\0';
break;
case IMAGE_OK_ORIGIN:
@@ -509,43 +508,6 @@ static int store_img(void)
return rc;
}
-/**
- * Update the index of a image already present in flash.
- *
- * \param num image number.
- * \return error code.
- */
-static int update_img_index(ulong num)
-{
- flash_info_t *flinfo = &(flash_info[0]);
- struct update_image *image = ctx.image;
- struct update_place *place = ctx.place;
- ulong i;
-
- place->flash_addr = (num * place->img_max_size) + place->img_0_addr;
- image->len = sizeof(spidcom_image_desc_t);
-
- for(i=0 ; ((flinfo->start[i] < place->flash_addr + sizeof(spidcom_image_desc_t)) &&
- (i < flinfo->sector_count)) ; i++);
-
- if(i == flinfo->sector_count)
- image->len = (flinfo->start[0] + flinfo->size) - place->flash_addr;
- else
- image->len = flinfo->start[i] - place->flash_addr;
-
- /* copy image header in ram word by word */
- for(i=0 ; i < (image->len/4) ; i++)
- {
- *(((ulong*)(place->ram_addr))+i) = *(((ulong*)(place->flash_addr))+i);
- }
-
- /* change index */
- ((spidcom_image_desc_t *)place->ram_addr)->index = place->index;
-
- /* copy header in flash */
- return store_img();
-}
-
/*
* MD5 functions
*/
@@ -842,7 +804,8 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
break;
}
- if(vs_update_start_req->version[0] == '\0')
+ if((vs_update_start_req->version[0] == '\0') ||
+ (strcmp(place->current_version, (char*)vs_update_start_req->version) == 0))
{
printf("Error (Bad Version).\n" );
ctx.modem_busy = 0;
@@ -854,26 +817,6 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
break;
}
- NetSetTimeout((ulong)(FLASH_WRITE_TOUT * CFG_HZ), SpidupdTimeout);
-
- /* if we already have valid image with the same version, don't update it */
- for(i=0 ; i<place->nb_img ; i++)
- {
- if(strcmp(place->versions[i], (char*)vs_update_start_req->version) == 0)
- {
- printf("Same Version, only update index.\n" );
-
- update_img_index(i);
-
- ctx.modem_busy = 0;
- ctx.start_cnf.start_update = SPIDUPD_BAD_VERSION;
- ctx.state = STATE_UPD_START;
-
- /* update is finished */
- NetState = NETLOOP_SUCCESS;
- break;
- }
- }
/* Save wanted version */
strncpy(ctx.wanted_version, (char*)vs_update_start_req->version, SPIDUPD_STRING_VERSION_SIZE);
}
@@ -1141,15 +1084,7 @@ void SpidupdStart(void)
printf("place.c_img_exist=%d\n",g_upd_place.correct_img_exist);
printf("place.c_type=%x\n",g_upd_place.correct_type);
printf("place.c_archi=%x\n",g_upd_place.correct_archi);
-
- {
- int i;
- printf("Versions:\n");
- for(i=0 ; i<MAX_IMG ; i++)
- {
- printf("%s\n", g_upd_place.versions[i]);
- }
- }
+ printf("Version: %s\n", g_upd_place.current_version);
#endif
}