Adding AI models to OpenMV ecosystem?

Hi,

Has anyone successfully completed this procedure for adding an AI model to the OpenMV ecosystem?

I’ve been trying to do it with Ubuntu on VirtualBox, and it keeps failing on step “1.6.2 Build the firmware”; when executing this command:
make CUBEAI=1

The below is the error output:

CC uart.c
uart.c: In function 'uart_get_baudrate':
uart.c:748:12: error: implicit declaration of function 'LL_USART_GetBaudRate'; did you mean 'HAL_USART_GetState'? [-Werror=implicit-function-declaration]
  748 |     return LL_USART_GetBaudRate(self->uartx, uart_get_source_freq(self),
      |            ^~~~~~~~~~~~~~~~~~~~
      |            HAL_USART_GetState
uart.c:752:9: error: 'LL_USART_OVERSAMPLING_16' undeclared (first use in this function); did you mean 'USART_OVERSAMPLING_16'?
  752 |         LL_USART_OVERSAMPLING_16);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
      |         USART_OVERSAMPLING_16
uart.c:752:9: note: each undeclared identifier is reported only once for each function it appears in
uart.c: In function 'uart_set_baudrate':
uart.c:756:5: error: implicit declaration of function 'LL_USART_SetBaudRate' [-Werror=implicit-function-declaration]
  756 |     LL_USART_SetBaudRate(self->uartx, uart_get_source_freq(self),
      |     ^~~~~~~~~~~~~~~~~~~~
uart.c:758:9: error: 'LL_USART_PRESCALER_DIV1' undeclared (first use in this function); did you mean 'USART_PRESCALER_DIV1'?
  758 |         LL_USART_PRESCALER_DIV1,
      |         ^~~~~~~~~~~~~~~~~~~~~~~
      |         USART_PRESCALER_DIV1
uart.c:760:9: error: 'LL_USART_OVERSAMPLING_16' undeclared (first use in this function); did you mean 'USART_OVERSAMPLING_16'?
  760 |         LL_USART_OVERSAMPLING_16, baudrate);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
      |         USART_OVERSAMPLING_16
uart.c: In function 'uart_get_baudrate':
uart.c:753:1: error: control reaches end of non-void function [-Werror=return-type]
  753 | }
      | ^
cc1: all warnings being treated as errors
make[1]: *** [../../py/mkrules.mk:77: /home/marwil/openmv_workspace/openmv/src/build/micropython/uart.o] Error 1
make: *** [omv/ports/stm32/omv_portconfig.mk:567: FIRMWARE_OBJS] Error 2
marwil@marwil-VirtualBox:~/openmv_workspace/openmv/src$ 

I carefully followed all steps. I tried it with both Ubuntu 18.04 LTS, as suggested, and Ubuntu 20.04 LTS. Prior to moving to the next step, I had always verified that each piece of software was installed, with the same version, e.g. stm32ai --version

Note, I did not install Keras. I just used the provided .h5 file.

Has anyone gone through this process successfully?

M

Yes very recently, and it was working. Don’t check the older tag just stay on the master branch, and use gcc-10.2.1.

Note you may need to reduce the heap as a final step to get the fimrware with CUBEAI=1 to link successfully.

2 Likes

Success!

Thanks for the advice.

M

1 Like

Hello,

Can you tell me what the problem was?

In the link below says that you must use: gcc-arm-none-eabi-7-2018-q2-update
https://wiki.st.com/stm32mcu/wiki/AI:How_to_add_AI_model_to_OpenMV_ecosystem

Is it wrong? Should I use this one “gcc-10.2.1”?

Hello,

Can you tell me what the problem is? I have also the same error mentioned in this page.

In the link below says that you must use: gcc-arm-none-eabi-7-2018-q2-update
https://wiki.st.com/stm32mcu/wiki/AI:How_to_add_AI_model_to_OpenMV_ecosystem

Is it wrong? Should I use this one “gcc-10.2.1”?

I found this link:

What do you mean with 10.2.1?? Which version is that exactly?

Thank you so much. I went to the master branch of the downloaded git repository and the error isn’t there as you said.
I used these commands to go to the master branch:

git checkout master

Then, I used the following command as there was a restriction to prevent overwriting the previously changed files.

git stash

But now, I have the following error. Do you know how to get rid of it?

CC ports/stm32/wifidbg.c
CC ports/stm32/main.c
CC ports/stm32/hash.c
CC ports/stm32/soft_i2c.c
CC ../hal/cmsis/src/dsp/BasicMathFunctions/arm_shift_q7.c
CC ../hal/cmsis/src/dsp/BasicMathFunctions/arm_shift_q15.c
CC ../hal/cmsis/src/dsp/BasicMathFunctions/arm_dot_prod_f32.c
CC ../hal/cmsis/src/dsp/SupportFunctions/arm_float_to_q7.c
CC ../hal/cmsis/src/dsp/SupportFunctions/arm_float_to_q15.c
CC ../hal/cmsis/src/dsp/SupportFunctions/arm_q7_to_float.c
CC ../hal/cmsis/src/dsp/SupportFunctions/arm_q15_to_float.c
CC ../hal/cmsis/src/dsp/SupportFunctions/arm_q7_to_q15.c
CC ../hal/cmsis/src/dsp/SupportFunctions/arm_q15_to_q7.c
CC nn_st.c
In file included from /home/hamedelahi/openmv_workspace/openmv/src/stm32cubeai/AI/Inc/ai_datatypes_defines.h:25,
                 from nn_st.h:17,
                 from nn_st.c:11:
nn_st.c: In function 'aiRun':
/home/hamedelahi/openmv_workspace/openmv/src/stm32cubeai/AI/Inc/ai_platform.h:323:4: error: 'union <anonymous>' has no member named 'format'
  323 | { .format = (ai_buffer_format)(format_), \
      |    ^~~~~~
/home/hamedelahi/openmv_workspace/openmv/src/stm32cubeai/data/network_data.h:45:3: note: in expansion of macro 'AI_BUFFER_OBJ_INIT'
   45 |   AI_BUFFER_OBJ_INIT( \
      |   ^~~~~~~~~~~~~~~~~~
nn_st.c:212:7: note: in expansion of macro 'AI_NETWORK_DATA_WEIGHTS'
  212 |       AI_NETWORK_DATA_WEIGHTS(ai_network_data_weights_get()),
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/home/hamedelahi/openmv_workspace/openmv/src/stm32cubeai/AI/Inc/ai_platform.h:324:4: error: 'union <anonymous>' has no member named 'n_batches'
  324 |   .n_batches = (n_batches_), \
      |    ^~~~~~~~~
....

Please use the master branch, and use gcc-10.2.1 and follow the rest of the ST instructions and it should work (note the cubeai version must be the same one as the ST instructions)

1 Like

Thank you for the answer, but see the link below. As it says, I must install the version 5.2.0 of X-Cube-AI and I’ve done and tested that. But the error is still there. So there must be another problem there.

https://community.st.com/s/question/0D53W000014Tucr/cube-ai-generated-code-error

I’ve tested it with all there versions “X-CUBE-AI.7.0.0”, “X-CUBE-AI.6.0.0” and “X-CUBE-AI.5.2.0”.

Thank you so much.

Now, I know what the problem was. I used this version X-CUBE-AI.6.0.0 and after that I added the STM32Cube.AI library to OpenMV, what I forgot to do. So, that was my problem. That was my fault and I didn’t do the following step:

1.4 Step 2 - Add the STM32Cube.AI library to OpenMV

Thank you very much for your help, again.