add WAMR to build
This commit is contained in:
+41
-5
@@ -6,10 +6,9 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if(ESP_PLATFORM)
|
||||
# --------------------------------------------------------------------------
|
||||
# 1. ESP-IDF BUILD MODE (Target: ESP32-P4)
|
||||
@@ -48,10 +47,11 @@ else()
|
||||
projCOVERAGE_TEST=0
|
||||
)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# FreeRTOS Kernel via FetchContent
|
||||
# --------------------------------------------------------------------------
|
||||
include(FetchContent)
|
||||
|
||||
# Download FreeRTOS-Kernel Repository
|
||||
FetchContent_Declare(
|
||||
@@ -70,8 +70,36 @@ else()
|
||||
# Disable FreeRTOS Demos/Tests
|
||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# WAMR (WebAssembly Micro Runtime) via FetchContent
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
FetchContent_Declare(
|
||||
wamr_runtime
|
||||
GIT_REPOSITORY https://github.com/bytecodealliance/wasm-micro-runtime.git
|
||||
GIT_TAG WAMR-2.4.5
|
||||
)
|
||||
|
||||
# WAMR Desktop-Konfiguration
|
||||
set(WAMR_BUILD_INTERP 1 CACHE BOOL "" FORCE)
|
||||
set(WAMR_BUILD_FAST_INTERP 1 CACHE BOOL "" FORCE)
|
||||
set(WAMR_BUILD_JIT 0 CACHE BOOL "" FORCE)
|
||||
set(WAMR_BUILD_AOT 0 CACHE BOOL "" FORCE)
|
||||
set(WAMR_BUILD_LIBC_BUILTIN 1 CACHE BOOL "" FORCE)
|
||||
|
||||
# Disable WASI
|
||||
set(WAMR_BUILD_LIBC_WASI 0 CACHE BOOL "" FORCE)
|
||||
|
||||
if(WIN32)
|
||||
set(WAMR_BUILD_PLATFORM "windows" CACHE STRING "" FORCE)
|
||||
elseif(APPLE)
|
||||
set(WAMR_BUILD_PLATFORM "darwin" CACHE STRING "" FORCE)
|
||||
else()
|
||||
set(WAMR_BUILD_PLATFORM "linux" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
# define Target 'freertos_kernel'
|
||||
FetchContent_MakeAvailable(FreeRTOS_Kernel)
|
||||
FetchContent_MakeAvailable(FreeRTOS_Kernel wamr_runtime)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Nova64 Core Target
|
||||
@@ -85,10 +113,18 @@ else()
|
||||
)
|
||||
|
||||
# Link FreeRTOS Kernel to the nova64_core library
|
||||
target_link_libraries(nova64_core PRIVATE freertos_kernel freertos_config)
|
||||
target_link_libraries(nova64_core PRIVATE freertos_kernel freertos_config vmlib)
|
||||
|
||||
target_compile_definitions(nova64_core PRIVATE NOVA64_EXPORTS)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_definitions(
|
||||
COMPILING_WASM_RUNTIME_API
|
||||
alignof=__alignof
|
||||
_Alignof=__alignof
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set_target_properties(nova64_core PROPERTIES
|
||||
C_VISIBILITY_PRESET hidden
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// Cross-platform DLL export/import visibility macros
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef NOVA64_INTERNAL_H
|
||||
#define NOVA64_INTERNAL_H
|
||||
|
||||
void nova64_log(const char *format, ...);
|
||||
|
||||
#endif // NOVA64_INTERNAL_H
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef WASM_RUNNER_H
|
||||
#define WASM_RUNNER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
wasm_runner_role_main = 0,
|
||||
wasm_runner_role_status,
|
||||
wasm_runner_role_background,
|
||||
} wasm_runner_role_t;
|
||||
|
||||
typedef struct wasm_runner_instance wasm_runner_instance_t;
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
} wasm_runner_framebuffer_config_t;
|
||||
|
||||
bool wasm_runner_initialize(void);
|
||||
|
||||
/**
|
||||
* @brief Starts a WASM program with optional framebuffer access.
|
||||
*
|
||||
* @param module_path Path to the WASM module to start.
|
||||
* @param framebuffer_config Optional framebuffer configuration. If NULL,
|
||||
* framebuffer access is disabled.
|
||||
* @param out_instance Optional output pointer that receives a handle to the
|
||||
* running WAMR instance.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
bool wasm_runner_start_program(
|
||||
const char *module_path,
|
||||
const wasm_runner_framebuffer_config_t *framebuffer_config,
|
||||
wasm_runner_instance_t **out_instance);
|
||||
|
||||
#endif // WASM_RUNNER_H
|
||||
@@ -1,17 +1,18 @@
|
||||
#include "nova64_core.h"
|
||||
#include "nova64_internal.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "task.h"
|
||||
#include "wasm_runner.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#if defined(ESP_PLATFORM)
|
||||
/* ESP32-spezifische Header für Low-Power & Watchdog */
|
||||
#include "esp_pm.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#elif defined(_WIN32)
|
||||
/* Windows API für Schlafen im Desktop-Thread */
|
||||
#include <windows.h>
|
||||
#else
|
||||
/* POSIX / Linux / macOS Sleep */
|
||||
@@ -30,7 +31,7 @@ static volatile bool shutdown_requested = false;
|
||||
|
||||
static const char *const kInternalLauncherPath = "SYS:/launcher.wasm";
|
||||
|
||||
static void nova64_log(const char *format, ...) {
|
||||
void nova64_log(const char *format, ...) {
|
||||
char buffer[512];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
@@ -46,6 +47,7 @@ static void nova64_log(const char *format, ...) {
|
||||
|
||||
static bool initialize_wasm_runtime(void) {
|
||||
nova64_log("Initializing WASM runtime...\n");
|
||||
wasm_runner_initialize();
|
||||
// TODO: Replace this stub with real WAMR initialization.
|
||||
return true;
|
||||
}
|
||||
@@ -174,8 +176,7 @@ NOVA64_API int32_t nova64_main() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
nova64_log(
|
||||
"Entering main runtime and starting FreeRTOS scheduler...\n");
|
||||
nova64_log("Entering main runtime and starting FreeRTOS scheduler...\n");
|
||||
vTaskStartScheduler();
|
||||
|
||||
// vTaskStartScheduler only returns if the scheduler fails to start or if
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "wasm_runner.h"
|
||||
#include "nova64_internal.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
struct wasm_runner_instance {
|
||||
void *native_instance;
|
||||
char *module_path;
|
||||
wasm_runner_framebuffer_config_t framebuffer_config;
|
||||
wasm_runner_instance_t *next;
|
||||
};
|
||||
|
||||
bool wasm_runner_initialize(void) {
|
||||
wasm_runtime_init();
|
||||
nova64_log("WASM runtime initialized successfully.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user