Skip to content
Snippets Groups Projects
  1. Aug 09, 2014
    • Stephen Warren's avatar
      dfu: add free_entity() to struct dfu_entity · cb7bd2e0
      Stephen Warren authored
      
      This allows the backend to free any resources allocated during the
      relevant dfu_fill_entity_*() call. This will soon be used by the
      SF backend.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      cb7bd2e0
    • Stephen Warren's avatar
      dfu: allow backend to specify a maximum buffer size · 7ac1b410
      Stephen Warren authored
      
      CONFIG_SYS_DFU_DATA_BUF_SIZE may be large to allow for FAT/ext layouts
      to transfer large files. However, this means that individual write
      operations will take a long time. Allow backends to specify a maximum
      buffer size, so that each write operation is limited to a smaller data
      block. This prevents the DFU protocol from timing out when e.g. writing
      to SPI flash. I would guess that NAND might benefit from setting this
      value too, but I can't test that.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      7ac1b410
    • Stephen Warren's avatar
      dfu: defer parsing of device string to IO backend · dd64827e
      Stephen Warren authored
      
      Devices are not all identified by a single integer. To support
      this, defer the parsing of the device string to the IO backed, so that
      it can apply the appropriate rules.
      
      SPI devices are specified as controller:chip_select. SPI/SF support will
      be added soon.
      
      MMC devices can also be specified as controller[.hwpart][:partition] in
      many commands, although we don't support that syntax in DFU.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      dd64827e
    • Stephen Warren's avatar
      dfu: add write error handling · 3ee9593f
      Stephen Warren authored
      
      Fix calls to dfu_write() and dfu_flush() to detect errors in the I/O
      itself. This could happen due to problems with the storage medium, or
      simply when trying to write a FAT/ext file that is larger than the buffer
      dfu_mmc.c maintains for this purpose.
      
      Signal the error by switching the DFU state/status. This will be picked
      up by the DFU client when it sends the next DFU request. Note that errors
      can't simply be returned from e.g. dnload_request_complete(), since that
      function has no way to pass errors back to the DFU client; a call to
      dnload_request_complete() simply means that a USB OUT completed.
      
      This error state/status needs to be cleared when the next DFU client
      connects. While there is a DFU_CLRSTATUS request, no DFU client seems to
      send this. Hence, clear this when selecting the USB alternate setting on
      the USB interface.
      
      Finally, dfu.c relies on a call to dfu_flush() to clear up the internal
      state of the write transaction. Now that errors in dfu_write() are
      detected, dfu_flush() may no longer be called for every transaction.
      Separate out the cleanup code into a new function, and call it whenever
      dfu_write() fails, as well as from any call to dfu_flush().
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      3ee9593f
    • Stephen Warren's avatar
      dfu: fix some issues with reads/uploads · 0e285b50
      Stephen Warren authored
      
      DFU read support appears to rely upon dfu->read_medium() updating the
      passed-by-reference len parameter to indicate the remaining size
      available for reading.
      
      dfu_read_medium_mmc() never does this, and the implementation of
      dfu_read_medium_nand() will only work if called just once; it hard-codes
      the value to the total size of the NAND device irrespective of read
      offset.
      
      I believe that overloading dfu->read_medium() is confusing. As such,
      this patch introduces a new function dfu->get_medium_size() which can
      be used to explicitly find out the medium size, and nothing else.
      dfu_read() is modified to use this function to set the initial value for
      dfu->r_left, rather than attempting to use the side-effects of
      dfu->read_medium() for this purpose.
      
      Due to this change, dfu_read() must initially set dfu->b_left to 0, since
      no data has been read.
      
      dfu_read_buffer_fill() must also be modified not to adjust dfu->r_left
      when simply copying data from dfu->i_buf_start to the upload request
      buffer. r_left represents the amount of data left to be read from HW.
      That value is not affected by the memcpy(), but only by calls to
      dfu->read_medium().
      
      After this change, I can read from either a 4MB or 1.5MB chunk of a 4MB
      eMMC boot partion with CONFIG_SYS_DFU_DATA_BUF_SIZE==1MB. Without this
      change, attempting to do that would result in DFU read returning no data
      at all due to r_left never being set.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      0e285b50
    • Stephen Warren's avatar
      fs: implement size/fatsize/ext4size · cf659819
      Stephen Warren authored
      
      These commands may be used to determine the size of a file without
      actually reading the whole file content into memory. This may be used
      to determine if the file will fit into the memory buffer that will
      contain it. In particular, the DFU code will use it for this purpose
      in the next commit.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      cf659819
  2. Aug 06, 2014
  3. Aug 05, 2014
  4. Aug 04, 2014
  5. Aug 01, 2014
Loading