WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Camera Module  (Read 15422 times)

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Camera Module
« on: January 08, 2015, 07:53:52 PM »
I got the Raspberry Pi camera module a couple of days ago and I'm somewhat confused on how to enable it in piCore or even if it will work at all.  Most of the camera setup guides are for Raspbian which have you select "enable camera" through raspi-config which is great for Raspbian but I'm not sure what that's actually doing which makes it a bit difficult to translate to piCore.

Is it loading the V4L2 kernel modules??  Is that what's needed for the camera or is that just one of several options?
Is it possible to grab kernel modules from the 3.12.35 Raspberry Pi github area and get them to work properly with piCore of the same kernel version?  Of course I have tried and failed but is it possible and I'm just not packaging them correctly or should I stop trying??  The version magics are different on them I guess even though the kernel version is the same?

I think that the raspistill / raspivid utils are not in the piCore repo is that true?

Sorry for the poorly worded post, I guess I'm just not "getting it" and I'm not even sure what questions to ask.  If someone can point me in the right direction I'd appreciate it.

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #1 on: January 09, 2015, 04:51:08 AM »
Looks like all raspi-config does is edit config.txt which I already did manually based on the Arch wiki.

raspi-config section:

Code: [Select]
# $1 is 0 to disable camera, 1 to enable it
set_camera() {
  # Stop if /boot is not a mountpoint
  if ! mountpoint -q /boot; then
    return 1
  fi

  [ -e /boot/config.txt ] || touch /boot/config.txt

  if [ "$1" -eq 0 ]; then # disable camera
    set_config_var start_x 0 /boot/config.txt
    sed /boot/config.txt -i -e "s/^startx/#startx/"
    sed /boot/config.txt -i -e "s/^start_file/#start_file/"
    sed /boot/config.txt -i -e "s/^fixup_file/#fixup_file/"
  else # enable camera
    set_config_var start_x 1 /boot/config.txt
    CUR_GPU_MEM=$(get_config_var gpu_mem /boot/config.txt)
    if [ -z "$CUR_GPU_MEM" ] || [ "$CUR_GPU_MEM" -lt 128 ]; then
      set_config_var gpu_mem 128 /boot/config.txt
    fi
    sed /boot/config.txt -i -e "s/^startx/#startx/"
    sed /boot/config.txt -i -e "s/^fixup_file/#fixup_file/"
  fi
}

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #2 on: January 09, 2015, 12:59:47 PM »
Found this write-up for using the camera on piCore 5.3.1.  I've already done the config.txt edits based on the arch wiki so I guess what I need next is the rpi-videocore.tcz for 6.x.  I will attempt to create it myself.

I think if I want to use video utils other than the raspistill/raspivid etc rpi-videocore.tcz then that's where I'll need the v4l2 modules.  Not sure though.

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #3 on: January 09, 2015, 10:48:30 PM »
I guess I got this working.  Raspistill seems to work, haven't tested anything else.  I compiled raspicam using the sources from the userland Raspberry Pi github location.

I cobbled together an extension for it if anyone wants to try it. I'm fairly sure it doesn't follow the extension guidelines *at all* but it does seem to load and work so I guess that's better than nothing.

You have to chmod 777 /dev/vchiq or use sudo. 

Code: [Select]
tc@box:~$ raspistill -v

raspistill Camera App v1.3.8

Width 2592, Height 1944, quality 85, filename (null)
Time delay 5000, Raw no
Thumbnail enabled Yes, width 64, height 48, quality 35
Link to latest frame enabled  no
Full resolution preview No
Capture method : Single capture

Preview Yes, Full screen Yes
Preview window 0,0,1024,768
Opacity 255
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
Camera component done
Encoder component done
Starting component connection stage
Connecting camera preview port to video render.
Connecting camera stills port to encoder input port
Closing down
Close down completed, all components disconnected, disabled and destroyed

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Camera Module
« Reply #4 on: January 09, 2015, 11:10:15 PM »
Complete set of kernel modules available here:

http://tinycorelinux.net/6.x/armv6/release/src/kernel/

You can find modules if you need any.

Also I will get a camera next week to try.
« Last Edit: January 10, 2015, 12:08:30 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #5 on: January 10, 2015, 06:25:25 AM »
Thanks a lot bmarkus, I think I'll need the v4l2 modules if I want to use apps other than the raspicam ones.
I'm anxious for you to get your camera so that I can see the right way to set it up :)

This is a wrap-up of what I did:

- Add to config.txt:
gpu_mem=128
start_file=start_x.elf
fixup_file=fixup_x.dat

- Compiled the raspicam binaries using the github userland repo, followed bits and pieces of this write-up.

- Bundled up the result into raspicam.tcz

- From a fresh boot:

Code: [Select]
tc@box:~$ uname -a
Linux box 3.12.35-piCore+ #1 PREEMPT Mon Dec 29 17:24:10 CET 2014 armv6l GNU/Linux
tc@box:~$ raspistill
-sh: raspistill: not found
tc@box:~$ tce-load -i raspicam.tcz
raspicam.tcz: OK
tc@box:~$ raspistill
* failed to open vchiq instance
tc@box:~$ sudo chmod 777 /dev/vchiq
tc@box:~$ raspistill
raspistill Camera App v1.3.8 [remaining output omitted]
tc@box:~$ raspistill -vf -hf -o test.jpg

Need to create a properly compiled and formatted extension for the raspicam utilities for 6.x.  You called it rpi-videcore.tcz for 5.x? Then add to onboot.lst and fix the /dev/vchiq permissions on boot (not sure what the best solution for that is).

Attached is a sample pic that I resized for upload.

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #6 on: January 11, 2015, 07:22:01 AM »
Is there a rule about replying to your own post over and over again?  :-\

Wanted to add that I noticed that the permissions on the /dev/vchiq device were back to 600 after some time had passed which gives you an error without sudo:

Code: [Select]
tc@box:~$ raspistill
* failed to open vchiq instance
tc@box:~$ uptime
 14:57:49 up 21:54,  2 users,  load average: 0.00, 0.01, 0.04

I know by the uptime that a reboot had not happened since I last did a chmod to /dev/vchiq.  Does udevd periodically check permissions based on the rules and reset them if they are wrong?

Is this even a problem or should I just prefix the commands with sudo and move on?  It seems other people are using root:video 660 on /dev/vchiq and adding the user to the video group.
« Last Edit: January 11, 2015, 07:29:01 AM by sodface »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Camera Module
« Reply #7 on: January 11, 2015, 07:35:05 AM »

Is this even a problem or should I just prefix the commands with sudo and move on?  It seems other people are using root:video 660 on /dev/vchiq and adding the user to the video group.

There are no video group in piCore.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline andyj

  • Hero Member
  • *****
  • Posts: 1021
Re: Camera Module
« Reply #8 on: January 24, 2015, 06:42:26 PM »
I loaded raspicam.tcz in 6.0 and chmod'ed /dev/vchiq, but I get this with raspistill -v:

raspistill Camera App v1.3.8

Width 2592, Height 1944, quality 85, filename (null)
Time delay 5000, Raw no
Thumbnail enabled Yes, width 64, height 48, quality 35
Link to latest frame enabled  no
Full resolution preview No
Capture method : Single capture

Preview Yes, Full screen Yes
Preview window 0,0,1024,768
Opacity 255
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not enabled in this build. Try running "sudo raspi-config" and ensure that "camera" has been enabled

I saw that MMAL is required somehow, but it didn't seem to be with the extension so do I need to get and compile it or is there an easier fix? I have a fully compiled kernel tree if needed.

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #9 on: January 24, 2015, 08:58:56 PM »
Did you double check your ribbon cable connections?  You did the edits to config.txt?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1021
Re: Camera Module
« Reply #10 on: January 25, 2015, 05:47:07 AM »
The connections looked OK but I reseated them anyway. That must have been it, because it's working now. It's kinda slow when taking a picture. Is that normal?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1072
Re: Camera Module
« Reply #11 on: January 25, 2015, 03:50:02 PM »
Taking pictures and writing to disk is quite slow. 

Offline sodface

  • Jr. Member
  • **
  • Posts: 90
Re: Camera Module
« Reply #12 on: January 25, 2015, 05:30:53 PM »
The connections looked OK but I reseated them anyway. That must have been it, because it's working now. It's kinda slow when taking a picture. Is that normal?

As I understand it, raspistill by default actually activates the camera and takes video for 5 seconds and then the "still" is the last frame of the video, which is the only part that's saved.  You can adjust the time with the -t option.

Offline andyj

  • Hero Member
  • *****
  • Posts: 1021
Re: Camera Module
« Reply #13 on: January 25, 2015, 08:29:13 PM »
What I would really like is to have the camera always running and saving the last few seconds of video in a loop so when I "click" I get a second before and after. I just got the camera yesterday and I was out of town most of today so I haven't had much of a chance to play with it.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1072
Re: Camera Module
« Reply #14 on: January 26, 2015, 08:59:22 AM »
What I would really like is to have the camera always running and saving the last few seconds of video in a loop so when I "click" I get a second before and after. I just got the camera yesterday and I was out of town most of today so I haven't had much of a chance to play with it.

That will kill an SD card quickly.   Why not just stream the video?