https://www.olimex.com/wiki/index.php?title=STK1160-howto-linux-sunxi-3_4&feed=atom&action=historySTK1160-howto-linux-sunxi-3 4 - Revision history2024-03-29T05:37:26ZRevision history for this page on the wikiMediaWiki 1.32.0https://www.olimex.com/wiki/index.php?title=STK1160-howto-linux-sunxi-3_4&diff=1221&oldid=prevDimitarTomov: Added ./build --check to media_build part2014-06-04T09:33:50Z<p>Added ./build --check to media_build part</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 09:33, 4 June 2014</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l136" >Line 136:</td>
<td colspan="2" class="diff-lineno">Line 136:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>git clone --depth=1 git://linuxtv.org/media_build.git<br/></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>git clone --depth=1 git://linuxtv.org/media_build.git<br/></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>cd media_build<br/></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>cd media_build<br/></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">./build --check<br/></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></code></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">Install missing packages showed from ./build --check and then continue<br/></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><code></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>patch -p1 < /path/to/media_build-makefilepl.patch<br/></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>patch -p1 < /path/to/media_build-makefilepl.patch<br/></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>make download<br/></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>make download<br/></div></td></tr>
<!-- diff cache key olimex-wiki_:diff::1.12:old-1220:rev-1221 -->
</table>DimitarTomovhttps://www.olimex.com/wiki/index.php?title=STK1160-howto-linux-sunxi-3_4&diff=1220&oldid=prevDimitarTomov: Initial version2014-06-04T08:54:46Z<p>Initial version</p>
<p><b>New page</b></p><div><br />
<br/><br />
STK1160 is the new kernel driver for Easycap like USB AV capture devices.<br/><br />
It is available in the linux kernel from version 3.7 and above, but linux-sunxi <br/><br />
stable kernel is 3.4 . So this driver does not exist native in that kernel.<br />
<br />
__TOC__<br />
<br />
== Why use stk1160 instead of the old driver easycap ? ==<br />
<br/><br />
One main reason: You can change input channel on your device.<br/><br />
<br />
If you have the single channel version you also have and a S-video input. But<br/><br />
with easycap driver you can't switch to that input. The input selection is not<br/><br />
supported by the easycap driver and you will be always on default input 0.<br />
<br />
If you have the four channel version you have four AV channels and most likely<br/><br />
you will want to be able to switch between channels. Again old easycap driver<br/><br />
does not have that functionality.<br />
<br />
NB: If you don't need changing the input channel you can use the old easycap<br/><br />
driver and there is one benefit: easycap supports two framerate modes: 5 and 25<br/><br />
fps by selecting the proper norm. For example there is norm PAL_BGHN and norm<br/><br />
PAL_BGHN_SLOW, which is the 5 fps mode. And on SBCs this framelimit relieve the<br/><br />
CPU a little bit as the capture streams only five frames per second. The stk1160<br/><br />
supports currently only 25 fps mode.<br />
<br />
== What do You need before starting ==<br />
<br/><br />
Kernel source.<br/><br />
Config file from your current kernel.<br/><br />
Compiler for the cross compilation.<br/><br />
<br />
=== Getting the kernel source ===<br />
<br/><br />
For the latest stable linux-sunxi 3.4.xx kernel the command is:<br />
<br />
<code><br />
git clone -b sunxi-3.4 --depth 1 https://github.com/linux-sunxi/linux-sunxi.git<br />
</code><br />
<br />
Wait for the download process to finish.<br />
<br />
=== Getting the config file from your current kernel ===<br />
<br/><br />
While on the device copy the /proc/config.gz to your build machine,<br/><br />
then use gunzip to extract and you now have your current kernel config.<br />
<br />
=== Getting compiler for the cross compilation ===<br />
<br/><br />
On Debian add to your /etc/apt/sources.list<br />
<br />
<code><br />
deb http://www.emdebian.org/debian unstable main<br />
</code><br />
<br />
then<br />
<br />
<code><br />
apt-get update<br/><br />
apt-get install gcc-4.7-arm-linux-gnueabihf<br />
</code><br />
<br />
Now you have compiler for the cross compilation.<br />
<br />
== Compiling stk1160 ==<br />
<br/><br />
The stk1160 will be build using backported version provided by media_build, more<br/><br />
info about media_build you can find at the following link:<br />
<br />
http://www.linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers<br />
<br />
But for this to work you need to build a new kernel with V4L support as modules,<br/><br />
so you can load the new V4L core from media_build and also patch dma-buf.c/.h in<br/><br />
the kernel tree, because of a missing function there.<br />
<br />
Lets get to work ...<br />
<br />
Will assume that you have your kernel source tree in ~/linux-sunxi, also that<br/><br />
you have already copied your current kernel config like ~/linux-sunxi/.config .<br />
<br />
=== Preparing the build environment ===<br />
<br/><br />
<code><br />
export CROSS_COMPILE=arm-linux-gnueabihf-<br/><br />
export ARCH=arm<br />
</code><br />
<br />
=== Patching the kernel tree: ===<br />
<br/><br />
The patch is available at:<br />
<br />
https://drive.google.com/file/d/0B6S44jnEBxzyQVhUNDFlQ2RnRUU/edit?usp=sharing<br />
<br />
Download and execute the following commands:<br />
<br />
<code><br />
cd ~/linux-sunxi<br/><br />
patch -p0 < /path/to/dma-buf-vmap.patch<br />
</code><br />
<br />
=== Building the new kernel with V4L core as modules ===<br />
<br/><br />
<code><br />
make silentoldconfig<br/><br />
make menuconfig<br />
</code><br />
<br />
Go to Device Drivers -> Multimedia support and mark Video for Linux with m.<br />
Exit and choose to save the changes to the config.<br />
Based on your build machine use -j with value #threads your CPU is capable,<br />
example values: dual-core no HT -j2, dual-core with HT -j4 and so on.<br />
<br />
<code><br />
make -j4 uImage<br/><br />
make -j4 INSTALL_MOD_PATH=out modules<br/><br />
make -j4 INSTALL_MOD_PATH=out modules_install<br />
</code><br />
<br />
The uImage file is located in linux-sunxi/arch/arm/boot/<br />
The kernel modules are located in linux-sunxi/out/lib/modules/3.x.xx+<br />
<br />
'''Do not rush to update your kernel and modules on your sd-card or nand.'''<br />
<br />
=== Building media_build ===<br />
<br/><br />
Download this patch for media_build:<br />
<br />
https://drive.google.com/file/d/0B6S44jnEBxzydGlELXl4S3I2dzg/edit?usp=sharing<br />
<br />
First we will go up one level to home dir as we were in ~/linux-sunxi, then<br/><br />
get latest media_build source and build it.<br />
<br />
<code><br />
cd ..<br/><br />
git clone --depth=1 git://linuxtv.org/media_build.git<br/><br />
cd media_build<br/><br />
patch -p1 < /path/to/media_build-makefilepl.patch<br/><br />
make download<br/><br />
make untar<br/><br />
make prepare<br/><br />
DIR=~/linux-sunxi make release<br/><br />
nano v4l/Makefile<br />
</code><br />
<br />
find and comment out the line<br />
<br />
<code><br />
-include $(obj)/Makefile.sound<br />
</code><br />
<br />
because sound modules require PCI support, which sunxi doesn't have<br />
<br />
<code><br />
nano v4l/.version<br />
</code><br />
<br />
append to the lines starting with<br />
<br />
<code><br />
SUBLEVEL:=...<br/><br />
KERNELRELEASE:=...<br />
</code><br />
<br />
one plus sign at the end as the kernel versions of linux-sunxi 3.4 stable are<br/><br />
in format 3.4.xx+ , but media_build for some reason omits the + .<br />
<br />
<code><br />
mv v4l/.config v4l/.config.orig<br/><br />
nano v4l/.config<br />
</code><br />
<br />
Insert the following:<br />
<br />
<code><br />
CONFIG_VIDEO_DEV=m<br/><br />
CONFIG_VIDEO_V4L2_COMMON=m<br/><br />
CONFIG_VIDEO_MEDIA=m<br/><br />
CONFIG_VIDEO_V4L2=m<br/><br />
CONFIG_VIDEOBUF_GEN=m<br/><br />
CONFIG_VIDEOBUF_DMA_CONTIG=m<br/><br />
CONFIG_DMA_SHARED_BUFFER=m<br/><br />
CONFIG_VIDEOBUF2_CORE=m<br/><br />
CONFIG_VIDEOBUF2_MEMOPS=m<br/><br />
CONFIG_VIDEOBUF2_VMALLOC=m<br/><br />
CONFIG_VIDEO_CAPTURE_DRIVERS=y<br/><br />
CONFIG_V4L_MEM2MEM_DRIVERS=y<br/><br />
CONFIG_V4L_PLATFORM_DRIVERS=y<br/><br />
CONFIG_VIDEO_SAA711X=m<br/><br />
CONFIG_VIDEO_STK1160_AC97=n<br/><br />
CONFIG_VIDEO_STK1160=m<br/><br />
CONFIG_VIDEO_STK1160_COMMON=m<br />
</code><br />
<br />
Save and exit. This is a stripped media_build configuration for stk1160 only.<br/><br />
'''NB: For audio support for your capture change CONFIG_VIDEO_STK1160_AC97 to y.'''<br />
<br />
<code><br />
make -j4<br/><br />
DESTDIR=~/linux-sunxi/out make install<br />
</code><br />
<br />
== Installing the new kernel and modules ==<br />
<br/><br />
Now you have the kernel and updated modules with the new V4L core and stk1160.<br/><br />
Copy from ~/linux-sunxi/arch/arm/boot/uImage to your /boot folder on the device.<br/><br />
Then copy the modules folder /linux-sunxi/out/lib/modules/3.x.xx+ to the device.<br />
<br />
'''Blacklisting the old easycap driver:'''<br/><br />
While on the device create /etc/modprobe.d/easycap-blacklist.conf and add:<br />
<br />
<code><br />
blacklist easycap<br />
</code><br />
<br />
Save and exit<br />
<br />
Reboot the device and all should be ok.<br />
<br />
== Testing ==<br />
<br/><br />
Insert the capture, check with lsmod for stk1160, check dmesg for any warnings,<br/><br />
errors, unresolved symbols, etc, there should be none. Check if video device was<br/><br />
created under /dev/video0 or /dev/videoX if you have more than one V4L device.<br/><br />
<br />
'''PAL norm is at number 5, by default stk1160 is configured for NTSC.'''<br/><br />
<br />
== Known issues ==<br />
<br/><br />
Sometimes you can see in dmesg warning from videobuf2-core.c, but this does not<br/><br />
effect the capturing or streaming. I have not found the reason for the warning,<br/><br />
but as it is not problematic I have left it for now.<br/><br />
<br />
'''Good luck and happy capturing using stk1160 :-)'''</div>DimitarTomov