Skip to content

Commit d09b019

Browse files
authored
Refactor and stabilize system initialization, messaging, and platform support (#75)
This squashed commit includes multiple improvements across runtime stability, messaging infrastructure, platform integration, and code hygiene: - Encapsulated global `argc` to improve initialization safety - Cleaned up Ocre messaging and fixed memory corruption in sensor discovery - Updated Zephyr to 4.2 and resolved malloc-related memory freeing issues - Refactored modules and improved filesystem access for containers - Enhanced logging granularity and error handling in message queues - Added Linux support to GitHub workflows and performed release cleanups - Improved GPIO macros for Pico 2 and aligned messaging topic prefixes - Miscellaneous fixes: printf formatting, newline removal, build config updates These changes collectively improve system robustness, portability, and maintainability. --------- Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent 8abfee8 commit d09b019

39 files changed

Lines changed: 1354 additions & 962 deletions

.github/workflows/build.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ on:
33
push:
44
branches:
55
- main
6+
- staging
67
pull_request:
78
branches:
89
- main
10+
- staging
911
jobs:
10-
build:
12+
build-zephyr:
1113
runs-on: zephyr-xlarge-runner
12-
1314
container:
1415
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
1516
options: --user root
@@ -21,6 +22,8 @@ jobs:
2122
uses: actions/checkout@v4
2223
with:
2324
path: application
25+
submodules: recursive
26+
fetch-depth: 0
2427

2528
- name: Setup Zephyr project
2629
uses: zephyrproject-rtos/action-zephyr-setup@v1
@@ -44,8 +47,26 @@ jobs:
4447
name: firmware
4548
path: build/zephyr/zephyr.bin
4649

50+
build-linux:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
with:
56+
path: application
57+
58+
- name: Setup project for Linux Build
59+
run: |
60+
cd application
61+
git submodule update --init --recursive
62+
63+
- name: Build Linux
64+
run: |
65+
cd application
66+
./build.sh -t l
67+
4768
flash:
48-
needs: build
69+
needs: build-zephyr
4970
runs-on: zephyr-xlarge-runner
5071
steps:
5172
- name: Download firmware

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ Thumbs.db
5959

6060
# VS Code IDE
6161
.vscode/
62+
# Generated by VS
63+
settings.json

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[submodule "wasm-micro-runtime"]
22
path = wasm-micro-runtime
33
url = https://github.com/bytecodealliance/wasm-micro-runtime.git
4+
branch = dev/zephyr_file_socket

Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ config MESSAGING_MAX_SUBSCRIPTIONS
193193
help
194194
Number of maximum subscriptions for Container Messaging
195195

196+
config OCRE_CONTAINER_FILESYSTEM
197+
bool "Enable OCRE Container File System support"
198+
default n
199+
help
200+
Enable support for containers to access the flash filesystem
201+
196202
config OCRE_SHELL
197203
bool "Enable OCRE Shell"
198204
default y

boards/b_u585i_iot02a.conf

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
# Critical Memory Sizes
1+
# Memory configuration and sizes
2+
CONFIG_ARM_MPU=y
23
CONFIG_MAIN_STACK_SIZE=8192
4+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1
35

4-
# ENC28J60 Ethernet driver
6+
# Bus interfaces
57
CONFIG_GPIO=y
8+
CONFIG_I2C=y
69
CONFIG_SPI=y
10+
11+
# ENC28J60 Ethernet driver
712
CONFIG_ETH_ENC28J60=y
813
CONFIG_NET_L2_ETHERNET=y
14+
CONFIG_LSM6DSO=y
915

10-
# hts221 sensor config
11-
CONFIG_I2C=y
16+
# Ocre Sensors support
1217
CONFIG_SENSOR=y
13-
CONFIG_CBPRINTF_FP_SUPPORT=y
18+
CONFIG_OCRE_SENSORS=y
19+
20+
# Ocre options
21+
CONFIG_OCRE_CONTAINER_FILESYSTEM=y
22+
23+
# Specific sensor drivers
24+
CONFIG_RNG_SENSOR=y
25+
CONFIG_IMU_SENSOR=y
26+
CONFIG_LSM6DSO=y
1427

1528
# Ocre GPIO Support
1629
CONFIG_OCRE_GPIO=y
1730
CONFIG_OCRE_GPIO_MAX_PORTS=8
1831
CONFIG_OCRE_GPIO_PINS_PER_PORT=16
1932
CONFIG_OCRE_GPIO_MAX_PINS=256
33+
34+
CONFIG_MEMC=y
35+
CONFIG_SPI_NOR=y
36+
CONFIG_FLASH=y
37+
CONFIG_FLASH_MAP=y
38+
39+
40+
CONFIG_CODE_DATA_RELOCATION=n
41+
42+
CONFIG_LINKER_LAST_SECTION_ID=y
43+
44+
CONFIG_MM_DRV=y
45+
CONFIG_MM_DRV_PAGE_SIZE=4096

boards/b_u585i_iot02a.overlay

Lines changed: 171 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,176 @@
1+
#include <zephyr/dt-bindings/pinctrl/stm32-pinctrl.h>
2+
13
/ {
2-
devices{
3-
rng_device: rng_0 {
4-
compatible = "custom,rng-sensor";
5-
label = "RNG Sensor";
6-
status = "okay";
4+
aliases {
5+
psram0 = &psram;
6+
rng0 = &rng_device;
7+
led0 = &green_led_1;
8+
led1 = &red_led_1;
9+
};
10+
11+
leds {
12+
compatible = "gpio-leds";
13+
green_led_1: led_1 {
14+
gpios = <&gpioh 7 GPIO_ACTIVE_LOW>;
15+
label = "User LD7";
16+
};
17+
red_led_1: led_3 {
18+
gpios = <&gpioh 6 GPIO_ACTIVE_LOW>;
19+
label = "User LD6";
20+
};
21+
};
22+
23+
gpio_keys {
24+
compatible = "gpio-keys";
25+
user_button: button {
26+
label = "User";
27+
gpios = <&gpioc 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
28+
zephyr,code = <INPUT_KEY_0>;
729
};
830
};
31+
32+
rng_device: rng_0 {
33+
compatible = "custom,rng-sensor";
34+
label = "RNG Sensor";
35+
status = "okay";
36+
};
37+
38+
devices {
39+
compatible = "custom,devices";
40+
status = "okay";
41+
device_list = <&rng_device &ism330dhcx>;
42+
};
43+
44+
reserved-memory {
45+
#address-cells = <1>;
46+
#size-cells = <1>;
47+
ranges;
48+
49+
psram0: psram@90000000 {
50+
compatible = "zephyr,memory-region";
51+
reg = <0x90000000 0x00800000>;
52+
zephyr,memory-region = "PSRAM";
53+
};
54+
};
55+
56+
chosen {
57+
zephyr,memory-region = &psram0;
58+
};
59+
};
60+
61+
&octospi1 {
62+
status = "okay";
63+
pinctrl-0 = <&octospi1_clk &octospi1_ncs &octospi1_dqs
64+
&octospi1_io0 &octospi1_io1 &octospi1_io2 &octospi1_io3
65+
&octospi1_io4 &octospi1_io5 &octospi1_io6 &octospi1_io7>;
66+
pinctrl-names = "default";
67+
68+
psram: psram@0 {
69+
compatible = "st,stm32-ospi-psram";
70+
reg = <0x0 0x00800000>;
71+
st,ospi-mode = <3>; // Octal mode
72+
st,ospi-clk-frequency = <104>; // MHz
73+
st,ospi-chip-select = <0>; // CS0
74+
};
75+
};
76+
77+
/* OCTOSPI1 pinmux setup */
78+
&pinctrl {
79+
octospi1_clk: octospi1_clk {
80+
pinmux = <STM32_PINMUX('E', 10, AF10)>;
81+
bias-disable;
82+
drive-push-pull;
83+
slew-rate = "very-high-speed";
84+
};
85+
86+
octospi1_ncs: octospi1_ncs {
87+
pinmux = <STM32_PINMUX('E', 11, AF10)>;
88+
bias-disable;
89+
drive-push-pull;
90+
slew-rate = "very-high-speed";
91+
};
92+
93+
octospi1_dqs: octospi1_dqs {
94+
pinmux = <STM32_PINMUX('E', 12, AF10)>;
95+
bias-disable;
96+
drive-push-pull;
97+
slew-rate = "very-high-speed";
98+
};
99+
100+
octospi1_io0: octospi1_io0 {
101+
pinmux = <STM32_PINMUX('E', 7, AF10)>;
102+
bias-disable;
103+
drive-push-pull;
104+
slew-rate = "very-high-speed";
105+
};
106+
107+
octospi1_io1: octospi1_io1 {
108+
pinmux = <STM32_PINMUX('E', 8, AF10)>;
109+
bias-disable;
110+
drive-push-pull;
111+
slew-rate = "very-high-speed";
112+
};
113+
114+
octospi1_io2: octospi1_io2 {
115+
pinmux = <STM32_PINMUX('E', 9, AF10)>;
116+
bias-disable;
117+
drive-push-pull;
118+
slew-rate = "very-high-speed";
119+
};
120+
121+
octospi1_io3: octospi1_io3 {
122+
pinmux = <STM32_PINMUX('E', 13, AF10)>;
123+
bias-disable;
124+
drive-push-pull;
125+
slew-rate = "very-high-speed";
126+
};
127+
128+
octospi1_io4: octospi1_io4 {
129+
pinmux = <STM32_PINMUX('E', 14, AF10)>;
130+
bias-disable;
131+
drive-push-pull;
132+
slew-rate = "very-high-speed";
133+
};
134+
135+
octospi1_io5: octospi1_io5 {
136+
pinmux = <STM32_PINMUX('E', 15, AF10)>;
137+
bias-disable;
138+
drive-push-pull;
139+
slew-rate = "very-high-speed";
140+
};
141+
142+
octospi1_io6: octospi1_io6 {
143+
pinmux = <STM32_PINMUX('E', 2, AF10)>;
144+
bias-disable;
145+
drive-push-pull;
146+
slew-rate = "very-high-speed";
147+
};
148+
149+
octospi1_io7: octospi1_io7 {
150+
pinmux = <STM32_PINMUX('D', 7, AF10)>;
151+
bias-disable;
152+
drive-push-pull;
153+
slew-rate = "very-high-speed";
154+
};
155+
};
156+
157+
&i2c2 {
158+
pinctrl-0 = <&i2c2_scl_ph4 &i2c2_sda_ph5>;
159+
pinctrl-names = "default";
160+
status = "okay";
161+
clock-frequency = <I2C_BITRATE_FAST>;
162+
163+
ism330dhcx: ism330dhcx@6b {
164+
compatible = "st,ism330dhcx";
165+
reg = <0x6b>;
166+
drdy-gpios = <&gpioe 11 GPIO_ACTIVE_HIGH>;
167+
status = "okay";
168+
label = "imu";
169+
accel-odr = <4>; // 104 Hz
170+
accel-range = <4>; // ±4 g
171+
gyro-odr = <4>; // 104 Hz
172+
gyro-range = <250>; // ±250 dps
173+
};
9174
};
10175

11176
&spi1 {
@@ -20,6 +185,7 @@
20185
};
21186
};
22187

188+
/* Optional: flash partitions */
23189
&flash0 {
24190
partitions {
25191
user_data_partition: partition@100000 {
@@ -29,7 +195,6 @@
29195
};
30196
};
31197

32-
/* Add hts221 sensor configurations */
33198
&die_temp {
34199
status = "disabled";
35200
};

boards/native_sim.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ CONFIG_NET_DHCPV4=n
2929
CONFIG_FS_LOG_LEVEL_OFF=y
3030

3131
# This is required to work around an issue where "-1" causes a crash using the `native_sim`
32-
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=262144
32+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=262144
33+
CONFIG_GPIO=y
34+
35+
# Ocre options
36+
CONFIG_OCRE_CONTAINER_FILESYSTEM=y

build.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ if [[ "$TARGET" == "z" ]]; then
5555
echo "Input files provided: ${INPUT_FILES[*]}"
5656
rm flash.bin
5757
west build -p -b $ZEPHYR_BOARD ./application -d build -- \
58-
-DMODULE_EXT_ROOT=`pwd`/application -DOCRE_INPUT_FILE="${INPUT_FILES[0]}" -DTARGET_PLATFORM_NAME=Zephyr
58+
-DMODULE_EXT_ROOT=`pwd`/application -DOCRE_INPUT_FILE="${INPUT_FILES[0]}" -DTARGET_PLATFORM_NAME=Zephyr || exit 1
5959
# Note: Only the first file is passed to OCRE_INPUT_FILE, adapt as needed for multiple files
6060
else
6161
rm flash.bin
6262
west build -p -b $ZEPHYR_BOARD ./application -d build -- \
63-
-DMODULE_EXT_ROOT=`pwd`/application -DTARGET_PLATFORM_NAME=Zephyr
63+
-DMODULE_EXT_ROOT=`pwd`/application -DTARGET_PLATFORM_NAME=Zephyr || exit 1
6464
fi
6565
elif [[ "$TARGET" == "l" ]]; then
6666
echo "Target is: Linux x86_64"
@@ -76,9 +76,12 @@ elif [[ "$TARGET" == "l" ]]; then
7676
if [[ $(tail -n 1 build.log) == "[100%] Built target app" ]]; then
7777
BUILD_SUCCESS=true
7878
fi
79+
if [ "$BUILD_SUCCESS" == false ]; then
80+
exit 1
81+
fi
7982
else
8083
echo "Target does not contain 'z' or 'l': exit"
81-
exit
84+
exit 1
8285
fi
8386

8487
# Execute run mode if -r flag is set and build was successful

modules/modules.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
set(ZEPHYR_WASM_MICRO_RUNTIME_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}/wasm-micro-runtime)
2-
set(ZEPHYR_WASM_MICRO_RUNTIME_KCONFIG ${CMAKE_CURRENT_LIST_DIR}/wasm-micro-runtime/Kconfig)
1+
# This project uses .gitmodules to manage various modules due to cross-platform solutions

0 commit comments

Comments
 (0)