mirror of
				https://github.com/bytecodealliance/wasm-micro-runtime.git
				synced 2025-10-31 05:11:19 +00:00 
			
		
		
		
	Fix some compilation warnings and add esp-idf platform for experiment (#454)
And fix some code indent issues.
This commit is contained in:
		
							parent
							
								
									7d8b79a7a7
								
							
						
					
					
						commit
						282831eba5
					
				|  | @ -106,13 +106,13 @@ attr_container_get_attr_begin(const attr_container_t *attr_cont, | ||||||
| 
 | 
 | ||||||
|     /* tag content */ |     /* tag content */ | ||||||
|     p += str_len; |     p += str_len; | ||||||
|     if (p - attr_cont->buf >= total_length) |     if ((uint32_t)(p - attr_cont->buf) >= total_length) | ||||||
|         return NULL; |         return NULL; | ||||||
| 
 | 
 | ||||||
|     /* attribute num */ |     /* attribute num */ | ||||||
|     attr_num = get_uint16(p); |     attr_num = get_uint16(p); | ||||||
|     p += sizeof(uint16_t); |     p += sizeof(uint16_t); | ||||||
|     if (p - attr_cont->buf >= total_length) |     if ((uint32_t)(p - attr_cont->buf) >= total_length) | ||||||
|         return NULL; |         return NULL; | ||||||
| 
 | 
 | ||||||
|     if (p_total_length) |     if (p_total_length) | ||||||
|  | @ -174,7 +174,8 @@ attr_container_find_attr(const attr_container_t *attr_cont, const char *key) | ||||||
| 
 | 
 | ||||||
|         if (str_len == strlen(key) + 1 |         if (str_len == strlen(key) + 1 | ||||||
|                 && memcmp(p + sizeof(uint16_t), key, str_len) == 0) { |                 && memcmp(p + sizeof(uint16_t), key, str_len) == 0) { | ||||||
|             if (p + sizeof(uint16_t) + str_len - attr_cont->buf >= total_length) |             if ((uint32_t)(p + sizeof(uint16_t) + str_len | ||||||
|  |                            - attr_cont->buf) >= total_length) | ||||||
|                 return NULL; |                 return NULL; | ||||||
|             return p; |             return p; | ||||||
|         } |         } | ||||||
|  | @ -337,7 +338,7 @@ bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key, | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* Set the attr buf */ |     /* Set the attr buf */ | ||||||
|     str_len = strlen(key) + 1; |     str_len = (uint16_t)(strlen(key) + 1); | ||||||
|     set_uint16(p, str_len); |     set_uint16(p, str_len); | ||||||
|     p += sizeof(uint16_t); |     p += sizeof(uint16_t); | ||||||
|     bh_memcpy_s(p, str_len, key, str_len); |     bh_memcpy_s(p, str_len, key, str_len); | ||||||
|  | @ -366,7 +367,7 @@ bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key, | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (p1 - p + msg_end - attr_end >= attr_len) { |         if ((uint32_t)(p1 - p + msg_end - attr_end) >= attr_len) { | ||||||
|             memmove(p, p1, attr_end - p1); |             memmove(p, p1, attr_end - p1); | ||||||
|             bh_memcpy_s(p + (attr_end - p1), attr_len, attr_buf, attr_len); |             bh_memcpy_s(p + (attr_end - p1), attr_len, attr_buf, attr_len); | ||||||
|             attr_container_free(attr_buf); |             attr_container_free(attr_buf); | ||||||
|  | @ -399,7 +400,7 @@ bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key, | ||||||
|         return true; |         return true; | ||||||
|     } else { |     } else { | ||||||
|         /* key not found */ |         /* key not found */ | ||||||
|         if (msg_end - attr_end >= attr_len) { |         if ((uint32_t)(msg_end - attr_end) >= attr_len) { | ||||||
|             bh_memcpy_s(attr_end, msg_end - attr_end, attr_buf, attr_len); |             bh_memcpy_s(attr_end, msg_end - attr_end, attr_buf, attr_len); | ||||||
|             attr_container_inc_attr_num(attr_cont); |             attr_container_inc_attr_num(attr_cont); | ||||||
|             attr_container_free(attr_buf); |             attr_container_free(attr_buf); | ||||||
|  | @ -564,6 +565,9 @@ attr_container_get_attr(const attr_container_t *attr_cont, const char *key) | ||||||
|         bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \ |         bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \ | ||||||
|         break;                                              \ |         break;                                              \ | ||||||
|       }                                                     \ |       }                                                     \ | ||||||
|  |       default:                                              \ | ||||||
|  |         bh_assert(0);                                       \ | ||||||
|  |         break;                                              \ | ||||||
|     }                                                       \ |     }                                                       \ | ||||||
|     return val.var_name;                                    \ |     return val.var_name;                                    \ | ||||||
|   } while (0) |   } while (0) | ||||||
|  | @ -819,6 +823,9 @@ void attr_container_dump(const attr_container_t *attr_cont) | ||||||
|                     get_uint32(p)); |                     get_uint32(p)); | ||||||
|             p += sizeof(uint32_t) + get_uint32(p); |             p += sizeof(uint32_t) + get_uint32(p); | ||||||
|             break; |             break; | ||||||
|  |         default: | ||||||
|  |             bh_assert(0); | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "bh_platform.h" | #include "bh_platform.h" | ||||||
| #include "app_manager_export.h" | #include "app_manager_export.h" | ||||||
| #include "module_wasm_app.h" | #include "../app-manager/module_wasm_app.h" | ||||||
| #include "timer_native_api.h" | #include "timer_native_api.h" | ||||||
| 
 | 
 | ||||||
