428 Commits

Author SHA1 Message Date
Bernhard Nortmann
2a4af4f5f2 fexc: Convert version[0] header field to filesize
Vendor-provided .bin files have repeatedly demonstrated that our
previous interpretation of this field as version[0] is likely
wrong. Instead, it seems to represent the file size (in bytes)
of the .bin file.

This commit fixes both decompilation (and header checks) and
generation of .bin files, where it will now store the size to
this field.

TODO: It's unclear whether the 'filesize' needs some specific
alignment (and the .bin corresponding padding). A value of
34864 (0x8830) has already been observed, so any possible
alignment is expected not to exceed 16 bytes (0x10). (Currently
our .bin generator doesn't care about any specific alignment.)

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-10 13:59:43 +01:00
Bernhard Nortmann
bf735b2c47 Makefile: Modify default CFLAGS
This removes the "-g -O0" default (to leave them up to the user
CFLAGS), and adds a switch to ignore "unused result" warnings.
The latter is relevant when trying to compile nand-part.c with
optimizations enabled.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-10 13:34:31 +01:00
NiteHawk
3dab68f94c Merge pull request #77 from n1tehawk/contrib
Makefile: Revert sunxi-pio change from 209633a
2016-11-09 12:26:28 +01:00
Bernhard Nortmann
6cd51fe547 Makefile: Revert sunxi-pio change from 209633a
The previous commit had introduced a new build rule that made
sunxi-pio always (cross-)compile as part of TARGET_TOOLS. This
originated from a misunderstanding, and is wrong - sunxi-pio
should be part of TOOLS instead.

sunxi-pio is a "dual mode" utility. When run natively on a sunxi
SoC, it can mmap() and manipulate the PIO registers directly. But
it also supports file-based operation, to be used in conjunction
with sunxi-fel (after uploading fel-pio.bin thunk code). This
should work over USB from non-sunxi hosts, and thus puts sunxi-pio
in the TOOLS category. See the fel-gpio shell script for details.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-06 13:28:30 +01:00
NiteHawk
1c3a6ca549 Merge pull request #75 from n1tehawk/contrib
Makefile: Ensure that user-supplied CFLAGS get respected
2016-11-03 13:08:07 +01:00
Bernhard Nortmann
bb4c2a6b1b travisci: Extend the build testing for Mac OS X
The build configuration will now also execute
"make install-tools install-misc" for OSX.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-03 13:04:35 +01:00
Bernhard Nortmann
95d40f8fcf Makefile: Ensure that user-supplied CFLAGS get respected
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-29 18:48:07 +02:00
Bernhard Nortmann
9d4658f9cd README: fixup: wrong description, "make install-misc" available now
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-29 12:20:04 +02:00
NiteHawk
40e6ff5db8 Merge pull request #73 from n1tehawk/20161027_issue70
Build system improvements
2016-10-29 11:34:12 +02:00
Bernhard Nortmann
90070ac822 Prepare v1.4.1 tag
For now, this is for informational purposes (program version
output), but it might also serve as an anchor point for a
"bugfix" release after some changes made to the build system.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-29 11:31:18 +02:00
Bernhard Nortmann
fbae32235b travisci: Adjust build config to use "make all" on Linux
For Linux build testing, we want all targets compiled. To do so
without a cross-toolchain, simply use the host compiler for the
target tools. This can be achieved by setting CROSS_COMPILE to
an empty string.

OSX can't handle this: It neither supports "-static", nor would
it successfully compile meminfo.c. Thus we keep the default
"make", which should only build the 'tools' target.

On Linux we'll also test the install-* targets by requesting
installation to /tmp/sunxi-tools as a post-build step.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-29 11:16:39 +02:00
Bernhard Nortmann
8d1afa6d02 README: Document build dependencies and "make" targets
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-29 11:16:39 +02:00
Bernhard Nortmann
209633ab1d Makefile: Unify rules for target-tools, narrow down on dependencies
This appends sunxi-meminfo to the TARGET_TOOLS, and adds a new rule
to fix the compilation of sunxi-pio (by making it *cross-compile*
for the target).

Additionally adds a new build target "make install-misc".

For more details, see github issues #69 and #70.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-29 11:16:24 +02:00
NiteHawk
1351c828dd Merge pull request #72 from n1tehawk/contrib
Minor compilation fixes
2016-10-28 14:10:56 +02:00
Bernhard Nortmann
beed002864 meminfo: Add missing version output, fix initializer syntax
(Changing to a proper struct initializer avoids a possible
compiler warning.)

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-28 12:28:34 +02:00
Bernhard Nortmann
5244e88f6b Makefile: Adjust default targets for "make" and "make install"
Fixing the (currently erroneous) compilation of sunxi-pio will
cause "make target-tools" to require a suitable cross-compiler
installed. Otherwise "make target-tools" fails to build.
As that is part of our default target ("make all"), we might
possibly introduce a build breakage on quite a few systems.

Avoid this situation by redefining "make tools" as the default,
and change "make install" to "make install-tools", i.e. limit
the standard targets to those builds that only rely on the host
toolchain. From now, if you actually want to include the cross-
compiling steps, use "make all" or "make install-all" instead.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-28 01:46:21 +02:00
Bernhard Nortmann
eb44a075db Makefile: allow overriding libusb Makefile variables externally
Also: Add the winsock2 library to LIBS for Windows. When not
linking against it, the usage of WS2 conversion functions from
portable_endian.h would cause unresolved symbols.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-26 21:38:33 +02:00
Bernhard Nortmann
f3960f4a77 fel: Change order of includes
For Windows portable_endian.h relies on and includes <winsock2.h>.
Thus it needs to be requested first, otherwise other includes might
pull in <windows.h> and cause a preprocessor warning / compilation
failure (observed with MinGW).

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-10-26 21:38:33 +02:00
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