Does not solve https://github.com/thesofproject/sof/issues/3423 but
converts a buffer overflow and crash into a more usable assert.
Buffer overflow found by running rimage with valgrind and the binaries
provided by @singalsu
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Checkpatch is a tool which checks patch code style
alignment with Linux kernel code.
By the way print short graphs of used commits, to
show whats under test.
Checkpatch call is precede by `set -x`, to show used
arguments values, especially checked commits range.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
It's encouraged to use version with $(...).
Backtick command substitution `...` is legacy
syntax with several issues.
1. It has a series of undefined behaviors related to quoting in POSIX.
2. It imposes a custom escaping mode with surprising results.
3. It's exceptionally hard to nest.
~https://github.com/koalaman/shellcheck/wiki/SC2006
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Caveat: this was just reported by valgrind. I did not test any actual
toml parsing error either (who tests error handling?) but this code
can't be worse than the previous one.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Passing a 64 bits ELF file by accident (for instance: '/usr/bin/openssl'
while messing up the command line options) caused an interesting cascade
of errors and memory corruption which are all caught in this commit.
This doesn't make rimage fuzz-proof far from it; only fool-proof which
is still useful.
In passing add some quotes so the error message when failing to find the
SHT_NULL section with an empty name is a little bit more readable.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Commit https://github.com/thesofproject/soft/commits/59d81995f6828 added
an -l option (for --liam? :-) which was never implemented. Remove it
because silently discarding user input is really not nice no matter how
wrong it is.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Error codes like ENOKEY and EBADE are not provide for all windows
toolchains, so to immit possible build errors, some more standard
error codes should be used.
Detailed error message is printed in stderr, so end user still
will be well informed about error source.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
It allows to assure right version of chosen headers during
reading logs in verbose mode.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Used platform should be defined by config file, given in
-c option. Double ways of defining platform may lead to
missalignement, so old way should be removed.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This allow to add new platform with old version of rimage tool.
Default values are easily to define for any fields, so fields
duplication in config files should be reduced.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Exported function will be used in configuration parser, to
assign correct function version depending on manifest versiony
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This part should be moved to separate function,
to allow easily add another way of machine description.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
TOML aims to be a minimal configuration file format that's easy to read
due to obvious semantics. TOML is designed to map unambiguously to a hash table.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This feature is not used by SOF anyway and only causes
FW load failures, we can set it to 0xffff so it will
work for ADL+ platforms.
Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
This makes the write_firmware NULL pointer added by commit
dd77445f01 and corresponding crash more user-friendly.
Before:
Program received signal SIGSEGV, Segmentation fault.
After:
rimage: src/rimage.c:197: main: Assertion `image.adsp->write_firmware'
failed.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Unlike hardcoded target_compile_options(-g) can be overriden from the
command line, from the parent ExternalProject_Add(CMAKE_ARGS) (tested)
or from a CMake GUI (not tested).
Default to Debug because the time spent running rimage is negligible
compared to building the image to sign and because the time saved
learning CMake when it crashes can be huge for some people.
BTW -O2 -g is rarely ever useful.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Path added to include should end at 'include' as usual, then
it is easy to see where specific headers comes from during reading
source code. It is especially important for projects composed from
a few parts, like firmware, driver, build and debug tools in this
project.
Moreover changed "" to <> in include directives because there is
specified full path to file from project include root and to be
aligned with code style from firmware repository,
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Because there is possibility to reference headers from this repo
from another one, there is a need to put every header into rimage
namespace. Otherwise reference to headers from duplicated
namespace (like kernel) from external repo may be ambiguous.
Update guard ifdef/define/endif sequence value, to make it more
unique
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Generator is part of rimage tool and there is any reference to them
in kernel source code, so it should be moved out of kernel folder.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
some sections may use different lma than vma address,
in such case rimage needs to use lma
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
Sometimes they will be different and this will make developer
aware of the differences
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
Try to build extended manifest only when `e` flag will be set,
to prevent error and warning printing during creating optional
part of formware image.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
elf_read_section() returns section size when everything is ok,
so ret value should be reset to 0 after this function call
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Such a solution improve code hermentization and flexibility.
Also such a solution is more relevant because of focus on particular
module during section reading, so there won't be possibility to
implicity scan section 'A' from first module and section 'B' from
second one.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This name is used in different part of source code so should refer
to single place instead by copied.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Extended manifest is a place to store metadata about firmware, known during
compilation time - for example firmware version or used compiler.
Given information are read on host side before firmware startup.
This part of output binary is not signed.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
In many functions there is need to read user section content
and check firmware version or write section content to some
manifest or dictionary. Previously to do it, in each function
was loop to search for proper section in proper module,
then allocate buffer, read content and check for possible error
between each step what is quite overwhelming. After change there
will be one function responsible for this task.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Fixes issue ".init_array" is not copied to ri image making it zero
filled. This causes Zephyr crashing trying to execute functions from
this section.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Fixes following error when compiling code:
...
src/elf.c: In function ‘elf_find_section’:
src/elf.c:469:20: error: initialization discards ‘const’ qualifier
from pointer target type [-Werror=discarded-qualifiers]
469 | Elf32_Ehdr *hdr = &module->hdr;
| ^
cc1: all warnings being treated as errors
...
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This changes the LICENSE file to match the LICENSE file
from the main SOF repo, except they entries for the kconfig
scripts which are not here in this repo.
Signed-off-by: Daniel Leung <danielcp@gmail.com>
Code formatting should be consistent and function arguments
should be aligned to opening parenthesis.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Since both fw.h and manifest.h are being used in the main SOF
repo and also here in the standalone rimage repo, to prevent
them getting out of sync, the SOF main repo is going to use
the ones coming from the rimage repo. So there is no need for
the option anymore.
Signed-off-by: Daniel Leung <danielcp@gmail.com>
This adds the necessary bits to allow building rimage
with CMake with similar configure options as the just
removed autotools files.
Also update README.md for new build instructions.
Signed-off-by: Daniel Leung <danielcp@gmail.com>
CMake is to be used instead of autotools. So remove the autotools
files.
This revert commit f6bf4b0d72 and
commit 0d33e87433
Signed-off-by: Daniel Leung <danielcp@gmail.com>
i.MX8X is very similar with i.MX8. Memory layout is the same
except IRQSTEER address.
Code will be shared but there will be different firmware binaries
named:
* sof-imx8.ri, for i.MX8
* sof-imx8x.ri, for i.MX8X
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>