summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/net/spidupd.c
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/u-boot-1.1.6/net/spidupd.c')
-rw-r--r--cleopatre/u-boot-1.1.6/net/spidupd.c102
1 files changed, 52 insertions, 50 deletions
diff --git a/cleopatre/u-boot-1.1.6/net/spidupd.c b/cleopatre/u-boot-1.1.6/net/spidupd.c
index ac616b70c2..364fa02b76 100644
--- a/cleopatre/u-boot-1.1.6/net/spidupd.c
+++ b/cleopatre/u-boot-1.1.6/net/spidupd.c
@@ -585,7 +585,7 @@ static void SpidupdSend(int rsp_type)
VsUpdStartCnf_t *vs_update_start_cnf;
VsUpdTransfCnf_t *vs_update_transfer_cnf;
VsUpdEndCnf_t *vs_update_end_cnf;
- VsUpdEndCnf_t *vs_update_end_ind;
+ VsUpdEndInd_t *vs_update_end_ind;
/* Set structures pointers */
pkt = NetTxPacket;
@@ -666,7 +666,7 @@ static void SpidupdSend(int rsp_type)
NetSendPacket(pkt, len);
if(transfer_end)
- printf("Done.\n");
+ printf("Transfer Done, Write image to flash...\n");
}
/**
@@ -883,54 +883,6 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
/* Abort the update */
NetState = NETLOOP_FAIL;
}
- else
- {
- /* Correct MD5 */
- TRACE("MD5 sum OK, will burn image...\n");
-
- NetSetTimeout((ulong)(FLASH_WRITE_TOUT * CFG_HZ), SpidupdTimeout);
-
- /* We will start to write new image from RAM to FLASH.
- * Set the index to correct value. */
- ((spidcom_image_desc_t *)place->ram_addr)->index = place->index;
-
- if(store_img() != ERR_OK)
- {
- /* Error writing flash */
- TRACE("Error.\nUpdate failure : image cannot be written to flash.\n");
- ctx.end_cnf.result = SPIDUPD_FLASH_WRITE_ERROR;
-
- /* Image on flash is corrupted! */
- ((spidcom_image_desc_t *)place->ram_addr)->is_valid = 0;
- flash_write( (char *)place->ram_addr, place->flash_addr, sizeof(spidcom_image_desc_t) );
-
- /*
- * We have no valid image anymore!
- * Update failed.
- */
- NetState = NETLOOP_FAIL;
- }
- else
- {
- /* Flash write OK */
- TRACE("Update image successfully written to flash.\n");
- ctx.end_cnf.result = SPIDUPD_SUCCESS;
- NetBootFileXferSize = image->len;
-
- NetState = NETLOOP_SUCCESS;
- }
-
- /* We finished update :
- * re-write header, but with the normal state indication -
- * put is_update flag to 0, because update is finished
- * (it was put to 1 by default when image is generated) */
- ((spidcom_image_desc_t *)place->ram_addr)->is_not_update = 0;
- if ( flash_write( (char*)place->ram_addr, place->flash_addr, sizeof(spidcom_image_desc_t) ) != ERR_OK )
- {
- printf("Error writting img desc header to flash -- image will not be valid.\n");
- }
-
- }
ctx.state = STATE_UPD_END;
}
@@ -944,6 +896,56 @@ static void SpidupdHandler(uchar *pkt, unsigned dest, unsigned src, unsigned len
/* Acknowledge the block just received, which will prompt
* the client for the next one. */
SpidupdSend(ctx.response);
+
+ /* Update communication is finish correctly lets copy image in flash */
+ if(ctx.state == STATE_UPD_END)
+ {
+ /* Correct MD5 */
+ TRACE("MD5 sum OK, will burn image...\n");
+
+ NetSetTimeout((ulong)(FLASH_WRITE_TOUT * CFG_HZ), SpidupdTimeout);
+
+ /* We will start to write new image from RAM to FLASH.
+ * Set the index to correct value. */
+ ((spidcom_image_desc_t *)place->ram_addr)->index = place->index;
+
+ if(store_img() != ERR_OK)
+ {
+ /* Error writing flash */
+ TRACE("Error.\nUpdate failure : image cannot be written to flash.\n");
+
+ /* Image on flash is corrupted! */
+ ((spidcom_image_desc_t *)place->ram_addr)->is_valid = 0;
+ flash_write( (char *)place->ram_addr, place->flash_addr, sizeof(spidcom_image_desc_t) );
+
+ /*
+ * We have no valid image anymore!
+ * Update failed.
+ */
+ ctx.end_ind.result = SPIDUPD_FLASH_WRITE_ERROR;
+ NetState = NETLOOP_FAIL;
+ }
+ else
+ {
+ /* Flash write OK */
+ TRACE("Update image successfully written to flash.\n");
+ ctx.end_ind.result = SPIDUPD_SUCCESS;
+ NetBootFileXferSize = image->len;
+ NetState = NETLOOP_SUCCESS;
+ }
+
+ /* We finished update :
+ * re-write header, but with the normal state indication -
+ * put is_update flag to 0, because update is finished
+ * (it was put to 1 by default when image is generated) */
+ ((spidcom_image_desc_t *)place->ram_addr)->is_not_update = 0;
+ if ( flash_write( (char*)place->ram_addr, place->flash_addr, sizeof(spidcom_image_desc_t) ) != ERR_OK )
+ {
+ printf("Error writting img desc header to flash -- image will not be valid.\n");
+ ctx.end_ind.result = SPIDUPD_FLASH_WRITE_ERROR;
+ }
+ SpidupdSend(UPD_IND);
+ }
}
/**