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 <l.majew...@samsung.com>
Cc: Kyungmin Park <kyungmin.p...@samsung.com>
Cc: Marek Vasut <ma...@denx.de>
Cc: Pantelis Antoniou <pa...@antoniou-consulting.com>
-- 
1.8.3.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to