-
Notifications
You must be signed in to change notification settings - Fork 654
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
zephyr: The simple
sample doesn't run on nucleo-h563zi
#3252
Comments
os_icache_flush(void *start, size_t len)
{
#if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU)
#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */
sys_cache_instr_flush_range(start, len);
#endif
#endif
} |
Is it better to use macro MPU_RASR_XN_Msk to control the code?
Is it better to include <zephyr/cache.h> when KERNEL_VERSION_NUMBER >= 0x030300? sys_cache_instr_flush_range is a static inline function and is always available when when KERNEL_VERSION_NUMBER >= 0x030300. @lucasAbadFr, @mkolchurin thanks for reporting the issue and the discussion, I tried to upload the patch according to the comments, could you check whether it work?: diff --git a/core/shared/platform/zephyr/platform_internal.h b/core/shared/platform/zephyr/platform_internal.h
index 00bb4956..3c0f5526 100644
--- a/core/shared/platform/zephyr/platform_internal.h
+++ b/core/shared/platform/zephyr/platform_internal.h
@@ -51,9 +51,7 @@
#endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */
#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */
-#if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU)
#include <zephyr/cache.h>
-#endif
#endif /* end of KERNEL_VERSION_NUMBER > 0x030300 */
#ifdef CONFIG_ARM_MPU
@@ -177,4 +175,15 @@ os_get_invalid_handle()
return -1;
}
+static inline int
+os_getpagesize()
+{
+#ifdef CONFIG_MMU
+ return CONFIG_MMU_PAGE_SIZE;
+#else
+ /* Return a default page size if the MMU is not enabled */
+ return 4096; /* 4KB */
+#endif
+}
+
#endif
diff --git a/core/shared/platform/zephyr/zephyr_platform.c b/core/shared/platform/zephyr/zephyr_platform.c
index 156ce537..fc54ba55 100644
--- a/core/shared/platform/zephyr/zephyr_platform.c
+++ b/core/shared/platform/zephyr/zephyr_platform.c
@@ -25,9 +25,11 @@ disable_mpu_rasr_xn(void)
would most likely be set at index 2. */
for (index = 0U; index < 8; index++) {
MPU->RNR = index;
+#ifdef MPU_RASR_XN_Msk
if (MPU->RASR & MPU_RASR_XN_Msk) {
MPU->RASR |= ~MPU_RASR_XN_Msk;
}
+#endif
}
}
#endif /* end of CONFIG_ARM_MPU */
@@ -185,6 +187,12 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
return BH_MALLOC(size);
}
+void *
+os_mremap(void *old_addr, size_t old_size, size_t new_size)
+{
+ return os_mremap_slow(old_addr, old_size, new_size);
+}
+
void
os_munmap(void *addr, size_t size)
{ |
@wenyongh it's works! Thanks |
The AOT ABI has changed after 1.3.x, see #3116. The aot runtime and wamrc must be consistent, please ensure both them are built from release/1.3.x, or both are built from main. |
Hello @wenyongh and @mkolchurin ! Apologies for the oversight, I forgot to mention in my issue that I was working on the @wenyongh, after testing with your changes, I was able to make the Output: Hello world!
buf ptr: 0x1458
buf: 1234
elapsed: 29 Would it be appropriate to raise an issue on Zephyr's GitHub to seek assistance with implementing the following two functions:
The current functionality is effective with three or four boards (may be more), but its compatibility with all Zephyr's supported boards is uncertain. Addressing this may facilitate the implementation of WAMR as a Zephyr module, as suggested by your pull request. I'm also quite interested in increasing zephyr plateform support, is there a guideline other than the |
OK, so let's merge the PR.
Here wasm-micro-runtime/core/iwasm/common/wasm_memory.c Lines 926 to 929 in 498eb5d
It is to ensure the size of memory mapped is multiple of the system page size, so mmap can allocate complete pages. I think it should not be an issue for zephyr since it uses malloc function. The last sentence should be *memory_data_size = align_as_and_cast(*memory_data_size, page_size) , we will fix it soon.I have no idea about disable_mpu_rasr_xn , maybe you can raise an issue in zephyr.
Yes, WAMR is an open community, it is highly appreciated that developer helps to contribute PRs. |
I'm marking this issue as closed since the pull request has been merged. |
Hello, I'm trying to build the
product-mini/platforms/zephyr/simple
example for thenucleo_h563zi
board. But I'm unable to make it work. Any help is appreciated. Thanks.I'm on Zephyr 3.6.0 even if it's currently unsupported by the WAMR, the
simple
example should work.My build command is:
I created a new board configuration for the
nucleo_h563zi
board. I used thenucleo_h563zi
zephyr default board configuration as a reference:MPU error
core/shared/platform/zephyr/zephyr_platform.c
, I temporarily changed the condition to usestatic void disable_mpu_rasr_xn(void)
.Linker error
function
sys_cache_instr_flush_range
:Error output is:
Work-around: In file
core/shared/platform/zephyr/zephyr_platform.c
, I added an include tozephyr/cache.h
.function
os_mremap
:Error output is:
Work-around: In file
core/shared/platform/zephyr/zephyr_platform.c
, I added the implementation ofos_mremap
.function
os_getpagesize
Error output is:
Work-around: In file
core/shared/platform/zephyr/zephyr_platform.c
, I added the implementation ofos_getpagesize
.wasm_runtime_full_init
error:After fixing the above errors, I got the code to compile and link successfully. But when I run the code, I get the following error:
📄 Notes: I used
minicom
to connect to the board and see the output. I added some prints to the code to see where it's failing. It seems to fail at thewasm_runtime_full_init
function.I'm not very familiar with the Cortex-M7 and Cortex-M33 architectures. I'm currently looking at the Cortex-M33 and Cortex-M7 documentations to see if there's anything that I'm missing. I think the issue might be related to the MPU configuration. I'll update this issue with my findings.
Any help will be appreciated. Thanks.
The text was updated successfully, but these errors were encountered: