Skip to content

Commit 65dc4b9

Browse files
Merge branch 'project-ocre:main' into test-implement-modbus-server-testing
2 parents dd2b29e + 4b15a2e commit 65dc4b9

66 files changed

Lines changed: 4489 additions & 3931 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ AllowShortEnumsOnASingleLine: false
1111
AllowShortFunctionsOnASingleLine: None
1212
AllowShortIfStatementsOnASingleLine: false
1313
AllowShortLoopsOnASingleLine: false
14-
BitFieldColonSpacing: After
15-
BreakBeforeBraces: Attach
14+
BitFieldColonSpacing: Both
15+
BreakBeforeBraces: Linux
1616
ColumnLimit: 120
1717
ConstructorInitializerIndentWidth: 8
1818
ContinuationIndentWidth: 8
19-
IndentCaseLabels: true
20-
IndentWidth: 4
21-
InsertBraces: true
19+
IndentCaseLabels: true # Linux is false
20+
IndentWidth: 8
21+
LineEnding: LF
2222
SpaceBeforeParens: ControlStatementsExceptControlMacros
23-
SortIncludes: Never
24-
#UseTab: ForContinuationAndIndentation
23+
SortIncludes: false
24+
UseTab: Always
25+
TabWidth: 8
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Coding Guidelines Check
2+
3+
# Trigger this workflow on all pull requests
4+
on:
5+
pull_request:
6+
7+
# Ensure only one instance of this workflow runs per branch
8+
# Cancel any in-progress runs when new commits are pushed
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: checkout
18+
uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
22+
# Install clang-format-16 for code formatting checks
23+
- name: Install clang-format-16
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y clang-format-16
27+
28+
- name: Run Formatting Check
29+
run: ./scripts/check_formatting.sh

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ add_custom_target(generate_messages DEPENDS ${MSG_GENERATED_FILE})
5757

5858
if(NOT "${OCRE_INPUT_FILE}" STREQUAL "")
5959
message("Using input file: ${OCRE_INPUT_FILE}")
60+
61+
# Extract filename without extension for use in software
62+
get_filename_component(OCRE_INPUT_FILE_NAME ${OCRE_INPUT_FILE} NAME_WE)
63+
message("Input file name (without extension): ${OCRE_INPUT_FILE_NAME}")
64+
add_definitions(-DOCRE_INPUT_FILE_NAME="${OCRE_INPUT_FILE_NAME}")
65+
6066
add_custom_command(
6167
OUTPUT ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g
62-
COMMAND xxd -n wasm_binary -i ${OCRE_INPUT_FILE} > ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g
68+
COMMAND xxd -n wasm_binary -i ${OCRE_INPUT_FILE} | sed 's/^unsigned/static const unsigned/' > ${OCRE_ROOT_DIR}/src/ocre/ocre_input_file.g
6369
DEPENDS ${OCRE_INPUT_FILE}
6470
COMMENT "Generating C header from ${OCRE_INPUT_FILE}"
6571
)

Kconfig

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ config OCRE_WAMR_HEAP_BUFFER_SIZE
3939
help
4040
A static memory allocation for WAMR to use as a heap.
4141

42+
config OCRE_STORAGE_HEAP_BUFFER_SIZE
43+
int "Storage heap buffer size in bytes"
44+
default 500000
45+
depends on MEMC
46+
help
47+
A static memory allocation for container storage to use as a heap.
48+
4249
config OCRE_CONTAINER_DEFAULT_HEAP_SIZE
4350
int "Default value for the container heap size"
4451
default 4096
@@ -217,5 +224,53 @@ config OCRE_NETWORKING
217224
default n
218225
help
219226
Enable networking support for containers.
220-
227+
228+
config OCRE_SHARED_HEAP
229+
bool "Enable container shared heap support"
230+
default n
231+
help
232+
Enable shared heap support for containers.
233+
234+
config OCRE_SHARED_HEAP_BUF_SIZE
235+
int "Shared heap buffer size in bytes"
236+
default 65536
237+
depends on OCRE_SHARED_HEAP
238+
help
239+
Size of the pre-allocated buffer for the shared heap.
240+
This memory is shared between WebAssembly modules.
241+
242+
choice OCRE_SHARED_HEAP_MODE
243+
prompt "Shared heap mode"
244+
depends on OCRE_SHARED_HEAP
245+
default OCRE_SHARED_HEAP_BUF_VIRTUAL
246+
help
247+
Select the shared heap memory mode:
248+
- Physical: Map physical hardware registers (e.g., GPIO) to WASM address space
249+
- Virtual: Allocate shared heap from regular RAM
250+
251+
config OCRE_SHARED_HEAP_BUF_PHYSICAL
252+
bool "Physical (hardware register mapping)"
253+
help
254+
Enable physical memory mapping for hardware access.
255+
Maps physical hardware registers (like GPIO at 0x42020000) to WASM address space.
256+
Use this when containers need direct access to hardware peripherals.
257+
258+
config OCRE_SHARED_HEAP_BUF_VIRTUAL
259+
bool "Virtual (RAM allocation)"
260+
help
261+
Enable virtual shared heap allocated from regular RAM.
262+
Use this for normal inter-module communication without
263+
direct hardware access.
264+
265+
endchoice
266+
267+
config OCRE_SHARED_HEAP_BUF_ADDRESS
268+
hex "Shared heap buffer address"
269+
default 0x00
270+
depends on OCRE_SHARED_HEAP
271+
help
272+
Shared heap buffer address.
273+
- For physical mode: Physical address of hardware registers
274+
- For virtual mode: Leave as 0x00 to auto-allocate from RAM
275+
221276
endmenu

