zpu: check that enough memory is available for the image to operate.

This is a fixup commit for the previous commit (8D7B9D84).

ZPU is a stack machine where all code, constants, variables and function stack
are stored in a single memory block. Compiler doesn't through any warnings
or errors if the allocated memory is exhausted, so we have to check this
manually.

Our memory size is only 16383 bytes and we already had situation when all of it
is exhausted leading to unpredictable behaviour. Unfortunately we can't know
how much memory exactly do we need, but we estimated that 1300 bytes is enough
for us now, so this is what we're checking.
This commit is contained in:
Sergey Kostanbaev
2017-08-02 13:49:55 +03:00
committed by Alexander Chemeris
parent 8d7b9d84ed
commit 88e0f1c156
3 changed files with 5 additions and 4 deletions

View File

@@ -130,7 +130,7 @@ MACRO(GEN_OUTPUTS target)
)
ENDMACRO(GEN_OUTPUTS)
MACRO(TEST_STACK target minsize)
MACRO(TEST_STACK_SIZE target minsize)
GET_FILENAME_COMPONENT(name ${target} NAME_WE)
ADD_CUSTOM_COMMAND(
OUTPUT ${name}.freestack DEPENDS ${target}
@@ -142,7 +142,7 @@ MACRO(TEST_STACK target minsize)
ADD_CUSTOM_TARGET(
${name}_freestack ALL DEPENDS ${name}.freestack
)
ENDMACRO(TEST_SIZE)
ENDMACRO(TEST_STACK_SIZE)
########################################################################
# Add the subdirectories
########################################################################

View File

@@ -47,5 +47,5 @@ SET(GEN_OUTPUTS_BIN_SIZE 0x3fff)
ADD_EXECUTABLE(umtrx_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c ${libumtrxfw_FILES})
# TARGET_LINK_LIBRARIES(umtrx_txrx_uhd.elf libumtrxfw)
GEN_OUTPUTS(umtrx_txrx_uhd.elf)
TEST_STACK(umtrx_txrx_uhd.elf ${MIN_STACK})
TEST_STACK_SIZE(umtrx_txrx_uhd.elf ${MIN_STACK})

View File

@@ -41,4 +41,5 @@ ADD_EXECUTABLE(bootloader.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c ${libumtrxfw_
SET(GEN_OUTPUTS_BIN_SIZE 0x3fff)
GEN_OUTPUTS(bootloader.elf)
GEN_RMI(bootloader.bin)
TEST_STACK(bootloader.elf ${MIN_STACK})
TEST_STACK_SIZE(bootloader.elf ${MIN_STACK})