I have a project which requires full control of the camera board on a Raspberry Pi from a custom C application, so I recently started looking into getting a toolchain and code running on the Pi. The Raspberry Pi is actually a really powerful and advanced SBC, with a full Broadcom VideoCore GPU and a connection to a 5MP camera that can do full 1080 HD video at 30 FPS. The project I am working on takes a single picture from the camera and saves it to the flash. I could use the raspistill application and some bash scripting, however I want full control over the camera and since eventually I will be processing video from a camera, the access should be as fast as possible by using the GPU. The first step was to build a tool chain and cross compiler to get things working, and then make a test application that uses the Multi-Media Abstraction Layer (mmal) library to access the VideoCore (VC) pipeline. I followed these two articles on how to use crosstool-ng to make a crosscompiler for the Pi. The next step was to make a simple application with some hooks into mmal and link it against the mmal libraries. It turns out the easiest way to build the mmal libraries is to clone the userland code for the Pi and build it locally using your new crosscompiler. I modified the cmake file in the makefile/cmake/toolchain/ directory to point to my custom crosstool-ng compiler rather than the compiler from git (Here are my modified buildme and cmake files).
Everything built successfully and the final step was to add in some mmal variables and function calls and build against the mmal libraries. This was more of a pain than I thought it was going to be. There are like 6 libraries that need to be preferences and 5 include paths for the VideoCore and mmal paths. After a few hours of searching and trial and error I found the correct include paths and library paths for GCC and the linker. One really annoying part was the fact that you have to explicitly add ALL libraries to the ld command, even if they are dependencies of libraries and the .so file is in the same directory as an already linked .so file. Take a look at this image and you will get the idea, all was fixed when I added -l entries for each missing lib. Here is what you need to build and link against if you want to access the camera on the Pi via mmal using VideoCore.
Include paths:
-I ../userland/
-I ../userland/build/inc/interface/vcos/
-I ../userland/host_applications/linux/apps/raspicam/
-I ../userland/host_applications/linux/libs/bcm_host/include/
-I ../userland/interface/vmcs_host/linux/
-I ../userland/interface/vcos/pthreads/
-I ../userland/interface/vcos/
Library include path:
-L ../userland/build/lib
Libraries to link:
-lmmal_core
-lmmal
-lmmal_util
-lvcos
-lcontainers
-lbcm_host
-lmmal_vc_client
-lmmal_components
-lvchiq_arm
Hi,
I am also going throught RaspiStill application.
I want to debug how mmal communicating with VideoCore.
But I am not able to find which driver mmal is communicating with.
So can you share some thing about How mmal communicating with GPU?
Or how any camera send image to mmal?