boards/b_u585i_iot02a.conf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Memory configuration and sizes
2-
CONFIG_ARM_MPU=y
2+
CONFIG_ARM_MPU=n
3+
CONFIG_FPU=y
34
CONFIG_MAIN_STACK_SIZE=8192
45
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1
56

@@ -8,7 +9,8 @@ CONFIG_MEMC=y
89

910
# Container defaults
1011
CONFIG_MAX_CONTAINERS=5
11-
CONFIG_OCRE_WAMR_HEAP_BUFFER_SIZE=8388608
12+
CONFIG_OCRE_WAMR_HEAP_BUFFER_SIZE=6388608
13+
CONFIG_OCRE_STORAGE_HEAP_BUFFER_SIZE=2000000
1214

1315
# Bus interfaces
1416
CONFIG_GPIO=y

boards/b_u585i_iot02a.overlay

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <zephyr/dt-bindings/pinctrl/stm32-pinctrl.h>
22

33
/ {
4+
chosen {
5+
zephyr,code-partition = &slot0_partition;
6+
};
7+
48
aliases {
59
rng0 = &rng_device;
610
led0 = &green_led_1;
@@ -82,12 +86,37 @@
8286
};
8387
};
8488

85-
/* Optional: flash partitions */
89+
/* Flash partitions - 2MB total, no MCUboot */
8690
&flash0 {
91+
/delete-node/ partitions;
92+
93+
partitions {
94+
compatible = "fixed-partitions";
95+
#address-cells = <1>;
96+
#size-cells = <1>;
97+
98+
/* Application partition - 1900KB */
99+
slot0_partition: partition@0 {
100+
label = "image-0";
101+
reg = <0x00000000 DT_SIZE_K(2000)>;
102+
};
103+
/* Dummy slot1 partition for MCUboot compatibility (unused) */
104+
slot1_partition: partition@1F5000 {
105+
label = "image-1";
106+
reg = <0x001F5000 DT_SIZE_K(44)>;
107+
};
108+
};
109+
};
110+
111+
// 64MB external flash
112+
&mx25lm51245 {
87113
partitions {
88-
user_data_partition: partition@100000 {
114+
/delete-node/ partition;
115+
116+
/* Use the whole flash for the filesystem. */
117+
user_data_partition: storage_partition: partition@0 {
89118
label = "user_data";
90-
reg = <0x00100000 DT_SIZE_K(256)>;
119+
reg = <0x00000000 DT_SIZE_M(64)>;
91120
};
92121
};
93122
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
CONFIG_ARM_MPU=y
2+
CONFIG_MAIN_STACK_SIZE=4096
3+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
4+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1
5+
CONFIG_HEAP_MEM_POOL_SIZE=32768
6+
7+
# Container defaults - Reduced for nRF5340's limited RAM
8+
CONFIG_MAX_CONTAINERS=2
9+
CONFIG_OCRE_WAMR_HEAP_BUFFER_SIZE=180000
10+
CONFIG_OCRE_CONTAINER_DEFAULT_HEAP_SIZE=4096
11+
CONFIG_OCRE_CONTAINER_DEFAULT_STACK_SIZE=4096
12+
13+
# DISABLE OCRE SHELL (this is what's causing the shell_fprintf errors!)
14+
CONFIG_OCRE_SHELL=n
15+
16+
# Disable the main Zephyr shell AND all shell subsystems
17+
CONFIG_NET_SHELL=n
18+
CONFIG_FILE_SYSTEM_SHELL=n
19+
CONFIG_SENSOR_SHELL=n
20+
21+
# Override shell-related configs from prj.conf since shell is disabled
22+
23+
# Random number generator (REQUIRED by networking and RNG sensor)
24+
CONFIG_ENTROPY_GENERATOR=y
25+
CONFIG_TEST_RANDOM_GENERATOR=y
26+
27+
# Reduce networking stack sizes to save RAM
28+
CONFIG_NET_TX_STACK_SIZE=1024
29+
CONFIG_NET_RX_STACK_SIZE=2048
30+
CONFIG_NET_BUF_TX_COUNT=8
31+
CONFIG_NET_BUF_RX_COUNT=16
32+
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
33+
CONFIG_NET_PKT_RX_COUNT=8
34+
CONFIG_NET_PKT_TX_COUNT=8
35+
CONFIG_NET_BUF_DATA_SIZE=128
36+
37+
# Bus interfaces
38+
CONFIG_GPIO=y
39+
40+
# Ocre Sensors support
41+
CONFIG_SENSOR=y
42+
CONFIG_OCRE_SENSORS=y
43+
CONFIG_RNG_SENSOR=y
44+
45+
# Ocre GPIO Support (minimal)
46+
CONFIG_OCRE_GPIO=y
47+
CONFIG_OCRE_GPIO_MAX_PORTS=4
48+
CONFIG_OCRE_GPIO_PINS_PER_PORT=8
49+
CONFIG_OCRE_GPIO_MAX_PINS=32
50+
51+
# Disable container messaging to save RAM
52+
CONFIG_OCRE_CONTAINER_MESSAGING=y
53+
54+
# Enable container filesystem for WASI stdio
55+
CONFIG_OCRE_CONTAINER_FILESYSTEM=y
56+
57+
# CONFIG_BOOTLOADER_MCUBOOT=n
58+
# # CONFIG_IMG_MANAGER=n
59+
# CONFIG_MCUBOOT_IMG_MANAGER=n
60+
# CONFIG_STREAM_FLASH=n
61+
# CONFIG_IMG_ERASE_PROGRESSIVELY=n
62+
63+
# Flash settings
64+
CONFIG_FLASH=y
65+
CONFIG_FLASH_MAP=y
66+
CONFIG_FLASH_PAGE_LAYOUT=y
67+
68+
# Serial/UART
69+
CONFIG_SERIAL=y
70+
CONFIG_UART_CONSOLE=y
71+
CONFIG_CONSOLE=y
72+
73+
# Reduce other buffers
74+
CONFIG_ZVFS_OPEN_MAX=8
75+
CONFIG_ZVFS_EVENTFD_MAX=5
76+
77+
CONFIG_LOG_TRACE_SHORT_TIMESTAMP=n
78+
79+
CONFIG_SHELL_PROMPT_UART=""
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/ {
2+
aliases {
3+
rng0 = &rng_device;
4+
led0 = &led0;
5+
};
6+
7+
rng_device: rng_0 {
8+
compatible = "custom,rng-sensor";
9+
label = "RNG Sensor";
10+
status = "okay";
11+
};
12+
13+
devices {
14+
compatible = "custom,devices";
15+
status = "okay";
16+
device_list = <&rng_device>;
17+
};
18+
};
19+
20+
/* Enable one LED for blinky */
21+
&led0 {
22+
status = "okay";
23+
};
24+
25+
&flash0 {
26+
partitions {
27+
/delete-node/ partition@f8000;
28+
29+
user_data_partition: partition@e0000 {
30+
label = "user_data";
31+
reg = <0x000e0000 DT_SIZE_K(128)>;
32+
};
33+
};
34+
};

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ if [[ "$TARGET" == "z" ]]; then
9191
-DDTC_OVERLAY_FILE=boards/${ZEPHYR_BOARD}.overlay\;boards/enc28j60.overlay"
9292
echo "Building for b_u585i_iot02a with ENC28J60 support"
9393
;;
94+
nrf5340)
95+
ZEPHYR_BOARD="nrf5340dk/nrf5340/cpuapp"
96+
CONF_EXTRA=""
97+
echo "Building for nrf5340dk board: App CPU"
98+
;;
9499
*)
95100
ZEPHYR_BOARD="$BOARD_ARG"
96101
CONF_EXTRA=""

0 commit comments

Comments
 (0)