Beagleboard XM + LI-5M03 (mt9p031)

Hi,

Sorry for bothering you with this, but I can’t find information on it, so I came here looking for help.

I can run the LI-5M03 camera in a BBxm using Robert Nelson’s ubuntu 13.04 (kernel 3.7.10-x13), but with a very small frame rate (~5 fps). Is there a way to improve the frame rate to about 15/20 fps? Is there a problem in the driver? I tried different resolutions (1024x768, 640x480, etc) and different viewers (mplayer, vlc) and nothing seems to change the fps. Thanks in advance for any insight about this.

best regards,
Pedro

Tengo el mismo problema; pero además no puedo ver nada; solo una imagen amarilla y negra.

To translate what Jose Rubio said in spanish:

“Tengo el mismo problema; pero además no puedo ver nada; solo una imagen amarilla y negra.”
“I have the same problem; I also can’t see anything; just a yellow and black image.”

Dear people,

Finally I have the camera working with a decent frame rate (640x480@14 fps), so I write this in the hope that will be usefull to others.

Special thanks to Robert Nelson and Laurent Pinchart for their time to answer my questions. I really appreciate their help.

Hardware:
BeagleBoard xm Rev. C1 powered from the +5V jack
LI-5M03 camera board (mt9p031)

Software:
Robert Nelson’s ubuntu image 2013-07-22
mplayer + menconder

  1. Install image as instructed in http://elinux.org/BeagleBoardUbuntu#Demo_Image

  2. Modify uEnv.txt to setup the display and to enable the camera. I have a DVI to VGA adapter, so my setup is

dvimode=1024x768-16@60

camera=li5m03

  1. If you need to configure the keyboard for other language, you can do that with “sudo dpkg-reconfigure keyboard-configuration”

  2. Boot the board and install network (wired or wireless)

  3. Install lxde desktop

  4. run aptina-media-ctl-n-yavta.sh and aptina-test-capture.sh

  5. test in the BBxm webserver that a .jpg image from the camera is available

  6. Install mplayer: “sudo apt-get install mplayer”

  7. Test video from the camera with this script:
    Script to see video on the screen
    #! /bin/bash
    set DISPLAY=:0
    sudo media-ctl -r -l ‘“mt9p031 2-0048”:0->“OMAP3 ISP CCDC”:0[1], “OMAP3 ISP CCDC”:2->“OMAP3 ISP preview”:0[1], “OMAP3 ISP preview”:1->“OMAP3 ISP resizer”:0[1], “OMAP3 ISP resizer”:1->“OMAP3 ISP resizer output”:0[1]’
    sudo media-ctl -f ‘“mt9p031 2-0048”:0 [crop:(16,54)/640x480 fmt:SGRBG10/640x480], “OMAP3 ISP CCDC”:2 [SGRBG10 640x480], “OMAP3 ISP preview”:1 [UYVY 640x480], “OMAP3 ISP resizer”:1 [UYVY 640x480]’
    sudo mplayer tv:// -tv driver=v4l2:device=/dev/video6:outfmt=uyvy:width=640:height=480 -vo x11

  8. Install mencoder: “sudo apt-get install mencoder”

  9. Test video recording and file playing with these scripts
    Script to record video to file
    #! /bin/bash
    set DISPLAY=:0
    sudo media-ctl -r -l ‘“mt9p031 2-0048”:0->“OMAP3 ISP CCDC”:0[1], “OMAP3 ISP CCDC”:2->“OMAP3 ISP preview”:0[1], “OMAP3 ISP preview”:1->“OMAP3 ISP resizer”:0[1], “OMAP3 ISP resizer”:1->“OMAP3 ISP resizer output”:0[1]’
    sudo media-ctl -f ‘“mt9p031 2-0048”:0 [crop:(16,54)/640x480 fmt:SGRBG10/640x480], “OMAP3 ISP CCDC”:2 [SGRBG10 640x480], “OMAP3 ISP preview”:1 [UYVY 640x480], “OMAP3 ISP resizer”:1 [UYVY 640x480]’
    sudo mencoder tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video6:fps=20:outfmt=uyvy -nosound -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1000 -ffourcc xvid -o ./output.avi

Script to play video
#! /bin/bash
mplayer ./output.avi -vo x11

Technical notes:
The media-ctl commands are needed only once to configure the camera subsystem, they can be moved to their own configuration script also. I added them to every script for testing purposes only.

The camera can play around 5/7 fps out of the box. The problem seems to be that the I/O voltage of the leopard camera must be 2.8 volts to get tha maximun throughput, but in beagleboard the I/O voltage is 1.8 volts, so the internal PLL of the camera must be set to half of the frequency (48MHz instead of 96MHz with 2.8 volts).
With that setting, the maximun fps for 2592x1944 will be aprox. 8 fps. Someone said in the beagleboard list that with camera overclocking it is possible to get 27 fps for one special resolution [1].
So, to get a better frame rate without recompiling, is necessary to crop the image to a lower resolution. That is done with the [crop: ] options.

To increase the pixel clock, is not so easy:
The camera subsystem is a part of the omap SoC and need a clock to be synchronized with the rest of the Soc, this clock is the fuctional clock (CAM_FCLK), the mt9p031 chip in leopart imaging board needs a clock to be sinchronized with the camera subsystem, this is the external clock to the image sensor (CAM_XCLKA), and there is a third clock, that the image sensor sends to the camera subsystem for the pixel stream (CAM_PCLK).

I believe that the software names for those clocks are:

CAM_PCLK:
mt9p031 → pll.pix_clk (mt9p031.c)
beagle_mt9p031_platform_data.target_freq (board-omap3beagle.c)

CAM_XCLKA:
mt9p031 → pll.ext_clk (mt9p031.c)
beagle_mt9p031_platform_data.ext_freq (board-omap3beagle.c)

CAM_FCLK:
isp_device.clock[1] (#define ISP_CLK_CAM_MCLK 1) in isp.h (I didn’t found yet where this struct is filled to check the value of CAM_FCLK)

In the dm3730 Technical Reference Manual (http://www.ti.com/product/dm3730), on page 1133, it states:

“Functional clock domain, this clock is from L3 interconnect along with
Interface master write port clock. It is required to be 2x faster than the
pixel clock.”

So, to change CAM_PCLK from 48MHz to 96MHz, is necessary to check that CAM_FCLK is greater than 192MHz. I didn’t find the place to do that yet.

I am using a dvi to vga adapter based on the LT8511A ic, but it seems that this chip needs a little bit more than 100mA, so the PTC RXEF010 on the BBxm is triggered, cutting the DVI_+5V and shutting down the adapter. So in the boot process, before loading plymount, the current seems to be less than 100mA, and the adapter works. After loading plymounth, there is a inrush current that triggers the PTC and disables the adapter. So what it looks like a software related issue between the adapter and the boot process, is a hardware issue solved shortcircuiting the PTC

Hope that helps,
Pedro

[1] http://markmail.org/message/3h3zviiokgywwzcg?q=Add+driver+for+Aptina+Micron+mt9p031+sensor+list:com.googlegroups.beagleboard+from:"ozkannn01%40gmail.com"&page=1