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: 7 additions & 11 deletions boards/b_u585i_iot02a.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ CONFIG_ARM_MPU=y
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1

# PSRAM
CONFIG_MEMC=y

# Container defaults
CONFIG_MAX_CONTAINERS=5
CONFIG_OCRE_WAMR_HEAP_BUFFER_SIZE=8388608

# Bus interfaces
CONFIG_GPIO=y
CONFIG_I2C=y
Expand Down Expand Up @@ -36,19 +43,8 @@ CONFIG_OCRE_GPIO_MAX_PORTS=8
CONFIG_OCRE_GPIO_PINS_PER_PORT=16
CONFIG_OCRE_GPIO_MAX_PINS=256

CONFIG_MEMC=y
CONFIG_SPI_NOR=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y


CONFIG_CODE_DATA_RELOCATION=n

CONFIG_LINKER_LAST_SECTION_ID=y

CONFIG_MM_DRV=y
CONFIG_MM_DRV_PAGE_SIZE=4096

# Networking options
CONFIG_NET_TCP=y
CONFIG_NET_MAX_CONN=10
Expand Down
113 changes: 0 additions & 113 deletions boards/b_u585i_iot02a.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/ {
aliases {
psram0 = &psram;
rng0 = &rng_device;
led0 = &green_led_1;
led1 = &red_led_1;
Expand Down Expand Up @@ -40,118 +39,6 @@
status = "okay";
device_list = <&rng_device &ism330dhcx &lps22hh &hts221 &iis2mdc &veml6030>;
};

reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;

psram0: psram@90000000 {
compatible = "zephyr,memory-region";
reg = <0x90000000 0x00800000>;
zephyr,memory-region = "PSRAM";
};
};

chosen {
zephyr,memory-region = &psram0;
};
};

&octospi1 {
status = "okay";
pinctrl-0 = <&octospi1_clk &octospi1_ncs &octospi1_dqs
&octospi1_io0 &octospi1_io1 &octospi1_io2 &octospi1_io3
&octospi1_io4 &octospi1_io5 &octospi1_io6 &octospi1_io7>;
pinctrl-names = "default";

psram: psram@0 {
compatible = "st,stm32-ospi-psram";
reg = <0x0 0x00800000>;
st,ospi-mode = <3>; // Octal mode
st,ospi-clk-frequency = <104>; // MHz
st,ospi-chip-select = <0>; // CS0
};
};

