23 Commits

Author SHA1 Message Date
RavRabbit
edec4d2f6c fex: add support for '-' and '/' characters
Newer fex files like orangepi_oneplus.fex from the sunxi-boards repo fail
conversion to the binary format:
--------------------------
E: orangepi_oneplus.fex:258: invalid character at 4.
--------------------------
This is because they contain a '-' character in section and key names, and
also '/' characters in some section names, which our compiler denies.

Relax the section and key filter to allow '-' and '/' as well.

Signed-off-by: Andre Przywara <osp@andrep.de>
2022-02-18 15:21:46 +00:00
Bernhard Nortmann
610ca15715 common.h: Rename errf() to pr_error(), add pr_fatal()
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-12-07 08:15:03 +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
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
7d59d75eee fexc: Regroup code in script_decompile_bin()
Move some lines so that the safeguards run (and exit, if needed)
before the normal output of header information.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-04-20 09:29:50 +02:00
Bernhard Nortmann
ef545814de fexc: Improve script_decompile_bin() safeguards
When declaring 'signed' values for section count and version
information in the script_bin_head structure, testing them to be
below certain thresholds (SCRIPT_BIN_*_LIMIT) is insufficient;
as 'negative' values like in "fexc-bin: script.bin: version:
-404840454.-1074397186.-1073906177" would still pass.

Fix this by making these member fields unsigned.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-04-20 09:29:50 +02:00
Reinhard Max
d53292760f Allow empty sections as found in the FEX files of Ippo q8h v1.2 and FSL S8
Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
2014-10-28 21:44:50 +01:00
Bartosz J
dfece178b7 Fix issue #25: - Omit SCRIPT_VALUE_TYPE_NULL entries with no key name 2014-09-27 18:41:17 +02:00
Luc Verhaegen
eda2b42282 fexc: add some sanity checking to bin reading
Signed-off-by: Luc Verhaegen <libv@skynet.be>
2014-08-14 22:30:24 +02:00
Alejandro Mery
92f1d0dec1 fexc: add support for pio banks up to N
needed for A31 support. closes issue #9

Signed-off-by: Alejandro Mery <amery@geeks.cl>
2013-01-19 14:05:40 +01:00
Alejandro Mery
dbc4515eed fexc: add port:power support 2012-07-23 17:07:28 +02:00
Alejandro Mery
79ea14d4e0 Relicensed as GPLv2+ 2012-06-15 22:34:22 +02:00
Alejandro Mery
9bb5adf7d5 script_bin: add pr_debug() helper 2012-06-14 10:45:37 +02:00
Alejandro Mery
0fd1bc1004 bin2fex: split across script_bin and script_fex 2012-05-11 16:13:39 +02:00
Alejandro Mery
73b18fcfc9 fexc: move bin2fex's main() in 2012-05-11 12:02:10 +02:00
Alejandro Mery
02a8f0abd2 fexc: use script_bin.o 2012-05-11 10:34:51 +02:00
Alejandro Mery
352188a376 renamed sunxi-tools.h to common.h 2012-05-10 09:33:41 +02:00
Alejandro Mery
a431934d95 script_bin: and finally generate the bin 2012-05-07 12:37:22 +02:00
Alejandro Mery
ca7c27734f script_bin: generate_bin: calculate base offsets and write header 2012-05-07 10:56:24 +02:00
Alejandro Mery
919237127d fex2bin: call generate_bin() and write data out on success 2012-05-07 10:25:24 +02:00
Alejandro Mery
049f0daf13 fex2bin: refactored generate_bin() as calculate_bin_size() into script_bin.c 2012-05-07 09:39:02 +02:00