Permalink
Commits on Jan 22, 2016
  1. fel: Add fel spl command support for Allwinner A64

    ssvb committed Jan 22, 2016
    The SCTLR bits are somewhat different because the V bit is set
    to 0 on A64 (Low exception vectors, base address 0x00000000) and
    the UNK bit (Reads of this bit return an UNKNOWN value) is also not
    the same as on the other SoCs. So the SCTLR check can be relaxed.
    
    Tested using a custom built UART0 hello world bootable image.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Commits on Dec 19, 2015
  1. fel: Add "readl" and "writel" commands

    ssvb committed Dec 19, 2015
    The read/write operations done by FEL are not suitable for accessing
    hardware registers. For example, trying to read a SID value using
    the "read" or "hexdump" commands results in the following:
    
      $ sunxi-fel hexdump 0x01c23800 4
      01c23800: 87 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __
    
    Apparently, FEL tries to read data one byte at a time and this does
    not always work correctly. Introducing new commands to explicitly
    do 32-bit reads and writes helps:
    
      $ sunxi-fel readl 0x01c23800
      0x16254187
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  2. fel: Move the temporary scratch buffer under the IRQ stack

    ssvb committed Dec 19, 2015
    Doing certain operations may need uploading and executing code
    on the device. For example, such operations right now are
    reading/writing ARM CP15 coprocessor registers. Uploading the
    code to the device is naturally overwriting some part of SRAM
    as a side effect. Right now it is not a problem, because the
    CP15 coprocessor registers are only accessed as part of uploading
    and executing U-Boot SPL. They are nicely timed not to cause
    problems and the temporary scratch area gets overwritten by
    the SPL code anyway.
    
    But if we decide to provide access to such operations via
    command line interface, then any side effects may potentially
    cause problems for the users. Consider the following scenario:
    
      sunxi-fel clear 0x2000 0x100 \
                advanced-command-which-uploads-and-executes-code \
                hexdump 0x2000 0x100
    
    The user may rightfully expect that clearing a buffer in SRAM
    to zero and then reading it back should show all zero bytes.
    But inserting advanced commands in the middle may cause data
    corruption.
    
    In order to resolve this problem, just move the scratch area
    away from the 0x2000-0x5BFF addresses range. These particular
    addresses are already known to the users as a safe place for
    their bare metal expariments in FEL mode. The "sunxi-fel spl"
    command is a special case though and it is expected to
    overwrite data in this area too.
    
    A possible alternative would be to just backup & restore data
    in the scratch area. But this has some disadvantages:
      1. Extra code in the sunxi-fel tool and extra roundtrips over
         USB to do the backup/restore job.
      2. If we allow the OpenRISC core to use the 0x2000-0x5C00
         range in SRAM A1, then this becomes unsafe and racy
         (we can't really backup & restore data without causing
         a temporarily glitch for the currently running code on
         the OpenRISC core).
    
    To sum it up. With this patch we make it so that now the
    0x2000-0x5BFF range is freely available for the users of the
    sunxi-fel tool. The 0x1000-0x1FFF range is off limits (the
    upper part of it is used by the FEL IRQ handler, the lower
    part of it is reserved for internal use by the sunxi-fel
    tool). The 0x0000-0x1FFF addresses range is reserved for
    passing data from the SPL to the main U-Boot binary (via
    the SPL header) and is also off limits.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Commits on Dec 17, 2015
  1. fel: Move the backup storage to the SRAM section A1 on H3

    ssvb committed Dec 17, 2015
    This allows the SRAM section A2 to be exclusively used by
    the OpenRISC core.
    
    There are no substantial differences between H3 and A10/A13/A20.
    It just has 64 KiB of SRAM starting at the address 0x0 instead
    of 48 KiB.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  2. fel: Move the backup storage to the SRAM B on A31

    ssvb committed Dec 17, 2015
    This allows the SRAM section A2 to be exclusively used by
    the OpenRISC core.
    
    Regarding the potential U-Boot SPL size. The SRAM section A1
    only has 32 KiB. But at least the stack can be set at the end
    of the SRAM section B. Or runtime UCL or LZO decompression can
    be used to unpack the SPL code to 0x24000-0x2FFFF and have
    48 KiB of available space there.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  3. fel: Rename the backup buffers which use AR100 (OpenRISC) SRAM

    ssvb committed Dec 17, 2015
    That would be a more appropriate name. And A31 is going to
    implement this in a different way and give the SRAM back to
    OpenRISC.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  4. fel: Move backup area to higher addresses in SRAM on A10/A13/A20

    ssvb committed Dec 17, 2015
    Previously the backup area was allocated at the address 0x8000.
    This is not very good because it means that the U-Boot SPL can
    only safely use memory at addresses 0x0000-0x7FFF (32 KiB). But
    if we move the backup area to the end of the SRAM A4, this can
    allow U-Boot SPL to use memory 0x0000-0x9FFF (40 KiB). The BROM
    can't load such large SPLs from the SD card. But the SPL still
    can move its stack up to the 40 KiB boundary or do UCL or LZO
    decompression at runtime to squeeze more code into it.
    
    This patch makes the sunxi-fel tool compatible with 40 KiB SPLs,
    even though the current U-Boot releases do not use them yet.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  5. fel: fix memory leak, properly shut down USB library

    n1tehawk authored and ssvb committed Dec 16, 2015
    The aw_fel_process_spl_and_uboot() was missing a free() for the file
    buffer. This patch also adds a proper libusb cleanup/shutdown.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  6. fel: unify handling of "prefix"-type command line arguments

    n1tehawk authored and ssvb committed Dec 16, 2015
    This patch forces relevant options to be placed at the beginning of
    the command line, but also makes sure that their specific order does
    not matter.
    Currently this applies to "-p" (--progress) and "-v" (--verbose).
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  7. fel: bugfix - revert autostart change from d99d59c

    n1tehawk authored and ssvb committed Dec 16, 2015
    Commit d99d59c introduces a bug when the "spl" command is used with a
    file that contains a U-Boot binary. "spl" will now try to execute it,
    while it's not supposed to. (The command should only start the SPL.)
    
    This patch brings back the `uboot_autostart` flag, which is meant to
    remain `false` for the "spl" command, and gets set by "uboot" only.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Commits on Dec 16, 2015
  1. README: Cross-compilation examples

    Justin Swartz authored and ssvb committed Dec 1, 2015
    The meminfo example has been corrected to match the Makefile's
    "sunxi-meminfo" target, and an example has been added for the
    "sunxi-script_extractor" target.
    
    Signed-off-by: Justin Swartz <justin.swartz@risingedge.co.za>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  2. Makefile: Add sunxi-script_extractor target

    Justin Swartz authored and ssvb committed Dec 1, 2015
    Signed-off-by: Justin Swartz <justin.swartz@risingedge.co.za>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  3. fel: support updating the caption for "dialog --gauge"

    n1tehawk authored and ssvb committed Nov 27, 2015
    This patch adds an "echo-gauge" command that is intended for use with
    sunxi-fel's output piped into the dialog utility. "echo-gauge" will
    output its string argument in a way that updates (i.e. overwrites)
    the prompt text that dialog displays, so it's possible to change that
    inbetween file transfers from sunxi-fel.
    
    Example:
    	sunxi-fel uboot ${UBOOT} \
    		echo-gauge "Uploading kernel (1/2)" \
    		write-with-gauge 0x42000000 ${KERNEL} \
    		write 0x43100000 ${SCRIPT} \
    		echo-gauge "Uploading rootfs (2/2)" \
    		write-with-gauge 0x44000000 ${ROOTFS} \
    		| dialog --gauge "" 6 70
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  4. fel: support FEL progress gauge via dialog utility

    n1tehawk authored and ssvb committed Nov 26, 2015
    This patch adds some additional commands, and implements corresponding
    progress callbacks that produce output for the 'dialog' utility:
    http://invisible-island.net/dialog/dialog.html
    
    The simple "*-with-gauge" just emits percentage numbers, line by line,
    while "*-with-xgauge" outputs extended information to update the
    dialog prompt. Both are meant for directly piping the output:
    sunxi-fel write-with-gauge <...> | dialog --gauge "FEL upload" 6 70
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  5. fel: implement "write-with-progress" and "multiwrite"

    n1tehawk authored and ssvb committed Nov 26, 2015
    The two new commands both imply that a (simple) progress bar
    display is requested. "multi[write]" allows to upload a group
    of files with a single command, resulting in their transfer
    showing a common, 'overall' progress status.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  6. fel: Add file_size() and factor out a reusable file_upload()

    n1tehawk authored and ssvb committed Nov 26, 2015
    This patch moves some code out of the "write" handler, with the intention
    to reuse it later for similar commands.
    
    At the same time, it also discards the previous transfer rate output when
    using "-v", as that has become redundant with the 'progress bar' display
    available by "-p".
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Commits on Dec 8, 2015
  1. script_extractor: Remove unnecessary size argument

    jwrdegoede committed Dec 8, 2015
    The script_extractor tool before this commit used to take a size argument
    on the cmdline, but the passed in size was only used in some places not
    in others. Leading to a segfault if the passed in argument was not
    exactly the same as SCRIPT_SIZE.
    
    This commit drops the argument, so that script_extractor will just
    work.
    
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Commits on Dec 7, 2015
  1. fel: extend progress display with transfer rate and ETA

    n1tehawk committed Nov 26, 2015
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  2. fel: implement simple progress bar for larger transfers

    n1tehawk committed Nov 13, 2015
    Add "--progress" option and a progress bar display for FEL
    transfers. This picks up on a suggestion from Alexander Kaplan
    and the discussion at
    https://groups.google.com/forum/#!topic/linux-sunxi/lz0oQBwjex0
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  3. fel: extend usb_bulk_send() for progress updates

    n1tehawk committed Nov 13, 2015
    This patch adds a boolean parameter "progress" to several functions.
    When set (true), it will cause usb_bulk_send() to notify the progress
    framework, using progress_update() to convey the current transfer
    status.
    
    The feature gets enabled for the "write" command, and is forced
    inactive in most other places, e.g. aw_fel_write_uboot_image().
    Also, we specifically want the internal use of aw_fel_write() to
    never use it.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  4. fel: refactor aw_fel_write()

    n1tehawk committed Nov 13, 2015
    This patch introduces a new function aw_write_buffer() to
    allow a better distinction between FEL write operations.
    
    aw_fel_write() is meant for "privileged" internal use, while
    aw_write_buffer() now represents the preferred entry point
    for user code like the "write", "fill" or "clear" commands.
    
    There is some deliberate code duplication here that makes sense
    when combined with the next patch, where the aw_usb_write()
    call will differ. We want aw_fel_write() to enforce no progress
    update/callback, while aw_write_buffer() will (optionally)
    support it.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  5. fel: Introduce progress framework

    n1tehawk committed Nov 13, 2015
    This patch adds two new source files that will deal with code
    related to progress callbacks and display. I have decided to
    keep this separate, as there will be many smaller routines
    involved, which otherwise would bloat fel.c unnecessarily.
    
    For starters, let's also move the gettime() function there.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Commits on Nov 24, 2015
  1. fel: Enable MMU on Allwinner-H3 to improve FEL transfer speed

    ssvb committed Nov 10, 2015
    When the CPU clock speed is set to 480 MHz by the U-Boot SPL,
    the performance of 'sunxi-fel write' transfers to DRAM improves
    from ~95 KB/s to ~510 KB/s.
    
    When the CPU clock speed is set to 1008 MHz by the U-Boot SPL,
    the performance of 'sunxi-fel write' transfers to DRAM improves
    from ~180 KB/s to ~510 KB/s.
    
    This means that the CPU is not a bottleneck for FEL transfers
    anymore. Further performance improvements are possible by
    increasing the AHB1 clock speed in the U-Boot SPL (up to
    something like ~900 KB/s).
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
  2. fel: Support for enabling MMU after running SPL on new SoC variants

    ssvb committed Nov 17, 2015
    The BROM in newer SoC variants doesn't enable MMU by default anymore.
    So in order to benefit from e4b3da2
    ("fel: Faster USB transfers via 'fel write' to DRAM"), we need to
    be able to enable it from the 'sunxi-fel' tool.
    
    This patch can be interpreted as simply reverting the changes done
    by Allwinner and bringing back the MMU support in roughly the same
    way as it was before. That's why the values in the hardware
    registers and the translation table entries replicate the A20 setup.
    
    Additionally, the code is now more defensive and introduces new
    "canary" checks for certain known magic values in the coprocessor
    registers in order to safeguard against any unpleasant surprises.
    
    MMU tuning for A80 and A64 will probably need a more sophisticated
    setup with a second level page table. Because both the SRAM and
    the BROM reside in the same 1MB section there and we need finer
    granularity. In other words, enabling the MMU on A80 and A64 is
    not supported yet.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
  3. fel: Helper functions for reading/writing ARM coprocessor registers

    ssvb committed Nov 16, 2015
    This helps to reduce code duplication if we want to read and write
    many different kinds of coprocessor registers.
    
    Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