/* OCTOSPI1 pinmux setup */
&pinctrl {
octospi1_clk: octospi1_clk {
pinmux = <STM32_PINMUX('E', 10, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_ncs: octospi1_ncs {
pinmux = <STM32_PINMUX('E', 11, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_dqs: octospi1_dqs {
pinmux = <STM32_PINMUX('E', 12, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io0: octospi1_io0 {
pinmux = <STM32_PINMUX('E', 7, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io1: octospi1_io1 {
pinmux = <STM32_PINMUX('E', 8, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io2: octospi1_io2 {
pinmux = <STM32_PINMUX('E', 9, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io3: octospi1_io3 {
pinmux = <STM32_PINMUX('E', 13, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io4: octospi1_io4 {
pinmux = <STM32_PINMUX('E', 14, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io5: octospi1_io5 {
pinmux = <STM32_PINMUX('E', 15, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io6: octospi1_io6 {
pinmux = <STM32_PINMUX('E', 2, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};

octospi1_io7: octospi1_io7 {
pinmux = <STM32_PINMUX('D', 7, AF10)>;
bias-disable;
drive-push-pull;
slew-rate = "very-high-speed";
};
};

// Add labels for sensors defined in the board .dtsi file, and any other user configuration
Expand Down
68 changes: 44 additions & 24 deletions src/ocre/components/container_supervisor/cs_sm_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#ifdef CONFIG_OCRE_CONTAINER_MESSAGING
#include "ocre_messaging/ocre_messaging.h"
#endif
#if defined(CONFIG_OCRE_TIMER) || defined(CONFIG_OCRE_GPIO) || defined(CONFIG_OCRE_SENSORS)
#if defined(CONFIG_OCRE_TIMER) || defined(CONFIG_OCRE_GPIO) || defined(CONFIG_OCRE_SENSORS) || \
defined(CONFIG_OCRE_CONTAINER_MESSAGING)
#include "api/ocre_common.h"
#endif

Expand All @@ -33,6 +34,16 @@ LOG_MODULE_DECLARE(ocre_cs_component, OCRE_LOG_LEVEL);
#include "cs_sm.h"
#include "cs_sm_impl.h"

// External RAM support for WAMR heap on boards that have it
#if defined(CONFIG_MEMC)
#if defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7)
__attribute__((section("SDRAM1"), aligned(32)))
#elif defined(CONFIG_BOARD_B_U585I_IOT02A)
__attribute__((section(".stm32_psram"), aligned(32)))
#elif defined(CONFIG_BOARD_MIMXRT1064_EVK)
__attribute__((section("SDRAM"), aligned(32)))
#endif // defined (<board>)
#endif // defined(CONFIG_MEMC)
static char wamr_heap_buf[CONFIG_OCRE_WAMR_HEAP_BUFFER_SIZE] = {0};

// Thread pool for container execution
Expand Down Expand Up @@ -329,36 +340,35 @@ ocre_container_status_t CS_run_container(ocre_container_t *container) {
return CONTAINER_STATUS_RUNNING;
}

#ifdef CONFIG_OCRE_NETWORKING
#define ADDRESS_POOL_SIZE 1
const char *addr_pool[ADDRESS_POOL_SIZE] = {
"0.0.0.0/0",
};
wasm_runtime_set_wasi_addr_pool(curr_container_arguments->module, addr_pool, ADDRESS_POOL_SIZE);
#endif

#ifdef CONFIG_OCRE_CONTAINER_FILESYSTEM
// Simple for now: map CONTAINER_FS_PATH to /
// TODO: eventually every container should probably have its own root folder,
// however wasm_runtime_set_wasi_args expects constant values.
#define DIR_LIST_SIZE 1
static const char *dir_map_list[DIR_LIST_SIZE] = {
"/::" CONTAINER_FS_PATH
};
wasm_runtime_set_wasi_args(curr_container_arguments->module,
NULL, 0,
dir_map_list, DIR_LIST_SIZE,
NULL, 0, NULL, 0);
#endif


if (container->container_runtime_status != CONTAINER_STATUS_CREATED &&
container->container_runtime_status != CONTAINER_STATUS_STOPPED) {
LOG_ERR("Container (ID: %d), is not in a valid state to run", curr_container_ID);
container->container_runtime_status = CONTAINER_STATUS_ERROR;
return CONTAINER_STATUS_ERROR;
}

#ifdef CONFIG_OCRE_NETWORKING
#define ADDRESS_POOL_SIZE 1
const char *addr_pool[ADDRESS_POOL_SIZE] = {
"0.0.0.0/0",
};
wasm_runtime_set_wasi_addr_pool(curr_container_arguments->module, addr_pool, ADDRESS_POOL_SIZE);
#endif

#ifdef CONFIG_OCRE_CONTAINER_FILESYSTEM
// Simple for now: map CONTAINER_FS_PATH to /
// TODO: eventually every container should probably have its own root folder,
// however wasm_runtime_set_wasi_args expects constant values.
#define DIR_LIST_SIZE 1
static const char *dir_map_list[DIR_LIST_SIZE] = {
"/::" CONTAINER_FS_PATH
};
wasm_runtime_set_wasi_args(curr_container_arguments->module,
NULL, 0,
dir_map_list, DIR_LIST_SIZE,
NULL, 0, NULL, 0);
#endif

if (curr_container_arguments->module_inst) {
LOG_INF("WASM runtime already instantiated for container:%d", curr_container_ID);
} else {
Expand Down Expand Up @@ -446,7 +456,17 @@ ocre_container_status_t CS_stop_container(ocre_container_t *container, ocre_cont

for (int i = 0; i < CONTAINER_THREAD_POOL_SIZE; i++) {
if (container_thread_active[i] && container_threads[i].user_options == curr_container_ID) {
#if defined(CONFIG_OCRE_CONTAINER_WAMR_TERMINATION)
/**
* wasm_runtime_terminate uses POSIX signals to terminate the thread from the outside; calling core_thread_destroy
* would try to destroy again the thread, and pthread_join() will never return, while freeing the stack would cause
* segfault. This separation is needed to distinguish platform supported by wamr with this features,
* from those which aren't. Since this function exists on those platforms, but stubbed, config parameter is used.
*/
wasm_runtime_terminate(curr_container_arguments->module_inst);
#else
core_thread_destroy(&container_threads[i]);
#endif
container_thread_active[i] = false;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/platform/posix/core_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//#define CONFIG_OCRE_CONTAINER_MESSAGING /*!< Enable container messaging support */
#define CONFIG_OCRE_NETWORKING /*!< Enable networking support */
#define CONFIG_OCRE_CONTAINER_FILESYSTEM
#define CONFIG_OCRE_CONTAINER_WAMR_TERMINATION

// Base paths for the application
#define OCRE_BASE_PATH "./ocre" /*!< Base directory for Ocre resources */
Expand Down