Skip to content

usb: dfu: introduce dfuMANIFEST state

Heiko Schocher u-boot 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 0 repliesNew
  2. v23 patches 0 repliesSuperseded
  3. v13 patches 0 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3usb, dfu: extract flush code into seperate functiondrivers/dfu/dfu.c include/dfu.h+25 -180 replies
2/3usb: dfu: introduce dfuMANIFEST stateREADME drivers/dfu/dfu.c drivers/usb/gadget/f_dfu.c +1 more+55 -100 replies
3/3am335x, dfu: add DFU_MANIFEST_POLL_TIMEOUT to the siemens boardsinclude/configs/siemens-am33x-common.h+1 -00 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchLukasz Majewski
1/3
2/3
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [U-Boot] [PATCH v3 0/3] usb: dfu: introduce dfuMANIFEST state

on nand flash using ubi, after the download of the new image into the flash, the "rest" of the nand sectors get erased while flushing the medium. With current u-boot version dfu-util may show:

Starting download: [##################################################] finished! state(7) = dfuMANIFEST, status(0) = No error condition is present unable to read DFU status

as dfu_get_status is not answered while erasing sectors, if erasing needs some time.

So do the following changes to prevent this:

- introduce dfuManifest state
According to dfu specification [1] section 7:
"the device enters the dfuMANIFEST-SYNC state and awaits the solicitation
of the status report by the host. Upon receipt of the anticipated DFU_GETSTATUS, the device enters the dfuMANIFEST state, where it completes its reprogramming operations."

- when stepping into dfuManifest state, sending a PollTimeout DFU_MANIFEST_POLL_TIMEOUT in ms, to the host, so the host (dfu-util) waits the PollTimeout before sending a get_status again.

Patch 0002-usb-dfu-introduce-dfuMANIFEST-state.patch shows following checkpatch errors, but I think they are OK, as the hole file uses CamelCase for the statenames as this in sync with [1]

CHECK: Avoid CamelCase: <DFU_STATE_dfuMANIFEST>
#103: FILE: drivers/usb/gadget/f_dfu.c:190:
+ f_dfu->dfu_state = DFU_STATE_dfuMANIFEST;

CHECK: Avoid CamelCase: <DFU_STATE_dfuIDLE>
#156: FILE: drivers/usb/gadget/f_dfu.c:491:
+ f_dfu->dfu_state = DFU_STATE_dfuIDLE;

CHECK: Avoid CamelCase: <DFU_STATE_dfuERROR>
#166: FILE: drivers/usb/gadget/f_dfu.c:501:
+ f_dfu->dfu_state = DFU_STATE_dfuERROR;

total: 0 errors, 0 warnings, 3 checks, 133 lines checked

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE

[1]:
http://www.usb.org/developers/devclass_docs/usbdfu10.pdf

- changes for v3:
- remove "{" after "if" as Marek Vasut suggested
- changes for v2:
- add Pantelis Antoniou to Cc
- add comment from Marek Vasut
- move comment and "if" back to dfu_write()
- add comment from Lukasz Majewski:
- remove unneccessary comment "end?"
- add Readme entry for DFU_DEFAULT_POLL_TIMEOUT
- remove unneeded flag setpolltimeout

- ToDo:
- look if it is possible to get rid of the constant DFU_MANIFEST_POLL_TIMEOUT for all dfu entities. Maybe as Lukasz suggested:
Add a callback - called e.g. (*poll_timeout) to the struct [mmc|nand]_internal_data. Then some helper functions would be defined at dfu_[mmc|nand].c and used at f_dfu.c so we can decide on a per medium/partition base, how long a PollTimeout would be for a dfu entity ... This can be done in a seperate
step.

Heiko Schocher (3):
usb, dfu: extract flush code into seperate function
usb: dfu: introduce dfuMANIFEST state
am335x, dfu: add DFU_MANIFEST_POLL_TIMEOUT to the siemens boards

 README                                 | 10 +++++++
 drivers/dfu/dfu.c                      | 42 +++++++++++++++--------------
 drivers/usb/gadget/f_dfu.c             | 48 +++++++++++++++++++++++++++++-----
 include/configs/siemens-am33x-common.h |  1 +
 include/dfu.h                          |  4 +++
 5 files changed, 79 insertions(+), 26 deletions(-)
Cc Lukasz Majewski <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Pantelis Antoniou <[email protected]>
Signature · 1 line
1.8.3.1