657 Commits

Author SHA1 Message Date
Bernhard Nortmann
ea3f7fee3d fel: Rework some of the USB functions' logic
This moves claiming / releasing the interface into the respective
"open" / "close" functions. The USB code in main() is now trimmed
down to:

feldev_init();
handle = open_fel_device(...);
feldev_done(handle);

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-29 14:22:09 +01:00
Bernhard Nortmann
edf6d6c5e6 fel: Eliminate 'global' vars, switching to their handle counterparts
We move USB endpoint detection into the feldev_claim() routine, so
higher level code is no longer involved with that. Also make use of
the "detached" flag within feldev_handle, instead of relying on an
isolated variable.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-29 14:22:09 +01:00
Bernhard Nortmann
1c8f81aa86 fel: Modify existing USB interface to use a new "FEL device" type
This enables us to move forward to a cleaner implementation,
where the "core" fel.c code will become independent of direct
libusb usage. After moving USB code to a separate module,
in the end the libusb handle could become an 'opaque' field of
feldev_handle.

The "device" handle might also be extended later, to provide
(FEL) version data and SoC-specific information (chip ID, SRAM
info, human-readable name).

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-29 14:22:09 +01:00
Bernhard Nortmann
85943dfa8f (Fix permissions on autoversion.sh) 2016-11-29 14:07:51 +01:00
Bernhard Nortmann
60ea132fcc Prepare "point" release tag (v1.4.2)
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-29 13:59:21 +01:00
Bernhard Nortmann
384ff64734 portable_endian.h: A more uniform fix for the various BSD flavours
See pull requests #59 and #83.

It looks like various BSD derivates have adopted the more common naming
conventions for the endian conversion macros, which means that we would
attempt to redefine them without need (potentially even to 'historic'
names that no longer exist).

Try to avoid this by properly checking for existing functions first.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-29 13:50:09 +01:00
Chen-Yu Tsai
4c4111034f fel: Add SID register address for A80
The SID block in the A80 is at 0x01c0e000, with the e-fuses we care
about at offset 0x200 within the block.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2016-11-29 13:47:39 +01:00
Siarhei Siamashka
40a8f5299e Merge pull request #86 from wens/r40
R40 support for fel and uart0-helloworld
2016-11-29 09:43:26 +02:00
Chen-Yu Tsai
e480633927 uart0-helloworld: Add support for R40
The R40 is the same as the A20 for all intents and purposes of
uart0-helloworld.

Add R40's SOC ID.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2016-11-29 15:23:11 +08:00
Chen-Yu Tsai
bbfcf117bb fel: Add SOC ID, SRAM info and SID address for R40
The R40 is marketed as the successor to the A20. The SRAM layout is the
same as the A20, but there doesn't seem to be a secure SRAM block.

The SID block is at a completely different address. The layout is the
same as the newer SoCs, with the e-fuses at an offset of 0x200.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2016-11-29 15:21:17 +08:00
Bernhard Nortmann
8e53d2bf9a fel: Add fel_readl_n() and fel_writel_n() wrappers
These functions solve the problem that large readl/writel
transfers might be limited by insufficient (scratch) buffer
size. To solve this, chunks of no more than LCODE_MAX_WORDS
get transferred individually.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-19 16:49:55 +01:00
Bernhard Nortmann
c4389988aa fel: Rework aw_fel_(read|write)l_n code
This patch reduces on FEL protocol overhead for the 'multiple'
readl/writel transfers (functions that do word-aligned memory
access on the SoC). The ARM "scratch" code now takes a word count
and is able to work with buffered data, so the host is no longer
required to transfer single words in a piecemeal fashion.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-19 16:49:34 +01:00
Bernhard Nortmann
93a26d58ad uart0-helloworld: Refactor SoC detection
Besides having fewer lines of code, the #define macros should
also prevent users from accidentally using these names without
braces (i.e. as function pointers). Instead, this will cause
compiler errors now.

