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>
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>
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>
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>
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>
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>
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>