summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleopatre/devkit/doc/cleopatre_mme_specs.odtbin158108 -> 155300 bytes
-rw-r--r--cleopatre/tools/spidupd/spidupd_host.c59
-rw-r--r--cleopatre/u-boot-1.1.6/net/spidupd.c102
-rw-r--r--cleopatre/u-boot-1.1.6/net/spidupd.h4
4 files changed, 111 insertions, 54 deletions
diff --git a/cleopatre/devkit/doc/cleopatre_mme_specs.odt b/cleopatre/devkit/doc/cleopatre_mme_specs.odt
index 63877d855f..7e0bfaa4a0 100644
--- a/cleopatre/devkit/doc/cleopatre_mme_specs.odt
+++ b/cleopatre/devkit/doc/cleopatre_mme_specs.odt
Binary files differ
diff --git a/cleopatre/tools/spidupd/spidupd_host.c b/cleopatre/tools/spidupd/spidupd_host.c
index 72907b12f4..a4879baed7 100644
--- a/cleopatre/tools/spidupd/spidupd_host.c
+++ b/cleopatre/tools/spidupd/spidupd_host.c
@@ -39,8 +39,9 @@
#include <unistd.h>
#include "../../u-boot-1.1.6/include/asm/arch-spc300/image_desc.h"
-#define MAX_RETRY 40
-#define RESTART_TIMEOUT 200000
+#define MAX_RETRY 40
+#define RESTART_TIMEOUT 200000
+#define FLASHING_TIMEOUT 3000000
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -526,6 +527,52 @@ disconnect_from_server (connection_t *connect, unsigned char *md5_sum)
return result;
}
+
+static int
+image_flashing_on_server (connection_t *connect)
+{
+ int result = -1;
+ unsigned char *rx_pkt;
+ rx_status_t rx_status;
+ VsUpdEndInd_t *end_ind;
+ unsigned long retry;
+
+ /* Allocate TX and RX buffers for Request and Confirm MME exchange. */
+ rx_pkt = (unsigned char *) malloc (PKTSIZE);
+ end_ind = (VsUpdEndInd_t *) (rx_pkt + sizeof (MME_t));
+
+ /* Flashing result procedure. */
+ for (retry = 0 ; retry < MAX_RETRY ; retry++)
+ {
+ /* Wait END_IND MME. */
+ rx_status = receive_packet (connect, rx_pkt, PKTSIZE, FLASHING_TIMEOUT,
+ VS_UPDATE_END_IND);
+
+ /* We receive a good packet. */
+ if (rx_status == RX_OK)
+ {
+ /* Check the server response and quit whatever the answer. */
+ if (end_ind->result == SPIDUPD_SUCCESS)
+ result = 0;
+ else
+ printf ("Error on server during flashing procedure (error=%d)\n",
+ end_ind->result);
+ break;
+ }
+
+ /* There was an internal error during reception. Stop all. */
+ else if (rx_status == RX_ERROR)
+ break;
+
+ /* We have received a wrong packet or a timeout.
+ * Send the END_REQ MME again. */
+ else
+ continue;
+ }
+
+ free (rx_pkt);
+ return result;
+}
int
main (int argc, char **argv)
{
@@ -604,6 +651,14 @@ main (int argc, char **argv)
}
printf ("done\n");
+ printf ("Wait image flashing...\n");
+ if (image_flashing_on_server (connect))
+ {
+ close_connection (connect);
+ return -1;
+ }
+ printf ("done\n");
+
close_connection (connect);
return 0;
}
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);
+ }
}
/**
diff --git a/cleopatre/u-boot-1.1.6/net/spidupd.h b/cleopatre/u-boot-1.1.6/net/spidupd.h
index b97b0015e9..862bc82fd6 100644
--- a/cleopatre/u-boot-1.1.6/net/spidupd.h
+++ b/cleopatre/u-boot-1.1.6/net/spidupd.h
@@ -113,10 +113,10 @@ typedef struct
/* end_cnf */
#define SPIDUPD_MD5_ERROR 0x01
-#define SPIDUPD_FLASH_WRITE_ERROR 0x02
/* end_ind */
-#define SPIDUPD_TOUT 0x03
+#define SPIDUPD_FLASH_WRITE_ERROR 0x01
+#define SPIDUPD_TOUT 0x02