Skip to main content
C. Mart
Associate II
September 2, 2022
Solved

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

  • September 2, 2022
  • 4 replies
  • 3402 views

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!

Best answer by C. Mart

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

4 replies

C. Mart
C. MartAuthorBest answer
Associate II
September 3, 2022

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
June 13, 2024

solved for me. thanks

C. Mart
C. MartAuthor
Associate II
September 6, 2022

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

KK.10
Visitor II
February 28, 2023

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
February 14, 2025

This should solve your problem:

 

ai_buffer* ai_input = AI_SINE_MODEL_IN;

ai_buffer* ai_output = AI_SINE_MODEL_OUT;