Enable AoT and wamr-sdk, and change arguments of call wasm API (#157)
* Implement memory profiler, optimize memory usage, modify code indent * Implement memory.grow and limit heap space base offset to 1G; modify iwasm build type to Release and 64 bit by default * Add a new extension library: connection * Fix bug of reading magic number and version in big endian platform * Re-org platform APIs: move most platform APIs from iwasm to shared-lib * Enhance wasm loader to fix some security issues * Fix issue about illegal load of EXC_RETURN into PC on stm32 board * Updates that let a restricted version of the interpreter run in SGX * Enable native/app address validation and conversion for wasm app * Remove wasm_application_exectue_* APIs from wasm_export.h which makes confused * Refine binary size and fix several minor issues Optimize interpreter LOAD/STORE opcodes to decrease the binary size Fix issues when using iwasm library: _bh_log undefined, bh_memory.h not found Remove unused _stdin/_stdout/_stderr global variables resolve in libc wrapper Add macros of global heap size, stack size, heap size for Zephyr main.c Clear compile warning of wasm_application.c * Add more strict security checks for libc wrapper API's * Use one libc wrapper copy for sgx and other platforms; remove bh_printf macro for other platform header files * Enhance security of libc strcpy/sprintf wrapper function * Fix issue of call native for x86_64/arm/mips, add module inst parameter for native wrapper functions * Remove get_module_inst() and fix issue of call native * Refine wgl lib: remove module_inst parameter from widget functions; move function index check to runtime instantiate * Refine interpreter call native process, refine memory boudary check * Fix issues of invokeNative function of arm/mips/general version * Add a switch to build simple sample without gui support * Add BUILD_TARGET setting in makefile to replace cpu compiler flags in source code * Re-org shared lib header files, remove unused info; fix compile issues of vxworks * Add build target general * Remove unused files * Update license header * test push * Restore file * Sync up with internal/feature * Sync up with internal/feature * Rename build_wamr_app to build_wasm_app * Fix small issues of README * Enhance malformed wasm file checking Fix issue of print hex int and implement utf8 string check Fix wasi file read/write right issue Fix minor issue of build wasm app doc * Sync up with internal/feature * Sync up with internal/feature: fix interpreter arm issue, fix read leb issue * Sync up with internal/feature * Fix bug of config.h and rename wasi config.h to ssp_config.h * Sync up with internal/feature * Import wamr aot * update document * update document * Update document, disable WASI in 32bit * update document * remove files * update document * Update document * update document * update document * update samples * Sync up with internal repo
This commit is contained in:
@ -1,156 +1,32 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
project (simple)
|
||||
|
||||
set (TARGET_PLATFORM "linux")
|
||||
################ wamr runtime settings ################
|
||||
|
||||
# Reset default linker flags
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||
|
||||
if (NOT ("$ENV{VALGRIND}" STREQUAL "YES"))
|
||||
add_definitions(-DNVALGRIND)
|
||||
endif ()
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||
|
||||
set (BUILD_AS_64BIT_SUPPORT "YES")
|
||||
## use library and headers in the SDK
|
||||
link_directories(${WAMR_ROOT_DIR}/wamr-sdk/out/simple/runtime-sdk/lib)
|
||||
include_directories(
|
||||
${WAMR_ROOT_DIR}/wamr-sdk/out/simple/runtime-sdk/include
|
||||
)
|
||||
|
||||
# Set BUILD_TARGET, currently values supported:
|
||||
# "X86_64", "AMD_64", "X86_32", "ARM[sub]", "THUMB[sub]", "MIPS", "XTENSA"
|
||||
if (NOT DEFINED BUILD_TARGET)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if (BUILD_AS_64BIT_SUPPORT STREQUAL "YES")
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
set (BUILD_TARGET "X86_64")
|
||||
else ()
|
||||
set (BUILD_TARGET "X86_32")
|
||||
endif ()
|
||||
else ()
|
||||
# Build as X86_32 by default in 32-bit platform
|
||||
set (BUILD_TARGET "X86_32")
|
||||
endif ()
|
||||
endif ()
|
||||
################ application related ################
|
||||
|
||||
string(TOUPPER ${BUILD_TARGET} BUILD_TARGET)
|
||||
|
||||
# Add definitions for the build target
|
||||
if (BUILD_TARGET STREQUAL "X86_64")
|
||||
add_definitions(-DBUILD_TARGET_X86_64)
|
||||
elseif (BUILD_TARGET STREQUAL "AMD_64")
|
||||
add_definitions(-DBUILD_TARGET_AMD_64)
|
||||
elseif (BUILD_TARGET STREQUAL "X86_32")
|
||||
add_definitions(-DBUILD_TARGET_X86_32)
|
||||
elseif (BUILD_TARGET MATCHES "ARM.*")
|
||||
add_definitions(-DBUILD_TARGET_ARM)
|
||||
add_definitions(-DBUILD_TARGET="${BUILD_TARGET}")
|
||||
elseif (BUILD_TARGET MATCHES "THUMB.*")
|
||||
add_definitions(-DBUILD_TARGET_THUMB)
|
||||
add_definitions(-DBUILD_TARGET="${BUILD_TARGET}")
|
||||
elseif (BUILD_TARGET STREQUAL "MIPS")
|
||||
add_definitions(-DBUILD_TARGET_MIPS)
|
||||
elseif (BUILD_TARGET STREQUAL "XTENSA")
|
||||
add_definitions(-DBUILD_TARGET_XTENSA)
|
||||
else ()
|
||||
message (FATAL_ERROR "-- Build target isn't set")
|
||||
endif ()
|
||||
|
||||
message ("-- Build as target ${BUILD_TARGET}")
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if (BUILD_TARGET STREQUAL "X86_64" OR BUILD_TARGET STREQUAL "AMD_64")
|
||||
# Add -fPIC flag if build as 64-bit
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
|
||||
else ()
|
||||
add_definitions (-m32)
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE Debug)
|
||||
endif (NOT CMAKE_BUILD_TYPE)
|
||||
message ("-- CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE})
|
||||
|
||||
if (NOT PLATFORM)
|
||||
SET(PLATFORM linux)
|
||||
endif (NOT PLATFORM)
|
||||
message ("-- PLATFORM = " ${PLATFORM})
|
||||
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -Wno-pedantic")
|
||||
|
||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||
set(WASM_DIR ${WAMR_ROOT_DIR}/core/iwasm)
|
||||
set(APP_MGR_DIR ${WAMR_ROOT_DIR}/core/app-mgr)
|
||||
set(SHARED_DIR ${WAMR_ROOT_DIR}/core/shared-lib)
|
||||
|
||||
if ("${ENABLE_GUI}" STREQUAL "YES")
|
||||
set (LV_DRIVERS_DIR ${WASM_DIR}/lib/3rdparty/lv_drivers)
|
||||
set (LVGL_DIR ${WASM_DIR}/lib/3rdparty/lvgl)
|
||||
file(GLOB_RECURSE LV_DRIVERS_SOURCES "${LV_DRIVERS_DIR}/*.c" )
|
||||
endif()
|
||||
|
||||
enable_language (ASM)
|
||||
|
||||
include (${WASM_DIR}/runtime/utils/utils.cmake)
|
||||
include (${WASM_DIR}/runtime/vmcore-wasm/vmcore.cmake)
|
||||
include (${WASM_DIR}/lib/native/base/wasm_lib_base.cmake)
|
||||
include (${WASM_DIR}/lib/native/libc/wasm_libc.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/sensor/wasm_lib_sensor.cmake)
|
||||
if ("${ENABLE_GUI}" STREQUAL "YES")
|
||||
include (${WASM_DIR}/lib/native/extension/gui/wasm_lib_gui.cmake)
|
||||
endif()
|
||||
include (${WASM_DIR}/lib/native/extension/connection/wasm_lib_conn.cmake)
|
||||
include (${WASM_DIR}/lib/native/extension/connection/${TARGET_PLATFORM}/connection_mgr.cmake)
|
||||
include (${WASM_DIR}/lib/native-interface/native_interface.cmake)
|
||||
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
|
||||
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
|
||||
include (${SHARED_DIR}/platform/${TARGET_PLATFORM}/shared_platform.cmake)
|
||||
include (${SHARED_DIR}/utils/shared_utils.cmake)
|
||||
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
include (${SHARED_DIR}/coap/lib_coap.cmake)
|
||||
|
||||
|
||||
include_directories(${SHARED_DIR}/include)
|
||||
include_directories(${WASM_DIR}/runtime/platform/include)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
||||
|
||||
#Note: uncomment below line to use UART mode
|
||||
#add_definitions (-DCONNECTION_UART)
|
||||
add_definitions (-DWASM_ENABLE_BASE_LIB)
|
||||
add_definitions (-Dattr_container_malloc=bh_malloc)
|
||||
add_definitions (-Dattr_container_free=bh_free)
|
||||
add_definitions (-DLV_CONF_INCLUDE_SIMPLE)
|
||||
|
||||
if ("${ENABLE_GUI}" STREQUAL "YES")
|
||||
add_definitions (-DWASM_ENABLE_GUI=1)
|
||||
endif()
|
||||
|
||||
add_library (vmlib
|
||||
${WASM_PLATFORM_LIB_SOURCE}
|
||||
${WASM_UTILS_LIB_SOURCE}
|
||||
${VMCORE_LIB_SOURCE}
|
||||
${WASM_LIBC_SOURCE}
|
||||
${APP_MGR_SOURCE}
|
||||
${WASM_LIB_BASE_SOURCE}
|
||||
${WASM_LIB_EXT_SOURCE}
|
||||
${WASM_LIB_SENSOR_SOURCE}
|
||||
${WASM_LIB_GUI_SOURCE}
|
||||
${WASM_LIB_CONN_SOURCE}
|
||||
${WASM_LIB_CONN_MGR_SOURCE}
|
||||
${PLATFORM_SHARED_SOURCE}
|
||||
${UTILS_SHARED_SOURCE}
|
||||
${MEM_ALLOC_SHARED_SOURCE}
|
||||
${NATIVE_INTERFACE_SOURCE}
|
||||
)
|
||||
|
||||
if ("${ENABLE_GUI}" STREQUAL "YES")
|
||||
add_executable (simple src/main.c src/iwasm_main.c src/ext_lib_export.c ${LV_DRIVERS_SOURCES})
|
||||
target_link_libraries (simple vmlib -lm -ldl -lpthread -lSDL2)
|
||||
else ()
|
||||
add_executable (simple src/main.c src/iwasm_main.c src/ext_lib_export.c)
|
||||
target_link_libraries (simple vmlib -lm -ldl -lpthread)
|
||||
endif ()
|
||||
add_executable (simple src/main.c src/iwasm_main.c src/ext_lib_export.c)
|
||||
target_link_libraries (simple vmlib -lm -ldl -lpthread)
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
Introduction
|
||||
==============
|
||||
This project builds out both host tools running on the host side, and an application running on the device side. The device application consists of iwasm, application library, application manager, timers and sensors support. The device runs on Linux OS and interacts with host tools.
|
||||
|
||||
It demonstrates an end to end scenario, the wasm applications life cycle management and communication programming models.
|
||||
|
||||
"simple" sample introduction
|
||||
==============
|
||||
|
||||
This sample demonstrates following scenarios:
|
||||
|
||||
- Use tool "host_tool" to remotely install/uninstall wasm applications from the WAMR runtime over either TCP socket or UART cable
|
||||
- Inter-app communication programming models
|
||||
- Communication between WASM applications and the remote app host_tool
|
||||
- A number of WASM applications built on top of WAMR application framework API sets
|
||||
|
||||
|
||||
|
||||
Directory structure
|
||||
------------------------------
|
||||
@ -19,25 +27,20 @@ simple/
|
||||
├── connection.c
|
||||
├── event_publisher.c
|
||||
├── event_subscriber.c
|
||||
├── gui.c
|
||||
├── request_handler.c
|
||||
├── request_sender.c
|
||||
├── sensor.c
|
||||
└── timer.c
|
||||
```
|
||||
|
||||
- build.sh<br/>
|
||||
The script to build all binaries.
|
||||
- build_no_gui.sh<br/>
|
||||
The script to build all binaries without gui library support.
|
||||
- CMakeLists.txt<br/>
|
||||
CMake file used to build the simple application.
|
||||
- README.md<br/>
|
||||
The file you are reading currently.
|
||||
- src/ext_lib_export.c<br/>
|
||||
This file is used to export native APIs. See the `The mechanism of exporting Native API to WASM application` section in WAMR README.md for detail.
|
||||
- src/iwam_main.c<br/>
|
||||
This file is the implementation by platform integrator. It implements the interfaces that enable the application manager communicating with the host side. See `{WAMR_ROOT}/core/app-mgr/app-mgr-shared/app_manager_export.h` for the definition of the host interface.
|
||||
## Set physical communication between device and remote
|
||||
|
||||
|
||||
|
||||
```
|
||||
/* Interfaces of host communication */
|
||||
typedef struct host_interface {
|
||||
@ -45,69 +48,45 @@ typedef struct host_interface {
|
||||
host_send_fun send;
|
||||
host_destroy_fun destroy;
|
||||
} host_interface;
|
||||
|
||||
```
|
||||
The `host_init_func` is called when the application manager starts up. And `host_send_fun` is called by the application manager to send data to the host.
|
||||
|
||||
Define a global variable "interface" of the data structure:
|
||||
|
||||
```
|
||||
|
||||
host_interface interface = {
|
||||
.init = host_init,
|
||||
.send = host_send,
|
||||
.destroy = host_destroy
|
||||
};
|
||||
```
|
||||
This interface is passed to application manager by calling
|
||||
This interface is passed to application manager during the runtime startup:
|
||||
```
|
||||
app_manager_startup(&interface);
|
||||
```
|
||||
|
||||
The `host_init_func` is called when the application manager starts up. And `host_send_fun` is called by the application manager to send data to the host.
|
||||
>**Note:** Currently application manager keeps running and never exit, `host_destroy_fun` has no chance to get executed. So you can leave this API implementation empty.
|
||||
>
|
||||
|
||||
- src/main.c<br/>
|
||||
The main file.
|
||||
- wasm-apps<br/>
|
||||
Source files of sample wasm applications.
|
||||
**Note:** The connection between simple and host_tool is TCP by default. The simple application works as a server and the host_tool works as a client. You can also use UART connection. To achieve this you have to uncomment the below line in CMakeLists.txt and rebuild.
|
||||
|
||||
Configure 32 bit or 64 bit build
|
||||
==============
|
||||
On 64 bit operating system, there is an option to build 32 bit or 64 bit binaries. In file `CMakeLists.txt`, modify the line:
|
||||
`set (BUILD_AS_64BIT_SUPPORT "YES")`
|
||||
where `YES` means 64 bit build while `NO` means 32 bit build.
|
||||
|
||||
Install required SDK and libraries
|
||||
==============
|
||||
- 32 bit SDL(simple directmedia layer) (Note: only necessary when `BUILD_AS_64BIT_SUPPORT` is set to `NO`)
|
||||
Use apt-get:
|
||||
`sudo apt-get install libsdl2-dev:i386`
|
||||
Or download source from www.libsdl.org:
|
||||
```
|
||||
./configure C_FLAGS=-m32 CXX_FLAGS=-m32 LD_FLAGS=-m32
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
- 64 bit SDL(simple directmedia layer) (Note: only necessary when `BUILD_AS_64BIT_SUPPORT` is set to `YES`)
|
||||
Use apt-get:
|
||||
`sudo apt-get install libsdl2-dev`
|
||||
Or download source from www.libsdl.org:
|
||||
```
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
#add_definitions (-DCONNECTION_UART)`
|
||||
```
|
||||
|
||||
- Install EMSDK
|
||||
```
|
||||
https://emscripten.org/docs/tools_reference/emsdk.html
|
||||
```
|
||||
To run the UART based test, you have to set up a UART hardware connection between host_tool and the simple application. See the help of host_tool for how to specify UART device parameters.
|
||||
|
||||
Build all binaries
|
||||
|
||||
Build the sample
|
||||
==============
|
||||
Execute the build.sh script then all binaries including wasm application files would be generated in 'out' directory.
|
||||
`./build.sh`
|
||||
|
||||
Or execute the build_no_gui.sh script to build all binaries without gui library support.
|
||||
`./build_no_gui.sh`
|
||||
|
||||
Out directory structure
|
||||
------------------------------
|
||||
|
||||
**Out directory structure**
|
||||
|
||||
```
|
||||
out/
|
||||
├── host_tool
|
||||
@ -116,7 +95,6 @@ out/
|
||||
├── connection.wasm
|
||||
├── event_publisher.wasm
|
||||
├── event_subscriber.wasm
|
||||
├── gui.wasm
|
||||
├── request_handler.wasm
|
||||
├── request_sender.wasm
|
||||
├── sensor.wasm
|
||||
@ -130,42 +108,22 @@ out/
|
||||
- simple:
|
||||
A simple testing tool running on the host side that interact with WAMR. It is used to install, uninstall and query WASM applications in WAMR, and send request or subscribe event, etc. See the usage of this application by executing "./simple -h".
|
||||
`./simple -h`
|
||||
>****Note:**** The connection between simple and host_tool is TCP by default and is what this guide uses. The simple application works as a server and the host_tool works as a client. You can also use UART connection. To achieve this you have to uncomment the below line in CMakeLists.txt and rebuild. You have to set up a UART hardware connection between 2 machines one of which runs the host_tool and the other runs the simple application. See the help of host_tool and the simple application to know how to specify UART device parameters.<br/>
|
||||
`#add_definitions (-DCONNECTION_UART)`
|
||||
>
|
||||
|
||||
- wasm-apps:
|
||||
Sample wasm applications that demonstrate all APIs of the WAMR programming model. The source codes are in the wasm-apps directory under the root of this project.
|
||||
+ connection.wasm<br/>
|
||||
This application shows the connection programming model. It connects to a TCP server on 127.0.0.1:7777 and periodically sends message to it.
|
||||
+ event_publisher.wasm<br/>
|
||||
This application shows the sub/pub programming model. The pub application publishes the event "alert/overheat" by calling api_publish_event() API. The subscriber could be host_tool or other wasm application.
|
||||
+ event_subscriber.wasm<br/>
|
||||
This application shows the sub/pub programming model. The sub application subscribes the "alert/overheat" event by calling api_subscribe_event() API so that it is able to receive the event once generated and published by the pub application. To make the process clear to interpret, the sub application dumps the event when receiving it.
|
||||
+ gui.wasm<br/>
|
||||
This application shows the built-in 2D graphical user interface API with which various widgets could be created.
|
||||
+ request_handler.wasm<br/>
|
||||
This application shows the request/response programming model. The request handler application registers 2 resources(/url1 and /url2) by calling api_register_resource_handler() API. The request sender could be host_tool or other wasm application.
|
||||
+ request_sender.wasm<br/>
|
||||
This application shows the request/response programming model. The sender application sends 2 requests, one is "/app/request_handler/url1" and the other is "url1". The former is an accurate request which explicitly specifies the name of request handler application in the middle of the URL and the later is a general request.
|
||||
+ sensor.wasm<br/>
|
||||
This application shows the sensor programming model. It opens a test sensor and configures the sensor event generating interval to 1 second. To make the process clear to interpret, the application dumps the sensor event when receiving it.
|
||||
+ timer.wasm<br/>
|
||||
This application shows the timer programming model. It creates a periodic timer that prints the current expiry number in every second.
|
||||
|
||||
Run the scenario
|
||||
Run the sample
|
||||
==========================
|
||||
- Enter the out directory<br/>
|
||||
- Enter the out directory
|
||||
```
|
||||
$ cd ./out/
|
||||
```
|
||||
|
||||
- Startup the 'simple' process works in TCP server mode and you would see "App Manager started." is printed.<br/>
|
||||
- Startup the 'simple' process works in TCP server mode and you would see "App Manager started." is printed.
|
||||
```
|
||||
$ ./simple -s
|
||||
App Manager started.
|
||||
```
|
||||
|
||||
- Query all installed applications<br/>
|
||||
- Query all installed applications
|
||||
```
|
||||
$ ./host_tool -q
|
||||
|
||||
@ -175,7 +133,7 @@ response status 69
|
||||
}
|
||||
```
|
||||
|
||||
The `69` stands for response status to this query request which means query success and a payload is attached with the response. See `{WAMR_ROOT}/core/iwasm/lib/app-libs/base/wasm_app.h` for the definitions of response codes. The payload is printed with JSON format where the `num` stands for application installations number and value `0` means currently no application is installed yet.
|
||||
The `69` stands for response code SUCCESS. The payload is printed with JSON format where the `num` stands for application installations number and value `0` means currently no application is installed yet.
|
||||
|
||||
- Install the request handler wasm application<br/>
|
||||
```
|
||||
@ -183,20 +141,11 @@ $ ./host_tool -i request_handler -f ./wasm-apps/request_handler.wasm
|
||||
|
||||
response status 65
|
||||
```
|
||||
The `65` stands for response status to this installation request which means success.
|
||||
|
||||
Output of simple
|
||||
```
|
||||
Install WASM app success!
|
||||
sent 16 bytes to host
|
||||
WASM app 'request_handler' started
|
||||
```
|
||||
|
||||
Now the request handler application is running and waiting for host or other wasm application to send a request.
|
||||
|
||||
- Query again<br/>
|
||||
- Query again
|
||||
```
|
||||
$ ./host_tool -q
|
||||
$ ./host_tool -q
|
||||
|
||||
response status 69
|
||||
{
|
||||
@ -207,7 +156,7 @@ response status 69
|
||||
```
|
||||
In the payload, we can see `num` is 1 which means 1 application is installed. `applet1`stands for the name of the 1st application. `heap1` stands for the heap size of the 1st application.
|
||||
|
||||
- Send request from host to specific wasm application<br/>
|
||||
- Send request from host to specific wasm application
|
||||
```
|
||||
$ ./host_tool -r /app/request_handler/url1 -A GET
|
||||
|
||||
@ -220,7 +169,7 @@ response status 69
|
||||
|
||||
We can see a response with status `69` and a payload is received.
|
||||
|
||||
Output of simple
|
||||
Output of simple application:
|
||||
```
|
||||
connection established!
|
||||
Send request to applet: request_handler
|
||||
@ -242,7 +191,7 @@ response status 69
|
||||
}
|
||||
```
|
||||
|
||||
Output of simple
|
||||
Output of simple application:
|
||||
```
|
||||
connection established!
|
||||
Send request to app request_handler success.
|
||||
@ -252,7 +201,7 @@ sent 150 bytes to host
|
||||
Wasm app process request success.
|
||||
```
|
||||
|
||||
- Install the event publisher wasm application<br/>
|
||||
- Install the event publisher wasm application
|
||||
```
|
||||
$ ./host_tool -i pub -f ./wasm-apps/event_publisher.wasm
|
||||
|
||||
|
||||
@ -6,44 +6,67 @@ OUT_DIR=${PWD}/out
|
||||
BUILD_DIR=${PWD}/build
|
||||
|
||||
IWASM_ROOT=${PWD}/../../core/iwasm
|
||||
APP_LIBS=${IWASM_ROOT}/lib/app-libs
|
||||
NATIVE_LIBS=${IWASM_ROOT}/lib/native-interface
|
||||
APP_LIB_SRC="${APP_LIBS}/base/*.c ${APP_LIBS}/extension/sensor/*.c ${APP_LIBS}/extension/connection/*.c ${APP_LIBS}/extension/gui/src/*.c ${NATIVE_LIBS}/*.c"
|
||||
APP_FRAMEWORK_DIR=${PWD}/../../core/app-framework
|
||||
NATIVE_LIBS=${APP_FRAMEWORK_DIR}/app-native-shared
|
||||
APP_LIB_SRC="${APP_FRAMEWORK_DIR}/base/app/*.c ${APP_FRAMEWORK_DIR}/sensor/app/*.c \
|
||||
${APP_FRAMEWORK_DIR}/connection/app/*.c ${NATIVE_LIBS}/*.c"
|
||||
WASM_APPS=${PWD}/wasm-apps
|
||||
CLEAN=
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "build.sh [options]"
|
||||
echo " -p [platform]"
|
||||
echo " -t [target]"
|
||||
echo " -c, rebuild SDK"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
while getopts "p:t:ch" opt
|
||||
do
|
||||
case $opt in
|
||||
p)
|
||||
PLATFORM=$OPTARG
|
||||
;;
|
||||
t)
|
||||
TARGET=$OPTARG
|
||||
;;
|
||||
c)
|
||||
CLEAN="TRUE"
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 1;
|
||||
;;
|
||||
?)
|
||||
echo "Unknown arg: $arg"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z $KW_BUILD ] || [ -z $KW_OUT_FILE ];then
|
||||
echo "Local Build Env"
|
||||
cmakewrap="cmake"
|
||||
makewrap="make"
|
||||
else
|
||||
echo "Klocwork Build Env"
|
||||
cmakewrap="cmake -DCMAKE_BUILD_TYPE=Debug"
|
||||
makewrap="kwinject -o $KW_OUT_FILE make"
|
||||
fi
|
||||
|
||||
rm -rf ${OUT_DIR}
|
||||
mkdir ${OUT_DIR}
|
||||
mkdir ${OUT_DIR}/wasm-apps
|
||||
|
||||
cd ${WAMR_DIR}/core/shared-lib/mem-alloc
|
||||
cd ${WAMR_DIR}/core/shared/mem-alloc
|
||||
if [ ! -d "tlsf" ]; then
|
||||
git clone https://github.com/mattconte/tlsf
|
||||
fi
|
||||
|
||||
cd ${WAMR_DIR}/core/iwasm/lib/3rdparty
|
||||
if [ ! -d "lvgl" ]; then
|
||||
git clone https://github.com/littlevgl/lvgl.git --branch v6.0.1
|
||||
fi
|
||||
if [ ! -d "lv_drivers" ]; then
|
||||
git clone https://github.com/littlevgl/lv_drivers.git
|
||||
fi
|
||||
echo "#####################build wamr sdk"
|
||||
cd ${WAMR_DIR}/wamr-sdk
|
||||
./build_sdk.sh -n simple -x ${CURR_DIR}/wamr_config_simple.cmake $*
|
||||
|
||||
echo "#####################build simple project"
|
||||
cd ${CURR_DIR}
|
||||
mkdir -p cmake_build
|
||||
cd cmake_build
|
||||
$cmakewrap -DENABLE_GUI=YES ..
|
||||
$makewrap
|
||||
cmake .. -DWAMR_BUILD_SDK_PROFILE=simple
|
||||
make
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL simple exit as $?\n"
|
||||
exit 2
|
||||
@ -51,12 +74,13 @@ fi
|
||||
cp -a simple ${OUT_DIR}
|
||||
echo "#####################build simple project success"
|
||||
|
||||
echo -e "\n\n"
|
||||
echo "#####################build host-tool"
|
||||
cd ${WAMR_DIR}/test-tools/host-tool
|
||||
mkdir -p bin
|
||||
cd bin
|
||||
$cmakewrap ..
|
||||
$makewrap
|
||||
cmake ..
|
||||
make
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL host tool exit as $?\n"
|
||||
exit 2
|
||||
@ -64,26 +88,28 @@ fi
|
||||
cp host_tool ${OUT_DIR}
|
||||
echo "#####################build host-tool success"
|
||||
|
||||
|
||||
echo -e "\n\n"
|
||||
echo "#####################build wasm apps"
|
||||
|
||||
cd ${WASM_APPS}
|
||||
|
||||
for i in `ls *.c`
|
||||
do
|
||||
APP_SRC="$i ${APP_LIB_SRC}"
|
||||
APP_SRC="$i"
|
||||
OUT_FILE=${i%.*}.wasm
|
||||
clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
|
||||
-I${APP_LIBS}/extension/connection \
|
||||
-I${APP_LIBS}/extension/gui \
|
||||
-DENABLE_WGL=1 \
|
||||
|
||||
/opt/wasi-sdk/bin/clang \
|
||||
-I${WAMR_DIR}/wamr-sdk/out/simple/app-sdk/wamr-app-framework/include \
|
||||
-L${WAMR_DIR}/wamr-sdk/out/simple/app-sdk/wamr-app-framework/lib \
|
||||
-lapp_framework \
|
||||
--target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
--sysroot=${WAMR_DIR}/wamr-sdk/out/simple/app-sdk/libc-builtin-sysroot \
|
||||
-Wl,--allow-undefined-file=${WAMR_DIR}/wamr-sdk/out/simple/app-sdk/libc-builtin-sysroot/share/defined-symbols.txt \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_destroy \
|
||||
-Wl,--export=on_request -Wl,--export=on_response \
|
||||
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_connection_data -Wl,--export=on_widget_event \
|
||||
-Wl,--export=on_connection_data \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
||||
echo "build ${OUT_FILE} success"
|
||||
@ -91,4 +117,5 @@ else
|
||||
echo "build ${OUT_FILE} fail"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "#####################build wasm apps done"
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
CURR_DIR=$PWD
|
||||
WAMR_DIR=${PWD}/../..
|
||||
OUT_DIR=${PWD}/out
|
||||
BUILD_DIR=${PWD}/build
|
||||
|
||||
IWASM_ROOT=${PWD}/../../core/iwasm
|
||||
APP_LIBS=${IWASM_ROOT}/lib/app-libs
|
||||
NATIVE_LIBS=${IWASM_ROOT}/lib/native-interface
|
||||
APP_LIB_SRC="${APP_LIBS}/base/*.c ${APP_LIBS}/extension/sensor/*.c ${APP_LIBS}/extension/connection/*.c ${NATIVE_LIBS}/*.c"
|
||||
WASM_APPS=${PWD}/wasm-apps
|
||||
|
||||
rm -rf ${OUT_DIR}
|
||||
mkdir ${OUT_DIR}
|
||||
mkdir ${OUT_DIR}/wasm-apps
|
||||
|
||||
cd ${WAMR_DIR}/core/shared-lib/mem-alloc
|
||||
if [ ! -d "tlsf" ]; then
|
||||
git clone https://github.com/mattconte/tlsf
|
||||
fi
|
||||
|
||||
echo "#####################build simple project"
|
||||
cd ${CURR_DIR}
|
||||
mkdir -p cmake_build
|
||||
cd cmake_build
|
||||
cmake -DENABLE_GUI=NO ..
|
||||
make
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL simple exit as $?\n"
|
||||
exit 2
|
||||
fi
|
||||
cp -a simple ${OUT_DIR}
|
||||
echo "#####################build simple project success"
|
||||
|
||||
echo "#####################build host-tool"
|
||||
cd ${WAMR_DIR}/test-tools/host-tool
|
||||
mkdir -p bin
|
||||
cd bin
|
||||
cmake ..
|
||||
make
|
||||
if [ $? != 0 ];then
|
||||
echo "BUILD_FAIL host tool exit as $?\n"
|
||||
exit 2
|
||||
fi
|
||||
cp host_tool ${OUT_DIR}
|
||||
echo "#####################build host-tool success"
|
||||
|
||||
|
||||
echo "#####################build wasm apps"
|
||||
|
||||
cd ${WASM_APPS}
|
||||
|
||||
for i in `ls *.c | grep -v gui`
|
||||
do
|
||||
APP_SRC="$i ${APP_LIB_SRC}"
|
||||
OUT_FILE=${i%.*}.wasm
|
||||
clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
|
||||
-I${APP_LIBS}/extension/connection \
|
||||
--target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
|
||||
-Wl,--export=on_init -Wl,--export=on_destroy \
|
||||
-Wl,--export=on_request -Wl,--export=on_response \
|
||||
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
|
||||
-Wl,--export=on_connection_data \
|
||||
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
||||
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
||||
echo "build ${OUT_FILE} success"
|
||||
else
|
||||
echo "build ${OUT_FILE} fail"
|
||||
fi
|
||||
done
|
||||
echo "#####################build wasm apps done"
|
||||
@ -2,16 +2,9 @@
|
||||
#include "sensor_api.h"
|
||||
#include "connection_api.h"
|
||||
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
#include "gui_api.h"
|
||||
#endif
|
||||
|
||||
static NativeSymbol extended_native_symbol_defs[] = {
|
||||
#include "runtime_sensor.inl"
|
||||
#include "connection.inl"
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
#include "wamr_gui.inl"
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
#include "ext_lib_export.h"
|
||||
|
||||
@ -29,17 +29,9 @@
|
||||
#include "bh_thread.h"
|
||||
#include "bh_memory.h"
|
||||
#include "runtime_sensor.h"
|
||||
#include "attr_container.h"
|
||||
#include "bi-inc/attr_container.h"
|
||||
#include "module_wasm_app.h"
|
||||
#include "wasm_export.h"
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
#include "wgl.h"
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
#include "lv_drivers/display/monitor.h"
|
||||
#include "lv_drivers/indev/mouse.h"
|
||||
#endif
|
||||
|
||||
#define MAX 2048
|
||||
|
||||
@ -362,7 +354,7 @@ static host_interface interface = { .send = uart_send, .destroy = uart_destroy }
|
||||
|
||||
#endif
|
||||
|
||||
static char global_heap_buf[512 * 1024] = { 0 };
|
||||
static char global_heap_buf[1024 * 1024] = { 0 };
|
||||
|
||||
static void showUsage()
|
||||
{
|
||||
@ -392,7 +384,7 @@ static bool parse_args(int argc, char *argv[])
|
||||
|
||||
while (1) {
|
||||
int optIndex = 0;
|
||||
static struct option longOpts[] = {
|
||||
static struct option longOpts[] = {
|
||||
#ifndef CONNECTION_UART
|
||||
{ "server_mode", no_argument, NULL, 's' },
|
||||
{ "host_address", required_argument, NULL, 'a' },
|
||||
@ -402,10 +394,10 @@ static bool parse_args(int argc, char *argv[])
|
||||
{ "baudrate", required_argument, NULL, 'b' },
|
||||
#endif
|
||||
{ "help", required_argument, NULL, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "sa:p:u:b:h", longOpts, &optIndex);
|
||||
c = getopt_long(argc, argv, "sa:p:u:b:w:h", longOpts, &optIndex);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
@ -444,40 +436,6 @@ static bool parse_args(int argc, char *argv[])
|
||||
return true;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
/**
|
||||
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
|
||||
*/
|
||||
static void hal_init(void)
|
||||
{
|
||||
/* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
|
||||
monitor_init();
|
||||
|
||||
/*Create a display buffer*/
|
||||
static lv_disp_buf_t disp_buf1;
|
||||
static lv_color_t buf1_1[480*10];
|
||||
lv_disp_buf_init(&disp_buf1, buf1_1, NULL, 480*10);
|
||||
|
||||
/*Create a display*/
|
||||
lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
disp_drv.buffer = &disp_buf1;
|
||||
disp_drv.flush_cb = monitor_flush;
|
||||
// disp_drv.hor_res = 200;
|
||||
// disp_drv.ver_res = 100;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
/* Add the mouse as input device
|
||||
* Use the 'mouse' driver which reads the PC's mouse*/
|
||||
mouse_init();
|
||||
lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Driver function
|
||||
int iwasm_main(int argc, char *argv[])
|
||||
{
|
||||
@ -486,7 +444,11 @@ int iwasm_main(int argc, char *argv[])
|
||||
if (!parse_args(argc, argv))
|
||||
return -1;
|
||||
|
||||
#if 1
|
||||
if (bh_memory_init_with_pool(global_heap_buf, sizeof(global_heap_buf))
|
||||
#else
|
||||
if (bh_memory_init_with_allocator(malloc, free)
|
||||
#endif
|
||||
!= 0) {
|
||||
printf("Init global heap failed.\n");
|
||||
return -1;
|
||||
@ -501,11 +463,6 @@ int iwasm_main(int argc, char *argv[])
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
wgl_init();
|
||||
hal_init();
|
||||
#endif
|
||||
|
||||
init_sensor_framework();
|
||||
|
||||
// timer manager
|
||||
@ -525,9 +482,6 @@ int iwasm_main(int argc, char *argv[])
|
||||
|
||||
exit_wasm_timer();
|
||||
exit_sensor_framework();
|
||||
#if WASM_ENABLE_GUI != 0
|
||||
wgl_exit();
|
||||
#endif
|
||||
exit_connection_framework();
|
||||
|
||||
fail1:
|
||||
|
||||
@ -1,310 +0,0 @@
|
||||
/**
|
||||
* @file lv_drv_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPY THIS FILE AS lv_drv_conf.h
|
||||
*/
|
||||
|
||||
#if 1 /*Set it to "1" to enable the content*/
|
||||
|
||||
#ifndef LV_DRV_CONF_H
|
||||
#define LV_DRV_CONF_H
|
||||
|
||||
#include "lv_conf.h"
|
||||
|
||||
/*********************
|
||||
* DELAY INTERFACE
|
||||
*********************/
|
||||
#define LV_DRV_DELAY_INCLUDE <stdint.h> /*Dummy include by default*/
|
||||
#define LV_DRV_DELAY_US(us) /*delay_us(us)*/ /*Delay the given number of microseconds*/
|
||||
#define LV_DRV_DELAY_MS(ms) /*delay_ms(ms)*/ /*Delay the given number of milliseconds*/
|
||||
|
||||
/*********************
|
||||
* DISPLAY INTERFACE
|
||||
*********************/
|
||||
|
||||
/*------------
|
||||
* Common
|
||||
*------------*/
|
||||
#define LV_DRV_DISP_INCLUDE <stdint.h> /*Dummy include by default*/
|
||||
#define LV_DRV_DISP_CMD_DATA(val) /*pin_x_set(val)*/ /*Set the command/data pin to 'val'*/
|
||||
#define LV_DRV_DISP_RST(val) /*pin_x_set(val)*/ /*Set the reset pin to 'val'*/
|
||||
|
||||
/*---------
|
||||
* SPI
|
||||
*---------*/
|
||||
#define LV_DRV_DISP_SPI_CS(val) /*spi_cs_set(val)*/ /*Set the SPI's Chip select to 'val'*/
|
||||
#define LV_DRV_DISP_SPI_WR_BYTE(data) /*spi_wr(data)*/ /*Write a byte the SPI bus*/
|
||||
#define LV_DRV_DISP_SPI_WR_ARRAY(adr, n) /*spi_wr_mem(adr, n)*/ /*Write 'n' bytes to SPI bus from 'adr'*/
|
||||
|
||||
/*------------------
|
||||
* Parallel port
|
||||
*-----------------*/
|
||||
#define LV_DRV_DISP_PAR_CS(val) /*par_cs_set(val)*/ /*Set the Parallel port's Chip select to 'val'*/
|
||||
#define LV_DRV_DISP_PAR_SLOW /*par_slow()*/ /*Set low speed on the parallel port*/
|
||||
#define LV_DRV_DISP_PAR_FAST /*par_fast()*/ /*Set high speed on the parallel port*/
|
||||
#define LV_DRV_DISP_PAR_WR_WORD(data) /*par_wr(data)*/ /*Write a word to the parallel port*/
|
||||
#define LV_DRV_DISP_PAR_WR_ARRAY(adr, n) /*par_wr_mem(adr,n)*/ /*Write 'n' bytes to Parallel ports from 'adr'*/
|
||||
|
||||
/***************************
|
||||
* INPUT DEVICE INTERFACE
|
||||
***************************/
|
||||
|
||||
/*----------
|
||||
* Common
|
||||
*----------*/
|
||||
#define LV_DRV_INDEV_INCLUDE <stdint.h> /*Dummy include by default*/
|
||||
#define LV_DRV_INDEV_RST(val) /*pin_x_set(val)*/ /*Set the reset pin to 'val'*/
|
||||
#define LV_DRV_INDEV_IRQ_READ 0 /*pn_x_read()*/ /*Read the IRQ pin*/
|
||||
|
||||
/*---------
|
||||
* SPI
|
||||
*---------*/
|
||||
#define LV_DRV_INDEV_SPI_CS(val) /*spi_cs_set(val)*/ /*Set the SPI's Chip select to 'val'*/
|
||||
#define LV_DRV_INDEV_SPI_XCHG_BYTE(data) 0 /*spi_xchg(val)*/ /*Write 'val' to SPI and give the read value*/
|
||||
|
||||
/*---------
|
||||
* I2C
|
||||
*---------*/
|
||||
#define LV_DRV_INDEV_I2C_START /*i2c_start()*/ /*Make an I2C start*/
|
||||
#define LV_DRV_INDEV_I2C_STOP /*i2c_stop()*/ /*Make an I2C stop*/
|
||||
#define LV_DRV_INDEV_I2C_RESTART /*i2c_restart()*/ /*Make an I2C restart*/
|
||||
#define LV_DRV_INDEV_I2C_WR(data) /*i2c_wr(data)*/ /*Write a byte to the I1C bus*/
|
||||
#define LV_DRV_INDEV_I2C_READ(last_read) 0 /*i2c_rd()*/ /*Read a byte from the I2C bud*/
|
||||
|
||||
|
||||
/*********************
|
||||
* DISPLAY DRIVERS
|
||||
*********************/
|
||||
|
||||
/*-------------------
|
||||
* Monitor of PC
|
||||
*-------------------*/
|
||||
#ifndef USE_MONITOR
|
||||
# define USE_MONITOR 1
|
||||
#endif
|
||||
|
||||
#if USE_MONITOR
|
||||
# define MONITOR_HOR_RES LV_HOR_RES_MAX
|
||||
# define MONITOR_VER_RES LV_VER_RES_MAX
|
||||
|
||||
/* Scale window by this factor (useful when simulating small screens) */
|
||||
# define MONITOR_ZOOM 1
|
||||
|
||||
/* Used to test true double buffering with only address changing.
|
||||
* Set LV_VDB_SIZE = (LV_HOR_RES * LV_VER_RES) and LV_VDB_DOUBLE = 1 and LV_COLOR_DEPTH = 32" */
|
||||
# define MONITOR_DOUBLE_BUFFERED 0
|
||||
|
||||
/*Eclipse: <SDL2/SDL.h> Visual Studio: <SDL.h>*/
|
||||
# define MONITOR_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||
|
||||
/*Different rendering might be used if running in a Virtual machine*/
|
||||
# define MONITOR_VIRTUAL_MACHINE 0
|
||||
|
||||
/*Open two windows to test multi display support*/
|
||||
# define MONITOR_DUAL 0
|
||||
#endif
|
||||
|
||||
/*-----------------------------------
|
||||
* Native Windows (including mouse)
|
||||
*----------------------------------*/
|
||||
#ifndef USE_WINDOWS
|
||||
# define USE_WINDOWS 0
|
||||
#endif
|
||||
|
||||
#define USE_WINDOWS 0
|
||||
#if USE_WINDOWS
|
||||
# define WINDOW_HOR_RES 480
|
||||
# define WINDOW_VER_RES 320
|
||||
#endif
|
||||
|
||||
/*----------------
|
||||
* SSD1963
|
||||
*--------------*/
|
||||
#ifndef USE_SSD1963
|
||||
# define USE_SSD1963 0
|
||||
#endif
|
||||
|
||||
#if USE_SSD1963
|
||||
# define SSD1963_HOR_RES LV_HOR_RES
|
||||
# define SSD1963_VER_RES LV_VER_RES
|
||||
# define SSD1963_HT 531
|
||||
# define SSD1963_HPS 43
|
||||
# define SSD1963_LPS 8
|
||||
# define SSD1963_HPW 10
|
||||
# define SSD1963_VT 288
|
||||
# define SSD1963_VPS 12
|
||||
# define SSD1963_FPS 4
|
||||
# define SSD1963_VPW 10
|
||||
# define SSD1963_HS_NEG 0 /*Negative hsync*/
|
||||
# define SSD1963_VS_NEG 0 /*Negative vsync*/
|
||||
# define SSD1963_ORI 0 /*0, 90, 180, 270*/
|
||||
# define SSD1963_COLOR_DEPTH 16
|
||||
#endif
|
||||
|
||||
/*----------------
|
||||
* R61581
|
||||
*--------------*/
|
||||
#ifndef USE_R61581
|
||||
# define USE_R61581 0
|
||||
#endif
|
||||
|
||||
#if USE_R61581
|
||||
# define R61581_HOR_RES LV_HOR_RES
|
||||
# define R61581_VER_RES LV_VER_RES
|
||||
# define R61581_HSPL 0 /*HSYNC signal polarity*/
|
||||
# define R61581_HSL 10 /*HSYNC length (Not Implemented)*/
|
||||
# define R61581_HFP 10 /*Horitontal Front poarch (Not Implemented)*/
|
||||
# define R61581_HBP 10 /*Horitontal Back poarch (Not Implemented */
|
||||
# define R61581_VSPL 0 /*VSYNC signal polarity*/
|
||||
# define R61581_VSL 10 /*VSYNC length (Not Implemented)*/
|
||||
# define R61581_VFP 8 /*Vertical Front poarch*/
|
||||
# define R61581_VBP 8 /*Vertical Back poarch */
|
||||
# define R61581_DPL 0 /*DCLK signal polarity*/
|
||||
# define R61581_EPL 1 /*ENABLE signal polarity*/
|
||||
# define R61581_ORI 0 /*0, 180*/
|
||||
# define R61581_LV_COLOR_DEPTH 16 /*Fix 16 bit*/
|
||||
#endif
|
||||
|
||||
/*------------------------------
|
||||
* ST7565 (Monochrome, low res.)
|
||||
*-----------------------------*/
|
||||
#ifndef USE_ST7565
|
||||
# define USE_ST7565 0
|
||||
#endif
|
||||
|
||||
#if USE_ST7565
|
||||
/*No settings*/
|
||||
#endif /*USE_ST7565*/
|
||||
|
||||
/*-----------------------------------------
|
||||
* Linux frame buffer device (/dev/fbx)
|
||||
*-----------------------------------------*/
|
||||
#ifndef USE_FBDEV
|
||||
# define USE_FBDEV 1
|
||||
#endif
|
||||
|
||||
#if USE_FBDEV
|
||||
# define FBDEV_PATH "/dev/fb0"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INPUT DEVICES
|
||||
*********************/
|
||||
|
||||
/*--------------
|
||||
* XPT2046
|
||||
*--------------*/
|
||||
#ifndef USE_XPT2046
|
||||
# define USE_XPT2046 0
|
||||
#endif
|
||||
|
||||
#if USE_XPT2046
|
||||
# define XPT2046_HOR_RES 480
|
||||
# define XPT2046_VER_RES 320
|
||||
# define XPT2046_X_MIN 200
|
||||
# define XPT2046_Y_MIN 200
|
||||
# define XPT2046_X_MAX 3800
|
||||
# define XPT2046_Y_MAX 3800
|
||||
# define XPT2046_AVG 4
|
||||
# define XPT2046_INV 0
|
||||
#endif
|
||||
|
||||
/*-----------------
|
||||
* FT5406EE8
|
||||
*-----------------*/
|
||||
#ifndef USE_FT5406EE8
|
||||
# define USE_FT5406EE8 0
|
||||
#endif
|
||||
|
||||
#if USE_FT5406EE8
|
||||
# define FT5406EE8_I2C_ADR 0x38 /*7 bit address*/
|
||||
#endif
|
||||
|
||||
/*---------------
|
||||
* AD TOUCH
|
||||
*--------------*/
|
||||
#ifndef USE_AD_TOUCH
|
||||
# define USE_AD_TOUCH 0
|
||||
#endif
|
||||
|
||||
#if USE_AD_TOUCH
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------
|
||||
* Mouse or touchpad on PC (using SDL)
|
||||
*-------------------------------------*/
|
||||
#ifndef USE_MOUSE
|
||||
# define USE_MOUSE 1
|
||||
#endif
|
||||
|
||||
#if USE_MOUSE
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------
|
||||
* Mousewheel as encoder on PC (using SDL)
|
||||
*------------------------------------------*/
|
||||
#ifndef USE_MOUSEWHEEL
|
||||
# define USE_MOUSEWHEEL 1
|
||||
#endif
|
||||
|
||||
#if USE_MOUSEWHEEL
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------
|
||||
* Touchscreen as libinput interface (for Linux based systems)
|
||||
*------------------------------------------------*/
|
||||
#ifndef USE_LIBINPUT
|
||||
# define USE_LIBINPUT 0
|
||||
#endif
|
||||
|
||||
#if USE_LIBINPUT
|
||||
# define LIBINPUT_NAME "/dev/input/event0" /*You can use the "evtest" Linux tool to get the list of devices and test them*/
|
||||
#endif /*USE_LIBINPUT*/
|
||||
|
||||
/*-------------------------------------------------
|
||||
* Mouse or touchpad as evdev interface (for Linux based systems)
|
||||
*------------------------------------------------*/
|
||||
#ifndef USE_EVDEV
|
||||
# define USE_EVDEV 0
|
||||
#endif
|
||||
|
||||
#if USE_EVDEV
|
||||
# define EVDEV_NAME "/dev/input/event0" /*You can use the "evtest" Linux tool to get the list of devices and test them*/
|
||||
# define EVDEV_SWAP_AXES 0 /*Swap the x and y axes of the touchscreen*/
|
||||
|
||||
# define EVDEV_SCALE 0 /* Scale input, e.g. if touchscreen resolution does not match display resolution */
|
||||
# if EVDEV_SCALE
|
||||
# define EVDEV_SCALE_HOR_RES (4096) /* Horizontal resolution of touchscreen */
|
||||
# define EVDEV_SCALE_VER_RES (4096) /* Vertical resolution of touchscreen */
|
||||
# endif /*EVDEV_SCALE*/
|
||||
|
||||
# define EVDEV_CALIBRATE 0 /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
|
||||
# if EVDEV_CALIBRATE
|
||||
# define EVDEV_HOR_MIN 3800 /*If EVDEV_XXX_MIN > EVDEV_XXX_MAX the XXX axis is automatically inverted*/
|
||||
# define EVDEV_HOR_MAX 200
|
||||
# define EVDEV_VER_MIN 200
|
||||
# define EVDEV_VER_MAX 3800
|
||||
# endif /*EVDEV_SCALE*/
|
||||
#endif /*USE_EVDEV*/
|
||||
|
||||
/*-------------------------------
|
||||
* Keyboard of a PC (using SDL)
|
||||
*------------------------------*/
|
||||
#ifndef USE_KEYBOARD
|
||||
# define USE_KEYBOARD 1
|
||||
#endif
|
||||
|
||||
#if USE_KEYBOARD
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRV_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
9
samples/simple/wamr_config_simple.cmake
Normal file
9
samples/simple/wamr_config_simple.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
set (WAMR_BUILD_PLATFORM "linux")
|
||||
set (WAMR_BUILD_TARGET X86_64)
|
||||
set (WAMR_BUILD_INTERP 1)
|
||||
set (WAMR_BUILD_AOT 1)
|
||||
set (WAMR_BUILD_JIT 0)
|
||||
set (WAMR_BUILD_LIBC_BUILTIN 1)
|
||||
set (WAMR_BUILD_LIBC_WASI 0)
|
||||
set (WAMR_BUILD_APP_FRAMEWORK 1)
|
||||
set (WAMR_BUILD_APP_LIST WAMR_APP_BUILD_BASE WAMR_APP_BUILD_CONNECTION WAMR_APP_BUILD_SENSOR)
|
||||
@ -4,6 +4,9 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/connection.h"
|
||||
#include "wa-inc/timer_wasm_app.h"
|
||||
#include "wa-inc/request.h"
|
||||
|
||||
/* User global variable */
|
||||
static int num = 0;
|
||||
@ -44,7 +47,7 @@ void my_close_handler(request_t * request)
|
||||
api_timer_cancel(g_timer);
|
||||
api_close_connection(g_conn);
|
||||
}
|
||||
|
||||
|
||||
make_response_for_request(request, response);
|
||||
set_response(response, DELETED_2_02, 0, NULL, 0);
|
||||
api_response_send(response);
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/request.h"
|
||||
#include "wa-inc/timer_wasm_app.h"
|
||||
|
||||
int num = 0;
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/request.h"
|
||||
|
||||
void over_heat_event_handler(request_t *request)
|
||||
{
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "wasm_app.h"
|
||||
|
||||
static void btn_event_cb(wgl_obj_t btn, wgl_event_t event);
|
||||
|
||||
uint32_t count = 0;
|
||||
char count_str[11] = { 0 };
|
||||
wgl_obj_t hello_world_label;
|
||||
wgl_obj_t count_label;
|
||||
wgl_obj_t btn1;
|
||||
wgl_obj_t label_count1;
|
||||
int label_count1_value = 0;
|
||||
char label_count1_str[11] = { 0 };
|
||||
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
wgl_label_set_text(count_label, count_str);
|
||||
}
|
||||
++count;
|
||||
}
|
||||
|
||||
void on_init()
|
||||
{
|
||||
char text[32] = {0};
|
||||
|
||||
hello_world_label = wgl_label_create((wgl_obj_t)NULL, (wgl_obj_t)NULL);
|
||||
wgl_label_set_text(hello_world_label, "Hello world!");
|
||||
wgl_label_get_text(hello_world_label, text, sizeof(text));
|
||||
printf("Label text %d %s \n", wgl_label_get_text_length(hello_world_label), text);
|
||||
wgl_obj_align(hello_world_label, (wgl_obj_t)NULL, WGL_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
|
||||
count_label = wgl_label_create((wgl_obj_t)NULL, (wgl_obj_t)NULL);
|
||||
wgl_obj_align(count_label, (wgl_obj_t)NULL, WGL_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
btn1 = wgl_btn_create((wgl_obj_t)NULL, (wgl_obj_t)NULL); /*Create a button on the currently loaded screen*/
|
||||
wgl_obj_set_event_cb(btn1, btn_event_cb); /*Set function to be called when the button is released*/
|
||||
wgl_obj_align(btn1, (wgl_obj_t)NULL, WGL_ALIGN_CENTER, 0, 0); /*Align below the label*/
|
||||
|
||||
/*Create a label on the button*/
|
||||
wgl_obj_t btn_label = wgl_label_create(btn1, (wgl_obj_t)NULL);
|
||||
wgl_label_set_text(btn_label, "Click ++");
|
||||
|
||||
label_count1 = wgl_label_create((wgl_obj_t)NULL, (wgl_obj_t)NULL);
|
||||
wgl_label_set_text(label_count1, "0");
|
||||
wgl_obj_align(label_count1, (wgl_obj_t)NULL, WGL_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
|
||||
/* set up a timer */
|
||||
user_timer_t timer;
|
||||
timer = api_timer_create(10, true, false, timer1_update);
|
||||
api_timer_restart(timer, 10);
|
||||
}
|
||||
|
||||
static void btn_event_cb(wgl_obj_t btn, wgl_event_t event)
|
||||
{
|
||||
if(event == WGL_EVENT_RELEASED) {
|
||||
label_count1_value++;
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
wgl_label_set_text(label_count1, label_count1_str);
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "wasm_app.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
extern char g_widget_text[];
|
||||
|
||||
static void btn_event_cb(lv_obj_t *btn, lv_event_t event);
|
||||
|
||||
uint32_t count = 0;
|
||||
char count_str[11] = { 0 };
|
||||
lv_obj_t *hello_world_label;
|
||||
lv_obj_t *count_label;
|
||||
lv_obj_t *btn1;
|
||||
lv_obj_t *label_count1;
|
||||
int label_count1_value = 100;
|
||||
char label_count1_str[11] = { 0 };
|
||||
|
||||
void timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
lv_label_set_text(count_label, count_str);
|
||||
}
|
||||
++count;
|
||||
}
|
||||
|
||||
void on_init()
|
||||
{
|
||||
char *text;
|
||||
|
||||
hello_world_label = lv_label_create(NULL, NULL);
|
||||
lv_label_set_text(hello_world_label, "Hello world!");
|
||||
text = lv_label_get_text(hello_world_label);
|
||||
printf("Label text %lu %s \n", strlen(text), text);
|
||||
lv_obj_align(hello_world_label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
|
||||
count_label = lv_label_create(NULL, NULL);
|
||||
lv_obj_align(count_label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
btn1 = lv_btn_create(NULL, NULL); /*Create a button on the currently loaded screen*/
|
||||
lv_obj_set_event_cb(btn1, btn_event_cb); /*Set function to be called when the button is released*/
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align below the label*/
|
||||
|
||||
/*Create a label on the button*/
|
||||
lv_obj_t *btn_label = lv_label_create(btn1, NULL);
|
||||
lv_label_set_text(btn_label, "Click --");
|
||||
|
||||
label_count1 = lv_label_create(NULL, NULL);
|
||||
lv_label_set_text(label_count1, "100");
|
||||
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
|
||||
/* set up a timer */
|
||||
user_timer_t timer;
|
||||
timer = api_timer_create(10, true, false, timer1_update);
|
||||
api_timer_restart(timer, 10);
|
||||
}
|
||||
|
||||
static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_RELEASED) {
|
||||
label_count1_value--;
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
if (label_count1_value == 0)
|
||||
label_count1_value = 100;
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/request.h"
|
||||
|
||||
static void url1_request_handler(request_t *request)
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/request.h"
|
||||
|
||||
static void my_response_handler(response_t *response, void *user_data)
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/sensor.h"
|
||||
|
||||
static sensor_t sensor = NULL;
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "wasm_app.h"
|
||||
#include "wa-inc/timer_wasm_app.h"
|
||||
|
||||
/* User global variable */
|
||||
static int num = 0;
|
||||
|
||||
Reference in New Issue
Block a user