Commits on Nov 19, 2015
  1. sunxi-tools: make use of proper boolean data types

    n1tehawk committed Nov 19, 2015
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
  2. sunxi-tools: some trivial fixes

    n1tehawk committed Nov 19, 2015
    - get rid of double includes
    - fix U-Boot source reference
    - get rid of "uboot_autostart" variable
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
Commits on Oct 27, 2015
  1. Makefile: use force option when creating symlinks

    jacmet authored and ssvb committed Oct 23, 2015
    So it doesn't error out if the symlink already exists (E.G. is pointing to
    the old name).
    
    Also add the -n option for consistency with the install target.
    
    Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
    Acked-by: Ian Campbell <ijc@hellion.org.uk>
Commits on Oct 23, 2015
  1. Makefile: Add an install rule

    ijc authored and ssvb committed Oct 14, 2015
    Allow for separate installation of tools and target-tools, to aid in packaging.
    
    By default everything the tools are installed into /usr/local/bin but this can
    be overridden using PREFIX= or BINDIR= on the make invocation.
    
    To enable this it was necessary to split fex2bin and bin2fex out from $(TOOLS)
    into $(FEXC_LINKS), because install(1) does not seem to have a mode which
    preserves symlinks so it needs to be done separately.
    
    Supports DESTDIR to allow for convenient installation into a staging dir for
    distro packaging convenience.
    
    Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
  2. Makefile: Split out target tools rules

    ijc authored and ssvb committed Oct 14, 2015
    Target tools are those which are only useful on a target sunxi system (i.e.
    which probe hardware etc).
    
    Currently this is only sunxi-pio. At first I thought sunxi-nand-part might be
    included, but I think that is useful on NAND images as well as actual devices.
    
    This will allow for easier packaging, by letting packagers only include the
    target tools when building for a suitable ARM architecture.
    
    Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
  3. Makefile: Prefix most tools with sunxi-

    ijc authored and ssvb committed Oct 14, 2015
    Several of the tools here are too generic and/or short for distro packaging
    purposes (which like to try and avoid naming clashes in $PATH). Prefix the
    following with "sunxi-":
      - fexc
      - bootinfo
      - fel
      - pio
      - meminfo
    
    Do not prefix any of the fel "payloads" or raw binaries since they would not
    normally be installed in $PATH.
    
    Do not prefix "phoenix_info", since "phoenix" already seems like an appropriate
    prefix for this particular tool.
    
    Update in-tree callers, README and .gitignore accordingly.
    
    Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
    Acked-by: Peter Korsgaard <peter@korsgaard.com>
