-
Notifications
You must be signed in to change notification settings - Fork 349
[SKIP CI] Use west manifest in SOF #6005
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
Conversation
lgirdwood
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.
@nashif @aborisovich I assume this is complementary to the SOF app PR from @nashif ?
.gitignore
Outdated
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 think we also have something in the python/bash build scripts that check/report on submodules. This would need updated too.
Fwiw, the python/bash scripts should probably also print out that they are being deprecated for Intel/NXP and west should be used instead as part of this PR.
|
Right now it downloads *all Zephyr modules. Maybe it is a bit of an overkill (download takes ~10 min on my machine). |
west.yml
Outdated
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.
instead of blacklisting, you should be whitelisting I guess and only add the things you need. Start with only those:
- hal_xtensa
- mbedtls
- mipi-sys-t
And then try and see if there are any other hidden deps you might want to add.
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.
import:
name-whitelist:
- mainline-app
- lib2
ea0b421 to
1cbcad0
Compare
|
Push update:
|
scripts/xtensa-build-zephyr.py
Outdated
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.
accidental autoadd, will remove
I think they should be independent from each other. I recommend we adjust all CI(s) for the other one first, it's much less disruptive. |
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.
You don't need to delete find_west_workspace() yet. Keep it for now and make this disruptive PR smaller and easier to review.
Of course you need to remove the --clone feature but I don't see why you need to remove the --west-path option, it should not matter here? Again this should make this disruptive PR smaller hence easier to review, test and troubleshoot (and less disruptive for CI)
Removed "zephyr revision" or "-z" argument as it is no longer
needed and did not have actual implementation.
That's not correct, who would have added this option without testing it? I think we use this in CI now. I'm not saying this should be kept; I'm only saying the commit message is wrong.
Removed rimage submodule from git, added it to .gitignore.
Again you probably don't need to do this yet, a transition period is likely possible. There are still git submodule commands in CMakeLists.txt. It's bad and they should have been removed earlier anyway but for the moment they are still here so it's probably easier to have a transition period. The simpler is probably for west to download rimage in a different directory and update CMake to use either.
Removing the rimage submodule is also breaking non-Zephyr builds which are still being tested in CI.
scripts/xtensa-build-zephyr.py
Outdated
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 don't see the value of adding a bare layer of indirection on a mere west update. The purpose of this PR is to increase the direct usage of west and reduce the usage of this script.
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.
The purpose of this PR is to increase the direct usage of west and reduce the usage of this script.
That is a very bold statement. I do not agree with it.
Usage of west is still more cumbersome that usage of this script.
Even when we move all platforms to Zephyr XTOS and integrate @nashif s PR6004 , the set of commands required to build a single platform (from scratch) is:
west updatewest build build --build-dir build-<platform> -p always -b <board_name> sof/appcmake -B ./build-rimage -S ./drivers.audio.firmware.converged/rimagecmake --build ./build-rimagewest sign --build-dir build-mtl -t rimage --tool-path ./build-rimage/rimage --tool-data ./sof/rimage/config -- -k ./sof/keys/some_key.pem./build-mtl/zephyr/smex_ep/build/smex -l ./build-mtl/zephyr/zephyr.ldc ./build-mtl/zephyr/zephyr.elf
This is much longer than:
./scripts/xtensa-build-zephyr.py -c <platform>
That does this all for you. Maybe someday we will integrate it better so there are less commands to call but we are not there yet.
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.
Good points, this script will still be used a lot.
OK, now I see this function is used as part of west init AND west update AND symlink, makes sense to me now.
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.
Unresolving to keep @aborisovich's good summary visible.
At least two more things the script do:
- building sof-logger
- iterating on multiple platforms and "installing" all the files in the correct subdirectories:
build-sof-staging
├── tools
│ ├── cavstool.py
│ ├── cavstool_client.py
│ ├── cavstwist.sh
│ └── sof-logger
└── sof
├── sof-cnl.ldc
├── community
│ ├── sof-apl.ri
│ └── sof-cnl.ri
└── sof-apl.ldc
scripts/xtensa-build-zephyr.py
Outdated
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.
| def west_update_submodules(): | |
| def west_update_sof_rimage(): |
They're not "submodules" anymore here.
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'm not convinced of the value of updating rimage only. Why not update hal_xtensa and all other SOF dependencies at the same time?
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.
Marc I think you misunderstood the content.
It does not update rimage only. It updates also tomlc99.
It is also going to update alsa-lib but I need to add it as @lgirdwood suggested.
The idea behind splitting two modes:
"init_mode" and "update_mode" is that there are platforms in SOF that do not use Zephyr.
When building those platforms, you do not need to wait that ~3 min to download Zephyr and its dependencies.
So the "init_mode" is supposed to clone only SOF dependencies: rimage, tomlc99 and alsa-lib.
Then "update_mode" does the same as "init_mode" but also it updates Zephyr dependencies.
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 think my understanding on what this script does was also a bit wrong.
After all it is called xtensa-build_zephyr.py and should be used to build with zephyr only right?
I should not care for non-zephyr platforms/builds in this particular script.
I think I will remove "init_mode" completely.
miRoox
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.
It seems to break our XTOS build. Will we completely move to Zephyr soon?
As mentioned above I don't think it has too. This PR can add as much while removing less.
"Soon" yes but "now" is a bit too early still. |
west.yml
Outdated
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.
Please try to use a different location. Removing submodules and replacing them by something else in the same directory makes switching branches super painful, breaks git bisect etc.
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.
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.
Ok I see a potencial bad scenario:
west updateclones rimage and tomlc99 but does not registers them as submodules on branch A- end-user does not run
git submodule update --init --recursive(because why would he/she)? - End-user checks out to branch B that have submodules registered to other SHA than branch A.
- End-user runs platform build that fails with eg. image sining
- End-user runs
git statusthat does not show any changes because submodules had not been registered at all (and they are actually there cloned by west and checked out to wrong revision).
However:
- Note, that that's how west revision control works. It does not show git submodules change because its not git.
The fact that we do not remove git submodules is temporary because we can't do it easily. - I don't think that cloning "submodules" using
west updateto let's say new rimage_west directory is beneficial. Yes you would avoid confusion described in bad scenario above but the cost of redoing scripts, headers and adding tons of logic everywhere "it not rimage dir use rimage_west dir". Seems not worth it to me.
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.
Thanks for the testing and analysis. I agree the issue you described is acceptable. If someone uses west, they should use west all the way and then they should ask west to manage everything. No back and forth between west and submodules, that's simply not supported.
Yes you are right, especially that I still use "content" of this function in "west_init" function
I might need your help with this one. I need to figure out where it is used and provide appropriate resolution.
Lets get rid of "transition periods" and remove this all in single PR. |
|
@lgirdwood I had checked content of scripts/docker_build/sof_builder/Dockerfile that clones alsa-lib and alsa-utils.
Handling of alsa dependency should be done in separate PR and it involves some considerate amount of work. |
1cbcad0 to
b47eb46
Compare
Except we already support multiple ways. The current script has already and successfully been supporting multiple directory structures. Was this additional complexity and confusion that should have been best avoided? Maybe yes but we are already there, so adding a new option does not make things worse. The magic that make different directory structures possible in the same git version is So it would be really sad not to try to leverage |
|
Push update: changes to xtensa-build-zephyr.py
GIT: Other changes: |
|
@wszypelt can you check CI, looks like it may have stalled. Thanks ! |
|
@lgirdwood |
|
How can I add additional directory in the container that CI uses? |
|
Checkpatch reports "Co-authored-by: " as "WARNING: Non-standard signature: Co-authored-by:". |
|
@lgirdwood |
|
https://github.com/thesofproject/sof/blob/main/scripts/checkpatch.pl has We're trying to minimize changes with the Linux version of This being said, if adding |
I'm not 100% sure I understand the question but would this help? BTW this discussion is linked from the issue this PR is fixing. |
|
Push update:
|
This file provides the flexibility to test any Zephyr commit in Linux CI without any pollution of `git -C sof describe --dirty`. See (too) long discussion in thesofproject#6005 for details. This new file will have no effect until thesofproject#6005 is merged. However it can and SHOULD be merged before thesofproject#6005 because thesofproject#6005 is backwards incompatible and requires a "flag day" and the synchronization of several moving parts. So merging this commit earlier means having one less moving part to synchronize and it will simplify "flag day" rehearsals. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
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 performed a pretty extensive review, hope I did NOT miss anything. Overall logic looks good but there are still some local but important problems to address: exit code -1, strtobool() removed in Python 3.12,... see below. No logical change requested, should hopefully be easy and not controversial.
I'm also worried about the rimage key / symlink failure experienced by both @aiChaoSONG and @keqiaozhang... Can we use a direct link to the rimage key just for now instead of the indirect one through the (sometimes missing) symbolic link? Then we can discuss the symlink situation in a later, smaller and more focused PR. It's only a nice-to-have now and people can create it manually if it's missing for any reason.
PS @keqiaozhang: the function create_zephyr_sof_symlink() is still here, it has not changed and is still being called... in theory.
scripts/xtensa-build-zephyr.py
Outdated
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.
The "more pythonic" way is to drop check=False and replace with
except subprocess.CalledProcessError:
return None, NoneThere 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.
Well, generally yes but not in this specific case.
Look at the "check" flag docs fragment
If check is true, and the process exits with a non-zero exit code, a CalledProcessError exception will be raised. Attributes of that exception hold the arguments, the exit code, and stdout and stderr if they were captured.
So it's not like we catch an exception from subprocess directly but python command subprocess.run generates that exception and raises it if you set check=True. So in this case asking subprocess.run to raise exception just to catch it seems irrational.
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.
The operating system only provides error codes, so all subprocess exceptions are "faked" anyway. subprocess synthesizes exceptions because it's more "pythonic".
My suggestion to catch CalledProcessError was also a suggestion to let other, unexpected exceptions/error codes "crash" the script with a stack trace to help debug it.
Nevermind, no real issue here.
This file provides the flexibility to test any Zephyr commit in Linux CI without any pollution of `git -C sof describe --dirty`. See (too) long discussion in #6005 for details. This new file will have no effect until #6005 is merged. However it can and SHOULD be merged before #6005 because #6005 is backwards incompatible and requires a "flag day" and the synchronization of several moving parts. So merging this commit earlier means having one less moving part to synchronize and it will simplify "flag day" rehearsals. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Added usage of west manifest in the script to update both SOF and zephyr dependencies. Renamed "clone-mode" to "update" flag - the logic where sof dependencies and zephyr with dependencies is cloned. Removed "point-mode" from script as it will no longer work (west manifests require fixed directory structure). Removed "zephyr revision" or "-z" argument as it is no longer needed (now revision may be set in west.yml manifest). Added "-p" pristine flag to rebuild platforms while removing build directory. Co-developed-by: Krzysztof Frydryk <krzysztofx.frydryk@intel.com> Signed-off-by: Krzysztof Frydryk <krzysztofx.frydryk@intel.com> Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
460d175 to
85f8904
Compare
|
Push update:
|
|
@keqiaozhang fyi - current plan is to merge this tomorrow. Pls sync with @marc-hb and @mengdonglin |
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.
Looks good to me except for just ONE last problem which I'm afraid is a serious one, please prove me wrong: it seems to me that the previous west project is re-initialized with rm -rf even when the user answers "no". If correct then it is obviously a big problem!
zephyr/docker-build.sh
Outdated
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 added this if/then/else so this docker script can be tested locally, outside CI without having to delete and re-clone everything.
Now things are different and it's not such a problem anymore but I think an if/then/else would still be nice to drop the -u when everything is already cloned, it would save a bit of time. No big deal, can be re-added later.
scripts/xtensa-build-zephyr.py
Outdated
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'm afraid this perform re-initialization even when the user answered 'n'?
| if not reinitialize_answer: | |
| if reinitialize_answer != 'y': |
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.
Thanks, was fixing in hurry and missed this one!
scripts/xtensa-build-zephyr.py
Outdated
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.
The operating system only provides error codes, so all subprocess exceptions are "faked" anyway. subprocess synthesizes exceptions because it's more "pythonic".
My suggestion to catch CalledProcessError was also a suggestion to let other, unexpected exceptions/error codes "crash" the script with a stack trace to help debug it.
Nevermind, no real issue here.
scripts/xtensa-build-zephyr.py
Outdated
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 would print these in any case...
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.
Added new flag for non-interactive mode that should be used when script is invoked programmatically. In default (interactive) mode user is asked using a prompt whether to reinitialize west manifest if it is initialized to manifest other than SOFs. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
xtensa-build-zephyr.py had been using some execute_command calls when building rimage and using rimage keys over symlink from modules/audio/sof. Changed it so that calls are executed now over normal sof directory and symlink is not needed for script execution. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
…r.py Removed old flags from python script call and replaced with new one. Added one more working directory to zephyr-build container now SOF is placed in /workdir/sof and west workspace in /workdir . Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
Added versioning to scripts/xtensa-build-zephyr.py to get version information when incompatible changes are done to the script. Added yml schema version number to west.yml manifest. Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
85f8904 to
6e34ff5
Compare
Well, it depends on the operating system. There are systems like linux, written mostly in C where exceptions are "too C++" and can not be ever allowed according to linux kernel project religion |
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.
Thanks @aborisovich for the huge effort.
@keqiaozhang you're the conductor, the timing is all yours.
|
@wszypelt this should not be tested by CI yet, but the TGL DUT copy is failing again. Could be a bad DUT ? |
|
@keqiaozhang pls let us know when CI is ready and I'll merge this. Thanks ! |


Implemented west tool along with its manifest to SOF
To use it please install:
pip3 install --user -U westFor new build guides head to updated SOF project documentation Build with Zephyr.
Features
west init -m <SOF_URL>command (well... after this PR is merged).west init -l <SOF_DIR>to use westwest updatewill cause to download SOF dependencies (previously submodules) and zephyr along with dependencies required for SOF platforms building and testing (except modules/audio/sof - we don't need another SOF copy!)./sof/scripts/xtensa-build-zephyr.pywhen building with Zephyr, you need to manually create a symlink for Zephyr:ln -s ./modules/audio/sof ./sof(run in ~/workspace/my_sof_workspace see directory structure example below)Changes to GIT
Changes to directory structure of SOF & Zephyr
Changes to xtensa-build-zephyr.py
Signed-off-by: Andrey Borisovich andrey.borisovich@intel.com