Update Zephyr support to v3.5.0 and make instructions generic to boards (#2805)

Includes a number of updates to the Zephyr example, including removing a fair
amount of stale configuration. This is part of moving towards supporting WAMR
as a Zephyr module as described in #2782. Some functionality is removed as
part of this diff (e.g. AOT XTENSA support), but it had become stale while not
being actively maintained. It is anticipated that it (and AOT support for other
platforms) will be added back, along with CI support for ensuring they do not
become stale again.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
This commit is contained in:
Daniel Mangum
2023-11-22 19:56:04 -06:00
committed by GitHub
parent f9e8b9535e
commit 2175910bac
14 changed files with 86 additions and 559 deletions

View File

@ -104,56 +104,6 @@ app_instance_main(wasm_module_inst_t module_inst)
static char global_heap_buf[CONFIG_GLOBAL_HEAP_BUF_SIZE] = { 0 };
#endif
#ifdef CONFIG_BOARD_ESP32
#include "mem_alloc.h"
/*
esp32_technical_reference_manual:
"
The capacity of Internal SRAM 1 is 128 KB. Either CPU can read and write this
memory at addresses 0x3FFE_0000 ~ 0x3FFF_FFFF of the data bus, and also at
addresses 0x400A_0000 ~ 0x400B_FFFF of the instruction bus.
"
The custom linker script defines dram0_1_seg and map it to 0x400A_0000 ~
0x400B_FFFF for instruction bus access. Here we define the buffer that will be
placed to dram0_1_seg.
*/
static char esp32_executable_memory_buf[100 * 1024]
__attribute__((section(".aot_code_buf"))) = { 0 };
/* the poll allocator for executable memory */
static mem_allocator_t esp32_exec_mem_pool_allocator;
static int
esp32_exec_mem_init()
{
if (!(esp32_exec_mem_pool_allocator =
mem_allocator_create(esp32_executable_memory_buf,
sizeof(esp32_executable_memory_buf))))
return -1;
return 0;
}
static void
esp32_exec_mem_destroy()
{
mem_allocator_destroy(esp32_exec_mem_pool_allocator);
}
static void *
esp32_exec_mem_alloc(unsigned int size)
{
return mem_allocator_malloc(esp32_exec_mem_pool_allocator, size);
}
static void
esp32_exec_mem_free(void *addr)
{
mem_allocator_free(esp32_exec_mem_pool_allocator, addr);
}
#endif /* end of #ifdef CONFIG_BOARD_ESP32 */
void
iwasm_main(void *arg1, void *arg2, void *arg3)
{
@ -189,16 +139,6 @@ iwasm_main(void *arg1, void *arg2, void *arg3)
return;
}
#ifdef CONFIG_BOARD_ESP32
/* Initialize executable memory */
if (esp32_exec_mem_init() != 0) {
printf("Init executable memory failed.\n");
goto fail1;
}
/* Set hook functions for executable memory management */
set_exec_mem_alloc_func(esp32_exec_mem_alloc, esp32_exec_mem_free);
#endif
#if WASM_ENABLE_LOG != 0
bh_log_set_verbose_level(log_verbose_level);
#endif
@ -211,11 +151,7 @@ iwasm_main(void *arg1, void *arg2, void *arg3)
if (!(wasm_module = wasm_runtime_load(wasm_file_buf, wasm_file_size,
error_buf, sizeof(error_buf)))) {
printf("%s\n", error_buf);
#ifdef CONFIG_BOARD_ESP32
goto fail1_1;
#else
goto fail1;
#endif
}
/* instantiate the module */
@ -236,12 +172,6 @@ fail2:
/* unload the module */
wasm_runtime_unload(wasm_module);
#ifdef CONFIG_BOARD_ESP32
fail1_1:
/* destroy executable memory */
esp32_exec_mem_destroy();
#endif
fail1:
/* destroy runtime environment */
wasm_runtime_destroy();