Commits on Oct 3, 2015
  1. fel: add a mechanism to provide boot information via FEL

    n1tehawk authored and ssvb committed Sep 29, 2015
    This patch makes use of a new sunxi SPL header format, where
    fields for passing data to U-Boot are reserved. This allows the
    "fel" utility to provide specific pieces of information by
    setting these fields (which will be evaluated by U-Boot then).
    
    For now, we provide the memory location of the boot script file
    (boot.scr) this way. A suitably modified U-Boot can adjust the
    boot process accordingly and will auto-execute the script.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  2. fel: implement persistent sram_info information

    n1tehawk authored and ssvb committed Sep 29, 2015
    Information about the SoC-specific memory layout may be required across
    several places in the fel utility code. To avoid having to retrieve this
    information repeatedly, this patch modifies the aw_fel_get_sram_info()
    function to cache its result (via an internal static pointer).
    
    This makes it safe to call aw_fel_get_sram_info() wherever needed, while
    avoiding additional aw_fel_get_version() lookups, and potential surplus
    "no 'soc_sram_info' data for your SoC" warnings.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
  3. fel: refactor image type detection/query

    n1tehawk authored and ssvb committed Sep 29, 2015
    This patch moves retrieving the image header type into a function
    of its own. The idea is that fel "write" can and will also make
    use of this function to detect boot scripts (by IH_TYPE_SCRIPT).
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Commits on Sep 13, 2015
  1. fix compiler warnings due to deprecated _BSD_SOURCE

    n1tehawk authored and ssvb committed Sep 9, 2015
    With glibc 2.20 (and newer), defining _BSD_SOURCE (only)
    will now generate compiler warnings similar to:
    
    /usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE
    and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
    
    See the glibc 2.20 release notes, https://lwn.net/Articles/611162/.
    
    This patch adds the required _DEFAULT_SOURCE.
    
    Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
    Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>