07 Jan, 2020

2 commits

  • When the `dfu` command is called from the U-Boot environment,
    it now accepts an optional parameter that specifies a timeout (in seconds).
    If a DFU connection is not made within that time the `dfu` command exits
    (as it would if Ctrl+C was pressed). If the timeout is left empty or being
    zero the `dfu` command behaves as it does now.

    This is useful for allowing U-Boot to check to see if anything wants to
    upload new firmware before continuing to boot.

    The patch is based on the commit
    https://github.com/01org/edison-u-boot/commit/5e966ccc3c65c18c9783741fa04e0c45e021780c
    by Sebastien Colleur, which has been heavily reworked due to U-Boot changes
    in the past.

    Signed-off-by: Brad Campbell
    Signed-off-by: Andy Shevchenko

    Andy Shevchenko
     
  • After the commit 1cc03c5c53c0 ("dfu: Provide means to find difference between
    dfu-util -e and -R") the dangling ptototype appeared. Remove it here.

    Fixes: 1cc03c5c53c0 ("dfu: Provide means to find difference between dfu-util -e and -R")
    Cc: Lukasz Majewski
    Cc: Stephen Warren
    Signed-off-by: Andy Shevchenko
    Acked-by: Lukasz Majewski

    Andy Shevchenko
     

31 Oct, 2019

6 commits

  • Add weak callback to allow board specific behavior
    - flush
    - initiated

    This patch prepare usage of DFU back end for communication with
    STM32CubeProgrammer on stm32mp1 platform with stm32prog command.

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • Add a virtual DFU backend to allow board specific read and write
    (for OTP update for example).

    Acked-by: Lukasz Majewski
    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • Add the support of MTD partition for the MTD backend.

    The expected dfu_alt_info for one alternate on the mtd device :
    part
    partubi

    "partubi" also erase up to the end of the partition after write operation.

    For example: dfu_alt_info = "spl part 1;u-boot part 2; UBI partubi 3"

    U-Boot> dfu 0 mtd nand0

    Acked-by: Lukasz Majewski
    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • Add DFU backend for MTD device: allow to read
    and write on all MTD device (NAND, SPI-NOR,
    SPI-NAND,...)

    For example :
    > set dfu_alt_info "nand_raw raw 0x0 0x100000"
    > dfu 0 mtd nand0

    This MTD backend provides the same level than dfu nand
    backend for NAND and dfu sf backend for SPI-NOR;
    So it can replace booth of them but it also
    add support of spi-nand.

    > set dfu_alt_info "nand_raw raw 0x0 0x100000"
    > dfu 0 mtd spi-nand0

    The backend code is based on the "mtd" command
    introduced by commit 5db66b3aee6f ("cmd: mtd:
    add 'mtd' command")

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • Split the function dfu_config_entities with 2 new functions
    - dfu_alt_init
    - dfu_alt_add

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     
  • Copy the partition support from NAND backend to SF,
    support part and partubi option.
    In case of ubi partition, erase the rest of the
    partition as it is mandatory for UBI.

    The added code is under compilation flag CONFIG_DFU_SF_PART
    activated by default.

    for example:

    U-Boot> env set dfu_alt_info "spl part 0 1;\
    u-boot part 0 2;u-boot-env part 0 3;UBI partubi 0 4"
    U-Boot> dfu 0 sf 0:0:10000000:0

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     

31 Jan, 2019

1 commit

  • This unbreaks dfu mmc_file_op which is currently broken since using the
    load cmd on a buffer from heap is not allowed - added with
    commit aa3c609e2be5 ("fs: prevent overwriting reserved memory")

    Fixes: commit aa3c609e2be5 ("fs: prevent overwriting reserved memory")
    Reported-by: Stephen Warren
    Signed-off-by: Simon Goldschmidt
    Tested-by: Stephen Warren
    Acked-by: Lukasz Majewski

    Simon Goldschmidt
     

26 Jan, 2019

1 commit

  • Do this by using $(SPL_) in Makefiles and CONFIG_IS_ENABLED in C code.
    This ensures the files and features are only built into the right build
    for which they are enabled. Using the macros to simplify this patch was
    made possible by the config symbol rename done in the last patch.

    Signed-off-by: Andrew F. Davis
    Reviewed-by: Tom Rini
    Acked-by: Lukasz Majewski

    Andrew F. Davis
     

07 May, 2018

1 commit

  • When U-Boot started using SPDX tags we were among the early adopters and
    there weren't a lot of other examples to borrow from. So we picked the
    area of the file that usually had a full license text and replaced it
    with an appropriate SPDX-License-Identifier: entry. Since then, the
    Linux Kernel has adopted SPDX tags and they place it as the very first
    line in a file (except where shebangs are used, then it's second line)
    and with slightly different comment styles than us.

    In part due to community overlap, in part due to better tag visibility
    and in part for other minor reasons, switch over to that style.

    This commit changes all instances where we have a single declared
    license in the tag as both the before and after are identical in tag
    contents. There's also a few places where I found we did not have a tag
    and have introduced one.

    Signed-off-by: Tom Rini

    Tom Rini
     

29 Jul, 2017

2 commits


25 Feb, 2016

1 commit

  • This patch fixes situation when one would like to write large file into
    medium with the file system (fat, ext4, etc).
    This change sets file size limitation to the DFU internal buffer size.

    Since u-boot is not supporting interrupts and seek on file systems, it
    becomes challenging to store large file appropriately.

    To reproduce this error - create large file (around 26 MiB) and sent it
    to the target board.

    Lets examine the flow of USB transactions:

    0. DFU uses EP0 with 64B MPS [Max Packet Size]

    1. Send file - OUT (PC->target) - dat_26MiB.img is sent with 4096 B transactions

    2. Get status - OUT (PC->target) - wait for DFU_STATE_dfuDNLOAD_IDLE (0x05) sent
    from target board - IN transaction
    (target->PC)

    3. The whole file content is sent to target - OUT (PC->target) with ZLP [Zero
    Length Packet]

    Now the interesting part starts:

    4. OUT (PC->target) Setup transaction (request to share DFU state)

    5. IN (target->PC) - reply the current DFU state
    - In the UDC driver the req->completion (with dfu_flush) is called
    after successful IN transfer.
    - The dfu_flush() (called from req->completion callback) saves the
    whole file at once (u-boot doesn't support seek on fs).
    Such operation takes considerable time. When the file
    is large - e.g. 26MiB - this time may be more than 5 seconds.

    6. OUT (PC->target) - ZLP, is send in the same time when dfu_flush()
    writes data to eMMC memory.
    The dfu-util application has hard coded timeout on USB transaction
    completion set to 5 seconds (it uses libusb calls).

    When the file to store is large (e.g. 26 MiB) the time needed to write it
    may excess the dfu-util timeout and following error message will be displayed:
    "unable to read DFU status" on the HOST PC console.

    This change is supposed to leverage DFU's part responsible for storing files
    on file systems. Other DFU operations - i.e. raw/partition write to NAND and
    eMMC should work as before.

    The only functional change is the error reporting. When dfu_flush() fails
    the u-boot prompt will exit with error information and dfu-util application
    exits afterwards as well.

    Test HW:
    - Odroid XU3 (Exynos5433) - test with large file
    - Trats (Exynos4210) - test for regression - eMMC, raw,

    Signed-off-by: Lukasz Majewski
    Reported-by: Alex Gdalevich
    Tested-by: Stephen Warren
    Tested-by: Heiko Schocher

    Lukasz Majewski
     

07 Sep, 2015

2 commits


26 Feb, 2015

1 commit


18 Dec, 2014

1 commit


02 Sep, 2014

1 commit

  • This commit provides distinction between DFU device detach and reset.
    The -R behavior is preserved with proper handling of the dfu-util's -e
    switch, which detach the DFU device.

    By running dfu-util -e; one can force device to finish the execution of
    dfu command on target and execute some other scripted commands.

    Moreover, some naming has been changed - the dfu_reset() method now is known
    as dfu_detach(). New name better reflects the purpose of the code.

    It was also necessary to increase the number of usb_gadget_handle_interrupts()
    calls since we also must wait for detection of the USB reset event.

    Example usage:
    1. -e (detach) switch
    dfu-util -a0 -D file1.bin;dfu-util -a3 -D uImage;dfu-util -e

    access to u-boot prompt.

    2. -R (reset) switch
    dfu-util -a0 -D file1.bin;dfu-util -R -a3 -D uImage

    target board reset

    Signed-off-by: Lukasz Majewski
    Reviewed-by: Stephen Warren
    Tested-by: Stephen Warren

    Lukasz Majewski
     

09 Aug, 2014

5 commits

  • This allows SPI Flash to be programmed using DFU.

    Signed-off-by: Stephen Warren

    Stephen Warren
     
  • 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: Stephen Warren

    Stephen Warren
     
  • 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: Stephen Warren

    Stephen Warren
     
  • 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: Stephen Warren

    Stephen Warren
     
  • 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: Stephen Warren

    Stephen Warren
     

15 May, 2014

1 commit

  • Before this patch it was only possible to access the default eMMC HW
    partition. By partition selection I mean the access to eMMC via the
    ext_csd[179] register programming.

    It sometimes happens that it is necessary to write to other partitions.
    This patch adds extra attribute to "raw" sub type of the dfu_alt_info
    environment variable (e.g. boot-mmc.bin raw 0x0 0x200 mmcpart 1;)

    It saves the original boot value and restores it after storing the file.

    Signed-off-by: Lukasz Majewski

    Lukasz Majewski
     

08 May, 2014

1 commit

  • add a possibility to add a medium specific polltimeout
    function. So it is possible to define different
    poll timeouts.

    Used on nand medium, for setting the DFU_MANIFEST_POLL_TIMEOUT
    only on nand ubi partitions, which is currently the only
    usecase.

    Change-Id: If1db5f49b32d93fefa7481e8dfe5b7ccc0e65af4
    Signed-off-by: Heiko Schocher
    Cc: Kyungmin Park
    Cc: Marek Vasut
    Cc: Pantelis Antoniou
    Reviewed-by: Marek Vasut
    Acked-by: Lukasz Majewski

    Heiko Schocher
     

05 May, 2014

2 commits

  • Preprocessor definitions and hardcoded implementation selection in
    g_dnl core were replaced by a linker list made of (usb_function_name,
    bind_callback) pairs.

    Signed-off-by: Mateusz Zalega
    Acked-by: Lukasz Majewski
    Acked-by: Marek Vasut

    Mateusz Zalega
     
  • When user attempted to perform a raw write using DFU (vide
    dfu_fill_entity_mmc) with MMC interface not initialized before,
    get_mmc_blk_size() reported invalid (zero) block size - it wasn't
    possible to write ie. a new u-boot image.

    This commit fixes that by initializing MMC device before use in
    dfu_fill_entity_mmc().

    While fixing initialization sequence, I had to change about half of
    dfu_fill_entity_mmc's body, so I refactored it on the way to make it,
    IMHO, considerably more comprehensible.

    Being left as dead code, get_mmc_blk_size() was removed.

    Tested on Samsung Goni.

    Signed-off-by: Mateusz Zalega
    Signed-off-by: Kyungmin Park
    Acked-by: Lukasz Majewski
    Acked-by: Tom Rini
    Cc: Minkyu Kang

    Mateusz Zalega
     

23 Mar, 2014

2 commits

  • 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 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
    ( http://www.usb.org/developers/devclass_docs/usbdfu10.pdf ) 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.

    Signed-off-by: Heiko Schocher
    Cc: Lukasz Majewski
    Cc: Kyungmin Park
    Cc: Marek Vasut
    Cc: Pantelis Antoniou

    Heiko Schocher
     
  • move the flushing code into an extra function dfu_flush(),
    so it can be used from other code.

    Signed-off-by: Heiko Schocher
    Cc: Lukasz Majewski
    Cc: Kyungmin Park
    Cc: Marek Vasut
    Cc: Pantelis Antoniou

    Heiko Schocher
     

19 Dec, 2013

2 commits


21 Oct, 2013

2 commits


24 Sep, 2013

5 commits

  • The download gadget code and DFU function lacks of proper declarations
    for the case when a target board wants to use only one of available usb
    functions.

    Moreover the relevant declarations have been moved to consistent
    localization (like ).

    Signed-off-by: Lukasz Majewski
    Cc: Marek Vasut

    Lukasz Majewski
     
  • DFU spec mentions it as a method to upgrade firmware (software stored
    in writable non-volatile memory). It also says other potential uses of
    DFU is beyond scope of the spec.

    Here such a beyond the scope use is being attempted - directly pumping
    binary images from host via USB to RAM. This facility is a developer
    centric one in that it gives advantage over upgrading non-volatile
    memory for testing new images every time during development and/or
    testing.

    Directly putting image onto RAM would speed up upgrade process. This and
    convenience was the initial thoughts that led to doing this, speed
    improvement over MMC was only 1 second though - 6 sec on RAM as opposed
    to 7 sec on MMC in beagle bone, perhaps enabling cache and/or optimizing
    DFU framework to avoid multiple copy for ram (if worth) may help, and
    on other platforms and other boot media like NAND maybe improvement
    would be higher.

    And for a platform that doesn't yet have proper DFU suppport for
    non-volatile media's, DFU to RAM can be used.

    Another minor advantage would be to increase life of mmc/nand as it
    would be less used during development/testing.

    usage: ram
    eg. kernel ram 0x81000000 0x1000000

    Downloading images to RAM using DFU is not something new, this is
    acheived in openmoko also.

    DFU on RAM can be used for extracting RAM contents to host using dfu
    upload. Perhaps this can be extended to io for squeezing out register
    dump through usb, if it is worth.

    Signed-off-by: Afzal Mohammed
    Cc: Heiko Schocher
    Cc: Marek Vasut
    Cc: Lukasz Majewski
    Cc: Pantelis Antoniou
    Cc: Gerhard Sittig
    Acked-by: Marek Vasut
    Acked-by: Lukasz Majewski
    Acked-by: Heiko Schocher

    Afzal Mohammed
     
  • MMC and NAND independently defines same enumerators for read/write.
    Unify them by defining enum in dfu header. RAM support that is being
    added newly also can make use of it.

    Signed-off-by: Afzal Mohammed
    Cc: Heiko Schocher
    Cc: Marek Vasut
    Cc: Lukasz Majewski
    Cc: Pantelis Antoniou
    Acked-by: Lukasz Majewski
    Acked-by: Marek Vasut
    Acked-by: Heiko Schocher

    Afzal Mohammed
     
  • New dfu_init_env_entities() function has been extracted from cmd_dfu.c and
    stored at dfu core.

    This is a dfu centric code, so it shall be processed in the core.

    Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2
    Signed-off-by: Lukasz Majewski
    Tested-by: Heiko Schocher

    Lukasz Majewski
     
  • Up till now the DFU maximum file size (to be written to e.g. eMMC)
    was different from the DFU data buffer size. It caused errors when
    one buffer was smaller than data to be written.

    Now, the maximum DFU file size is equal to default DFU buffer size.
    In spite of this, user is still able to manually adjust those default
    values.

    Change-Id: Ied75d0f7b59588ebd79dae9a22af801d36622216
    Signed-off-by: Lukasz Majewski

    Lukasz Majewski
     

27 Aug, 2013

1 commit

  • updating an ubi partition needs a completely erased mtd partition,
    see:
    http://lists.infradead.org/pipermail/linux-mtd/2011-May/035416.html

    So, add partubi alt setting for the dfu_alt_info environment
    variable to mark this partition as an ubi partition. In case we
    update an ubi partition, we erase after flashing the image into the
    partition, the remaining sektors.

    Signed-off-by: Heiko Schocher
    Cc: Pantelis Antoniou
    Cc: Tom Rini
    Cc: Lukasz Majewski
    Cc: Kyungmin Park
    Cc: Marek Vasut
    Cc: Wolfgang Denk
    Cc: Scott Wood

    Heiko Schocher