Running Impulse on STM32H7 Dual Core Board

Hi everyone,

I’ve been trying to run an Image Classifier impulse on my STM32H745I-Disco Board, which has two MCUs: Arm-M4 and Arm-M7. However, even when I try to run a simple use case as in https://docs.edgeimpulse.com/docs/using-cubeai, I keep getting a lot of undefined reference errors (for the functions: ei_calloc, ei_free, ei_malloc, ei_printf_float, ei_read_timer_ms, and ei_run_impulse_check_canceled). I checked where these functions are defined and I only found their prototypes in the ei_classifier_porting.h file.

I’m using STM32CubeIDE, and it seems like an error when including new libraries. If my understanding is correct, when I program a dual-core board such as from the H7 series, then I must treat each MCU as a different CubeIDE project. This seems a bit confusing, below there’s a capture of the errors I’m hitting after following instructions carefully.

Would appreciate any kind of help,
Alejandro.

Hi,

Thanks for reaching out. Can you check if the macro EI_PORTING_STM32_CUBEAI is defined in your project. This guards around the implementation of the missing functions.

Regards,
Arjan

Hi Arjan,

It looks like it is defined in ei_classifier_porting.h:

Tested it by doing a simple ei_printf like this, and it is also defined as 1:

Maybe I’m missing something else?

Hi, managed to solve the issue.

As seen below, there are two Middlewares folders, one for the general project (in this case, named EI-H745-ImageClassifier), and another one for the project associated with the Arm-M7 MCU (named EI-H745-ImageClassifier_CM7). It looks like the source code for the script ei_classifier_porting.h that is copied into the MCU’s directory, is the one for the HIMAX board, for some reason. I solved the problem by copying the content of the ei_classifier_porting.cpp from the stm32-cubeai folder into the one in the file: EI-H745-ImageClassifier_CM7>Middlewares>MachineLearning>image-classifier>Core>ei_classifier_porting.cpp.

Tried repeating the process again to check if it was an error from my side, but it doesn’t seem to be. Would appreciate if you guys could see if there is something missing when adding the Software Package associated to the .pack file.

However, now I’m hitting another error due to memory allocation, this is what I’m getting, maybe it’s related to the previous issue:

'Failed to allocate TFLite arena (error code 1)'
'run_classifier returned: -6'
'Predictions (DSP: 0 ms., Classification: 0 ms., Anomaly: 0 ms.):'
'[0, 0, 0]'
2 Likes

Hey Alejandro,

Thanks for the detailed description of the issue and workaround, I was able to reproduce this issue on my end as well.

For the arena issue, that’s most often a legitimate error due to being too low on RAM to load the model. A similar error was actually recently discussed a bit here if you hadn’t already seen it.

Interestingly enough, they didn’t seem to run into the cmsis-pack issue we saw.

Best,
David

Managed to solve the memory error by modifying assignation in the Linker Script as follows:

/* Highest address of the user mode stack */
_estack = 0x24080000;  // <--- Change _estack end of RAM address  /* end of RAM */ 
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200 ;      /* required amount of heap  */
_Min_Stack_Size = 0x400 ; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw)      : ORIGIN = 0x24000000, LENGTH = 512K // <--- change origin address and length
ITCMRAM (xrw)      : ORIGIN = 0x00000000, LENGTH = 64K
}
3 Likes