From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Tue, 11 Dec 2012 08:56:25 +0100 Subject: [U-Boot] [PATCH] [DFU] Implement NAND dfu support In-Reply-To: <1355188195.5334.24@snotra> References: <1355153072-6047-1-git-send-email-panto@antoniou-consulting.com> <1355188195.5334.24@snotra> Message-ID: <20121211085625.03a6aece@amdc308.digital.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Scott, > On 12/10/2012 09:24:32 AM, Pantelis Antoniou wrote: > > Introduce on-the fly DFU NAND support. > > > > Signed-off-by: Pantelis Antoniou > > --- > > drivers/dfu/Makefile | 1 + > > drivers/dfu/dfu.c | 7 ++ > > drivers/dfu/dfu_nand.c | 194 > > +++++++++++++++++++++++++++++++++++++++++++++++++ > > include/dfu.h | 23 ++++++ > > 4 files changed, 225 insertions(+) > > create mode 100644 drivers/dfu/dfu_nand.c > > What is DFU? I don't see anything in README or doc/, despite there > already being CONFIG symbols for it. DFU means Device Firmware Upgrade. It is a relatively simple protocol to update firmware on the target (mainly with small files - e.g. uImage). For more information please skim: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf > > > +static int nand_block_op(enum dfu_nand_op op, struct dfu_entity > > *dfu, > > + u64 offset, void *buf, long *len) > > +{ > > + char cmd_buf[DFU_CMD_BUF_SIZE]; > > + u64 start, count; > > + int ret; > > + int dev; > > + loff_t actual; > > + > > + /* if buf == NULL return total size of the area */ > > + if (buf == NULL) { > > + *len = dfu->data.nand.size; > > + return 0; > > + } > > + > > + start = dfu->data.nand.start + offset + dfu->bad_skip; > > + count = *len; > > + if (start + count > > > + dfu->data.nand.start + > > dfu->data.nand.size) { > > + printf("%s: block_op out of bounds\n", __func__); > > + return -1; > > + } > > + dev = nand_curr_device; > > + if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || > > + !nand_info[dev].name) { > > + printf("%s: invalid nand device\n", __func__); > > + return -1; > > + } > > + > > + sprintf(cmd_buf, "nand %s %p %llx %llx", > > + op == DFU_OP_READ ? "read" : "write", > > + buf, start, count); > > + > > + debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf); > > + ret = run_command(cmd_buf, 0); > > Why not use the C interface to NAND? We also support there eMMC (both with raw and file systems). Moreover we had this discussion some time ago (if we shall use "command" or native C API). > > > + /* find out how much actual bytes have been written */ > > + /* the difference is the amount of skip we must add from > > now on */ > > + actual = nand_extent_skip_bad(&nand_info[dev], start, > > count); > > ...especially since you already need to interact with it here? > > -Scott -- Best regards, Lukasz Majewski Samsung Poland R&D Center | Linux Platform Group