All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/7] dfu: MMC specific routines for DFU operation
Date: Fri, 27 Jul 2012 14:43:44 +0200	[thread overview]
Message-ID: <201207271443.45189.marex@denx.de> (raw)
In-Reply-To: <20120727123612.B3E4E200347@gemini.denx.de>

Dear Wolfgang Denk,

> Dear Lukasz Majewski,
> 
> In message <1341416922-13792-5-git-send-email-l.majewski@samsung.com> you 
wrote:
> > Support for MMC storage devices to work with DFU framework.
> 
> Sorry for jumping in late.
> 
> > +	switch (dfu->layout) {
> > +	case RAW_ADDR:
> > +		sprintf(cmd_buf, "mmc write 0x%x %x %x", (unsigned int) buf,
> > +			dfu->data.mmc.lba_start, dfu->data.mmc.lba_size);
> > +		break;
> > +	case FAT:
> > +		sprintf(cmd_buf, "fatwrite mmc %d:%d 0x%x %s %lx",
> > +			dfu->data.mmc.dev, dfu->data.mmc.part,
> > +			(unsigned int) buf, dfu->name, *len);
> > +		break;
> > +	default:
> > +		printf("%s: Wrong layout!\n", __func__);
> > +	}
> 
> In case of error, you should always print what the unexpected data
> was.  The end user who receives an "Wrong layout!" error is probably
> pretty much surpised and doesn't know what he did wrong.   If you
> print instead: "EXT2 layout not supported (yet)" he would know exactly
> what to change to make it work.
> 
> 
> There has been some dicussion already if using this sprintf() /
> run_command() approach is good or not, or how it should be fixed.
> 
> It appears, all this discussion forgot to take into account that
> patch 3/7 dfu: DFU backend implementation promised to add "platform
> and storage independent operation of DFU."  Here we are breaking this
> promise.
> 
> And by adding special functions to the FAT file system code thing sget
> just worse, as now not only the DFU code needs to be extended when we
> want to use this with any other file system type, but suddenly this
> also bleeds into all supported file system code.
> 
> 
> I am aware that the current implementation suffers from the fact that
> we don't have a unified access to file systems - each comes with it's
> own set of commands and more or less (in)compatible command line and
> function call interfaces.  This will hopefully improve in the context
> of the device model rework, but we don't want to block you until then.
> But considering that this is going to change in a foreseeable future,
> it also makes littel sense to invest big efforts into generic code
> that covers all potential future uses.
> 
> Here is my poposal:
> 
> Let's introduce a thin shim layer to abstract the file system
> interface from the accesses you need here.  As far as I can see here,
> you need exactly 4 functions:
> 
> - block_read()
> - block_write()
> - file_read()
> - file_write()
> 
> These names could be function pointers to implement the device I/O in
> a both device and file system agnostic way; you can implement
> specific versions of the functions like mmc_block_read(),
> usb_block_read(), ... etc. and use the settings of dfu_device_type
> and dfu_layout to set the pointers to these functions.
> 
> For this shim layer I would actually prefer the original approach
> (shown above) to use sprintf() to build commands based on the existing
> command interface

We discussed it for a while ... figure out the missing typechecking and abuse of 
the command line interface is not a way to go.

> this is the minimal intrusive way to implement
> this for now.  With this approach, no modifications to file system
> and/or device driver code are needed, and we still maintain full
> flexibility here in the DFU code.  Yes, error checking may not be
> perfect, and we my not win a price for elegance of design either, but
> we should get mostly clean, working code quickly.

But now that we started going in the typechecking way, I'd prefer to go all the 
way. And once DFU extends properly towards other supported filesystems/devices, 
the rest of the interface can get cleaned along the way.

> The advantage I see for this code is that we have separated all
> this device interface stuff from both the generic DFU code and from
> the device and file system code as well.  As soon as we have a better
> implementation below, all we need to adjust (or potentially even
> remove) is this shim layer.

Shim layer is cool -- abusing command line is not cool ;-)

> Best regards,
> 
> Wolfgang Denk

  reply	other threads:[~2012-07-27 12:43 UTC|newest]

