[yocto] [meta-raspberrypi] Using the camera

Alex J Lennon ajlennon at dynamicdevices.co.uk
Sun Jun 1 18:18:22 PDT 2014


On 01/06/2014 22:35, Alex J Lennon wrote:
>
> On 01/06/2014 22:22, Alexandru Vaduva wrote:
>> This are indeed some very good news Alex J Lennon.
>> I have some questions, but those maybe can be answered by the
>> maintainers of the meta-raspberrypi layer:
>> Why was this change done?
>>      -PREFERRED_PROVIDER_virtual/egl ?= "vc-graphics-hardfp"
>>      -PREFERRED_PROVIDER_virtual/libgles2 ?= "vc-graphics-hardfp"
>>      +PREFERRED_PROVIDER_virtual/egl ?= "userland"
>>      +PREFERRED_PROVIDER_virtual/libgles2 ?= "userland"
>> How it may affect other applications?
>> Andrei: Do you have any input on this?
>>
>>

I think I've worked out what is happening. It looks like an interesting,
and pretty obscure, effect of the default bitbake linker flags.

There's an __attribute__(constructor) decorated function that is
supposed to be executed when libmmal_vc_client.so is loaded.

However by default bitbake passes in LDFLAGS of --as-needed which means
that although raspivid is set to be linked against libmmal_vc_client,
the dependency, which is un-needed by raspivid as there's no call into
that library, is removed.

The userland code for Raspivid tries to create a component with a call
to  mmal_component_create() which is in libmmal_core

ref:
https://github.com/raspberrypi/userland/blob/master/host_applications/linux/apps/raspicam/RaspiVid.c

This function goes to a default constructor     which walks a list
mmal_component_supplier_create(const char *name, MMAL_COMPONENT_T
*component)

ref:
https://github.com/raspberrypi/userland/blob/master/interface/mmal/core/mmal_component.c

The function that populates the supplier list,
mmal_component_supplier_register(), is called from a function in another
library, libmmal_vc_client, which is decorated with

MMAL_CONSTRUCTOR(mmal_register_component_videocore);

which is defined as

# define MMAL_CONSTRUCTOR(func) void __attribute__((constructor,used))
func(void)

i.e. This registration function would normally execute when the library
it lives in is loaded, but because there's no call into that library
from raspivid, and because we linked with --as-needed, the library is
removed from the executable's dependency list, and the components are
never registered...

Diffing the working and non-working raspivids,

Dynamic Section:
   NEEDED               libmmal_core.so
   NEEDED               libmmal_util.so
-  NEEDED               libmmal_vc_client.so
   NEEDED               libvcos.so

So if I modify the userland_git.bb to remove the --as-needed

+LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu"

With this change I can now build userland out of meta-raspberrypi and
raspivid works for me.

Cheers,

Alex



 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20140602/78432ca2/attachment.html>


More information about the yocto mailing list