Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,25 @@ set(lib_sources
)

# Compile in sensors framework if enabled.
if(DEFINED CONFIG_SENSOR)
if(CONFIG_OCRE_SENSORS)
set(ocre_sources ${ocre_sources} ${OCRE_ROOT_DIR}/src/ocre/ocre_sensors/ocre_sensors.c)
endif()

# Compile random sensor if enabled.
if(CONFIG_RNG_SENSOR)
set(ocre_sources ${ocre_sources} ${OCRE_ROOT_DIR}/src/ocre/ocre_sensors/rng_sensor.c)
endif()

if(DEFINED CONFIG_OCRE_GPIO)
set(lib_sources ${lib_sources}
src/ocre/ocre_sensors/ocre_sensors.c
src/ocre/ocre_sensors/rng_sensor.c
src/ocre/ocre_gpio/ocre_gpio.c
)
endif()

# Compile container messaging if enabled.
if(CONFIG_OCRE_CONTAINER_MESSAGING)
set(lib_sources ${lib_sources} src/ocre/container_messaging/messaging.c)
endif()

set(component_sources
# Component support
Expand Down
55 changes: 53 additions & 2 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ source "subsys/logging/Kconfig.template.log_config"

endif

config OCRE_SENSORS
bool "Enable OCRE Sensors support"
default n
depends on SENSOR
help
Enable support for OCRE sensors

config RNG_SENSOR
bool "RNG Sensor"
default n
depends on SENSOR
depends on OCRE_SENSORS
help
Enable support for the custom RNG sensor.

Expand Down Expand Up @@ -109,6 +116,50 @@ config MAX_CHANNELS_PER_SENSOR
help
Defines the maximum number of channels that each sensor can have.

config OCRE_MEMORY_CHECK_ENABLED
bool "Enable memory availability checking for containers"
default y
help
Enable runtime memory checks before creating containers


config OCRE_GPIO
bool "OCRE GPIO Driver"
default y
help
Enable the OCRE GPIO driver that provides a portable API layer
for GPIO operations across different hardware platforms.

config OCRE_GPIO_MAX_PINS
int "Maximum number of GPIO pins"
default 32
help
Maximum number of GPIO pins that can be managed by the OCRE GPIO driver.

config OCRE_GPIO_MAX_PORTS
int "Maximum number of GPIO ports"
default 4
help
Maximum number of GPIO port devices that can be used by the OCRE GPIO driver.

config OCRE_GPIO_PINS_PER_PORT
int "Number of pins per GPIO port"
default 32
help
Number of pins available on each GPIO port. This is used to map the
logical pin numbers to physical port and pin numbers.

config OCRE_CONTAINER_MESSAGING
bool "Enable OCRE Container Messaging support"
default n
help
Enable support for OCRE Container Messaging

config MESSAGING_MAX_SUBSCRIPTIONS
int "Number of maximum subscriptions for Container Messaging"
default 10
depends on OCRE_CONTAINER_MESSAGING
help
Number of maximum subscriptions for Container Messaging


endmenu
2 changes: 1 addition & 1 deletion boards/b_u585i_iot02a.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ CONFIG_NET_L2_ETHERNET=y
# hts221 sensor config
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_CBPRINTF_FP_SUPPORT=y
4 changes: 4 additions & 0 deletions boards/native_sim.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
zephyr,uart-mcumgr = &uart0;
};

aliases {
rng0 = &rng_device;
};

