-
Notifications
You must be signed in to change notification settings - Fork 8.4k
west: sign/rimage: use rimage config to find SOF directory #99531
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
base: main
Are you sure you want to change the base?
west: sign/rimage: use rimage config to find SOF directory #99531
Conversation
marc-hb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a minor hack but still a hack: why is sof.git not in any manifest?
You can combine SOF with any moving Zephyr version of your choice using sof/west.yml + a "submanifest". Example:
This was not theoretical, this submanifest example was used "for real" in CI for a long time.
I regularly get lost in west "import" flexibility, yet none is suitable here? Just wondering about the use case. I suspect using an "out-of-manifest" Zephyr module causes other complications beyond this one?
scripts/west_commands/sign.py
Outdated
| sof_src_dir = pathlib.Path(os.getenv("SOF_SRC_DIR")) | ||
| else: | ||
| try: | ||
| sof_proj = command.manifest.get_projects(['sof'], allow_paths=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since 1a780f9 this is dead code, no point keeping it.
EDIT: I mean dead code unless sof/west.yml downloads... SOF recursively :-D
EDIT2: correction: or, someone combines zephyr/west.yml with some submanifest that downloads SOF. Looks like I got lost again in west infinite possibilities...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just remembered there is already west config rimage.path ... and also west sign --tool-path ....
Considering rimage has been merged back into sof a long time ago, maybe sof_src_dir could be automagically inferred from one of these when not found in the manifest, avoiding one extra configuration item.
If one new configuration item can really not be avoided, then west config ... is more flexible, IMHO more convenient and a new environment variable and more consistent with where rimage configuration already is.
My 2 cents.
478a2a5 to
e863ff2
Compare
|
Modified to use the rimage config path to find the SOF directory. |
e863ff2 to
536b2aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issue with cmake_cache.get('RIMAGE_CONFIG_PATH'), but the logic still does not feel right. For a very long time this code has been:
try:
to find SOF project in [zephyr/]west.yml
...
except: # not found, so assume that the manifest is sof/west.yml
...Now, SOF has been removed from zephyr/west.yml. But instead of changing the try clause, this PR changes the except clause?!
After this PR, the code looks like:
try:
to find something that will never be found! # changed location, unchanged code
...
except:
do something that might work in both zephyr/west.yml and sof/west.yml cases?This PR might work because your new except clause might work in both cases. But it's weird and confusing now.
BTW don't attempt to preserve the try: except: at all costs. An if/then/else might be enough now.
|
Obviously: please test this PR in both zephyr/west.yml and sof/west.yml cases. |
536b2aa to
78b1b9c
Compare
|
Change the discovery logic a bit to cover possible scenarios. |
78b1b9c to
7f18fac
Compare
|
Twister does not take west config variable so we still need a way to specific where SOF is, which is via environment variable |
marc-hb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this increases the number of ways to find the SOF git clone to four now! But we have only two different, known situations to deal with: zephyr/west.yml and sof/west.yml? Four different solutions for two situations?
This rimage area has alway been difficult to maintain because of the too many different combinations and possibilities; merely reading the (already too long) sign() method is enough to get the corresponding headache: can't touch anything because "you never know". Ideally, that sign method should support fewer variations, not more. In the meantime, each way to find the SOF git clone should at least tell in a source comment what specific situation it is supposed to deal with.
BTW do you know how having rimage in the path affects #99497 (comment) ?
Twister does not take west config variable so we still need a way to specific where SOF is, which is via environment variable SOF_SRC_DIR.
I don't get this: why does twister even need to know about west config? Both the environment variables and the west config approaches have the same advantage of "cutting through" the layer of indirections without them even knowing about it.
It's not like sof_src_dir is something dynamic that depends on the platform or test case.
scripts/west_commands/sign.py
Outdated
|
|
||
| # Make sure this is the actual SOF directory as | ||
| # RIMAGE_CONFIG_PATH may point to somewhere else. | ||
| versions_json_file = maybe_sof_dir / 'versions.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SonarCloud is not far off: this entire versions_json_file.exists() test is repeated 3 times. This is calling for some new test function.
Speaking of functions, the length of this PR (assuming it is justified) is now calling for some new def get_sof_dir() function too that get just return as soon as it finds something.
7f18fac to
da08589
Compare
|
The main reason for needing to find the SOF directory is simply the need to run the UUID generation script.
Whether rimage is in the path or specified via |
da08589 to
e8a6ede
Compare
After removal of SOF from manifest, if rimage is in path, the build would fail because the gen-uuid-reg.py cannot be found anymore. To fix this, use the rimage config path to find the SOF directory since the rimage config path is a directory under SOF. This would allow rimage to again sign images to run on hardware. Signed-off-by: Daniel Leung <[email protected]>
|



After removal of SOF from manifest, if rimage is in path, the build would fail because the gen-uuid-reg.py cannot be found anymore. To fix this, use the rimage config path to find the SOF directory since the rimage config path is a directory under SOF. This would allow rimage to again sign images to run on hardware.