22 Feb, 2018

3 commits

  • Fix two build warnings when building for arm64:

    drivers/dfu/dfu_tftp.c: In function ‘dfu_tftp_write’:
    drivers/dfu/dfu_tftp.c:59:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    ret = dfu_write_from_mem_addr(dfu, (void *)addr, len);
    ^
    and

    drivers/dfu/dfu_tftp.c: In function ‘dfu_tftp_write’:
    drivers/dfu/dfu_tftp.c:41:8: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘__kernel_size_t {aka long unsigned int}’ [-Wformat=]
    debug("%s: image name: %s strlen: %u\n", __func__, sb, strlen(sb));
    ^

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

    Marek Vasut
     
  • Do the following to make the symbol names less confusing.

    sed -i "s/\([TU][^_]\+\)_FUNCTION_DFU/DFU_OVER_\1/g" \
    `git grep _FUNCTION_DFU | cut -d ":" -f 1 | sort -u`

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

    Marek Vasut
     
  • Clean up the screaming mess of configuration options that DFU is.
    It was impossible to configure DFU such that TFTP is enabled and
    USB is not, this patch fixes that and assures that DFU TFTP and
    DFU USB can be enabled separatelly and that the correct pieces
    of code are compiled in.

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

    Marek Vasut
     

26 Jan, 2018

1 commit


04 Oct, 2017

1 commit

  • U-Boot widely uses error() as a bit noisier variant of printf().

    This macro causes name conflict with the following line in
    include/linux/compiler-gcc.h:

    # define __compiletime_error(message) __attribute__((error(message)))

    This prevents us from using __compiletime_error(), and makes it
    difficult to fully sync BUILD_BUG macros with Linux. (Notice
    Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)

    Let's convert error() into now treewide-available pr_err().

    Done with the help of Coccinelle, excluing tools/ directory.

    The semantic patch I used is as follows:

    //
    @@@@
    -error
    +pr_err
    (...)
    //

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Simon Glass
    [trini: Re-run Coccinelle]
    Signed-off-by: Tom Rini

    Masahiro Yamada
     

16 Aug, 2017

1 commit

  • We are now using an env_ prefix for environment functions. Rename these
    two functions for consistency. Also add function comments in common.h.

    Quite a few places use getenv() in a condition context, provoking a
    warning from checkpatch. These are fixed up in this patch also.

    Suggested-by: Wolfgang Denk
    Signed-off-by: Simon Glass

    Simon Glass
     

29 Jul, 2017

4 commits


12 Jul, 2017

1 commit


04 Jun, 2017

1 commit


12 May, 2017

1 commit


03 Nov, 2016

1 commit


27 Sep, 2016

1 commit

  • Introduce a hidden USB_FUNCTION_DFU Kconfig option and select it for
    CMD_DFU (as we must have the DFU command enabled to do anything DFU).
    Make all of the entries in drivers/dfu/Kconfig depend on CMD_DFU and add
    options for all of the back end choices that DFU can make use of.

    Cc: Lukasz Majewski
    Signed-off-by: Tom Rini
    Acked-by: Lukasz Majewski

    Tom Rini
     

02 Sep, 2016

1 commit

  • Now that nand_info[] is an array of pointers we need to test the
    pointer itself rather than using name as a proxy for NULLness.

    Fixes: b616d9b0a708eb9 ("nand: Embed mtd_info in struct nand_chip")
    Signed-off-by: Scott Wood
    Cc: Lukasz Majewski
    Cc: Tony Lindgren
    Acked-by: Tony Lindgren

    Scott Wood
     

12 Jul, 2016

1 commit


10 Jun, 2016

1 commit


04 Jun, 2016

2 commits

  • nand_info[] is now an array of pointers, with the actual mtd_info
    instance embedded in struct nand_chip.

    This is in preparation for syncing the NAND code with Linux 4.6,
    which makes the same change to struct nand_chip. It's in a separate
    commit due to the large amount of changes required to accommodate the
    change to nand_info[].

    Signed-off-by: Scott Wood

    Scott Wood
     
  • This typedef serves no purpose other than causing confusion with
    struct nand_chip.

    Signed-off-by: Scott Wood

    Scott Wood
     

