410 Commits

Author SHA1 Message Date
Bernhard Nortmann
b496582b3d Have a workaround for missing mmap() in fexc.c and pio.c
By defining NO_MMAP it's now possible to avoid the usage of
mmap() and munmap(). This benefits platforms that don't support
these functions, e.g. Windows.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-26 21:37:29 +02:00
Bernhard Nortmann
4564e7822b Fix some issues that showed up as compiler warnings with mingw64
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-26 21:37:29 +02:00
NiteHawk
9a3d62aa0c Merge pull request #68 from n1tehawk/20161021_autoversion
Prepare release v1.4
2016-10-26 20:53:37 +02:00
Bernhard Nortmann
9080136cc0 Prepare release v1.4
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-26 20:51:18 +02:00
NiteHawk
74d22ad65f Merge pull request #62 from n1tehawk/20161021_autoversion
Add support for version information
2016-10-26 20:44:02 +02:00
NiteHawk
f0a15f423b Merge pull request #67 from n1tehawk/contrib
fel: Improve file_upload() when no progress callback is passed
2016-10-26 00:47:33 +02:00
Bernhard Nortmann
2ae30430bc fel: Minor fixup - rename "progress" to "callback" for clarity
This commit renames the function pointer of type progress_cb_t
for file_upload(). That might help to avoid potential confusion
with other routines that use a boolean "progress" parameter to
indicate whether progress information is desired (at all).

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-25 21:04:33 +02:00
howientc
60601d611a fel: Improve file_upload() when no progress callback is passed
Until now, the function would always pass `true` as the "progress"
parameter to aw_write_buffer(). This has the potential drawback
of limiting the maximum USB transfer size.

By selectively passing `false` instead (with no progress function
active), we hint that aw_write_buffer() and subsequent routines
don't have to care about callbacks; so that usb_bulk_send() is
free to select a transfer size of AW_USB_MAX_BULK_SEND.

