From a0c65a3afa5aeba5499dde3e81e5fec71fcb6fb6 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Mon, 17 Nov 2025 14:52:03 +0100 Subject: [PATCH 1/2] feat(sample_container): use const specifier This will put the sample container in the flash, saving RAM. Signed-off-by: Marco Casaroli --- src/ocre/ocre_input_file.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ocre/ocre_input_file.h b/src/ocre/ocre_input_file.h index 74a39052..fea12761 100644 --- a/src/ocre/ocre_input_file.h +++ b/src/ocre/ocre_input_file.h @@ -8,7 +8,7 @@ #ifndef OCRE_INPUT_FILE_H #define OCRE_INPUT_FILE_H // Sample WASM binary data -static unsigned char wasm_binary[] = { +static const unsigned char wasm_binary[] = { 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x35, 0x09, 0x60, 0x03, 0x7f, 0x7f, 0x7f, 0x01, 0x7f, 0x60, 0x03, 0x7f, 0x7e, 0x7f, 0x01, 0x7e, 0x60, 0x01, 0x7f, 0x01, 0x7f, 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, @@ -332,6 +332,6 @@ static unsigned char wasm_binary[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00 }; -static unsigned int wasm_binary_len = 3850; +static const unsigned int wasm_binary_len = 3850; #endif // OCRE_INPUT_FILE_H From e271bcce9b4d93feed647c87d4ab88c4153fd1c5 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Mon, 17 Nov 2025 14:53:06 +0100 Subject: [PATCH 2/2] feat(generate_ocre_file): use const specifier This will put the generated sample container in the flash, saving RAM. Signed-off-by: Marco Casaroli --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38367542..7ce15320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ if(NOT "${OCRE_INPUT_FILE}" STREQUAL "") add_custom_command( OUTPUT ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g - COMMAND xxd -i ${OCRE_INPUT_FILE} | sed 's/unsigned char .*\\[/static const unsigned char wasm_binary[/' | sed 's/unsigned int .*_len/static const unsigned int wasm_binary_len/' > ${CMAKE_CURRENT_LIST_DIR}/src/ocre/ocre_input_file.g + COMMAND xxd -n wasm_binary -i ${OCRE_INPUT_FILE} | sed 's/^unsigned/static const unsigned/' > ${OCRE_ROOT_DIR}/src/ocre/ocre_input_file.g DEPENDS ${OCRE_INPUT_FILE} COMMENT "Generating C header from ${OCRE_INPUT_FILE}" )