| static bool timer_thread_run = true; | static bool timer_thread_run = true; | ||||||
|  |  | ||||||
|  | @ -396,4 +396,5 @@ module_interface *g_module_interfaces[Module_Max] = { | ||||||
| #else | #else | ||||||
|         NULL |         NULL | ||||||
| #endif | #endif | ||||||
|     }; | }; | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -215,7 +215,8 @@ int aee_host_msg_callback(void *msg, uint16_t msg_len) | ||||||
|                     request.sender = ID_HOST; |                     request.sender = ID_HOST; | ||||||
| 
 | 
 | ||||||
|                     am_dispatch_request(&request); |                     am_dispatch_request(&request); | ||||||
|                 } else { |                 } | ||||||
|  |                 else { | ||||||
|                     app_manager_printf("unexpected host msg type: %d\n", msg_type); |                     app_manager_printf("unexpected host msg type: %d\n", msg_type); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -73,8 +73,8 @@ bool send_error_response_to_host(int mid, int status, const char *msg) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     set_response(response, status, |     set_response(response, status, FMT_ATTR_CONTAINER, | ||||||
|     FMT_ATTR_CONTAINER, (const char *)payload, payload_len); |                  (const char *)payload, payload_len); | ||||||
|     response->mid = mid; |     response->mid = mid; | ||||||
| 
 | 
 | ||||||
|     send_response_to_host(response); |     send_response_to_host(response); | ||||||
|  |  | ||||||
|  | @ -173,11 +173,11 @@ typedef struct host_interface { | ||||||
|  * @return true if success, false otherwise |  * @return true if success, false otherwise | ||||||
|  */ |  */ | ||||||
| bool | bool | ||||||
| app_manager_host_init(host_interface *interface); | app_manager_host_init(host_interface *intf); | ||||||
| 
 | 
 | ||||||
| /* Startup app manager */ | /* Startup app manager */ | ||||||
| void | void | ||||||
| app_manager_startup(host_interface *interface); | app_manager_startup(host_interface *intf); | ||||||
| 
 | 
 | ||||||
| /* Get queue of current applet */ | /* Get queue of current applet */ | ||||||
| void * | void * | ||||||
|  |  | ||||||
|  | @ -226,7 +226,7 @@ | ||||||
| 
 | 
 | ||||||
| /* Default/min/max stack size of each app thread */ | /* Default/min/max stack size of each app thread */ | ||||||
| #if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \ | #if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \ | ||||||
|     && !defined(BH_PLATFORM_FREERTOS) |     && !defined(BH_PLATFORM_ESP_IDF) && !defined(BH_PLATFORM_OPENRTOS) | ||||||
| #define APP_THREAD_STACK_SIZE_DEFAULT (32 * 1024) | #define APP_THREAD_STACK_SIZE_DEFAULT (32 * 1024) | ||||||
| #define APP_THREAD_STACK_SIZE_MIN (24 * 1024) | #define APP_THREAD_STACK_SIZE_MIN (24 * 1024) | ||||||
| #else | #else | ||||||
|  | @ -259,5 +259,9 @@ | ||||||
| #define WASM_ENABLE_TAIL_CALL 0 | #define WASM_ENABLE_TAIL_CALL 0 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  | #ifndef WASM_ENABLE_CUSTOM_NAME_SECTION | ||||||
|  | #define WASM_ENABLE_CUSTOM_NAME_SECTION 0 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #endif /* end of _CONFIG_H_ */ | #endif /* end of _CONFIG_H_ */ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1663,6 +1663,10 @@ load_from_sections(AOTModule *module, AOTSection *sections, | ||||||
|                                              error_buf, error_buf_size)) |                                              error_buf, error_buf_size)) | ||||||
|                     return false; |                     return false; | ||||||
|                 break; |                 break; | ||||||
|  |             default: | ||||||
|  |                 set_error_buf(error_buf, error_buf_size, | ||||||
|  |                               "invalid aot section type"); | ||||||
|  |                 return false; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         section = section->next; |         section = section->next; | ||||||
|  |  | ||||||
|  | @ -36,8 +36,8 @@ typedef struct { | ||||||
|     REG_SYM(aot_call_indirect),           \ |     REG_SYM(aot_call_indirect),           \ | ||||||
|     REG_SYM(wasm_runtime_enlarge_memory), \ |     REG_SYM(wasm_runtime_enlarge_memory), \ | ||||||
|     REG_SYM(wasm_runtime_set_exception),  \ |     REG_SYM(wasm_runtime_set_exception),  \ | ||||||
|     REG_SYM(memset),                      \ |     REG_SYM(aot_memset),                  \ | ||||||
|     REG_SYM(memmove),                     \ |     REG_SYM(aot_memmove),                 \ | ||||||
|     REG_BULK_MEMORY_SYM()                 \ |     REG_BULK_MEMORY_SYM()                 \ | ||||||
|     REG_ATOMIC_WAIT_SYM() |     REG_ATOMIC_WAIT_SYM() | ||||||
| #else /* else of (defined(_WIN32) || defined(_WIN32_)) && defined(NDEBUG) */ | #else /* else of (defined(_WIN32) || defined(_WIN32_)) && defined(NDEBUG) */ | ||||||
|  | @ -47,8 +47,8 @@ typedef struct { | ||||||
|     REG_SYM(aot_call_indirect),           \ |     REG_SYM(aot_call_indirect),           \ | ||||||
|     REG_SYM(wasm_runtime_enlarge_memory), \ |     REG_SYM(wasm_runtime_enlarge_memory), \ | ||||||
|     REG_SYM(wasm_runtime_set_exception),  \ |     REG_SYM(wasm_runtime_set_exception),  \ | ||||||
|     REG_SYM(memset),                      \ |     REG_SYM(aot_memset),                  \ | ||||||
|     REG_SYM(memmove),                     \ |     REG_SYM(aot_memmove),                 \ | ||||||
|     REG_SYM(fmin),                        \ |     REG_SYM(fmin),                        \ | ||||||
|     REG_SYM(fminf),                       \ |     REG_SYM(fminf),                       \ | ||||||
|     REG_SYM(fmax),                        \ |     REG_SYM(fmax),                        \ | ||||||
|  |  | ||||||
|  | @ -1907,6 +1907,18 @@ aot_call_indirect(WASMExecEnv *exec_env, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void * | ||||||
|  | aot_memmove(void *dest, const void *src, size_t n) | ||||||
|  | { | ||||||
|  |     return memmove(dest, src, n); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void * | ||||||
|  | aot_memset(void *s, int c, size_t n) | ||||||
|  | { | ||||||
|  |     return memset(s, c, n); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #if WASM_ENABLE_BULK_MEMORY != 0 | #if WASM_ENABLE_BULK_MEMORY != 0 | ||||||
| bool | bool | ||||||
| aot_memory_init(AOTModuleInstance *module_inst, uint32 seg_index, | aot_memory_init(AOTModuleInstance *module_inst, uint32 seg_index, | ||||||
|  |  | ||||||
|  | @ -527,6 +527,12 @@ aot_call_indirect(WASMExecEnv *exec_env, | ||||||
| uint32 | uint32 | ||||||
| aot_get_plt_table_size(); | aot_get_plt_table_size(); | ||||||
| 
 | 
 | ||||||
|  | void * | ||||||
|  | aot_memmove(void *dest, const void *src, size_t n); | ||||||
|  | 
 | ||||||
|  | void * | ||||||
|  | aot_memset(void *s, int c, size_t n); | ||||||
|  | 
 | ||||||
| #if WASM_ENABLE_BULK_MEMORY != 0 | #if WASM_ENABLE_BULK_MEMORY != 0 | ||||||
| bool | bool | ||||||
| aot_memory_init(AOTModuleInstance *module_inst, uint32 seg_index, | aot_memory_init(AOTModuleInstance *module_inst, uint32 seg_index, | ||||||
|  |  | ||||||
|  | @ -7,6 +7,8 @@ | ||||||
| #include "bh_platform.h" | #include "bh_platform.h" | ||||||
| #include "mem_alloc.h" | #include "mem_alloc.h" | ||||||
| 
 | 
 | ||||||
|  | #define BH_ENABLE_MEMORY_PROFILING 0 | ||||||
|  | 
 | ||||||
| #if BH_ENABLE_MEMORY_PROFILING != 0 | #if BH_ENABLE_MEMORY_PROFILING != 0 | ||||||
| 
 | 
 | ||||||
| /* Memory profile data of a function */ | /* Memory profile data of a function */ | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
| #include "bh_log.h" | #include "bh_log.h" | ||||||
| 
 | 
 | ||||||
| #if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \ | #if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \ | ||||||
|     && !defined(BH_PLATFORM_FREERTOS) |     && !defined(BH_PLATFORM_OPENRTOS) && !defined(BH_PLATFORM_ESP_IDF) | ||||||
| #define ENABLE_QUICKSORT 1 | #define ENABLE_QUICKSORT 1 | ||||||
| #else | #else | ||||||
| #define ENABLE_QUICKSORT 0 | #define ENABLE_QUICKSORT 0 | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
| #ifndef _AOT_EXPORT_H | #ifndef _AOT_EXPORT_H | ||||||
| #define _AOT_EXPORT_H | #define _AOT_EXPORT_H | ||||||
| 
 | 
 | ||||||
| #include <inttypes.h> | #include <stdint.h> | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -6393,6 +6393,9 @@ handle_op_block_and_loop: | ||||||
|                             } |                             } | ||||||
| #endif | #endif | ||||||
|                             break; |                             break; | ||||||
|  |                         default: | ||||||
|  |                             bh_assert(0); | ||||||
|  |                             break; | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     ref_type = *(loader_ctx->frame_ref - 1); |                     ref_type = *(loader_ctx->frame_ref - 1); | ||||||
|  |  | ||||||
|  | @ -399,6 +399,31 @@ sprintf_out(int c, struct str_context *ctx) | ||||||
|     return c; |     return c; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #ifdef BH_PLATFORM_OPENRTOS | ||||||
|  | PRIVILEGED_DATA static char print_buf[128] = { 0 }; | ||||||
|  | PRIVILEGED_DATA static int print_buf_size = 0; | ||||||
|  | 
 | ||||||
|  | static int | ||||||
|  | printf_out(int c, struct str_context *ctx) | ||||||
|  | { | ||||||
|  |     if (c == '\n') { | ||||||
|  |         print_buf[print_buf_size] = '\0'; | ||||||
|  |         os_printf("%s\n", print_buf); | ||||||
|  |         print_buf_size = 0; | ||||||
|  |     } | ||||||
|  |     else if (print_buf_size >= sizeof(print_buf) - 2) { | ||||||
|  |         print_buf[print_buf_size++] = (char)c; | ||||||
|  |         print_buf[print_buf_size] = '\0'; | ||||||
|  |         os_printf("%s\n", print_buf); | ||||||
|  |         print_buf_size = 0; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         print_buf[print_buf_size++] = (char)c; | ||||||
|  |     } | ||||||
|  |     ctx->count++; | ||||||
|  |     return c; | ||||||
|  | } | ||||||
|  | #else | ||||||
| static int | static int | ||||||
| printf_out(int c, struct str_context *ctx) | printf_out(int c, struct str_context *ctx) | ||||||
| { | { | ||||||
|  | @ -406,6 +431,7 @@ printf_out(int c, struct str_context *ctx) | ||||||
|     ctx->count++; |     ctx->count++; | ||||||
|     return c; |     return c; | ||||||
| } | } | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| static int | static int | ||||||
| printf_wrapper(wasm_exec_env_t exec_env, | printf_wrapper(wasm_exec_env_t exec_env, | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ typedef enum { | ||||||
| 
 | 
 | ||||||
| /* CoAP response codes */ | /* CoAP response codes */ | ||||||
| typedef enum { | typedef enum { | ||||||
|   NO_ERROR = 0, |   COAP_NO_ERROR = 0, | ||||||
| 
 | 
 | ||||||
|   CREATED_2_01 = 65,            /* CREATED */ |   CREATED_2_01 = 65,            /* CREATED */ | ||||||
|   DELETED_2_02 = 66,            /* DELETED */ |   DELETED_2_02 = 66,            /* DELETED */ | ||||||
|  |  | ||||||
							
								
								
									
										25
									
								
								core/shared/platform/common/freertos/freertos_malloc.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								core/shared/platform/common/freertos/freertos_malloc.c
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (C) 2019 Intel Corporation.  All rights reserved. | ||||||
|  |  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include "platform_api_vmcore.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | void * | ||||||
|  | os_malloc(unsigned size) | ||||||
|  | { | ||||||
|  |     return NULL; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void * | ||||||
|  | os_realloc(void *ptr, unsigned size) | ||||||
|  | { | ||||||
|  |     return NULL; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void | ||||||
|  | os_free(void *ptr) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | @ -8,9 +8,12 @@ | ||||||
| 
 | 
 | ||||||
| #define bh_assert(v) do {                                   \ | #define bh_assert(v) do {                                   \ | ||||||
|     if (!(v)) {                                             \ |     if (!(v)) {                                             \ | ||||||
|  |         int _count = 1;                                     \ | ||||||
|         os_printf("\nASSERTION FAILED: %s, at %s, line %d\n",\ |         os_printf("\nASSERTION FAILED: %s, at %s, line %d\n",\ | ||||||
|                   #v, __FILE__, __LINE__);                  \ |                   #v, __FILE__, __LINE__);                  \ | ||||||
|         abort();                                            \ |         /* divived by 0 to make it abort */                 \ | ||||||
|  |         os_printf("%d\n", _count / (_count - 1));           \ | ||||||
|  |         while (1);                                          \ | ||||||
|     }                                                       \ |     }                                                       \ | ||||||
|   } while (0) |   } while (0) | ||||||
| 
 | 
 | ||||||
|  | @ -293,6 +296,7 @@ int os_thread_join(korp_tid thread, void **value_ptr) | ||||||
| int os_mutex_init(korp_mutex *mutex) | int os_mutex_init(korp_mutex *mutex) | ||||||
| { | { | ||||||
|     SemaphoreHandle_t semaphore; |     SemaphoreHandle_t semaphore; | ||||||
|  | 
 | ||||||
|     if (!(semaphore = xSemaphoreCreateMutex())) |     if (!(semaphore = xSemaphoreCreateMutex())) | ||||||
|         return BHT_ERROR; |         return BHT_ERROR; | ||||||
|     mutex->sem = semaphore; |     mutex->sem = semaphore; | ||||||
|  | @ -303,6 +307,7 @@ int os_mutex_init(korp_mutex *mutex) | ||||||
| int os_recursive_mutex_init(korp_mutex *mutex) | int os_recursive_mutex_init(korp_mutex *mutex) | ||||||
| { | { | ||||||
|     SemaphoreHandle_t semaphore; |     SemaphoreHandle_t semaphore; | ||||||
|  | 
 | ||||||
|     if (!(semaphore = xSemaphoreCreateRecursiveMutex())) |     if (!(semaphore = xSemaphoreCreateRecursiveMutex())) | ||||||
|         return BHT_ERROR; |         return BHT_ERROR; | ||||||
|     mutex->sem = semaphore; |     mutex->sem = semaphore; | ||||||
|  | @ -418,9 +423,3 @@ int os_cond_signal(korp_cond *cond) | ||||||
|     return BHT_OK; |     return BHT_OK; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8 *os_thread_get_stack_boundary() |  | ||||||
| { |  | ||||||
|     /* TODO: implement os_thread_get_stack_boundary */ |  | ||||||
|     return NULL; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
|  | @ -0,0 +1,8 @@ | ||||||
|  | # Copyright (C) 2019 Intel Corporation.  All rights reserved. | ||||||
|  | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
|  | 
 | ||||||
|  | set (PLATFORM_COMMON_FREERTOS_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||||||
|  | 
 | ||||||
|  | file (GLOB_RECURSE source_all ${PLATFORM_COMMON_FREERTOS_DIR}/*.c) | ||||||
|  | 
 | ||||||
|  | set (PLATFORM_COMMON_FREERTOS_SOURCE ${source_all} ) | ||||||
|  | @ -32,6 +32,10 @@ | ||||||
| 
 | 
 | ||||||
| #define __FDLIBM_STDC__ | #define __FDLIBM_STDC__ | ||||||
| 
 | 
 | ||||||
|  | #ifndef FLT_EVAL_METHOD | ||||||
|  | #define FLT_EVAL_METHOD 0 | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| typedef uint32_t u_int32_t; | typedef uint32_t u_int32_t; | ||||||
| typedef uint64_t u_int64_t; | typedef uint64_t u_int64_t; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										122
									
								
								core/shared/platform/esp-idf/espidf_platform.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								core/shared/platform/esp-idf/espidf_platform.c
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,122 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (C) 2019 Intel Corporation.  All rights reserved. | ||||||
|  |  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include "platform_api_vmcore.h" | ||||||
|  | #include "platform_api_extension.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | int errno = 0; | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | os_thread_sys_init(); | ||||||
|  | 
 | ||||||
|  | void | ||||||
|  | os_thread_sys_destroy(); | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | bh_platform_init() | ||||||
|  | { | ||||||
|  |     return os_thread_sys_init(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void | ||||||
|  | bh_platform_destroy() | ||||||
|  | { | ||||||
|  |     os_thread_sys_destroy(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int os_printf(const char *format, ...) | ||||||
|  | { | ||||||
|  |     int ret = 0; | ||||||
|  |     va_list ap; | ||||||
|  | 
 | ||||||
|  |     va_start(ap, format); | ||||||
|  |     ret += vprintf(format, ap); | ||||||
|  |     va_end(ap); | ||||||
|  | 
 | ||||||
|  |     return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | os_vprintf(const char *format, va_list ap) | ||||||
|  | { | ||||||
|  |     return vprintf(format, ap); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void * | ||||||
|  | os_mmap(void *hint, size_t size, int prot, int flags) | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |     return BH_MALLOC(size); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void | ||||||
|  | os_munmap(void *addr, size_t size) | ||||||
|  | { | ||||||
|  |     BH_FREE(addr); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | os_mprotect(void *addr, size_t size, int prot) | ||||||
|  | { | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void | ||||||
|  | os_dcache_flush() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | atoi(const char *nptr) | ||||||
|  | { | ||||||
|  |     bool is_negative = false; | ||||||
|  |     int total = 0; | ||||||
|  |     const char *p = nptr; | ||||||
|  |     char temp = '0'; | ||||||
|  | 
 | ||||||
|  |     if (NULL == p) { | ||||||
|  |         os_printf("invlaid atoi input\n"); | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (*p == '-') { | ||||||
|  |         is_negative = true; | ||||||
|  |         p++; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     while ((temp = *p++) != '\0') { | ||||||
|  |         if (temp > '9' || temp < '0') { | ||||||
|  |             continue; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         total = total * 10 + (int)(temp - '0'); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (is_negative) | ||||||
|  |         total = 0 - total; | ||||||
|  | 
 | ||||||
|  |     return total; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void * | ||||||
|  | memmove(void *dest, const void *src, size_t n) | ||||||
|  | { | ||||||
|  |     char *d = dest; | ||||||
|  |     const char *s = src; | ||||||
|  | 
 | ||||||
|  |     if (d < s) { | ||||||
|  |         while (n--) | ||||||
|  |             *d++ = *s++; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         const char *lasts = s + (n-1); | ||||||
|  |         char *lastd = d + (n-1); | ||||||
|  |         while (n--) | ||||||
|  |             *lastd-- = *lasts--; | ||||||
|  |     } | ||||||
|  |     return dest; | ||||||
|  | } | ||||||
|  | 
 | ||||||
							
								
								
									
										14
									
								
								core/shared/platform/esp-idf/espidf_thread.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								core/shared/platform/esp-idf/espidf_thread.c
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | /*
 | ||||||
|  |  * Copyright (C) 2019 Intel Corporation.  All rights reserved. | ||||||
|  |  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include "platform_api_vmcore.h" | ||||||
|  | #include "platform_api_extension.h" | ||||||
|  | 
 | ||||||
|  | uint8 *os_thread_get_stack_boundary() | ||||||
|  | { | ||||||
|  |     /* TODO: implement os_thread_get_stack_boundary */ | ||||||
|  |     return NULL; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | @ -20,8 +20,8 @@ | ||||||
| #include <task.h> | #include <task.h> | ||||||
| #include <os_api.h> | #include <os_api.h> | ||||||
| 
 | 
 | ||||||
| #ifndef BH_PLATFORM_FREERTOS | #ifndef BH_PLATFORM_ESP_IDF | ||||||
| #define BH_PLATFORM_FREERTOS | #define BH_PLATFORM_ESP_IDF | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #define BH_APPLET_PRESERVED_STACK_SIZE (2 * BH_KB) | #define BH_APPLET_PRESERVED_STACK_SIZE (2 * BH_KB) | ||||||
|  | @ -3,14 +3,17 @@ | ||||||
| 
 | 
 | ||||||
| set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR}) | set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||||||
| 
 | 
 | ||||||
| add_definitions(-DBH_PLATFORM_FREERTOS) | add_definitions(-DBH_PLATFORM_ESP_IDF) | ||||||
| 
 | 
 | ||||||
| include_directories(${PLATFORM_SHARED_DIR}) | include_directories(${PLATFORM_SHARED_DIR}) | ||||||
| include_directories(${PLATFORM_SHARED_DIR}/../include) | include_directories(${PLATFORM_SHARED_DIR}/../include) | ||||||
| 
 | 
 | ||||||
|  | include (${CMAKE_CURRENT_LIST_DIR}/../common/freertos/platform_api_freertos.cmake) | ||||||
| include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake) | include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake) | ||||||
| 
 | 
 | ||||||
| file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) | file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) | ||||||
| 
 | 
 | ||||||
| set (PLATFORM_SHARED_SOURCE ${source_all} ${PLATFORM_COMMON_MATH_SOURCE}) | set (PLATFORM_SHARED_SOURCE ${source_all} | ||||||
|  |                             ${PLATFORM_COMMON_MATH_SOURCE} | ||||||
|  |                             ${PLATFORM_COMMON_FREERTOS_SOURCE}) | ||||||
| 
 | 
 | ||||||
|  | @ -1,315 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (C) 2019 Intel Corporation.  All rights reserved. |  | ||||||
|  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #include "platform_api_vmcore.h" |  | ||||||
| #include "platform_api_extension.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| int errno = 0; |  | ||||||
| 
 |  | ||||||
| int |  | ||||||
| os_thread_sys_init(); |  | ||||||
| 
 |  | ||||||
| void |  | ||||||
| os_thread_sys_destroy(); |  | ||||||
| 
 |  | ||||||
| int |  | ||||||
| bh_platform_init() |  | ||||||
| { |  | ||||||
|     return os_thread_sys_init(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void |  | ||||||
| bh_platform_destroy() |  | ||||||
| { |  | ||||||
|     os_thread_sys_destroy(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void * |  | ||||||
| os_malloc(unsigned size) |  | ||||||
| { |  | ||||||
|     return NULL; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void * |  | ||||||
| os_realloc(void *ptr, unsigned size) |  | ||||||
| { |  | ||||||
|     return NULL; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void |  | ||||||
| os_free(void *ptr) |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int os_printf(const char *format, ...) |  | ||||||
| { |  | ||||||
|     /* TODO: implement os_printf */ |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int |  | ||||||
| os_vprintf(const char *format, va_list ap) |  | ||||||
| { |  | ||||||
|     /* TODO: implement os_vprintf */ |  | ||||||
|     return 1; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void * |  | ||||||
| os_mmap(void *hint, size_t size, int prot, int flags) |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
|     return BH_MALLOC(size); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void |  | ||||||
| os_munmap(void *addr, size_t size) |  | ||||||
| { |  | ||||||
|     BH_FREE(addr); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int |  | ||||||
| os_mprotect(void *addr, size_t size, int prot) |  | ||||||
| { |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void |  | ||||||
| os_dcache_flush() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int atoi(const char *nptr) |  | ||||||
| { |  | ||||||
|     bool is_negative = false; |  | ||||||
|     int total = 0; |  | ||||||
|     const char *p = nptr; |  | ||||||
|     char temp = '0'; |  | ||||||
| 
 |  | ||||||
|     if (NULL == p) { |  | ||||||
|         os_printf("invlaid atoi input\n"); |  | ||||||
|         return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (*p == '-') { |  | ||||||
|         is_negative = true; |  | ||||||
|         p++; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     while ((temp = *p++) != '\0') { |  | ||||||
|         if (temp > '9' || temp < '0') { |  | ||||||
|             continue; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         total = total * 10 + (int)(temp - '0'); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (is_negative) |  | ||||||
|         total = 0 - total; |  | ||||||
| 
 |  | ||||||
|     return total; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /**
 |  | ||||||
|  * TODO: implement these APIs which are needed by libc_builtin_wrapper.c |  | ||||||
|  *       and wasm_runtime_common.c |  | ||||||
|  */ |  | ||||||
| int strncasecmp(const char *s1, const char *s2, size_t n) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strncasecmp called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| long int strtol(const char *str, char **endptr, int base) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strtol called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| unsigned long int strtoul(const char *str, char **endptr, int base) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strtoul called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| unsigned long long int strtoull(const char *nptr, char **endptr, int base) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strtoull called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| double strtod(const char *nptr, char **endptr) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strtod called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| float strtof(const char *nptr, char **endptr) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strtof called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| char *strstr(const char *haystack, const char *needle) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strstr called!\n"); |  | ||||||
|     return NULL; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| size_t strspn(const char *s, const char *accept) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strspn called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| size_t strcspn(const char *s, const char *reject) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function strcspn called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void *memchr(const void *s, int c, size_t n) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function memchr called!\n"); |  | ||||||
|     return NULL; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isalnum(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isalnum called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isxdigit(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isxdigit called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isdigit(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isdigit called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isprint(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isprint called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isgraph(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isgraph called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isspace(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isspace called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isalpha(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isalpha called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int isupper(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function isupper called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int toupper(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function toupper called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int tolower(int c) |  | ||||||
| { |  | ||||||
|     os_printf("### unimplemented function tolower called!\n"); |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void *memmove(void *dest, const void *src, size_t n) |  | ||||||
| { |  | ||||||
|     char *d = dest; |  | ||||||
|     const char *s = src; |  | ||||||
| 
 |  | ||||||
|     if (d < s) { |  | ||||||
|         while (n--) |  | ||||||
|             *d++ = *s++; |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
|         const char *lasts = s + (n-1); |  | ||||||
|         char *lastd = d + (n-1); |  | ||||||
|         while (n--) |  | ||||||
|             *lastd-- = *lasts--; |  | ||||||
|     } |  | ||||||
|     return dest; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static union { |  | ||||||
|     int a; |  | ||||||
|     char b; |  | ||||||
| } __ue = { .a = 1 }; |  | ||||||
| 
 |  | ||||||
| #define is_little_endian() (__ue.b == 1) |  | ||||||
| 
 |  | ||||||
| static void swap32(uint8_t* pData) |  | ||||||
| { |  | ||||||
|     uint8_t value = *pData; |  | ||||||
|     *pData = *(pData + 3); |  | ||||||
|     *(pData + 3) = value; |  | ||||||
| 
 |  | ||||||
|     value = *(pData + 1); |  | ||||||
|     *(pData + 1) = *(pData + 2); |  | ||||||
|     *(pData + 2) = value; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void swap16(uint8_t* pData) |  | ||||||
| { |  | ||||||
|     uint8_t value = *pData; |  | ||||||
|     *(pData) = *(pData + 1); |  | ||||||
|     *(pData + 1) = value; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint32_t htonl(uint32_t value) |  | ||||||
| { |  | ||||||
|     uint32_t ret; |  | ||||||
|     if (is_little_endian()) { |  | ||||||
|         ret = value; |  | ||||||
|         swap32((uint8*) &ret); |  | ||||||
|         return ret; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return value; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint32_t ntohl(uint32_t value) |  | ||||||
| { |  | ||||||
|     return htonl(value); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint16_t htons(uint16_t value) |  | ||||||
| { |  | ||||||
|     uint16_t ret; |  | ||||||
|     if (is_little_endian()) { |  | ||||||
|         ret = value; |  | ||||||
|         swap16((uint8_t *)&ret); |  | ||||||
|         return ret; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return value; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint16_t ntohs(uint16_t value) |  | ||||||
| { |  | ||||||
|     return htons(value); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
|  | @ -147,7 +147,6 @@ int os_thread_detach(korp_tid thread) | ||||||
| 
 | 
 | ||||||
| void os_thread_exit(void *retval) | void os_thread_exit(void *retval) | ||||||
| { | { | ||||||
|     return BHT_OK; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8 *os_thread_get_stack_boundary() | uint8 *os_thread_get_stack_boundary() | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...) | ||||||
|     uint64 usec; |     uint64 usec; | ||||||
|     uint32 t, h, m, s, mills; |     uint32 t, h, m, s, mills; | ||||||
| 
 | 
 | ||||||
|     if (log_level > log_verbose_level) |     if ((uint32)log_level > log_verbose_level) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     self = os_self_thread(); |     self = os_self_thread(); | ||||||
|  |  | ||||||
							
								
								
									
										55
									
								
								product-mini/platforms/esp-idf/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								product-mini/platforms/esp-idf/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,55 @@ | ||||||
|  | # Copyright (C) 2019 Intel Corporation.  All rights reserved. | ||||||
|  | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||
|  | 
 | ||||||
|  | # from ESP-IDF 4.0 examples/build_system/cmake/idf_as_lib | ||||||
|  | cmake_minimum_required(VERSION 3.5) | ||||||
|  | 
 | ||||||
|  | project(wamr_esp_idf C) | ||||||
|  | 
 | ||||||
|  | enable_language (ASM) | ||||||
|  | 
 | ||||||
|  | # Include for ESP-IDF build system functions | ||||||
|  | include($ENV{IDF_PATH}/tools/cmake/idf.cmake) | ||||||
|  | 
 | ||||||
|  | # Create idf::esp32 and idf::freertos static libraries | ||||||
|  | idf_build_process(esp32 | ||||||
|  |                   # try and trim the build; additional components | ||||||
|  |                   # will be included as needed based on dependency tree | ||||||
|  |                   # | ||||||
|  |                   # although esptool_py does not generate static library, | ||||||
|  |                   # processing the component is needed for flashing related | ||||||
|  |                   # targets and file generation | ||||||
|  |                   COMPONENTS esp32 freertos esptool_py | ||||||
|  |                   SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig | ||||||
|  |                   BUILD_DIR ${CMAKE_BINARY_DIR}) | ||||||
|  | 
 | ||||||
|  | include_directories(build/config | ||||||
|  |                     xtensa/include | ||||||
|  |                     $ENV{IDF_PATH}/components/esp32/include | ||||||
|  |                     $ENV{IDF_PATH}/components/esp_common/include | ||||||
|  |                     $ENV{IDF_PATH}/components/esp_rom/include | ||||||
|  |                     $ENV{IDF_PATH}/components/freertos/include | ||||||
|  |                     $ENV{IDF_PATH}/components/heap/include | ||||||
|  |                     $ENV{IDF_PATH}/components/soc/esp32/include | ||||||
|  |                     $ENV{IDF_PATH}/components/xtensa/include | ||||||
|  |                     $ENV{IDF_PATH}/components/xtensa/esp32/include) | ||||||
|  | 
 | ||||||
|  | set(WAMR_BUILD_PLATFORM "esp-idf") | ||||||
|  | set(WAMR_BUILD_TARGET "XTENSA") | ||||||
|  | set(WAMR_BUILD_INTERP 1) | ||||||
|  | set(WAMR_BUILD_FAST_INTERP 1) | ||||||
|  | set(WAMR_BUILD_AOT 1) | ||||||
|  | set(WAMR_BUILD_LIBC_BUILTIN 1) | ||||||
|  | set(WAMR_BUILD_LIBC_WASI 0) | ||||||
|  | 
 | ||||||
|  | set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) | ||||||
|  | 
 | ||||||
|  | include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) | ||||||
|  | add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) | ||||||
|  | 
 | ||||||
|  | set(elf_file ${CMAKE_PROJECT_NAME}.elf) | ||||||
|  | add_executable(${elf_file} main.c iwasm_main.c) | ||||||
|  | 
 | ||||||
|  | # Link the static libraries to the executable | ||||||
|  | target_link_libraries(${elf_file} idf::esp32 idf::freertos idf::spi_flash vmlib) | ||||||
|  | 
 | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| # TODO: set WAMR root dir
 | # TODO: set WAMR root dir
 | ||||||
| WAMR_ROOT := ../../../../ | WAMR_ROOT := ../../.. | ||||||
| 
 | 
 | ||||||
| override PROJECT_CFLAGS := $(PROJECT_CFLAGS) -Wno-unused-parameter -Wno-pedantic | override PROJECT_CFLAGS := $(PROJECT_CFLAGS) -Wno-unused-parameter -Wno-pedantic | ||||||
| 
 | 
 | ||||||
|  | @ -12,11 +12,11 @@ override PROJECT_CFLAGS := $(PROJECT_CFLAGS) \ | ||||||
|                            -I$(WAMR_INC_ROOT)/core/shared/utils \
 |                            -I$(WAMR_INC_ROOT)/core/shared/utils \
 | ||||||
|                            -I$(WAMR_INC_ROOT)/core/shared/mem-alloc \
 |                            -I$(WAMR_INC_ROOT)/core/shared/mem-alloc \
 | ||||||
|                            -I$(WAMR_INC_ROOT)/core/shared/platform/include \
 |                            -I$(WAMR_INC_ROOT)/core/shared/platform/include \
 | ||||||
|                            -I$(WAMR_INC_ROOT)/core/shared/platform/freertos \
 |                            -I$(WAMR_INC_ROOT)/core/shared/platform/esp-idf \
 | ||||||
|                            -I$(WAMR_INC_ROOT)/core/iwasm/interpreter |                            -I$(WAMR_INC_ROOT)/core/iwasm/interpreter | ||||||
| 
 | 
 | ||||||
| override PROJECT_CFLAGS := $(PROJECT_CFLAGS) \ | override PROJECT_CFLAGS := $(PROJECT_CFLAGS) \ | ||||||
|                            -DBH_PLATFORM_FREERTOS \
 |                            -DBH_PLATFORM_ESP_IDF \
 | ||||||
|                            -DBH_MALLOC=wasm_runtime_malloc \
 |                            -DBH_MALLOC=wasm_runtime_malloc \
 | ||||||
|                            -DBH_FREE=wasm_runtime_free \
 |                            -DBH_FREE=wasm_runtime_free \
 | ||||||
|                            -DBUILD_TARGET_X86_32 \
 |                            -DBUILD_TARGET_X86_32 \
 | ||||||
|  | @ -25,10 +25,11 @@ override PROJECT_CFLAGS := $(PROJECT_CFLAGS) \ | ||||||
|                            -DWASM_ENABLE_LIBC_BUILTIN=1 |                            -DWASM_ENABLE_LIBC_BUILTIN=1 | ||||||
| 
 | 
 | ||||||
| override PROJECT_CSRC := $(PROJECT_CSRC) \ | override PROJECT_CSRC := $(PROJECT_CSRC) \ | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/platform/freertos/freertos_platform.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/platform/esp-idf/espidf_platform.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/platform/freertos/freertos_thread.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/platform/esp-idf/espidf_thread.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/platform/freertos/freertos_time.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/platform/common/freertos/freertos_malloc.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/platform/common/math/math.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/platform/common/freertos/freertos_thread.c \
 | ||||||
|  |                          $(WAMR_SRC_ROOT)/core/shared/platform/common/freertos/freertos_time.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/mem-alloc/mem_alloc.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/mem-alloc/mem_alloc.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/mem-alloc/ems/ems_kfc.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/mem-alloc/ems/ems_kfc.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/shared/mem-alloc/ems/ems_hmu.c \
 |                          $(WAMR_SRC_ROOT)/core/shared/mem-alloc/ems/ems_hmu.c \
 | ||||||
|  | @ -50,5 +51,5 @@ override PROJECT_CSRC := $(PROJECT_CSRC) \ | ||||||
|                          $(WAMR_SRC_ROOT)/core/iwasm/interpreter/wasm_interp_classic.c \
 |                          $(WAMR_SRC_ROOT)/core/iwasm/interpreter/wasm_interp_classic.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/iwasm/interpreter/wasm_loader.c \
 |                          $(WAMR_SRC_ROOT)/core/iwasm/interpreter/wasm_loader.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/core/iwasm/interpreter/wasm_runtime.c \
 |                          $(WAMR_SRC_ROOT)/core/iwasm/interpreter/wasm_runtime.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/product-mini/platforms/freertos/simple/iwasm_main.c \
 |                          $(WAMR_SRC_ROOT)/product-mini/platforms/esp-idf/iwasm_main.c \
 | ||||||
|                          $(WAMR_SRC_ROOT)/product-mini/platforms/freertos/simple/main.c |                          $(WAMR_SRC_ROOT)/product-mini/platforms/esp-idf/main.c | ||||||
|  | @ -134,8 +134,6 @@ else | ||||||
| CFLAGS += -DWASM_ENABLE_GLOBAL_HEAP_POOL=0 | CFLAGS += -DWASM_ENABLE_GLOBAL_HEAP_POOL=0 | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
| CFLAGS += -DBH_ENABLE_MEMORY_PROFILING=0 |  | ||||||
| 
 |  | ||||||
| CFLAGS += -Wno-strict-prototypes -Wno-shadow -Wno-unused-variable | CFLAGS += -Wno-strict-prototypes -Wno-shadow -Wno-unused-variable | ||||||
| CFLAGS += -Wno-int-conversion -Wno-implicit-function-declaration | CFLAGS += -Wno-int-conversion -Wno-implicit-function-declaration | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Wenyong Huang
						Wenyong Huang