Skip to content

Commit 4610b12

Browse files
committed
Ocre containers: Adding support for NRF5340-DK board
WIP: Using nordic NRF5340DK board for testing and leveraging Ocre containers. Currently adding minimal support to make it compile and run on the actual hardware. Will continue adding configs across with the functionalities
1 parent 4ced977 commit 4610b12

File tree

6 files changed

+142
-3
lines changed

6 files changed

+142
-3
lines changed

.gitmessage

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Title: Summary, imperative, start upper case, don't end with a period
2+
# No more than 50 chars. #### 50 chars is here: #
3+
4+
# Remember blank line between title and body.
5+
6+
# Body: Explain *what* and *why* (not *how*). Include task ID (Jira issue).
7+
# Wrap at 72 chars. ################################## which is here: #
8+
9+
10+
# At the end: Include Co-authored-by for all contributors.
11+
# Include at least one empty line before it. Format:
12+
# Co-authored-by: name <user@users.noreply.github.com>
13+
#
14+
# How to Write a Git Commit Message:
15+
# https://chris.beams.io/posts/git-commit/
16+
#
17+
# 1. Separate subject from body with a blank line
18+
# 2. Limit the subject line to 50 characters
19+
# 3. Capitalize the subject line
20+
# 4. Do not end the subject line with a period
21+
# 5. Use the imperative mood in the subject line
22+
# 6. Wrap the body at 72 characters
23+
# 7. Use the body to explain what and why vs. how

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endif()
88
if(TARGET_PLATFORM_NAME STREQUAL "Linux")
99
project(ocre LANGUAGES C ASM)
1010
elseif(TARGET_PLATFORM_NAME STREQUAL "Zephyr")
11-
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
11+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1212
project(ocre VERSION ${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_PATCHLEVEL}.${APP_VERSION_TWEAK} LANGUAGES C ASM)
1313
else()
1414
message(FATAL_ERROR "Unsupported TARGET_PLATFORM_NAME: ${TARGET_PLATFORM_NAME}")
@@ -59,7 +59,7 @@ if(NOT "${OCRE_INPUT_FILE}" STREQUAL "")
5959
message("Using input file: ${OCRE_INPUT_FILE}")
6060
add_custom_command(
6161
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
62+
COMMAND xxd -i ${OCRE_INPUT_FILE} | sed 's/unsigned char .*\\[/static unsigned char wasm_binary[/' | sed 's/unsigned int .*_len/static unsigned int wasm_binary_len/' > ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g
6363
DEPENDS ${OCRE_INPUT_FILE}
6464
COMMENT "Generating C header from ${OCRE_INPUT_FILE}"
6565
)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Memory configuration - CRITICAL: nRF5340 only has 512KB RAM!
2+
CONFIG_ARM_MPU=y
3+
CONFIG_MAIN_STACK_SIZE=4096
4+
CONFIG_SHELL_STACK_SIZE=2048
5+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
6+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1
7+
CONFIG_HEAP_MEM_POOL_SIZE=32768
8+
9+
# Container defaults - Reduced for nRF5340's limited RAM
10+
CONFIG_MAX_CONTAINERS=2
11+
CONFIG_OCRE_WAMR_HEAP_BUFFER_SIZE=180000
12+
CONFIG_OCRE_CONTAINER_DEFAULT_HEAP_SIZE=2048
13+
CONFIG_OCRE_CONTAINER_DEFAULT_STACK_SIZE=2048
14+
15+
# DISABLE OCRE SHELL (this is what's causing the shell_fprintf errors!)
16+
CONFIG_OCRE_SHELL=n
17+
18+
# Disable the main Zephyr shell
19+
CONFIG_SHELL=n
20+
21+
# Random number generator (REQUIRED by networking and RNG sensor)
22+
CONFIG_ENTROPY_GENERATOR=y
23+
CONFIG_TEST_RANDOM_GENERATOR=y
24+
25+
# Reduce networking stack sizes to save RAM
26+
CONFIG_NET_TX_STACK_SIZE=1024
27+
CONFIG_NET_RX_STACK_SIZE=2048
28+
CONFIG_NET_BUF_TX_COUNT=8
29+
CONFIG_NET_BUF_RX_COUNT=16
30+
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
31+
CONFIG_NET_PKT_RX_COUNT=8
32+
CONFIG_NET_PKT_TX_COUNT=8
33+
CONFIG_NET_BUF_DATA_SIZE=128
34+
35+
# Bus interfaces
36+
CONFIG_GPIO=y
37+
38+
# Ocre Sensors support
39+
CONFIG_SENSOR=y
40+
CONFIG_OCRE_SENSORS=y
41+
CONFIG_RNG_SENSOR=y
42+
43+
# Disable sensor shell
44+
CONFIG_SENSOR_SHELL=n
45+
CONFIG_SENSOR_INFO=n
46+
47+
# Ocre GPIO Support (minimal)
48+
CONFIG_OCRE_GPIO=y
49+
CONFIG_OCRE_GPIO_MAX_PORTS=4
50+
CONFIG_OCRE_GPIO_PINS_PER_PORT=8
51+
CONFIG_OCRE_GPIO_MAX_PINS=32
52+
53+
# Disable container messaging to save RAM
54+
CONFIG_OCRE_CONTAINER_MESSAGING=n
55+
56+
# Disable filesystem features (despite OCRE selecting it, we minimize usage)
57+
CONFIG_OCRE_CONTAINER_FILESYSTEM=n
58+
CONFIG_FILE_SYSTEM_SHELL=n
59+
60+
# Disable MCUboot/DFU
61+
CONFIG_IMG_MANAGER=n
62+
CONFIG_MCUBOOT_IMG_MANAGER=n
63+
CONFIG_STREAM_FLASH=n
64+
65+
# Flash settings
66+
CONFIG_FLASH=y
67+
CONFIG_FLASH_MAP=y
68+
CONFIG_FLASH_PAGE_LAYOUT=y
69+
70+
# Serial/UART
71+
CONFIG_SERIAL=y
72+
CONFIG_UART_CONSOLE=y
73+
CONFIG_CONSOLE=y
74+
75+
# Reduce other buffers
76+
CONFIG_ZVFS_OPEN_MAX=8
77+
CONFIG_ZVFS_EVENTFD_MAX=5
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+
5340)
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=""

prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CONFIG_DYNAMIC_THREAD_ALLOC=y
2222

2323
# File system
2424
CONFIG_FILE_SYSTEM=y
25-
#CONFIG_DISK_ACCESS=y
25+
#CONFIG_DISK_ACCESS=y
2626
CONFIG_FILE_SYSTEM_LITTLEFS=y
2727

2828
# Settings support

0 commit comments

Comments
 (0)