Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intel_adsp: move west sign from west flash to earlier west build #54700

Merged
merged 10 commits into from
Apr 11, 2023

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Feb 10, 2023

Invoking west sign in west build accelerates twister because west build is run in parallel, see rationale in superseded and very different (CMake-based) PR #52942

To maximize backwards compatibility:

  • west sign is optional in west build
  • west flash will sign (again) if any rimage --option is passed

This PR started with "v3", v1 and v2 happened in #54189. v3 is significantly smaller and simpler than v2

Should fix thesofproject/sof#6917

Unlike #52942, this moves the rimage configuration logic not to CMake but to west sign configuration instead.

You should read and understand #52942 before looking at this.

Also take a look at thesofproject/sof#6917

Signed-off-by: Marc Herbert [email protected]

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The overall design makes sense to me. I would ask that you think about a separate rimage-extra-args instead of tool-extra-args, so that we could add imgtool-extra-args in the future. This in turn would enable quick switching between west sign --tool imgtool and west sign --tool rimage in situations where users have to do both.

marc-hb added a commit to marc-hb/sof that referenced this pull request Feb 24, 2023
Zero functional change. Next commit will build rimage _before_ building
the firmware which will be required when `west build` starts signing by
default (zephyrproject-rtos/zephyr#54700)

Signed-off-by: Marc Herbert <[email protected]>
marc-hb added a commit to marc-hb/sof that referenced this pull request Feb 24, 2023
This will be required when signing is transferred to `west build`, see
zephyrproject-rtos/zephyr#54700

Signed-off-by: Marc Herbert <[email protected]>
@marc-hb marc-hb changed the title WIP: move rimage earlier to west build time instead of west flash intel_adsp: move west sign from west flash to earlier west build Feb 24, 2023
@marc-hb
Copy link
Collaborator Author

marc-hb commented Feb 24, 2023

I'm guessing the failures are because CI does not have rimage. Maybe I'll make signing at build time optional, downgrade a missing rimage to a warning (and make sure there's a good error message at later flash time)

lgirdwood pushed a commit to thesofproject/sof that referenced this pull request Mar 1, 2023
Zero functional change. Next commit will build rimage _before_ building
the firmware which will be required when `west build` starts signing by
default (zephyrproject-rtos/zephyr#54700)

Signed-off-by: Marc Herbert <[email protected]>
lgirdwood pushed a commit to thesofproject/sof that referenced this pull request Mar 1, 2023
This will be required when signing is transferred to `west build`, see
zephyrproject-rtos/zephyr#54700

Signed-off-by: Marc Herbert <[email protected]>
@marc-hb
Copy link
Collaborator Author

marc-hb commented Mar 2, 2023

I just discovered the pretty hard way[*] that CONFIG_CLEANUP_INTERMEDIATE_FILES=y voids any twister performance benefit brought by this PR.

CONFIG_CLEANUP_INTERMEDIATE_FILES=y was added by commit 7dc1ef0 and a few, similar other commits.

Workaround:

# only the first time! Passing extra CMake arguments rebuilds from scratch always
west build -b intel_adsp_cavs15 samples/hello_world/ -- -DCONFIG_CLEANUP_INTERMEDIATE_FILES=n
west build 

prj.conf or some overlay can also do this.

The example above increases the build directory size from 15M to 16M.

[*] out of desperation I ended up comparing generated/configs.c across working and non working boards.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Mar 2, 2023

I just discovered the pretty hard way[*] that CONFIG_CLEANUP_INTERMEDIATE_FILES=y voids any twister performance benefit brought by this PR.

@marc-hb marc-hb force-pushed the build-time-rimage2 branch from 10ad19b to 49bf97f Compare March 3, 2023 01:59
marc-hb added a commit to marc-hb/sof that referenced this pull request Mar 3, 2023
@marc-hb marc-hb force-pushed the build-time-rimage2 branch from 49bf97f to 21ecaed Compare March 3, 2023 05:18
@marc-hb marc-hb marked this pull request as ready for review March 3, 2023 05:35
@marc-hb marc-hb force-pushed the build-time-rimage2 branch from ec424fb to bd4a5ae Compare March 16, 2023 00:48
@marc-hb
Copy link
Collaborator Author

marc-hb commented Mar 16, 2023

removing all those [west flash] options makes it less flexible and breaks existing users depending on those options.

Yes, from the beginning the idea was to stop west flash from signing, transferred to west build instead. The much earlier #52942 was also dropping these signing options too with a... "little" difference: in #52942 west flash was silently dropping signing options :-)

In v4 bd4a5aecd63031 I think I found a simple way to preserve backwards compatibility and keep these options while achieving the other goals, especially signing in parallel => west flash now (re-)signs if any signing option was passed to it, otherwise it does not.

@nashif could you try this latest version? Thanks!

teburd
teburd previously approved these changes Apr 5, 2023
@nashif
Copy link
Member

nashif commented Apr 9, 2023

you need to rebase.

marc-hb added 10 commits April 9, 2023 18:47
Don't force 99% of the users to pass the same value.

Signed-off-by: Marc Herbert <[email protected]>
No functional change yet, will be used in the next commits.

Signed-off-by: Marc Herbert <[email protected]>
The --tool parameter is not required anymore thanks a [sign] entry in
west config like this one:

```
[sign]
tool = imgtool
```

Signed-off-by: Marc Herbert <[email protected]>
Reduce duplication, no functional change except for a shorter log
statement with slightly less information.

This is required by the next commits.

Signed-off-by: Marc Herbert <[email protected]>
Add a 3rd option besides --tool-path and $PATH

Signed-off-by: Marc Herbert <[email protected]>
Make RIMAGE_SIGN_KEY a CMake CACHE variable so `west sign` can find it
and use it as a default value.

Fixes thesofproject/sof#6917

Signed-off-by: Marc Herbert <[email protected]>
Zero functional change, pure preparation for the next commit.

Signed-off-by: Marc Herbert <[email protected]>
We never want to leave stale outputs behind after failing.

Signed-off-by: Marc Herbert <[email protected]>
Moving `west sign` from `west flash` to `west build` for rimage has
multiple advantages (including a bit more consistency with
imgtool). However it makes `west build` fail when rimage is missing.

To avoid forcing every CI and developer who never used it before to
install rimage, make signing optional when passing new `west sign`
option --if-tool-available. A clear warning is printed.

Signed-off-by: Marc Herbert <[email protected]>
Invoking `west sign` in `west build` accelerates twister because `west
build` is run in parallel, see rationale in superseded and very
different (CMake-based) PR zephyrproject-rtos#52942.

To maximize backwards compatibility:
- `west sign` is optional in `west build`
- `west flash` will sign (again) if any rimage --option is passed

Signed-off-by: Marc Herbert <[email protected]>
@marc-hb
Copy link
Collaborator Author

marc-hb commented Apr 9, 2023

Thanks @nashif for spotting this, looks like it's not possible to be notified of new conflicts without... Slack! ploomber/contributing#16
EDIT: upvote https://github.com/orgs/community/discussions/17258

So v5 b3b327d is a pure rebase, no code change besides resolving the minor board.cmake conflicts with the removal of older platforms in PR #56588. All tests passed in https://github.com/zephyrproject-rtos/zephyr/actions/runs/4652415270/jobs/8232619338?pr=54700 and internal tests passed as well.

The force-push lost all code reviews, would the previous reviewers be kind enough to re-approve? Sorry for the inconvenience.

@nashif nashif merged commit fad2da3 into zephyrproject-rtos:main Apr 11, 2023
@marc-hb marc-hb deleted the build-time-rimage2 branch April 11, 2023 06:14
marc-hb added a commit to marc-hb/rimage that referenced this pull request Apr 18, 2023
The deleted "install" target copied only the rimage executable and
left the config files behind. This gave the wrong impression that the
executable is useful without config files.

"Installing" also gave the wrong impression that rimage versions are
somewhat stable and relatively independent of SOF versions: they're
not. In fact there is no such thing as an rimage "version": everyone
should always use the exact rimage _git commit_ from the west manifest
or git submodule. There are no rimage "releases" and no semantic
versioning or anything like it, rimage is effectively part of the SOF
source and build and run directly from its build directory by
practically every SOF developer and SOF CI thanks to

  sof/src/arch/xtensa/CMakeLists.txt#ExternalProject_Add(rimage_ep ...
  sof/scripts/xtensa-build-zephyr.py#def build_rimage()
  sof/zephyr/CMakeLists.txt#set(RIMAGE_CONFIG_PATH ...

etc.

Providing an "install" target greatly increases the chances of
different people and CIs using different rimage versions which is the
last thing we want considering the many significant rimage changes
happening right now, examples:

- zephyrproject-rtos/zephyr#56099
- zephyrproject-rtos/zephyr#54700
- thesofproject/sof#7270
- thesofproject/sof#7304
- thesofproject/sof#7320
- thesofproject#155

While it's useful for multiple files (e.g.: config files), a CMake
target was always overkill to copy a single file. Someone or some
script who really wants to copy the rimage binary to some other place
that the build directory for some (discouraged) reason _can still do
so_ with a much more basic, simpler and more transparent file copy
command.

Finally, the default "bin" DESTINATION required root access which
is otherwise totally unncessary to build SOF.

Signed-off-by: Marc Herbert <[email protected]>
marc-hb added a commit to marc-hb/rimage that referenced this pull request Apr 18, 2023
The deleted "install" target copied only the rimage executable and
left the config files behind. This gave the wrong impression that the
executable is useful without config files.

"Installing" also gave the wrong impression that rimage versions are
somewhat stable and relatively independent of SOF versions: they're
not. In fact there is no such thing as an rimage "version": everyone
should always use the exact rimage _git commit_ from the west manifest
or git submodule. There are no rimage "releases" and no semantic
versioning or anything like it, rimage is effectively part of the SOF
source and build and run directly from its build directory by
practically every SOF developer and SOF CI thanks to

  sof/src/arch/xtensa/CMakeLists.txt#ExternalProject_Add(rimage_ep ...
  sof/scripts/xtensa-build-zephyr.py#def build_rimage()
  sof/zephyr/CMakeLists.txt#set(RIMAGE_CONFIG_PATH ...

etc.

Providing an "install" target greatly increases the chances of
different people and CIs using different rimage versions which is the
last thing we want considering the many significant rimage changes
happening right now, examples:

- zephyrproject-rtos/zephyr#56099
- zephyrproject-rtos/zephyr#54700
- thesofproject/sof#7270
- thesofproject/sof#7304
- thesofproject/sof#7320
- thesofproject#155

While it's useful for multiple files (e.g.: config files), a CMake
target was always overkill to copy a single file. Someone or some
script who really wants to copy the rimage binary to some other place
that the build directory for some (discouraged) reason _can still do
so_ with a much more basic, simpler and more transparent file copy
command.

Finally, the default "bin" DESTINATION required root access which
is otherwise totally unncessary to build SOF.

Signed-off-by: Marc Herbert <[email protected]>
kv2019i pushed a commit to thesofproject/rimage that referenced this pull request Apr 26, 2023
The deleted "install" target copied only the rimage executable and
left the config files behind. This gave the wrong impression that the
executable is useful without config files.

"Installing" also gave the wrong impression that rimage versions are
somewhat stable and relatively independent of SOF versions: they're
not. In fact there is no such thing as an rimage "version": everyone
should always use the exact rimage _git commit_ from the west manifest
or git submodule. There are no rimage "releases" and no semantic
versioning or anything like it, rimage is effectively part of the SOF
source and build and run directly from its build directory by
practically every SOF developer and SOF CI thanks to

  sof/src/arch/xtensa/CMakeLists.txt#ExternalProject_Add(rimage_ep ...
  sof/scripts/xtensa-build-zephyr.py#def build_rimage()
  sof/zephyr/CMakeLists.txt#set(RIMAGE_CONFIG_PATH ...

etc.

Providing an "install" target greatly increases the chances of
different people and CIs using different rimage versions which is the
last thing we want considering the many significant rimage changes
happening right now, examples:

- zephyrproject-rtos/zephyr#56099
- zephyrproject-rtos/zephyr#54700
- thesofproject/sof#7270
- thesofproject/sof#7304
- thesofproject/sof#7320
- #155

While it's useful for multiple files (e.g.: config files), a CMake
target was always overkill to copy a single file. Someone or some
script who really wants to copy the rimage binary to some other place
that the build directory for some (discouraged) reason _can still do
so_ with a much more basic, simpler and more transparent file copy
command.

Finally, the default "bin" DESTINATION required root access which
is otherwise totally unncessary to build SOF.

Signed-off-by: Marc Herbert <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] pass vendor specific FW signing options to west sign
8 participants