soc_info.c: add "A10s" label in comment for SoC ID 0x1625.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-16 17:37:50 +01:00
Bernhard Nortmann
b8e3a00323 README: add a badge to display commit count since release
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-16 17:37:50 +01:00
Bernhard Nortmann
8640291376 fel: Factor out SoC information (and SRAM buffers) retrieval
While at it, modify the former "sram_info" identifiers
to carry a broader "soc_info" meaning.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-13 21:33:58 +01:00
Bernhard Nortmann
6457c36d39 README: political correctness
Nowadays the term "hacking" has gained increasinly negative
connotations. We don't want people to get a wrong impression
and/or fancy ideas, so remove it.

While at it, also get rid of the emphasis on A10.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-13 21:33:49 +01:00
Bernhard Nortmann
8445d71f4e unify-fex: Use int64_t and portable format specifiers for its output
Otherwise we could run into ambiguities with "long long",
and Windows compilation is likely to bail out as it might
not understand "%ll".

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-13 15:56:32 +01:00
NiteHawk
dfce2034df Merge pull request #53 from n1tehawk/20160530_fextest
Extend continous integration by adding tests framework
2016-11-13 15:27:37 +01:00
Bernhard Nortmann
f957f89d21 fextest: Add a dedicated rule for (CI-)testing sunxi-boards
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-12 13:53:11 +01:00
Bernhard Nortmann
6ec3876b55 tests: Improve code coverage by testing corner cases
This patch adds shell scripts that deliberately go through some
extra program invocations, e.g. erroneous use of fex2bin. The goal
of these test cases is to improve on code (branch) coverage.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-12 13:51:38 +01:00
Bernhard Nortmann
cd5a0a3303 tests: Improve on testing fexc
After all .fex files can be successfully compiled, let's also
test the opposite direction by decompiling the resulting .bin.
The output then has to pass an automated diff against the source
.fex (transformed via some preprocessing with "unify-fex").

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-12 13:38:40 +01:00
Bernhard Nortmann
dd1882c7d7 travis-ci: Add and activate "make check" build step
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-12 13:38:40 +01:00
Bernhard Nortmann
5cbb0c91a4 tests: Introduce a basic testing framework
All tests should go into the new "tests" subdirectory. The idea is
that the separate Makefile in that directory will get invoked via
a top-level "make check".

The tests/Makefile should then take care of running all available
tests, returning an appropriate exit status. Future tests may be
functional, examine code metrics (coverage analysis), or both.

For a start, I'd simply like to check that sunxi-fexc is able to
properly compile all the .fex files from linux-sunxi/sunxi-boards.

(Note: This currently FAILS and will probably require adjustments
to both sunxi-tools and the .fex repository. To work around this,
for now I'm applying patches to fix sunxi-boards.)

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-12 13:38:40 +01:00
Bernhard Nortmann
d3e860b075 fel: Lower timeout to a more practical value
The previous timeout of 60 seconds was mostly based on scenarios
where large ("write") transfers take place. But it could easily
become annoying if users are awaiting completion of simpler
commands like "read" or "hexdump", and for some reason FEL fails
to respond.

Therefore I've decided to lower the timeout value to 10 seconds,
adjust the maximum chunk size accordingly and - while at it -
improve the source comments documenting their relationship.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-11 21:42:54 +01:00
NiteHawk
dc1b5889c3 Merge pull request #81 from n1tehawk/20161110_h5
Add initial H5 support in sunxi-fel and uart0-helloworld-sdboot.sunxi
2016-11-11 13:27:19 +01:00
NiteHawk
29c636211e Merge pull request #80 from n1tehawk/contrib
fexc: Fix .bin header treatment, improve .fex parser
2016-11-11 12:31:37 +01:00
Bernhard Nortmann
2e6697b2bb fexc: Default unquoted values to string type
Vendor-provided .fex files have repeatedly shown key-value pairs
(assignments) where the value is an identifier-style string *not*
surrounded by double quotes. The corresponding .bin files confirm
that such values end up as "string" type entries.

So far, our .fex parser has choked on these values. The commit
changes this behavior and treats them as strings now, to allow
processing 'original' .fex without adjustments.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-11 12:27:03 +01:00
Icenowy Zheng
acd958626d uart0-helloworld: port to H5
Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Reviewed-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-11 01:34:31 +01:00
Icenowy Zheng
c3dec8f9a9 fel: add SoC ID and SRAM info for H5
Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Reviewed-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-10 23:51:11 +01:00
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