fabrizio.dini
Posts: 7
Joined: Wed Oct 12, 2016 10:59 am

Failed to create MMAL component because of ENOSYS error

Mon Jan 22, 2018 3:33 pm

Hi everybody!

I am struggling to find what happened to my code... Here's the story (I'll try to make it quick).

I have a very mature (and complex) project based on raspberry pi with raspicam. The code has been used for about 5 years now, of course with many fixes and improvements throughout the years. All my code base is cross-compiled on a ubuntu-based laptop (16.04 LTS). Recently, I changed my hard drive to a brand new SSD (yay!) and apparently this is where the problems started to rise.

I re-installed the tool-chain to cross-compile for my RPi, and I found that arm-linux-gnueabihf-gcc had moved up to version 5. So I re-compiled all my code with the new toolchain, copied my executable on the RPi and...
mmal: mmal_component_create_core: could not find component 'vc.ril.camera'
I suspected I messed up different pieces of code, build with different versions of gcc, so I tried down-grading to version 5 to 4.9 to 4.8 (which I have used for years to build this project), but to no result. Investigating deeper in the error of MMAL it comes out that the mmal_component_create() function I am calling to create the camera component fails with status code 4, which should be ENOSYS "Function not implemented".

I have to admit it... I have run out of ideas. How to investigate further the problem?

Please note that:
  • raspivid is working correctly
  • sudo rpi-update already tried... nothing changed
  • tried on a brand new raspbian... nothing changed
  • tried with older version of the code (build with the new gcc)... nothing changed, I still got the error
Help! :?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5805
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Failed to create MMAL component because of ENOSYS error

Mon Jan 22, 2018 4:28 pm

https://github.com/raspberrypi/userland/issues/178
Has your new toolchain optimised out libmmal_vc_client because it relies on a constructor? Try adding the "--no-as-needed" flag.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

fabrizio.dini
Posts: 7
Joined: Wed Oct 12, 2016 10:59 am

Re: Failed to create MMAL component because of ENOSYS error

Mon Jan 22, 2018 5:11 pm

Thank you!

Unfortunately, that seems to have no effect, though things may be a little tricky... Actually, the code that uses MMAL is in a static library. My executable links statically to this library, which links dynamically to MMAL library. I tried to pass --no-as-needed option to the linker via xlinker option in gcc. The build was successful, but that seems to make no difference.

Don't know if this can be of any relevance, but I also tried to disable all code optimization by setting -O0, but that didn't work either...
:cry:

fabrizio.dini
Posts: 7
Joined: Wed Oct 12, 2016 10:59 am

Re: Failed to create MMAL component because of ENOSYS error

Mon Jan 22, 2018 5:12 pm

idea: maybe the options order in the GCC command line matters? :?: :idea:

fabrizio.dini
Posts: 7
Joined: Wed Oct 12, 2016 10:59 am

Re: Failed to create MMAL component because of ENOSYS error

Mon Jan 22, 2018 5:16 pm

Eureka! The options' order in GCC command line (as everybody know! :D ) DOES matter!

a -xlinker --no-as-needed added to my gcc linker options BEFORE -lmmal_core did the trick!

A BIG THANK YOU to 6by9! Great shot! :D

Return to “C/C++”