-
Notifications
You must be signed in to change notification settings - Fork 171
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
Add support for Zephyr's native test environment #260
Conversation
@arnopo I'm honestly not sure if this would be the best way to handle this, your feedback would be very welcome |
I answered in zephyrproject-rtos/libmetal#19: Seems to me not a platform but an option in the Zephyr build. You could try to address this in this in https://github.com/OpenAMP/libmetal/blob/main/lib/system/zephyr |
lib/processor/zephyr_native/atomic.h
Outdated
#ifndef __METAL_ZEPHYR_NATIVE_ATOMIC__H__ | ||
#define __METAL_ZEPHYR_NATIVE_ATOMIC__H__ | ||
|
||
#endif /* __METAL_ZEPHYR_NATIVE_ATOMIC__H__ */ |
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 really like to replace all these do nothing headers with a single copy of a generic version. For "cpus" where both files are do nothing they can just define cpu_generic or something like that.
For this case you have something real to do in cpu.h so the cmake can select the generic-atomic.h and you can have the real cpu.h below.
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 can do that in a separate commit if you want, though if you would not mind, maybe in a follow up PR after we agree this other matter, as it is a bit unrelated and I would prefer to not mingle things too much.
Thanks @wmamills , |
e68f993
to
37b06af
Compare
@arnopo The PR has been updated as you requested in zephyrproject-rtos/libmetal#19 |
37b06af
to
dc2de99
Compare
dc2de99
to
153430b
Compare
Please could you re-base your PR on top of the main branch to fix CI issue |
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 way of integrating it seems ok to me, I let other reviewers share their opinions
153430b
to
e7591da
Compare
Thanks @arnopo, corrections according to your feedback have been done. |
@arnopo & others, is there anything that should be different / that prevents this from being merged? Background: This enables a new type of tests and way of developing for AMP scenarios for Zephyr, so there is quite a few people looking forward to it. |
Hi @aescolar, |
Thank you very much for the consideration @arnopo . I set the PR in the zephyr module as ready, and provided the motivation in this comment: zephyrproject-rtos/libmetal#19 (comment) |
@wmamills, @tnmysh, @edmooring |
I still don't want to create yet another ALMOST do nothing "processor". Can we have a PR to do the generic files first and then this can use them. Instead of adding the fake "processor" and then removing it. |
Provide the metal_sleep_usec() required for hosted environments. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
a73fc2a
to
c936074
Compare
@wmamills is something like this what you were hoping for? A Zephyr CI run with the equivalent of this patch can be seen passing in |
Add a new hosted test environment "processor". This is meant as a build target used when the code is not built for a real target but as part of a test in a hosted environment (for ex. as a test environment like Zephyr's native_sim target). When building for this target PROJECT_PROCESSOR should be set as "hosted". In this, the "metal_sleep_usec()" call is expected to be provided by the system folder headers. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
c936074
to
b19688f
Compare
Refactor all processor headers which had the same content into a generic set, to reduce the number of duplicates. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
b19688f
to
56366e3
Compare
@aescolar Yes that look great! Lots of code deletion! At libmetal I would like to land the commits in the other order: generic first and then Zephyr test env. Question: Is zephyr native posix always == test environment or are there some cases where you would not want the sleep for the yield? |
@wmamills Thanks
Native_posix/native_sim and the related targets are test/simulation/development environment. |
@wmamills are you happy enough with this PR as to approve it? :) |
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 approve
Thanks guys :) |
Zephyr's native test environment is a setup which allows building the embedded SW with the Zephyr OS and HW models as a Linux executable.
When building for this target the Zephyr integration will set the PROJECT_PROCESSOR as "zephyr_native".
We need to provide appropriate headers for this "processor".
The "metal_cpu_yield()" call, which in other architectures is handled as either a hint for the CPU to yield to another thread or do nothing, and therefore busy waiting, needs replacing with a call out to the Zephyr API which will cause the CPU to waste 1 microsecond, therefore enabling the other CPU in the system to ready whatever we are waiting for in the meanwhile.