devices{
rng_device: rng_0 {
compatible = "custom,rng-sensor";
Expand Down
6 changes: 5 additions & 1 deletion prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ CONFIG_LOG_TRACE_SHORT_TIMESTAMP=y
CONFIG_SENSOR=y
CONFIG_RNG_SENSOR=y

CONFIG_OCRE_CONTAINER_MESSAGING=y
CONFIG_MESSAGING_MAX_SUBSCRIPTIONS=10

CONFIG_DEVICE_DT_METADATA=y
CONFIG_DEVICE_DEPS=y

Expand All @@ -81,5 +84,6 @@ CONFIG_MAX_TIMERS=5
CONFIG_MAX_SENSORS=10
CONFIG_MAX_CHANNELS_PER_SENSOR=5


CONFIG_OCRE_MEMORY_CHECK_ENABLED=n
CONFIG_OCRE_GPIO=n

23 changes: 22 additions & 1 deletion src/ocre/api/ocre_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "ocre_api.h"
#include "../ocre_timers/ocre_timer.h"
#include "../ocre_sensors/ocre_sensors.h"
#include "../ocre_gpio/ocre_gpio.h"
#include "../container_messaging/messaging.h"

int _ocre_posix_uname(wasm_exec_env_t exec_env, struct _ocre_posix_utsname *name) {
struct utsname info;
Expand Down Expand Up @@ -82,6 +84,15 @@ NativeSymbol ocre_api_table[] = {

{"ocre_sleep", ocre_sleep, "(i)i", NULL},

// Container Messaging API
#ifdef CONFIG_OCRE_CONTAINER_MESSAGING
{"ocre_msg_system_init", ocre_msg_system_init, "()", NULL},
{"ocre_publish_message", ocre_publish_message, "(***i)i", NULL},
{"ocre_subscribe_message", ocre_subscribe_message, "(**)i", NULL},
#endif

// Sensor API
#ifdef CONFIG_OCRE_SENSORS
// Sensor API
{"ocre_sensors_init", ocre_sensors_init, "()i", NULL},
{"ocre_sensors_discover", ocre_sensors_discover, "()i", NULL},
Expand All @@ -90,7 +101,7 @@ NativeSymbol ocre_api_table[] = {
{"ocre_sensors_get_channel_count", ocre_sensors_get_channel_count, "(i)i", NULL},
{"ocre_sensors_get_channel_type", ocre_sensors_get_channel_type, "(ii)i", NULL},
{"ocre_sensors_read", ocre_sensors_read, "(ii)i", NULL},

#endif
// Timer API
{"ocre_timer_create", ocre_timer_create, "(i)i", NULL},
{"ocre_timer_start", ocre_timer_start, "(iii)i", NULL},
Expand All @@ -99,6 +110,16 @@ NativeSymbol ocre_api_table[] = {
{"ocre_timer_get_remaining", ocre_timer_get_remaining, "(i)i", NULL},
{"ocre_timer_set_dispatcher", ocre_timer_set_dispatcher, "(i)v", NULL},

#ifdef CONFIG_OCRE_GPIO
// GPIO API
{"ocre_gpio_init", ocre_gpio_wasm_init, "()i", NULL},
{"ocre_gpio_configure", ocre_gpio_wasm_configure, "(iii)i", NULL},
{"ocre_gpio_set", ocre_gpio_wasm_set, "(iii)i", NULL},
{"ocre_gpio_get", ocre_gpio_wasm_get, "(ii)i", NULL},
{"ocre_gpio_toggle", ocre_gpio_wasm_toggle, "(ii)i", NULL},
{"ocre_gpio_register_callback", ocre_gpio_wasm_register_callback, "(ii)i", NULL},
{"ocre_gpio_unregister_callback", ocre_gpio_wasm_unregister_callback, "(ii)i", NULL},
#endif
};

int ocre_api_table_size = sizeof(ocre_api_table) / sizeof(NativeSymbol);
10 changes: 6 additions & 4 deletions src/ocre/components/container_supervisor/cs_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static void runtime_uninitialized_run(void *o) {

switch (msg->event) {
case EVENT_CS_INITIALIZE:
LOG_INF("Transitioning from state STATE_RUNTIME_UNINITIALIZED_RUN to state STATE_RUNTIME_RUNNING");
sm_transition(&ocre_cs_state_machine, STATE_RUNTIME_RUNNING);
break;

Expand All @@ -47,10 +48,6 @@ static void runtime_uninitialized_run(void *o) {
SM_MARK_EVENT_HANDLED(o);
}

// void callbackFcn(void) {
// LOG_INF("CALLBACK CALLED");
// }

static void runtime_running_entry(void *o) {
#if OCRE_CS_DEBUG_ON
LOG_INF("HELLO runtime_running_entry");
Expand All @@ -75,6 +72,7 @@ static void runtime_running_run(void *o) {
break;
}
case EVENT_RUN_CONTAINER: {
LOG_INF("EVENT_RUN_CONTAINER");
if (CS_run_container(ctx, &msg->containerId) == CONTAINER_STATUS_RUNNING) {
LOG_INF("Started container in slot:%d", msg->containerId);
} else {
Expand All @@ -83,18 +81,22 @@ static void runtime_running_run(void *o) {
break;
}
case EVENT_STOP_CONTAINER: {
LOG_INF("EVENT_STOP_CONTAINER");
CS_stop_container(ctx, msg->containerId, callback);
break;
}
case EVENT_DESTROY_CONTAINER: {
LOG_INF("EVENT_DESTROY_CONTAINER");
CS_destroy_container(ctx, msg->containerId, callback);
break;
}
case EVENT_RESTART_CONTAINER: {
LOG_INF("EVENT_RESTART_CONTAINER");
CS_restart_container(ctx, msg->containerId, callback);
break;
}
case EVENT_CS_DESTROY:
LOG_INF("EVENT_CS_DESTROY");
sm_transition(&ocre_cs_state_machine, STATE_RUNTIME_UNINITIALIZED);
break;
default:
Expand Down
Loading