*/
#include <common.h>
+#include "recovery.h"
#include "usbd.h"
-#include "onenand.h"
-#define OPS_READ 0
-#define OPS_WRITE 1
-
-static struct usbd_ops usbd_ops;
-static unsigned long down_ram_addr;
-
-int update_boot_image(void)
-{
- struct onenand_op *onenand_ops = onenand_get_interface();
- ulong len, offset;
-
-#if 1
- /* case: IPL, Recovery, u-boot are one file */
- offset = 0;
- len = CONFIG_RECOVERY_SIZE + CONFIG_RECOVERY_ADDR;
+#ifdef RECOVERY_DEBUG
+#define PUTS(s) serial_puts(DEBUG_MARK"usb: "s)
#else
- /* case: IPL, Recover are one file and u-boot is another */
- offset = CONFIG_RECOVERY_ADDR;
- len = CONFIG_RECOVERY_SIZE;
+#define PUTS(s)
#endif
- /* Erase */
- onenand_ops->erase(offset, len, 0);
- /* Write */
- onenand_ops->write(offset, len, NULL, (u_char *)down_ram_addr);
- return 0;
-}
+static struct usbd_ops usbd_ops;
+static unsigned long down_ram_addr;
/* Parsing received data packet and Process data */
static int process_data(struct usbd_ops *usbd)
switch (cmd) {
case COMMAND_DOWNLOAD_IMAGE:
+ PUTS("COMMAND_DOWNLOAD_IMAGE\n");
usbd->recv_setup((char *)down_ram_addr, (int)len);
/* response */
recvlen = usbd->recv_data();
/* Retry this commad */
- if (recvlen < len)
+ if (recvlen < len) {
+ PUTS("Error: wrong image size\n");
*((ulong *) usbd->tx_data) = STATUS_RETRY;
- else
+ } else
*((ulong *) usbd->tx_data) = STATUS_DONE;
usbd->send_data(usbd->tx_data, usbd->tx_len);
return 1;
case COMMAND_WRITE_PART_1:
+ PUTS("COMMAND_WRITE_PART_BOOT\n");
img_type = IMG_BOOT;
break;
/* Download complete -> reset */
case COMMAND_RESET_PDA:
+ PUTS("Download finished and Auto reset!\n");
+ PUTS("Wait........\n");
/* Stop USB */
usbd->usb_stop();
/* Error */
case COMMAND_RESET_USB:
+ PUTS("Error is occured!(maybe previous step)->\
+ Turn off and restart!\n");
/* Stop USB */
usbd->usb_stop();
return 0;
/* Erase and Write to NAND */
switch (img_type) {
case IMG_BOOT:
- update_boot_image();
+ ret = board_update_image((u32 *)down_ram_addr, len);
break;
default:
{
struct usbd_ops *usbd;
+ PUTS("USB Downloader\n");
/* interface setting */
usbd = usbd_set_interface(&usbd_ops);
down_ram_addr = usbd->ram_addr;
else
return 0;
+ PUTS("Receive the packet\n");
+
/* receive the data from Host PC */
while (1) {
usbd->recv_setup(usbd->rx_data, usbd->rx_len);