Reviewed-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-25 21:04:33 +02:00
NiteHawk
3b2e98b901 Merge pull request #63 from n1tehawk/contrib
Convert license file to Markdown syntax
2016-10-25 10:37:58 +02:00
Bernhard Nortmann
99942a6e1c Add a release (version) badge to README.md
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-24 14:53:37 +02:00
Bernhard Nortmann
569f189693 Have programs display version information in their usage help
This way we don't have to introduce new options for retrieving
version info. For those programs that do not output their usage
by default (e.g. because they would process stdin), you may pass
a "-?" option to get help - and thus version information.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-24 14:53:02 +02:00
NiteHawk
a8eadb9be8 fel: Add the ability to pass uEnv-style data via FEL (#60)
* fel: Add the ability to pass uEnv-style data via FEL

The corresponding format is recognized by having the environment
data (= text) start with a special "#=uEnv" marker. Upon transfer
of such a file, sunxi-fel will detect this condition, and set a
field in the SPL header accordingly - which in turn also requests
U-Boot to auto-import it (i.e. merge with the default environment).

(Note that this requires a U-Boot version that knows about the
new meaning of this field, namely v2016.09 or later. Older U-Boot
versions will fail to import the uEnv-style data.)

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-24 12:18:46 +02:00
Bernhard Nortmann
9047934148 Some minor adjustments in README.md
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-22 17:23:10 +02:00
Bernhard Nortmann
34eeea436a Convert license file to Markdown syntax
LICENSE.md replaces the former COPYING. It's an exact copy of the
original at https://www.gnu.org/licenses/old-licenses/gpl-2.0.md
(MD5 97bd67b5d0309e452b637f76e1c9a23c), retrieved as of Oct 22nd 2016:

HTTP/1.1 200 OK
Date: Sat, 22 Oct 2016 13:45:28 GMT
Last-Modified: Sat, 06 Aug 2016 17:46:02 GMT
ETag: "45e5-5396ac1a9ca80"
Content-Length: 17893
Content-Language: en

As github (auto)displays a license link and we also point to it
via a badge in the README.md, it's convenient to have Markdown
syntax display this file nicely formatted.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-22 17:21:11 +02:00
Bernhard Nortmann
6392ecf630 fel: bugfix: aw_fel_writel_n() transfers need to do endian conversion 2016-10-22 13:33:48 +02:00
Bernhard Nortmann
5792814010 Add support for auto-updated version information
The Makefile will now use a script (autoversion.sh) to update
version.h, which in turn defines a VERSION string and gets
included from common.h.

The idea is that version.h normally receives a git-describe
based identifier that represents the current checkout. In
cases where git might not be available, e.g. for builds from
a tarball, the script will instead fall back to a predefined
version (that should reflect the most recent release tag).

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-21 21:46:03 +02:00
NiteHawk
fc30490fd4 Merge pull request #59 from evadot/master
Fix portable_endian.h for building on FreeBSD
2016-10-05 12:48:01 +02:00
Emmanuel Vadot
043761b45b Fix building on FreeBSD 2016-10-01 16:36:22 +02:00
NiteHawk
89dac0f7ea Merge pull request #57 from bbrezillon/nand-image-builder
Nand image builder improvements
2016-06-06 21:10:15 +02:00
Boris Brezillon
fe299a32ab nand-image-builder: Fix --help/-h option
--help/-h is not working correctly (it's printing the help context on
stderr instead of stdout).
Adding a valid shortcut for --help solves the problem.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-06-06 20:57:52 +02:00
Boris Brezillon
35fb99c095 nand-image-builder: Rework the help context
Add explanations on where the options to pass to the tool should be
extracted from, and add two examples to illustrate this explanation.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
---
Changes since v3:
- cosmetic changes to the help context

Changes since v2:
- limit line width in the help context

Changes since v1:
- use shorter option names
- rework the help context
2016-06-06 20:57:52 +02:00
Boris Brezillon
7758d96dfb nand-image-builder: Add error messages to check_image_info()
Add error messages explaining what is wrong or missing in the arguments
passed by to the sunxi-nand-image-builder tool.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
---
Changes since v1:
- Drop uneeded braces
2016-06-06 20:57:52 +02:00
Boris Brezillon
8140dfc454 nand-image-builder: Fix the copyright header
Add NextThing Co. and Free Electrons copyrights and add myself as the
author of the randomizer and image builder implementation.

Remove the lengthy description explaining how the BCH implementation works,
since this is the purpose of this tool is not to expose a BCH library
(which was the case of the original source code I copied from the kernel).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
---
Changes since v1:
- Add a link to the original bch.c source file
2016-06-06 20:57:42 +02:00
Siarhei Siamashka
a4557874f0 Merge pull request #44 from ssvb/20160512-uart0-helloworld
Add new uart0-helloworld-sdboot.sunxi bootable test image
2016-06-03 06:17:24 +03:00
Siarhei Siamashka
958143e77b Add new uart0-helloworld-sdboot.sunxi bootable test image
This is a universal bootable image, which just prints a hello
message on UART0. For example, it is useful as a test payload
when debugging the SPI boot functionality:
   https://linux-sunxi.org/Bootable_SPI_flash

Changes in v2:
 - A workaround for https://patchwork.ozlabs.org/patch/622173
 - Also print the type of the used bootable media

Changes in v3:
 - Bernhard Nortmann's workaround for
   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63803

More details in https://github.com/linux-sunxi/sunxi-tools/pull/44

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
2016-06-03 06:04:44 +03:00
Olliver Schinagl
9febb550ec Merge pull request #54 from bbrezillon/nand-image-builder
Add a tool to generate raw NAND images
2016-05-31 10:10:40 +02:00
Boris Brezillon
e25f6e9024 Add a tool to generate raw NAND images
Generating raw NAND images is particularly useful for boot0 images
creation since the mainline driver is not supporting the funky layout
used by Allwinner's ROM code to load the boot0 binary from NAND.

This tools also allows one to generate raw images for 'normal' partitions
so that they can be flashed before soldering on the NAND on the board
(using a regular NAND programmer).

The tool takes care of generating ECC bytes and randomizing data as
expected by the NAND controller, and re-arranging the ECC/data sections
correctly.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-05-31 09:26:05 +02:00
NiteHawk
d93a631d95 Merge pull request #50 from n1tehawk/20160523_rmr-command
fel: Implement "rmr" commands to force warm reset into AArch32/AArch64
2016-05-30 18:05:05 +02:00
NiteHawk
b416803e8b Merge pull request #49 from n1tehawk/20160518_fexc-fixes
fexc fixes
2016-05-30 17:58:29 +02:00
NiteHawk
aff86a5e69 Merge pull request #52 from n1tehawk/20165227_issue48
fel-sdboot: Fix header corruption workaround
2016-05-28 12:37:15 +02:00
Bernhard Nortmann
17164d8d9a fel-sdboot: Fix header corruption workaround, implement in assembly
Now that we have a better understanding of what's causing the issue
that prevented entering FEL sometimes, we can adjust the workaround
code to a proper solution, i.e. skip over the problematic location.

Since the code amounts to less than a dozen ARM instructions, I've
decided to rewrite it as assembly code - fel-sdboot.S replaces the
former fel-sdboot.c.

The commit also includes a new binary (bin/fel-sdboot.sunxi) with
these changes.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
2016-05-28 12:32:55 +02:00
Bernhard Nortmann
23f239d0f3 fel: Implement "reset64" command to force warm reset into AArch64
This commit adds a new "reset64 <addr>" command "rmr32" that could
be helpful with new 64-bit SoCs. It takes an entry point (address)
parameter, stores it via RVBAR and then issues a RMR write to
request a warm boot into AArch64 mode.

For now, this is useful with the boot process of A64, where we might
wish to transfer control to a 64-bit binary (for ATF or U-Boot).
See e.g. http://linux-sunxi.org/Pine64#Boot_sequence

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-27 16:46:12 +02:00
Bernhard Nortmann
7a0a7012c6 fexc: Ignore lines starting with ':' when compiling .fex
Such lines do not conform to any known syntax rules.

With this patch, fexc will assume that they represent a special
case (where bin2fex extracted a malformed indentifier from a .bin
file - likely a remnant from a comment typo), issue a warning and
ignore the line.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-26 08:20:19 +02:00
Bernhard Nortmann
80aae9268a fexc: Warn when decompiling a malformed section entry (key string)
script_bin.c decompiles section entries even if they have invalid
indentifiers. Thus malformed .bin files were observed to result in
a .fex that couldn't be processed successfully with the sunxi-fexc
compiler.

This patch makes bin2fex now issue a warning for this kind of keys,
so that they're easier to notice and correct.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-26 07:46:58 +02:00
Bernhard Nortmann
a93b5e3636 fexc: More relaxed version data check in script_bin.c
Recent original .bin files showed up with a version[0] of 49152
= 0xC000, which won't pass our current sanity checks. Restrict
version[0] check to lower 14 bits, to make it pass again.

(This might require further investigation in the future, as it's
possible that this particular header field actually isn't related
to version data at all.)

Fixes #51.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-26 02:10:55 +02:00
Bernhard Nortmann
6271d370af fexc: Fix thinko in script decompiler
Both the error output in function decompile_section() and the
definition of GPIO_BANK_MAX in script.h suffered from an "off
by one" logic. The bank numbering in the .bin is based on 1,
so it should be added to ('A' - 1) for human-readable output,
and the maximum number corresponding to 'N' is 14.

This became apparent when trying to translate a fex2bin-compiled
a80_optimus_board.bin back to its original .fex equivalent.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-25 00:36:11 +02:00
Bernhard Nortmann
0b7bcc4aa2 fexc: Don't fail silently on parse error
A test case for this is "fex2bin a-star_kv49l.fex".

This patch fixes an execution path in script_fex.c that would
allow script_parse_fex() to fail (i.e. return 0) without providing
any feedback to the user.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-16 19:49:52 +02:00
NiteHawk
ce9cf33606 Merge pull request #42 from ssvb/20160506-fel-sdboot-for-a64
Make fel-sdboot.sunxi usable on A64 and A80

This also fixes potential problems with older SoCs when using certain (cross-)toolchains. See the discussion of #42
2016-05-13 07:35:40 +02:00
NiteHawk
938569f5aa Merge pull request #43 from ssvb/20160512-allwinner-a64-support
fel: Add fel spl command support for Allwinner A64
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-13 07:05:25 +02:00
Siarhei Siamashka
52768471b8 fel: Add fel spl command support for Allwinner A64
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.

Changes in v2:
 - Because the SRAM A and SRAM C reside back-to-back in the address
   space, it is possible to use 40 KiB of SRAM by the SPL for its
   code+data+stack. So the FEL backup storage is moved from 0x18000
   to 0x1A000 to support this.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
2016-05-12 02:19:22 +03:00
Siarhei Siamashka
b4d32f0711 fel-sdboot.sunxi: Add support for A64 and A80
This small bootable stub, which just passes control to the
FEL code in the BROM, needs to be adjusted to also support
Allwinner A64 and Allwinner A80 because the BROM is located
at a different address there.

The SD card boot has a very low priority on Allwinner A64, but
it at least has a higher priority than the SPI NOR Flash:

    https://linux-sunxi.org/BROM#A64

So this patch may help to simplify the FEL mode activation on
devices, which are booting their firmware from the SPI NOR Flash.

Changes in v2:
 - Use SCTLR.V to detect the exception vectors location as
   suggested by Jens Kuske.
 - Add a padding of 32 NOP instructions in the beginning as
   a workaround for some strange failures.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
2016-05-09 20:57:32 +03:00
Siarhei Siamashka
9e7f3a3a93 fel: Move the backup storage to the SRAM section A1 on H3
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>
2016-05-08 12:15:47 +02:00
Siarhei Siamashka
55f364129b fel: Move the backup storage to the SRAM B on A31
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>
Reviewed-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-08 12:15:47 +02:00
Siarhei Siamashka
39df14323b fel: Rename the backup buffers which use AR100 (OpenRISC) SRAM
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>
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-08 12:15:47 +02:00
Siarhei Siamashka
9a80504edd fel: Move backup area to higher addresses in SRAM on A10/A13/A20
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>
Acked-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-08 12:15:47 +02:00
Bernhard Nortmann
49cbb064a4 fel: Cosmetic fixes
- Convert C++ style comments for a uniform coding style.
- Some small formatting adjustments.
- Change "sid" command to print ':' separators instead of spaces.

Apart from "sid" output, no functional changes involved.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-06 14:08:27 +02:00
Siarhei Siamashka
776cf5543b Fix compatibility with Linaro toolchains for building ARM binaries
Add DISCARD directives to the linker scripts and also -marm option
to GCC command line. Without this, certain toolchains may build
Thumb2 code by default. Also junk sections may be present in the
final binary and they need to be removed.

This helps at least when using the following Linaro toolchain:
gcc-linaro-5.1-2015.08-x86_64_arm-linux-gnueabihf.tar.xz

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Reviewed-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-06 13:33:15 +02:00
Bernhard Nortmann
bbdae67440 Makefile: Add "binfiles" target and simplify rule sets
"make binfiles" should allow building ARM binaries more easily.

Factor out common $(ARM_ELF_FLAGS).

Also rewrite some rules using $< and $@, to avoid repeating
filenames. And trim down on the number of rules using patterns
for objcopy (%.elf -> %.bin) and mksunxiboot (%.bin -> %.sunxi).

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-06 13:14:32 +02:00
NiteHawk
68ce3d4d1a Merge pull request #41 from n1tehawk/sid-command-squashed
fel: Add new readl/writel functionality and a "sid" command
2016-05-05 18:20:33 +02:00
Bernhard Nortmann
848a054c6d fel: add "sid" command to print SID (128-bit key) on supported SoCs
This patch makes use of the new aw_fel_readl_n() function to output
the first four 32-bit values (SID key) from an SoC-specific address.
The corresponding e-fuses may not necessarily start at the SID
"base" address, e.g. on H3/A83T they are at <base+0x200>.

Note: SoC support is currently incomplete. In particular, reading
the SID on A31(s) is unsupported. Accessing it there is complicated
by the fact that Allwinner moved this information from the SoC into
the PMIC/AXP221.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-05-05 08:29:50 +02:00