Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [Bug 11996] New: opencv3 SIGILL on Cortex-A5 with VFPv4-D16
@ 2019-07-01 17:17 bugzilla at busybox.net
  2019-07-01 21:47 ` [Buildroot] [Bug 11996] " bugzilla at busybox.net
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bugzilla at busybox.net @ 2019-07-01 17:17 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=11996

            Bug ID: 11996
           Summary: opencv3 SIGILL on Cortex-A5 with VFPv4-D16
           Product: buildroot
           Version: 2019.02.3
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at buildroot.uclibc.org
          Reporter: jcowgill+busybox at jcowgill.uk
                CC: buildroot at uclibc.org
  Target Milestone: ---

I recently upgraded from 2018.02 to 2019.02 and discovered that opencv3 has
broken on my board (it worked with 2018.02). The board has a Cortex-A5 with
VFPv4-D16 enabled but without NEON and VFPv4 (so it only has 16 double floating
point registers).

These are the target options I have set:
BR2_arm=y
BR2_BINFMT_ELF=y
BR2_cortex_a5=y
BR2_ARM_ENABLE_NEON=n
BR2_ARM_ENABLE_VFP=y
BR2_ARM_EABIHF=y
BR2_ARM_FPU_VFPV4D16=y
BR2_ARM_INSTRUCTIONS_THUMB2=y

I can see that my application gets a SIGILL because it tries to load a value
into the d20 register which doesn't exist in VFPv4-D16.

0xb661d3d2 in cv::interpolateLanczos4 (coeffs=0xbef4602c, x=0.03125)
    at
/home/jcowgill/workspace/bsp/buildroot/output/build/opencv3-3.4.3/modules/imgproc/src/imgwarp.cpp:176
176    
/home/jcowgill/workspace/bsp/buildroot/output/build/opencv3-3.4.3/modules/imgproc/src/imgwarp.cpp:
No such file or directory.
(gdb) disassemble
...
   0xb661d3cc <+796>:   ldr     r3, [pc, #240]  ; (0xb661d4c0
<cv::initInterTab2D(int, bool)+1040>)
   0xb661d3ce <+798>:   vmov    s14, r8
=> 0xb661d3d2 <+802>:   vldr    d20, [r10]
   0xb661d3d6 <+806>:   vldr    d19, [r9]
   0xb661d3da <+810>:   add     r3, pc
   0xb661d3dc <+812>:   mov     r2, r7

========

I think this code in opencv3.mk is wrong (or maybe the ARM fpu config options
are wrong):

ifeq ($(BR2_ARCH_IS_64):$(BR2_ARM_CPU_HAS_VFPV3),:y)
OPENCV3_CONF_OPTS += -DENABLE_VFPV3=ON
else
OPENCV3_CONF_OPTS += -DENABLE_VFPV3=OFF
endif

Apparently I have BR2_ARM_CPU_HAS_VFPV3 set (even though I only have the -D16
version), but when you pass -DENABLE_VFPV3=ON to OpenCV, it passes -mfpu=vfpv3
to the compiler and this is what's causing the SIGILL.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Buildroot] [Bug 11996] opencv3 SIGILL on Cortex-A5 with VFPv4-D16
  2019-07-01 17:17 [Buildroot] [Bug 11996] New: opencv3 SIGILL on Cortex-A5 with VFPv4-D16 bugzilla at busybox.net
@ 2019-07-01 21:47 ` bugzilla at busybox.net
  2019-11-27 22:20 ` bugzilla at busybox.net
  2020-02-05 16:49 ` bugzilla at busybox.net
  2 siblings, 0 replies; 4+ messages in thread
From: bugzilla at busybox.net @ 2019-07-01 21:47 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=11996

--- Comment #1 from Arnout Vandecappelle <arnout@mind.be> ---
> I think this code in opencv3.mk is wrong (or maybe the ARM fpu config options
> are wrong):
>
> ifeq ($(BR2_ARCH_IS_64):$(BR2_ARM_CPU_HAS_VFPV3),:y)
> OPENCV3_CONF_OPTS += -DENABLE_VFPV3=ON
> else
> OPENCV3_CONF_OPTS += -DENABLE_VFPV3=OFF
> endif
> 
> Apparently I have BR2_ARM_CPU_HAS_VFPV3 set (even though I only have the 
> -D16 version), but when you pass -DENABLE_VFPV3=ON to OpenCV, it passes 
> -mfpu=vfpv3 to the compiler and this is what's causing the SIGILL.

If the only thing that ENABLE_VFPV3 does is to set the -mfpu=... option, then
we should just always set it to OFF, because we already pass that option.

Same for NEON, by the way.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Buildroot] [Bug 11996] opencv3 SIGILL on Cortex-A5 with VFPv4-D16
  2019-07-01 17:17 [Buildroot] [Bug 11996] New: opencv3 SIGILL on Cortex-A5 with VFPv4-D16 bugzilla at busybox.net
  2019-07-01 21:47 ` [Buildroot] [Bug 11996] " bugzilla at busybox.net
@ 2019-11-27 22:20 ` bugzilla at busybox.net
  2020-02-05 16:49 ` bugzilla at busybox.net
  2 siblings, 0 replies; 4+ messages in thread
From: bugzilla at busybox.net @ 2019-11-27 22:20 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=11996

--- Comment #2 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> ---
So, I did a bit more research on this, but couldn't come to a useful
conclusion. The handling of CPU optimizations in opencv3 is complicated.
ENABLE_VFPV3 and ENABLE_NEON seem to be obsolete options, but the replacement
CPU_BASELINE is not very clear.

With a VFPv3-D16 case, I get:

--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON

which is quite expected.

When NEON is enabled as the FPU, I get:

--   CPU/HW features:
--     Baseline:                    NEON
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON

So NEON seems to be detected, but it's also listed in the "disabled"
features... which doesn't make a lot of sense.

Then, if I use VFPv3 as the FPU, I get:

--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON

I.e, it doesn't detect that I have VFPv3.

(Of course the tests above are after removing ENABLE_VFPV3/ENABLE_NEON).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Buildroot] [Bug 11996] opencv3 SIGILL on Cortex-A5 with VFPv4-D16
  2019-07-01 17:17 [Buildroot] [Bug 11996] New: opencv3 SIGILL on Cortex-A5 with VFPv4-D16 bugzilla at busybox.net
  2019-07-01 21:47 ` [Buildroot] [Bug 11996] " bugzilla at busybox.net
  2019-11-27 22:20 ` bugzilla at busybox.net
@ 2020-02-05 16:49 ` bugzilla at busybox.net
  2 siblings, 0 replies; 4+ messages in thread
From: bugzilla at busybox.net @ 2020-02-05 16:49 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=11996

Thomas Petazzoni <thomas.petazzoni@free-electrons.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> ---
Fixed by
https://git.buildroot.org/buildroot/commit/?id=4d0f3dd8709f9f31a81eaa8a62cb35ef6ddddeaf

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-05 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-01 17:17 [Buildroot] [Bug 11996] New: opencv3 SIGILL on Cortex-A5 with VFPv4-D16 bugzilla at busybox.net
2019-07-01 21:47 ` [Buildroot] [Bug 11996] " bugzilla at busybox.net
2019-11-27 22:20 ` bugzilla at busybox.net
2020-02-05 16:49 ` bugzilla at busybox.net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox