joachimBurket / esp32-opencv

Shrinked OpenCV for ESP32

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help compiling hello_opencv - dangerous relocation: cannot decode instruction opcode:

ThinkTransit opened this issue · comments

Hi there,

Great project!

I'm trying to compile the hello_opencv example for an ESP32-S2 and I'm stuck with the following error and can't seem to find a fix. Just wondering if you have any ideas how to solve it? Seems to be lots of "dangerous relocation" errors.

atmul.dispatch.cpp:(.text._ZN2cv13mulTransposedERKNS_11_InputArrayERKNS_12_OutputArrayEbS2_di+0x2c1): dangerous relocation: cannot decode instruction opcode: (.text._ZN2cv13mulTransposedERKNS_11_InputArrayERKNS_12_OutputArrayEbS2_di+0x2cb) ../main/opencv/libopencv_core.a(matrix_decomp.cpp.obj): in function ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16':
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x20a): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x21a)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x232): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x248)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x3da): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x3e0)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x44d): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x453)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x6b2): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x6c2)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x6da): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x6f6)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x720): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x775)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x9ba): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x97d)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x9f2): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0x9c0)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0xa07): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0xa0d)
matrix_decomp.cpp:(.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0xa1f): dangerous relocation: cannot decode instruction opcode: (.text.ZN2cv3halL6QRImplIfEEiPT_jiiiS3_jS3_S2$constprop$16+0xa25)
../main/opencv/libopencv_core.a(matrix_decomp.cpp.obj): in function cv::hal::LU32f(float*, unsigned int, int, float*, unsigned int, int)': matrix_decomp.cpp:(.text._ZN2cv3hal5LU32fEPfjiS1_ji+0xc1): dangerous relocation: cannot decode instruction opcode: (.text._ZN2cv3hal5LU32fEPfjiS1_ji+0xf0) matrix_decomp.cpp:(.text._ZN2cv3hal5LU32fEPfjiS1_ji+0xd7): dangerous relocation: cannot decode instruction opcode: (.text._ZN2cv3hal5LU32fEPfjiS1_ji+0xe5) matrix_decomp.cpp:(.text._ZN2cv3hal5LU32fEPfjiS1_ji+0xf9): dangerous relocation: cannot decode instruction opcode: (.text._ZN2cv3hal5LU32fEPfjiS1_ji+0xff) matrix_decomp.cpp:(.text._ZN2cv3hal5LU32fEPfjiS1_ji+0x35f): dangerous relocation: cannot decode instruction opcode: (.text._ZN2cv3hal5LU32fEPfjiS1_ji+0x365)

I have only pasted a portion of the output because it is very big, here is the full output https://pastebin.com/4s4drzLd

Thanks

Hey,

Thanks, glad it can help :)

I haven't tried with the ESP32-S2, only with the ESP32. Have you tried to re-compile the OpenCV by specifying the ESP32-S2 toolchain? You will have to launch the script build_opencv_for_esp32.sh from the root of the project like this:

./esp32/scripts/build_opencv_for_esp32.sh <path-to-toolchain> <path-to-project>

Where the <path-to-toolchain> points to where your esp32-s2 toolchain is (normally in <path-to-espidf>/tools/cmake/ there must be a .cmake file for the esp32-s2).

The <path-to-project> points to where the lib will be installed. If not specified, it will be installed in esp32/lib/, and you can then manually copy the files from there to your project.

Hi,

Thanks for your help. You are correct I had compiled it for the ESP32 instead of the ESP32-S2!

Unfortunately I still get the dangerous relocation with the new libraries but at least I'm using the correct libraries now.

I will keep tinkering around with it but if you do have any further suggestions that would be great.

That's already a good news that you managed to compile OpenCV for the ESP32-S2 :)

I'm not sure but could it be that the ESP32-S2 needs a different sdkconfig that the one on the hello_opencv example ?
Maybe you should try starting a new clean project, making it compile for the ESP32-S2, then changing the menuconfig with the parameters needed for OpenCV to work*, and when it compiles for this, trying to add the hello_opencv code and the library on the project.

*Do the make menuconfig on the hello_opencv project, and find the parameters you need to change. I don't remember which are the important ones :/ but be sure you have the external RAM enabled, and Bluetooth and Trace Memory disabled (to be sure to have enough place in the internal RAM).