5

I have Ubuntu 14 installed on my Raspberry Pi 2, and I'm trying to access the camera, but all the instructions assume raspistill is available, but that only seems to be compiled for Raspbian. How do you access the Raspberry Pi camera from Ubuntu?

4

I seem to be the only person in the entire world who wants to use a regular Linux distro on the RPi, since I could find very little documentation on how to setup the camera from scratch, but in case someone else wants to use the Raspberry Pi camera on Ubuntu or any other distro besides Raspbian, here's how you do it.

  1. Enable kernel/firmware settings required by the camera:

    sudo bash -c "echo 'start_x=1' >> /boot/config.txt"
    sudo bash -c "echo 'gpu_mem=128' >> /boot/config.txt"
    

    Note, in the Ubuntu ARM image I used, these settings didn't exist in /boot/config.txt, so I can simply append them. If you've already added the variables, but with different values, you may need to edit them instead of appending.

  2. Install rpi-update and update the firmware

    If you're using a brand-new RPi, you'll almost certainly need to update the firmware, because whatever the factory installs is ancient:

    curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update && chmod +x /usr/bin/rpi-update
    sudo rpi-update
    

    Note, without these step, I was getting the infamous error:

    mmal: mmal_component_create_core: could not find component 'vc.ril.camera'
    mmal: Failed to create camera component
    mmal: main: Failed to create camera component
    mmal: Failed to run camera app. Please check for firmware updates
    
  3. Install userland binaries (e.g. raspistill):

    git clone https://github.com/raspberrypi/userland.git
    cd userland
    ./buildme
    touch ~/.bash_aliases
    echo -e 'PATH=$PATH:/opt/vc/bin\nexport PATH' >> ~/.bash_aliases
    echo -e 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib\nexport LD_LIBRARY_PATH' >> ~/.bash_aliases
    source ~/.bashrc
    ldconfig
    
  4. Give non-root users access to the camera device:

    echo 'SUBSYSTEM==\"vchiq\",GROUP=\"video\",MODE=\"0660\"' > /etc/udev/rules.d/10-vchiq-permissions.rules
    usermod -a -G video ubuntu
    

    Without these, I was getting the error:

    failed to open vchiq instance
    
  5. Reboot to make all changes take effect

    sudo reboot now
    

After these steps, raspistill -o cam.jpg correctly captured video input for me on a Raspberry Pi 2 running Ubuntu 14.04.

  • Quick question: which Ubuntu variant was this on, the Ubuntu MATE environment, Ubuntu Snappy Core, or something else? I'm interested as I should probably link to this from the picamera FAQ (I can imagine this might come up a bit in the future) – Dave Jones Oct 18 '15 at 8:11
  • @DaveJones, I'm using the community-maintained image of Ubuntu 14.04.2 LTS built specifically for the Raspberry Pi. wiki.ubuntu.com/ARM/RaspberryPi – Cerin Oct 18 '15 at 13:47
  • i am sorry to bother but did you mean sudo bash -c "echo 'start_x=1' >> /boot/config.txt" instead of sudo base -c "echo 'start_x=1' >> /boot/config.txt" ? – Shuoyuan Xu Feb 26 '17 at 14:43
  • @ShuoyuanXu, Yep, good catch. – Cerin Feb 26 '17 at 21:04
  • 1
    You can skip #3 and just use the VideoCore packages: sudo add-apt-repository ppa:ubuntu-raspi2/ppa; sudo apt-get install libraspberrypi-bin libraspberrypi-dev See wiki.ubuntu.com/ARM/RaspberryPi#VideoCore – Greg Bray Jun 30 '18 at 22:03
1

On a new Raspberry Pi 3 with Ubuntu Mate 16.04.2 installed all I needed to do was:

sudo rpi-update
sudo raspi-config
#Select 3 Interface Options then P1 to enable the camera
shutdown -r now

When it restarted both raspistill and cheese started working (after making sure the resolution was adjusted to something smaller).

0

As per this forum thread, most likely path is not being setup. You can check if utility is installed perfectly by checking sudo /opt/vc/bin/raspistill -o output.jpg. If it works perfectly, you need to add /opt/vc/bin location to path as it is not included by default in ubuntu.

How to do it ?

export PATH=$PATH:/path/to/dir

where, /path/to/dir in this case is /opt/vc/bin.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.