17 May, 2016

1 commit


07 May, 2016

2 commits


06 May, 2016

1 commit


25 Apr, 2016

2 commits

  • U-Boot typically interprets unprefixed numbers as base 16, and DFU RAM
    entity parsing has historically done so. Reverse the change to default
    to base 10, so that values in previously working command-lines aren't
    mis-parsed, causing RAM corruption, crashes, hangs, etc.

    Fixes: 6aeb877afef0 ("drivers: dfu: ram: fix a crash with dfu ram with invalid dfu_alt_info env")

    Cc: Mugunthan V N
    Cc: Tom Rini
    Signed-off-by: Stephen Warren
    Reviewed-by: Mugunthan V N
    Tested-by: Mugunthan V N
    [Test HW: AM335x BBB]

    Stephen Warren
     
  • U-Boot crashes when an invalid dfu_alt_info is set and tried
    using dfu command. Fixing this as it is handled in dfu-mmc.

    => dfu 0 ram 0
    data abort
    pc : [] lr : []
    reloc pc : [] lr : []
    sp : 9ef36cf0 ip : 00000158 fp : 9ffbc0b8
    r10: 9ffbc0b8 r9 : 9ef36ed8 r8 : 00000000
    r7 : 00000000 r6 : 9ffbc0c8 r5 : 9ef36cfc r4 : 9ef392c8
    r3 : 00000004 r2 : 00000000 r1 : 9ff9a985 r0 : ffffffff
    Flags: Nzcv IRQs off FIQs on Mode SVC_32
    Resetting CPU ...

    resetting ...

    Signed-off-by: Mugunthan V N
    Reviewed-by: Tom Rini

    Mugunthan V N
     

15 Mar, 2016

2 commits


14 Jan, 2016

2 commits

  • This will allow us to have multiple block device structs each referring
    to the same eMMC device, yet different HW partitions.

    For now, there is still a single block device per eMMC device. As before,
    this block device always accesses whichever HW partition was most recently
    selected. Clients wishing to make use of multiple block devices referring
    to different HW partitions can simply take a copy of this block device
    once it points at the correct HW partition, and use each one as they wish.
    This feature will be used by the next patch.

    In the future, perhaps get_device() could be enhanced to return a
    dynamically allocated block device struct, to avoid the client needing to
    copy it in order to maintain multiple block devices. However, this would
    require all users to be updated to free those block device structs at some
    point, which is rather a large change.

    Most callers of mmc_switch_part() wish to permanently switch the default
    MMC block device's HW partition. Enhance mmc_switch_part() so that it does
    this. This removes the need for callers to do this. However,
    common/env_mmc.c needs to save and restore the current HW partition. Make
    it do this more explicitly.

    Replace use of mmc_switch_part() with mmc_select_hwpart() in order to
    remove duplicate code that skips the call if that HW partition is already
    selected.

    Signed-off-by: Stephen Warren
    Reviewed-by: Tom Rini

    Stephen Warren
     
  • This will allow the implementation to make use of data in the block_dev
    structure beyond the base device number. This will be useful so that eMMC
    block devices can encompass the HW partition ID rather than treating this
    out-of-band. Equally, the existence of the priv field is crying out for
    this patch to exist.

    Signed-off-by: Stephen Warren
    Reviewed-by: Tom Rini

    Stephen Warren
     

04 Nov, 2015

1 commit

  • parse_dev() alters the string pointed by devstr parameter. Due to this
    subsequent parsing of sf entities will fail, as string pointed by devstr
    is no longer valid sf dev arguments.
    Fix this by passing pointer to the copy of the string to parse_dev
    instead of pointer to the actual devstr.

    Signed-off-by: Vignesh R
    Reviewed-by: Tom Rini

    Vignesh R
     

20 Oct, 2015