Thread overview: 147+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-03  9:38 [U-Boot] [PATCH 0/7] dfu:usb: Composite USB download gadget with DFU function Lukasz Majewski
2012-07-03  9:38 ` [U-Boot] [PATCH 1/7] dfu:usb: Support for g_dnl composite download gadget Lukasz Majewski
2012-07-03 18:41   ` Marek Vasut
2012-07-04  7:42     ` Lukasz Majewski
2012-07-20  4:14   ` Mike Frysinger
2012-07-23 15:25     ` Lukasz Majewski
2012-07-24 17:50       ` Mike Frysinger
2012-07-03  9:38 ` [U-Boot] [PATCH 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget Lukasz Majewski
2012-07-03 21:21   ` Marek Vasut
2012-07-04  8:39     ` Lukasz Majewski
2012-07-04 14:35       ` Marek Vasut
2012-07-04 15:04         ` Lukasz Majewski
2012-07-04 16:21           ` Marek Vasut
2012-07-03  9:38 ` [U-Boot] [PATCH 3/7] dfu: DFU backend implementation Lukasz Majewski
2012-07-03 21:28   ` Marek Vasut
2012-07-04  8:56     ` Lukasz Majewski
2012-07-04 14:36       ` Marek Vasut
2012-07-04 15:07         ` Lukasz Majewski
2012-07-04 16:22           ` Marek Vasut
2012-07-20  4:32   ` Mike Frysinger
2012-07-23 16:11     ` Lukasz Majewski
2012-07-03  9:38 ` [U-Boot] [PATCH 4/7] dfu: MMC specific routines for DFU operation Lukasz Majewski
2012-07-03 21:29   ` Marek Vasut
2012-07-03 21:55     ` Tom Rini
2012-07-03 22:01       ` Marek Vasut
2012-07-03 22:06         ` Tom Rini
2012-07-03 22:31           ` Marek Vasut
2012-07-03 22:33             ` Tom Rini
2012-07-03 23:07               ` Stephen Warren
2012-07-03 23:38                 ` Tom Rini
2012-07-03 23:58                   ` Stephen Warren
2012-07-04  0:13               ` Marek Vasut
2012-07-20  4:25                 ` Mike Frysinger
2012-07-04  9:10         ` Lukasz Majewski
2012-07-04 14:38           ` Marek Vasut
2012-07-04 15:13             ` Lukasz Majewski
2012-07-03  9:38 ` [U-Boot] [PATCH 5/7] dfu:cmd: Support for DFU u-boot command Lukasz Majewski
2012-07-03 21:32   ` Marek Vasut
2012-07-04  9:28     ` Lukasz Majewski
2012-07-04 14:39       ` Marek Vasut
2012-07-20  4:23         ` Mike Frysinger
2012-07-20 11:33           ` Marek Vasut
2012-07-20 14:43             ` Mike Frysinger
2012-07-20 21:11               ` Marek Vasut
2012-07-21 17:20                 ` Mike Frysinger
2012-07-21 17:21                   ` Marek Vasut
2012-07-20  4:22     ` Mike Frysinger
2012-07-20 11:35       ` Marek Vasut
2012-07-20  4:20   ` Mike Frysinger
2012-07-23 16:01     ` Lukasz Majewski
2012-07-24 18:00       ` Mike Frysinger
2012-07-24 20:48         ` Lukasz Majewski
2012-07-03  9:38 ` [U-Boot] [PATCH 6/7] arm:trats: Support for USB UDC driver at TRATS board Lukasz Majewski
2012-07-04  0:20   ` Minkyu Kang
2012-07-04  9:33     ` Lukasz Majewski
2012-07-03  9:38 ` [U-Boot] [PATCH 7/7] arm:trats: Enable g_dnl composite USB gadget with embedded DFU function on TRATS Lukasz Majewski
2012-07-04  0:22   ` Minkyu Kang
2012-07-03 12:52 ` [U-Boot] [PATCH 0/7] dfu:usb: Composite USB download gadget with DFU function Otavio Salvador
2012-07-03 12:59   ` Marek Vasut
2012-07-04 15:48 ` [U-Boot] [PATCH v2 " Lukasz Majewski
2012-07-04 15:48   ` [U-Boot] [PATCH v2 1/7] dfu:usb: Support for g_dnl composite download gadget Lukasz Majewski
2012-07-09 16:30     ` Marek Vasut
2012-07-04 15:48   ` [U-Boot] [PATCH v2 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget Lukasz Majewski
2012-07-09 16:34     ` Marek Vasut
2012-07-04 15:48   ` [U-Boot] [PATCH v2 3/7] dfu: DFU backend implementation Lukasz Majewski
2012-07-09 16:35     ` Marek Vasut
2012-07-27 11:58     ` Wolfgang Denk
2012-07-27 13:15       ` Lukasz Majewski
2012-07-27 13:35         ` Wolfgang Denk
2012-07-27 13:47           ` Lukasz Majewski
2012-07-04 15:48   ` [U-Boot] [PATCH v2 4/7] dfu: MMC specific routines for DFU operation Lukasz Majewski
2012-07-09 16:36     ` Marek Vasut
2012-07-10  8:45     ` Tom Rini
2012-07-10 10:38       ` Lukasz Majewski
2012-07-11 11:54         ` Tom Rini
2012-07-12 12:39           ` Lukasz Majewski
2012-07-12 12:46             ` Tom Rini
2012-07-13 10:29               ` Marek Vasut
2012-07-13 21:27                 ` Andy Fleming
2012-07-27 12:36     ` Wolfgang Denk
2012-07-27 12:43       ` Marek Vasut [this message]
2012-07-27 12:57         ` Wolfgang Denk
2012-07-27 13:15           ` Marek Vasut
2012-07-27 13:38             ` Wolfgang Denk
2012-07-27 13:33       ` Lukasz Majewski
2012-07-27 13:47         ` Wolfgang Denk
2012-07-04 15:48   ` [U-Boot] [PATCH v2 5/7] dfu:cmd: Support for DFU u-boot command Lukasz Majewski
2012-07-04 15:48   ` [U-Boot] [PATCH v2 6/7] arm:trats: Support for USB UDC driver at TRATS board Lukasz Majewski
2012-07-04 15:48   ` [U-Boot] [PATCH v2 7/7] arm:trats: Enable g_dnl composite USB gadget with embedded DFU function on TRATS Lukasz Majewski
2012-07-09 11:28   ` [U-Boot] [PATCH v2 0/7] dfu:usb: Composite USB download gadget with DFU function Lukasz Majewski
2012-07-09 11:46     ` Tom Rini
2012-07-09 16:25       ` Marek Vasut
2012-07-10  8:27         ` Lukasz Majewski
2012-07-10  9:28           ` Marek Vasut
2012-07-18 12:51 ` [U-Boot] [PATCH " Marek Vasut
2012-07-23  7:57   ` Lukasz Majewski
2012-07-23 10:57     ` Marek Vasut
2012-07-31  6:36 ` [U-Boot] [PATCH v3 0/7] dfu:usb: DFU support via USB Download gadget Lukasz Majewski
2012-07-31  6:36   ` [U-Boot] [PATCH v3 1/7] dfu:usb: Support for g_dnl composite download gadget Lukasz Majewski
2012-08-01 22:40     ` Mike Frysinger
2012-08-02  9:55       ` Lukasz Majewski
2012-07-31  6:36   ` [U-Boot] [PATCH v3 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget Lukasz Majewski
2012-08-01 22:45     ` Mike Frysinger
2012-08-02 10:54       ` Lukasz Majewski
2012-07-31  6:36   ` [U-Boot] [PATCH v3 3/7] dfu: DFU backend implementation Lukasz Majewski
2012-08-01 22:57     ` Mike Frysinger
2012-08-02 13:55       ` Lukasz Majewski
2012-08-03 23:19         ` Mike Frysinger
2012-08-04  7:47           ` Marek Vasut
2012-08-04 16:28             ` Mike Frysinger
2012-07-31  6:37   ` [U-Boot] [PATCH v3 4/7] dfu: MMC specific routines for DFU operation Lukasz Majewski
2012-08-01 23:00     ` Mike Frysinger
2012-08-02 14:47       ` Lukasz Majewski
2012-07-31  6:37   ` [U-Boot] [PATCH v3 5/7] dfu:cmd: Support for DFU u-boot command Lukasz Majewski
2012-07-31 17:14     ` Stephen Warren
2012-08-01  7:16       ` Lukasz Majewski
2012-08-01 17:13         ` Stephen Warren
2012-08-02  8:31           ` Lukasz Majewski
2012-08-02 15:52             ` Stephen Warren
2012-08-03  6:13               ` Lukasz Majewski
2012-08-03 15:32                 ` Stephen Warren
2012-08-06  7:13                   ` Lukasz Majewski
2012-08-01 18:04     ` Mike Frysinger
2012-08-02  7:16       ` Marek Vasut
2012-08-02 15:28         ` Lukasz Majewski
2012-08-02 17:47         ` Mike Frysinger
2012-07-31  6:37   ` [U-Boot] [PATCH v3 6/7] arm:trats: Support for USB UDC driver at TRATS board Lukasz Majewski
2012-07-31  8:31     ` Minkyu Kang
2012-07-31  6:37   ` [U-Boot] [PATCH v3 7/7] arm:trats: Enable g_dnl composite USB gadget with embedded DFU function on TRATS Lukasz Majewski
2012-07-31  8:32     ` Minkyu Kang
2012-08-03  7:45 ` [U-Boot] [PATCH v4 0/7] dfu:usb: DFU support via USB Download gadget Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 1/7] dfu:usb: Support for g_dnl composite download gadget Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 3/7] dfu: DFU backend implementation Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 4/7] dfu: MMC specific routines for DFU operation Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 5/7] dfu:cmd: Support for DFU u-boot command Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 6/7] arm:trats: Support for USB UDC driver at TRATS board Lukasz Majewski
2012-08-03  7:45   ` [U-Boot] [PATCH v4 7/7] arm:trats: Enable g_dnl composite USB gadget with embedded DFU function on TRATS Lukasz Majewski
2012-08-06 12:41 ` [U-Boot] [PATCH v5 0/7] dfu:usb: DFU support via USB Download gadget Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 1/7] dfu:usb: Support for g_dnl composite download gadget Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 3/7] dfu: DFU backend implementation Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 4/7] dfu: MMC specific routines for DFU operation Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 5/7] dfu:cmd: Support for DFU u-boot command Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 6/7] arm:trats: Support for USB UDC driver at TRATS board Lukasz Majewski
2012-08-06 12:41   ` [U-Boot] [PATCH v5 7/7] arm:trats: Enable g_dnl composite USB gadget with embedded DFU function on TRATS Lukasz Majewski
2012-08-06 20:31   ` [U-Boot] [PATCH v5 0/7] dfu:usb: DFU support via USB Download gadget Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201207271443.45189.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.