[U-Boot] A proposal/hack for an efficient USB DFU for linux based boards

Krishna Pattabiraman codelectron at googlemail.com
Fri Mar 14 11:42:29 CET 2014


Ok, so there is the current code:

>
>         do {
>             ret = dfu_get_status(dif, &dst);
>             if (ret < 0) {
>                 errx(EX_IOERR, "Error during download get_status");
>                 goto out_free;
>             }
>
>             if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE ||
>                     dst.bState == DFU_STATE_dfuERROR)
>                 break;
>
>             /* Wait while device executes flashing */
>             milli_sleep(dst.bwPollTimeout);
>         } while (1);
>
> And the code you refer in your webpage:
> http://codelectron.wordpress.com/2014/02/28/flexible-firmware-upgrade/
>         do {
>         ret = dfu_get_status(dif->dev_handle, dif->interface, &dst);
>         if (ret < 0) {
>                 fprintf(stderr, "Error during download get_status\n");
>                 goto out_free;
>         }
>         if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE ||
>                 dst.bState == DFU_STATE_dfuERROR)
>                 break;
>         /* Wait while device executes flashing */
>         if (quirks & QUIRK_POLLTIMEOUT)
>                 milli_sleep(DEFAULT_POLLTIMEOUT);
>         else
>                 milli_sleep(dst.bwPollTimeout);
>         } while (1);
>
> I'm a bit confused here, since it looks like the
> milli_sleep(DEFAULT_POLLTIMEOUT); is already removed.
>
> Am I missing something?
>
No not in the code. Yes they are different code but what I am speaking
about in the blog  is the removal of the whole block and removing the
corresponding states in u-boot also. I have also given the reasons for it
in the blog.


>
> I developed it keeping in mind a situation in field where there can
> be a complete change in memory organisation.

Maybe some special alt setting could be defined for such a behavior in
> u-boot? We can think about that if it solves a real problem.
>
Its a difference between a partition table style vs free style. My reason
for choosing the latter was
1. The partition table is actually inside the linux kernel and to change
partition, we need upgrade to u-boot-env as well as Linux kernel. Risk of
bricking was higher.
Like here
http://lxr.free-electrons.com/source/arch/arm/mach-omap2/board-omap3beagle.c?v=2.6.36#L53

2. I used SAM9G45 and for normal booting of Linux and U-boot for upgrade
and other maintanence purpose.
http://free-electrons.com/blog/at91bootstrap-linux/ .

I haven't considered other types of storage devices and boards, but I think
that the concept is very same for other devices too.


>
> I'm happy, that you had shared this fresh view.
>
> Do you have any other ideas for improvements?
>

Yes, When you plug the DFU enabled device to PC as per standard it should
show as Device Firware Updrade in the Device class. Device manager in
windows and any similar appplication in other OS will show that. I haven't
checked the current implementation in U-boot. It can be done by changing
the configuration descriptor in the USB driver. The class is FE and sub
class is 01 you can refer here
http://www.usb.org/developers/defined_class/#BaseClassFEh .

Thank you for your time.

Krishna
www.codelectron.com


More information about the U-Boot mailing list