one more DFU patch
Werner Almesberger
werner at openmoko.org
Sat Mar 10 00:43:03 CET 2007
Hi Harald,
here's one more. I think the last one on my list :-)
This patch adds "nand erase clean" for rootfs partitions.
Besides the supposed speed improvement on first mount, which I
couldn't test, this also eliminates changes from surviving a
filesystem replacement (through DFU).
Okay to commit ?
- Werner
--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina werner at almesberger.net /
/_http://www.almesberger.net/____________________________________________/
-------------- next part --------------
Index: u-boot/drivers/usbdfu.c
===================================================================
--- u-boot.orig/drivers/usbdfu.c
+++ u-boot/drivers/usbdfu.c
@@ -215,6 +215,29 @@ static int erase_flash_verify_nand(struc
return RET_NOTHING;
}
+static int erase_tail_clean_nand(struct urb *urb, struct dnload_state *ds)
+{
+ struct usb_device_instance *dev = urb->device;
+ int rc;
+
+ ds->erase_opts.offset = ds->off;
+ ds->erase_opts.length = ds->part->size-ds->off;
+ debug("Erasing 0x%x bytes @ offset 0x%x (jffs=%u)\n",
+ ds->erase_opts.length, ds->erase_opts.offset,
+ ds->erase_opts.jffs2);
+ rc = nand_erase_opts(ds->nand, &ds->erase_opts);
+ if (rc) {
+ debug("Error erasing\n");
+ dev->dfu_state = DFU_STATE_dfuERROR;
+ dev->dfu_status = DFU_STATUS_errERASE;
+ return RET_STALL;
+ }
+
+ ds->off += ds->part->size; /* for consistency */
+
+ return RET_NOTHING;
+}
+
/* Read the next erase blcok from NAND into buffer */
static int read_next_nand(struct urb *urb, struct dnload_state *ds)
{
@@ -294,10 +317,15 @@ static int handle_dnload(struct urb *urb
ds->ptr = ds->buf = ds->_buf;
break;
default:
+ rc = 0;
if (ds->ptr > ds->buf)
rc = erase_flash_verify_nand(urb, ds,
ds->nand->erasesize,
ds->nand->erasesize);
+ /* rootfs partition */
+ if (!rc && dev->alternate == 5)
+ rc = erase_tail_clean_nand(urb, ds);
+
ds->nand = NULL;
break;
}
More information about the openmoko-uboot
mailing list