-
Notifications
You must be signed in to change notification settings - Fork 17
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 POSIX architecture #19
Add support for Zephyr's POSIX architecture #19
Conversation
ead5f91
to
b055d15
Compare
Hi @aescolar the libmetal folder is aligned with the code in https://github.com/OpenAMP/libmetal. Therefore, we would like to avoid adding patches on top of itn as it would require rebases. That said, Any reason to not address this in https://github.com/OpenAMP/libmetal/blob/main/lib/system/zephyr? |
I'm certainly open to that. What would you recommend? |
b055d15
to
140cf24
Compare
@arnopo would something like this roughly what you had in mind? (if not please just tell how you'd like it) |
@arnopo |
I took more time to analyze solutions. there are different options... Do you need some other interface than the metal_cpu_yield ?
Here is one option that seem simple to implement with current design of the libmetal: static inline void metal_cpu_yield(void)
{
/*
* Native test environment let 1 microsecond pass
* to allow other threads to run
*/
metal_sleep_usec(1); /* I assume you can use the sleep method */
}; With such implementation, you have just to create a machine that will rely on Zephyr metal_sleep_usec() system implementation available here: |
@arnopo Thank you very much for looking into it, I really appreciate it :)
It seems the only trouble are the "processor" headers. And for these, only providing metal_cpu_yield() seems necessary.
It would be possible, though not too nice. Zephyr's k_sleep() has a resolution of the system tick period (10ms by default), so calling metal_sleep_usec(1), will sleep between 10ms and 20ms by default ( Due to that, it would be nicer to call either zephyr's If you want, we can have this special processor
If you think that is the best way to go, I can certainly do that. Though if you feel like it would be better to not have a weird name in the processor folder like "posix", but would prefer something a bit more descriptive like "hosted" I can also do that. If you want we can have a chat in discord (aescolar) or Teams. I updated this PR with something you may like. |
140cf24
to
4e8d789
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.
I made some remarks here but please push on libmetal github for next reviews
9b5a86e
to
96ef92d
Compare
Discussion moved to OpenAMP/libmetal#260 |
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_cpu_yield()" call is expected to be provided by the system folder headers, to provide whatever is needed for the metal_cpu_yield() function to perform its duty. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
When building for CMAKE_SYSTEM_PROCESSOR will be set to "posix" which is not usefull. Let's rename it instead to something else we can use. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
96ef92d
to
2455e70
Compare
As libmetal is now frozen until the end of the month, it would be very nice to make an exception and allow this patch into the zephyr module. Without this fix, it is not possible to build libmetal, and therefore openAMP for the native targets, including the simulated nrf5340. |
I'm Ok with that, @carlocaione any concerns? |
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 particular concern
@arnopo @carlocaione should this be merged? |
@aescolar with the openamp PR we rushed a bit but this time I'd like to do things properly. Can you open a zephyr PR with a manifest change pointing to this PR? After the Zephyr PR is greed, I will merge this. |
@carlocaione This is the PR that tests with this module update: zephyrproject-rtos/zephyr#63803 |
oooh ok, I missed that. |
@carlocaione Thanks! :) |
Zephyr's "POSIX architecture" is a test architecture which allows building the embedded SW with the Zephyr OS and HW models as a Linux executable.
When building for this target the Zephyr build
system will set the PROJECT_PROCESSOR as "posix".
We need to provide appropriate replacements
for the processor HAL for this "processor".
The "metal_cpu_yield()" call, which in other
architectures is handled as doing nothing, and therefore busy waiting, needs replacing with a call out to
Z_SPIN_DELAY(1)