STMicroelectronics / stm32ai-modelzoo

AI Model Zoo for STM32 devices
Other
295 stars 72 forks source link

Error When Porting Official Object Detection Post-Processing Library (STM32_Objdetect_Postprocess) #51

Open Flora233333 opened 22 hours ago

Flora233333 commented 22 hours ago

Dear Developer, Hi ! I am trying to port the object detection application from the stm32ai_application_code\object_detection directory to my STM32H723. However, I encountered issues when integrating the lib objdetect_pp_GCC.a into my Keil AC6 project.

Description:

X-CUBE-AI: 9.1.0 Device: Custom-made STM32H723 board IDE: Keil (AC6) Model: st_ssd_mobilenet_v1

When I add the library (objdetect_pp_GCC.a) to the project, I receive the following errors during the compilation:

Note: source file '..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a' - object file renamed from 'STM32_ssd\objdetect_pp_GCC.o' to 'STM32_ssd\objdetect_pp_gcc_1.o'.
assembling objdetect_pp_GCC.a...
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(1): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(2): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(3): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(4): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(5): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(6): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(7): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(8): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(9): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(10): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(11): error: A1167E: Invalid line start 
  11 00000000 ? (12): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(13): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(14): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(15): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(16): error: A1167E: Invalid line start 
..\Middlewares\ST\STM32_Objdetect_Postprocess\lib\objdetect_pp_GCC.a(17): error: A1167E: Invalid line start 
  17 00000000 ?(18): error: A1167E: Invalid line start 
  18 00000000 ???j??(19): warning: A1313W: Missing END directive at end of file

I attempted to rename the file to objdetect_pp_GCC.lib to resolve the above issue. (and it seems that the error was resolved)

However, I have encountered another compilation error when calling the objdetect_ssd_st_pp_process function in my code. Below is the function I added:

int32_t app_postprocess_run(void **pInput, postprocess_out_t *pOutput, void *pInput_static_param)
{
    int32_t error = AI_OBJDETECT_POSTPROCESS_ERROR_NO;

    ssd_st_pp_in_centroid_t pp_input =
    {
        .pAnchors = pInput[2],
        .pBoxes = pInput[1],
        .pScores = pInput[0],
    };

    error = objdetect_ssd_st_pp_process((ssd_st_pp_in_centroid_t *)&pp_input,
                                        (postprocess_out_t *)pOutput,
                                        (ssd_st_pp_static_param_t *)pInput_static_param);

    return error;
}

During compilation, I encounter the following error:

STM32_ssd\STM32_ssd.axf: Error: L6242E: Cannot link object objdetect_pp_ssd_st.o as its attributes are incompatible with the image attributes.
   ... wchart-16 clashes with wchart-32.
STM32_ssd\STM32_ssd.axf: Error: L6242E: Cannot link object objdetect_pp.o as its attributes are incompatible with the image attributes.
   ... wchart-16 clashes with wchart-32.

Could you please guide me on how to properly integrate the objdetect_pp_GCC.a library with my STM32H723 project in Keil AC6? Or is it necessary to write the post-processing code myself, as the official library might not be compatible

I appreciate your help and look forward to your response. Thank you!

GRATTINSTM commented 20 hours ago

Hello @Flora233333,

It is usually recommended not to use a library compiled with GCC in a project using another compiler. However, you may find a solution by using the appropriate compilation flags. Here is a troubleshooting guide available on the ARM website that seems to address your issue. Please tell me if it works for you.

Guillaume

Flora233333 commented 20 hours ago

Hi @GRATTINSTM,

Thank you for your reply.

I have already looked into the L6242E error doc and enabled short enums/wchar as suggested. However, I am still encountering the same errors:

STM32_ssd\STM32_ssd.axf: Error: L6242E: Cannot link object objdetect_pp_ssd_st.o as its attributes are incompatible with the image attributes.
   ... wchart-16 clashes with wchart-32.
STM32_ssd\STM32_ssd.axf: Error: L6242E: Cannot link object objdetect_pp.o as its attributes are incompatible with the image attributes.
   ... wchart-16 clashes with wchart-32.
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 4 information, 0 warning and 2 error messages.
"STM32_ssd\STM32_ssd.axf" - 2 Error(s), 0 Warning(s).

I hope to use the st_ssd_mobilenet_v1 post-processing code because I believe the official implementation may be more efficient.

Thanks again for your support!