2 commits

  • The dfu_alt_info_spl variable allows passing a starting point
    for the binary to be flashed in the SPI NOR.

    For example, if we have 'dfu_alt_info_spl=spl raw 0x400', this means
    that we want to flash the binary starting at address 0x400.

    In order to do so we need to erase the entire sector and write to
    the the subsequent SPI NOR sectors taking such start address
    into account for the address calculations.

    Tested by succesfully writing SPL binary into 0x400 offset and
    the u-boot.img at offset 64 kiB of a SPL NOR.

    Signed-off-by: Fabio Estevam
    Acked-by: Lukasz Majewski
    [trini: Use lldiv for the math]
    Signed-off-by: Tom Rini

    Fabio Estevam
     
  • SPI NOR flashes need to erase the entire sector size and we cannot pass
    any arbitrary length for the erase operation.

    To illustrate the problem:

    Copying data from PC to DFU device
    Download [=========================] 100% 478208 bytes
    Download done.
    state(7) = dfuMANIFEST, status(0) = No error condition is present
    state(10) = dfuERROR, status(14) = Something went wrong, but the
    device does not know what it was
    Done!

    In this case, the binary has 478208 bytes and the M25P32 SPI NOR
    has an erase sector of 64kB.

    478208 = 7 entire sectors of 64kiB + 19456 bytes.

    Erasing the first seven 64 kB sectors works fine, but when trying
    to erase the remainding 19456 causes problem and the board hangs.

    Fix the issue by always erasing with the erase sector size.

    Signed-off-by: Fabio Estevam
    Acked-by: Lukasz Majewski

    Fabio Estevam
     

12 Sep, 2015

2 commits

  • When writing to files in a filesystem on MMC, dfu_mmc.c buffers up the
    entire file content until the end of the transaction, at which point the
    file is written in one go. This allows writing files larger than the USB
    transfer size (CONFIG_SYS_DFU_DATA_BUF_SIZE); the maximum written file
    size is CONFIG_SYS_DFU_MAX_FILE_SIZE (the size of the temporary buffer).

    The current file reading code does not do any buffering, and so limits
    the maximum read file size to the USB transfer size. Enhance the code to
    do the same kind of buffering as the write path, so the same file size
    limits apply.

    Remove the size checking code from dfu_read() since all read paths now
    support larger files than the USB transfer buffer.

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

    Stephen Warren
     
  • DFU currently allocates buffer memory at the start of each data transfer
    operation and frees it at the end. Especially since memalign() is used to
    allocate the buffer, and various other allocations happen during the
    transfer, this can expose the code to heap fragmentation, which prevents
    the allocation from succeeding on subsequent transfers.

    Fix the code to allocate the buffer once when DFU mode is initialized,
    and free the buffer once when DFU mode is exited, to reduce the exposure
    to heap fragmentation.

    The failure mode is:

    // Internally to memalign(), this allocates a lot more than s to guarantee
    // that alignment can occur, then returns chunks of memory at the start/
    // end of the allocated buffer to the heap.
    p = memalign(a, s);
    // Various other malloc()s occur here, some of which allocate the RAM
    // immediately before/after "p".
    //
    // DFU transfer is complete, so buffer is released.
    free(p);
    // By chance, no other malloc()/free() here, in DFU at least.
    //
    // A new DFU transfer starts, so the buffer is allocated again.
    // In theory this should succeed since we just free()d a buffer of the
    // same size. However, this fails because memalign() internally attempts
    // to allocate much more than "s", yet free(p) above only free()d a
    // little more than "s".
    p = memalign(a, s);

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

    Stephen Warren
     

07 Sep, 2015

4 commits


28 Jul, 2015

1 commit

  • Use %p to print pointers.

    The max value of (i_buf - i_buf_start) should be dfu_buf_size, which is
    an unsigned long, so cast the pointer difference to that type to print.

    Change-Id: Iee242df9f8eb091aecfe0cea4c282b28b547acfe
    Signed-off-by: Stephen Warren
    Signed-off-by: Tom Warren

    Stephen Warren