Commit Graph

229 Commits

Author SHA1 Message Date
mengdonglin 9d453321f8 Write firmware file micro version to manifest for cAVS platforms
SOF CMake can extract FW file version from latest git tag and defines
SOF_MAJOR, SOF_MINOR and SOF_MICRO for 3 version fields. But rimage only
gets major and minor version from SOF CMake and writes them into the
standard firmware manifest header of cAVS platforms.

This patch make rimage also get the micro version from SOF CMake, and
write it to the unused hotfix_version field of manifest header.

This update will enable sof_ri_info.py to dump entire file version from
a FW binary for cAVS platforms. So we can check if a FW release candidate
is built from the correct git tag.

Signed-off-by: mengdonglin <mengdong.lin@intel.com>

update
2022-05-09 10:07:56 +01:00
Tinghan Shen 05be213d46 config: Add mt8186.toml
Add mt8186.toml to support sof-mt8186.ri binary build

Signed-off-by: Allen-KH Cheng <Allen-KH.Cheng@mediatek.com>
Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
2022-02-08 10:57:59 +00:00
Andrey Borisovich ee5c3e1deb Added handling of OpenSSL on Windows with MSYS2
Added new MSYS_INSTALL_DIR variable that points to MSYS2 installation
for Windows users. It is used to include POSIX native headers from
/usr/include also required openssl headers.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
2022-02-02 10:13:25 +00:00
Andrey Borisovich 1589641903 Fixed warning of wrong variable type in fprintf
Fixed warning where variable passed to fprintf was of type size_t and
fprintf expected format of long int.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
2022-02-02 10:13:25 +00:00
Marc Herbert d0062122a8 Fix confusion in headers between uint8_t arrays and strings
Strings are null terminated, byte arrays not always.

Fixes garbage in debug output issue #86

Add new parse_printable_key() function that takes a uint8_t * argument
instead of char *. Casting the argument on almost every call was a clear
indication of the problem.

Add new DUMP_PRINTABLE_BYTES() to printf uint8_t arrays _and_ their
_optional_ padding.

No change to the .ri output, bit for bit identical.

Here's an example of how the -v output is fixed:

```diff
    mem_zone.host_offset: 0x0

 cse
-         partition_name: 'ADSPADSP.man'
+         partition_name: ADSP
          header_version: 1
           entry_version: 1
              nb_entries: 3
-             entry.name: 'ADSP.man'
+             entry.name: ADSP.man\x00\x00\x00\x00
            entry.offset: 0x58
            entry.length: 0x378
-             entry.name: 'cavs0015.met'
+             entry.name: cavs0015.met
            entry.offset: 0x400
            entry.length: 0x60
-             entry.name: 'cavs0015'
+             entry.name: cavs0015\x00\x00\x00\x00
            entry.offset: 0x480
            entry.length: 0x0

@@ -140,7 +132,7 @@
           exponent_size: 1

 signed_pkg
-                   name: 'ADSP'
+                   name: ADSP
                     vcn: 0
                     svn: 0
                 fw_type: 0
@@ -161,17 +153,17 @@
                  bitmap: 0
                  bitmap: 0
                  bitmap: 0
-              meta.name: 'cavs0015.met^C^B '
+              meta.name: cavs0015.met
               meta.type: 0x3
          meta.hash_algo: 0x2
          meta.hash_size: 0x20
          meta.meta_size: 96

 partition_info
-                   name: 'ADSP'
+                   name: ADSP
            part_version: 0x10000000
             instance_id: 1
-            module.name: 'cavs0015.met^C'
+            module.name: cavs0015.met
        module.meta_size: 0x60
             module.type: 0x3

@@ -186,7 +178,7 @@

 fw_desc.header
               header_id: '$AM1'
-                   name: 'ADSPFW'
+                   name: ADSPFW\x00\x00
      preload_page_count: 0
          fw_image_flags: 0x0
            feature_mask: 0xffff
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-31 13:18:23 +00:00
Marc Herbert d855fbfe7c Remove unconditional "(1 || verbose)" debug hack in cavs25
This is especially a problem considering the -v option outputs non-ASCII
garbage which can break some automation, see issue #86

Fixes commit db40934e57 ("cavs: add support for cavs2.5 code
signing")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-01-31 13:18:23 +00:00
Andrey Borisovich ecb6a66932 Update to C99 standard to match SOF. Silenced warning generated by newest GCC compiler related to int cast of char typed values that may result in negative values. Syntax fix in linkage of crypto library to more generic approach. 2022-01-21 17:29:24 +00:00
Adrian Warecki ce69d7bad8 adsp_config: fix invalid format specifier
This patch fixes an invalid format specifier that causes a numeric value
to be interpreted as a string, resulting in an Segmentation fault.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
2022-01-17 16:33:43 +00:00
Trzcinski, Karol 8753a9e162 Remove unused declaration of global platform specific manifests
Such a global variables does not exists, so should not be declared.
It has been deprecated since:
2965908 (manifest: Remove -m option)

Signed-off-by: Trzcinski, Karol <karol.trzcinski@intel.com>
2022-01-14 09:53:07 +00:00
Jaska Uimonen 3b4b1429b0 rimage: fix openssl 1.0 support
cppcheck gives errors from openssl 1.0 related code that has some old
churn and should be fixed, so fix it.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2022-01-12 20:35:20 +00:00
Curtis Malainey 23a53ac8b6 cse: fix signed integer overflow
literals are signed by default, so shifting them 32 times is an
overflow, found via cppcheck

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2022-01-12 20:34:12 +00:00
Curtis Malainey 32052add99 remove x from getopt
x param was removed from switch case but not from getopt. So if you use
x rimage silently fails on the switch case.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-12-08 20:43:34 +00:00
Jaska Uimonen 0f64a20183 manifest: fix buffer init in resign
Set buffer to NULL to prevent freeing bogus memory in error case.

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2021-12-02 09:50:55 +00:00
Jaska Uimonen 3c232422a7 rimage: refactor and add openssl 3.0 support
Refactor the signing and verification functions as they have a lot of
duplicated code and adding openssl 3.0 support without refactor would
make things even more messy.

1) Add common "rimage_read_key" to read the key from file.

2) Variate most important functionality based on different openssl versions:
- rimage_check_key
- rimage_set_modexp
- rimage_sign
- rimage_verify
- rimage_get_key_size

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2021-12-01 11:05:21 +00:00
Jaska Uimonen bd51ec1aef rimage: add functionality to resign fw image
Add function to resign already signed images. This can
be done with switch "q" as follows:

"rimage -q sof-tgl.ri -o sof-tgl-mod.ri -c tgl.toml -k key.pem"

Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2021-11-16 15:07:10 +00:00
Marc Herbert bcbcec79e5 cmake: drop binutils-specific '-Wl,-EL' option
Fixes clang failure:

  clang: error: -Wl,-EL: 'linker' input unused [-Werror,-Wunused-command-line-argument]

-EL has an effect only when using OUTPUT_FORMAT or --oformat but rimage
uses neither.

The binaries produced by ld version 2.34 are strictly identical before
and after this removal.

It is not clear why -EL was ever added. It was added to src/Makefile.am
by commit 0d33e87433 and to src/CMakeLists.txt by commit 4e3ead0096
but these commits were initial additions of the entire files and they
did not get into detail.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-10-26 20:13:55 +01:00
Marc Herbert ecb921227e cmake: drop '3' from -Wimplicit-fallthrough=3, it's the default value
From the gcc documentation:

'-Wimplicit-fallthrough'

     '-Wimplicit-fallthrough' is the same as '-Wimplicit-fallthrough=3'
     and '-Wno-implicit-fallthrough' is the same as
     '-Wimplicit-fallthrough=0'.

clang supports only the number-less option.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-10-26 20:13:55 +01:00
Marc Herbert 0c66aa9122 css.c: add __func__ to "completing manifest" log
This is useful to show which one of the 3 duplicated functions runs.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-10-05 12:01:53 +01:00
Marc Herbert c038d62804 README.md: add warning that forks must be created using Github
Otherwise the SHA1 is not found and the rest of the process fails.

Problem discovered in
https://github.com/thesofproject/sof/pull/4790#discussion_r713326709

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-09-22 11:24:03 +01:00
Marc Herbert 8960097403 Revert "ext_manifest: Fix incorrect signature"
This reverts commit 241af313da so the DSP
can boot again.

On my APL UP2 this fixes:

10:06:38: 00:0e.0: unstall/run core: core_mask = 1
10:06:38: 00:0e.0: DSP core(s) enabled? 1 : core_mask 1
10:06:38: 00:0e.0: FW Poll Status: reg[0x4c]=0x40000000 successful
10:06:38: 00:0e.0: FW Poll Status: reg[0x4]=0x3030202 successful
10:06:38: 00:0e.0: FW Poll Status: reg[0x4]=0x1010202 successful
10:06:38: 00:0e.0: DSP core(s) enabled? 0 : core_mask 2
10:06:38: 00:0e.0: FW Poll Status: reg[0x80000]=0x5000001 successful
10:06:41: 00:0e.0: FW Poll Status: reg[0x80000]=0x80000007 timedout
10:06:41: 00:0e.0: error: cl_copy_fw: timeout HDA_DSP_SRAM_REG_ROM_STATUS read
10:06:41: 00:0e.0: FW Poll Status: reg[0x160]=0x140000 successful
10:06:41: 00:0e.0: ------------[ DSP dump start ]------------
10:06:41: 00:0e.0: unknown ROM status value 80000007
10:06:41: 00:0e.0: error: extended rom status:  0x80000007 0x2f 0x0 0x0 \
                                                0x0 0x0 0x1522100 0x0
10:06:41: 00:0e.0: ------------[ DSP dump end ]------------
10:06:41: 00:0e.0: error: load fw failed ret: -110
10:06:41: 00:0e.0: error: failed to start DSP
10:06:41: 00:0e.0: error: failed to boot DSP firmware -110
10:06:41: 00:0e.0: FW Poll Status: reg[0x4]=0x1d003c timedout
10:06:41: 00:0e.0: error: hda_dsp_core_reset_enter: timeout on  \
                                                  HDA_DSP_REG_ADSPCS read
10:06:41: 00:0e.0: error: dsp core reset failed: core_mask 3
10:06:41: probe of 0000:00:0e.0 failed with error -110

Test PR https://github.com/thesofproject/sof/pull/4782 show this commit
broke the DSP boot on ALL platforms
  https://sof-ci.01.org/sofpr/PR4782/build10387/devicetest/

```
[    7.798750] kernel: sof-audio-acpi-intel-bdw INT3438:00: error: invalid firmware signature
[    7.798827] kernel: sof-audio-acpi-intel-bdw INT3438:00: error: invalid FW header
[    7.798943] kernel: sof-audio-acpi-intel-bdw INT3438:00: error: failed to load DSP firmware -22
[    7.810348] kernel: sof-audio-acpi-intel-bdw INT3438:00: error:
sof_probe_work failed err: -22
```

This also broke QEMU boot on a number of platforms: BDW, BYT and CHT, see
`error: invalid firmware signature` in

https://sof-ci.01.org/sofpr/PR4782/build10387/boottest/ and
https://github.com/thesofproject/sof/pull/4782/checks?check_run_id=3634915322

How was it tested?

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-09-17 15:16:19 -05:00
Marc Herbert 0d7f2d4a34 Do not exit(0) on invalid options or parameters
When some automation script gets some rimage flag wrong then rimage
exits and does not run at all. In such a case we want the build to fail
immediately and see the error at the bottom of the build logs and not
obscured by other, consecutive failures caused by the lack of rimage
output.

Take control of the exit code away from usage() and give it back to
main() where it belongs.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-09-17 15:05:50 +01:00
Marc Herbert 6e22944e05 README.md: explain how to run SOF tests on new rimage code
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-09-17 09:18:19 +01:00
Marcin Rajwa a9faf85fe5 remove '-x' option
This patch removes the unnecessary and unscalable -x option.
This option aims to add an offset to the .data section of
its parent .module section. This is horrible idea because this
offset will vary depend on the compiler used. It is better and
much easier to just store only the .data section so the offset
is always 0.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-09-14 14:02:41 +01:00
Marcin Rajwa 241af313da ext_manifest: Fix incorrect signature
This patch changes the incorrect signature of extended manifest
to the correct one "$AE1"

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-09-14 13:58:58 +01:00
Marc Herbert 4823e87f29 pkcs: quote the name of key file when logging it
This makes is more obvious when the filename is empty, which happened in
bug https://github.com/thesofproject/sof/pull/4711

Also prefix identical log statements with their different __func__
names.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-09-06 12:01:18 +01:00
Karol Trzcinski dcfcef80cb config: Remove unused, platform specific, memory region definitions
After commit 916fc2cd73ff: "config: Remove unused adsp structs"
those defines are unused.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-09-01 09:58:27 +03:00
Karol Trzcinski fc4d7b8519 rimage: Fix error message content after adsp malloc fail
Message should reflect error root cause.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-09-01 09:58:12 +03:00
Karol Trzcinski 3e20076f97 config: Return error value in parse_uint32_* functions when key is not found
Return value, for error case should be unified.
For those functions, default error value is UINT32_MAX.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-08-31 21:26:14 +01:00
Karol Trzcinski ada30c15b5 config: Explicit state return value for error cases in parse_uint32_* functions
Developer should know what is ther return value for error cases.
Improved doxydoc may be used eg. by IDE to speed-up code development.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-08-31 21:26:14 +01:00
Karol Trzcinski de9177b841 config: Adjust return type with function name
Function with `parse_uint32` should return uint32_t value

Signed-off-by: Karol Trzcinski <karolx.trzcinski@intel.com>
2021-08-31 21:26:14 +01:00
Karol Trzcinski c4a7456254 config: Remove machine_id field
This enum value is used only to distinguish suecreek from other
platforms, which can be done also by platform name.

Manual enumeration, in separate toml files with manual synchronization
in enum definition is quite error prone. After commit
9bf46d3: "rimage: Add support for mt8195" and
9716e10: "config: Add imx8ulp.toml" there are two different
platform with the same enum value 15 specified, which proves such a
thesis.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-08-31 21:23:28 +01:00
Karol Trzcinski 916fc2cd73 config: Remove unused adsp structs
After commit 2965908 "manifest: Remove -m option" those
structs are unused. ADSP configuration comes from toml
configuration files.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2021-08-31 16:15:04 +01:00
Allen-kh Cheng 9bf46d3fe2 rimage: Add support for mt8195
Add mt8195.toml to support sof-mt8195.ri binary build.
Add mt8195 memory layout
Add mt8195 machine_id

Signed-off-by: YC Hung <yc.hung@mediatek.com>
Signed-off-by: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
2021-08-27 13:56:56 +01:00
Marcin Rajwa aea1969225 adsp_config: fix potential overflow in strtol()
This patch fixes the potential overflow which may happen during
conversion of signed long. On a platforms where signed long
is only 32 bits the address which is stored in temp_s will experience
overflow.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2021-08-27 13:49:27 +01:00
Zhang Peng 9716e10a3e config: Add imx8ulp.toml
Add imx8ulp toml file to support sof-imx8ulp.ri binary build.

Signed-off-by: Zhang Peng <peng.zhang_8@nxp.com>
2021-07-29 14:22:39 +03:00
sunil b28b9939dc fixing incorrect data offset in ri_manifest_sign_v1_5 2021-07-27 17:40:10 +01:00
balakishorepati d1553e9321 config: add rn toml file to support renoir build
Add rn toml file to support sof-rn.ri binary build

Signed-off-by: Basavaraj Hiregoudar <basavaraj.hiregoudar@amd.com>
Signed-off-by: Anup Kulkarni <anup.kulkarni@amd.com>
Signed-off-by: balapati <balakishore.pati@amd.com>
2021-07-26 14:44:51 +01:00
Keyon Jie 246ea6469a config: skl: change image_size to the real SRAM size
We have 30 bank HP and 2 bank LP SRAM on SKL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-23 13:58:03 +08:00
Keyon Jie 9c9e07c650 config: kbl: change image_size to the real SRAM size
We have 30 bank HP and 2 bank LP SRAM on KBL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-23 13:58:03 +08:00
Keyon Jie 44b37d19a2 config: sue: change image_size to the real SRAM size
We have 47 bank HP and 1 bank LP SRAM on Suecreek, change the toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-21 11:58:20 +01:00
Rander Wang 580e4d674e config: tgl-cavs: change image_size to the real SRAM size
Apply "config: tgl: change image_size to the real SRAM size"
(9e50a02f1b) to tgl-cavs

Signed-off-by: Rander Wang <rander.wang@intel.com>
2021-07-21 18:03:59 +08:00
Keyon Jie 9a26e45580 config: apl: change image_size to the real SRAM size
We have 8 bank HP and 2 bank LP SRAM on APL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 8a2ea0044d config: cnl: change image_size to the real SRAM size
We have 47 bank HP and 1 bank LP SRAM on CNL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 1de9ccca33 config: jsl: change image_size to the real SRAM size
We have 16 bank HP and 1 bank LP SRAM on JSL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie f52a078aad config: icl: change image_size to the real SRAM size
We have 47 bank HP and 1 bank LP SRAM on ICL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 8073ea3ef9 config: tgl-h: change image_size to the real SRAM size
We have 30 bank HP and 1 bank LP SRAM on TGL-H, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Keyon Jie 9e50a02f1b config: tgl: change image_size to the real SRAM size
We have 46 bank HP and 1 bank LP SRAM on TGL, change to toml config file
to reflect that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-07-02 12:51:46 +01:00
Slawomir Blauciak 5aeb95b19b sanity check allocated memory
Issue detected by Klocwork

Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
2021-05-26 13:22:32 +01:00
Curtis Malainey 6f45b61921 actions: add cppcheck and yamllint
CI saves lives

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-19 11:12:14 +01:00
Curtis Malainey 7764a8bd31 manifest: close file on error
found via cppcheck

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-05-19 11:12:14 +01:00