Skip to main content
C. Mart
Associate II
Sep 2, 2022 10:59 AM UTC
Solved

Invalid Initializer error with auto-generated code X-CUBE-AI

Hello!

I'm having the exact same issue than the one described here: https://community.st.com/s/question/0D53W00001YbCCCSA3/invalid-initializer-and-initializer-element-is-not-constant-errors-in-stmcubeai?t=1662110397892

Wrapping ai_network_params inside a function didn't solve the issue, and also it doesn't make much sense.

OP suggests to adjust settings for the compiler and linker. Anyone can give some guidelines on how to do this properly without breaking anything, or knows any workaround?

Thank you in advance

Regards!

This topic has been closed for replies.
C. Mart
C. MartBest answer
Associate II
Sep 3, 2022 9:42 PM UTC

My problem solved when I modified the error occurrences in sin_model.h from this:

AI_DEPRECATED
#define AI_SIN_MODEL_IN \
 ai_sin_model_inputs_get(AI_HANDLE_NULL, NULL)

to this:

AI_DEPRECATED
#define AI_SIN_MODEL_IN { \
 {ai_sin_model_inputs_get(AI_HANDLE_NULL, NULL)} \
}

 Occurrences were on lines 38-41 and 55-58

5 replies

C. Mart
C. MartAuthorBest answer
Associate II
Sep 3, 2022 9:42 PM UTC

My problem solved when I modified the error occurrences in sin_model.h from this:

AI_DEPRECATED
#define AI_SIN_MODEL_IN \
 ai_sin_model_inputs_get(AI_HANDLE_NULL, NULL)

to this:

AI_DEPRECATED
#define AI_SIN_MODEL_IN { \
 {ai_sin_model_inputs_get(AI_HANDLE_NULL, NULL)} \
}

 Occurrences were on lines 38-41 and 55-58

Explorer II
Jun 13, 2024 10:10 AM UTC

solved for me. thanks

C. Mart
C. MartAuthor
Associate II
Sep 6, 2022 9:46 AM UTC

This removed the compiling error, but still the code does not work.

KK.10
Visitor II
Feb 28, 2023 4:34 PM UTC

X-CUBE-AI 7.0 code example doesn't work with later versions. In my case 7.3.0.

Completely disregard example code for 7.0 version and use code from ST example: "How to perform motion sensing on STM32L4 IoTnode".

Section 6: "Create an STM32Cube.AI application using X-CUBE-AI".

Visitor II
Feb 14, 2025 12:35 PM UTC

This should solve your problem:

 

ai_buffer* ai_input = AI_SINE_MODEL_IN;

ai_buffer* ai_output = AI_SINE_MODEL_OUT;