summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/common
diff options
context:
space:
mode:
authordraskovic2009-10-16 16:08:24 +0000
committerdraskovic2009-10-16 16:08:24 +0000
commitc896461419f61c2a8d5ef739e403aa5a0680ce3d (patch)
treeea897103e31042243c62a6e7070f2f54913b8251 /cleopatre/u-boot-1.1.6/common
parent87cb494245ba3803532380677380d382e1fc6aa4 (diff)
[CLEO][U-BOOT] Changed image valididty test code to write flag not_valid into the flash even for wrong architecture or type.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6164 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre/u-boot-1.1.6/common')
-rw-r--r--cleopatre/u-boot-1.1.6/common/cmd_spidboot.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/cleopatre/u-boot-1.1.6/common/cmd_spidboot.c b/cleopatre/u-boot-1.1.6/common/cmd_spidboot.c
index de13a193ab..b406c2f27d 100644
--- a/cleopatre/u-boot-1.1.6/common/cmd_spidboot.c
+++ b/cleopatre/u-boot-1.1.6/common/cmd_spidboot.c
@@ -230,9 +230,22 @@ static int check_img(spidcom_image_desc_t *desc, char *addr)
int descriptor_changed = 0;
int result = IMAGE_OK;
+ /* First check image validity. If it was set as a non valid before,
+ * we will not even bother to look further. */
+ if (desc->is_valid == 0)
+ {
+ return IMAGE_NOT_VALID;
+ }
+
+ /* Now check other flagas... */
+
if ( strcmp(desc->magic, SPIDCOM_IMG_DESC_MAGIC) )
{
- return BAD_MAGIC_NUMBER;
+ desc->is_valid = 0;
+ /* Mark descriptor has changed to write this new value under flash */
+ descriptor_changed = 1;
+ result = BAD_MAGIC_NUMBER;
+ goto outahere;
}
#if defined(__ARM__)
@@ -241,12 +254,20 @@ static int check_img(spidcom_image_desc_t *desc, char *addr)
# error Unknown CPU type
#endif
{
- return WRONG_IMAGE_ARCH;
+ desc->is_valid = 0;
+ /* Mark descriptor has changed to write this new value under flash */
+ descriptor_changed = 1;
+ result = WRONG_IMAGE_ARCH;
+ goto outahere;
}
if (desc->type != SPIDCOM_IMG_DESC_NORMAL_TYPE)
{
- return WRONG_IMAGE_TYPE;
+ desc->is_valid = 0;
+ /* Mark descriptor has changed to write this new value under flash */
+ descriptor_changed = 1;
+ result = WRONG_IMAGE_TYPE;
+ goto outahere;
}
if (desc->index == SPIDCOM_IMG_DESC_ORIGIN_INDEX)
@@ -257,11 +278,7 @@ static int check_img(spidcom_image_desc_t *desc, char *addr)
/* Mark descriptor has changed to write this new value under flash */
descriptor_changed = 1;
result = IMAGE_OK_ORIGIN;
- }
-
- if (desc->is_valid == 0)
- {
- return IMAGE_NOT_VALID;
+ goto outahere;
}
if (desc->is_not_update != 0)
@@ -270,6 +287,7 @@ static int check_img(spidcom_image_desc_t *desc, char *addr)
/* Mark descriptor has changed to write this new value under flash */
descriptor_changed = 1;
result = UPD_NOT_FINISHED;
+ goto outahere;
}
if (desc->index == SPIDCOM_IMG_DESC_INVALID_INDEX)
@@ -278,22 +296,22 @@ static int check_img(spidcom_image_desc_t *desc, char *addr)
/* Mark descriptor has changed to write this new value under flash */
descriptor_changed = 1;
result = INDEX_NOT_VALID;
+ goto outahere;
}
/* fix image validity based on previous booting attempt */
if(!desc->is_1st_boot && desc->is_not_success)
{
/* image is corrupted : invalidate it !!! */
- if(desc->is_valid)
- {
- desc->is_valid = 0;
-
- /* Mark descriptor has changed to write this new value under flash */
- descriptor_changed = 1;
- }
+ desc->is_valid = 0;
+ /* Mark descriptor has changed to write this new value under flash */
+ descriptor_changed = 1;
result = IMAGE_NOT_SUCCESS;
+ goto outahere;
}
+outahere:
+
if(descriptor_changed)
{
/* Replacing 1s with 0s is allowed without erase.