<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>twam.info &#187; Linux</title>
	<atom:link href="http://www.twam.info/category/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://www.twam.info</link>
	<description>My computer, physics, electronics &#38; photography blog</description>
	<lastBuildDate>Wed, 25 Jan 2012 20:49:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>v4l2grab Version 0.2</title>
		<link>http://www.twam.info/linux/v4l2grab-version-02</link>
		<comments>http://www.twam.info/linux/v4l2grab-version-02#comments</comments>
		<pubDate>Tue, 09 Jun 2009 17:33:28 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[twam.info]]></category>
		<category><![CDATA[V4L2]]></category>
		<category><![CDATA[WebCam]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=520</guid>
		<description><![CDATA[A few weeks ago, I published my v4l2grab program to grab JPEGs from V4l2 devices. Today I got an request by email to include support for integer conversion from YUV422 to RGB as descriped by Wikipedia. So I included it and did some style adjustments, too. You can download it here: v4l2grab Version 0.2 To use [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I published my <a href="http://www.twam.info/linux/v4l2grab-grabbing-jpegs-from-v4l2-devices">v4l2grab</a> program to grab JPEGs from V4l2 devices.</p>
<p>Today I got an request by email to include support for integer conversion from YUV422 to RGB as descriped by <a href="http://en.wikipedia.org/wiki/YUV#Converting_from_Y.27UV_to_RGB">Wikipedia</a>. So I included it and did some style adjustments, too.</p>
<p>You can download it here: <a href="http://www.twam.info/wp-content/uploads/2009/06/v4l2grab.c">v4l2grab Version 0.2<span id="more-520"></span></a></p>
<p>To use integer conversion you have to compile with an additional</p>
<pre>-DNTSC</pre>
<p>for NTSC like conversion or</p>
<pre>-DITU_R_INT</pre>
<p>for ITU-R integer conversion. Both standars are explained in the referenced wikipedia article. The use of</p>
<pre>-DITU_R_FLOAT</pre>
<p>uses the previous floating point version of ITU-R which is default if no compiling options are specified. More information about compilation can be found on the <a href="http://www.twam.info/linux/v4l2grab-grabbing-jpegs-from-v4l2-devices">original post</a>.</p>
<p><strong>The current version of V4L2grab can be found on <a href="http://github.com/twam/v4l2grab/tree/master">github</a>.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/v4l2grab-version-02/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CHOST: i586 vs. i486 on AMD Geode LX</title>
		<link>http://www.twam.info/hardware/chost-i586-vs-i486-on-amd-geode-lx</link>
		<comments>http://www.twam.info/hardware/chost-i586-vs-i486-on-amd-geode-lx#comments</comments>
		<pubDate>Mon, 25 May 2009 18:27:01 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Alix]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ALIX.3D3]]></category>
		<category><![CDATA[CHOST]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=510</guid>
		<description><![CDATA[On my blog post about Installing Gentoo on ALIX.3D3 Mart Raudsepp made an interesting comment: He pointed out, that on AMD Geode CPUs it might be better to use i486 CHOST instead of my used i586, because the CPU is more like a i486 as far as instruction scheduling and times go. This sounded interesting, [...]]]></description>
			<content:encoded><![CDATA[<p>On my blog post about <a href="http://www.twam.info/linux/gentoo/installing-gentoo-on-alix3d3">Installing Gentoo on ALIX.3D3 </a>Mart Raudsepp made an interesting <a href="http://www.twam.info/linux/gentoo/installing-gentoo-on-alix3d3/comment-page-1#comment-67">comment</a>: He pointed out, that on AMD Geode CPUs it might be better to use i486 CHOST instead of my used i586, because the CPU is more like a i486 as far as instruction scheduling and times go.</p>
<p>This sounded interesting, so I googled for some benchmark test to measure differences. I found <a href="http://www.tux.org/~mayer/linux/bmark.html">nbench</a>, which measures performance by executing some typical algorithms and compares them to a Pentium 90 based system. So I installed it and run on the i586 CHOST system, then rebuild it completely to i486 CHOST and run it again.<span id="more-510"></span> The differences are not that huge, but on some algorithms they&#8217;re measurable:</p>
<p><a href="http://www.twam.info/wp-content/uploads/2009/05/i486_i586_comparison.png"><img class="aligncenter size-full wp-image-513" title="i486 &amp; i586 CHOST comparison" src="http://www.twam.info/wp-content/uploads/2009/05/i486_i586_comparison.png" alt="i486 &amp; i586 CHOST comparison" width="580" height="450" /></a></p>
<p>The first 13 bars are the different algorithms. The main difference is on the string sort, which is heavily memory dependent. That last 3 rows are a index based on the algorithms. Here is main difference on memory index, as the normalized version shows very clear (positive values mean that i486 is faster):</p>
<p><a href="http://www.twam.info/wp-content/uploads/2009/05/i486_i586_comparison_normalized.png"><img class="aligncenter size-full wp-image-514" title="i486 &amp; i586 CHOST comparison (normalized)" src="http://www.twam.info/wp-content/uploads/2009/05/i486_i586_comparison_normalized.png" alt="i486 &amp; i586 CHOST comparison (normalized)" width="580" height="450" /></a></p>
<p>As there is no significant disadvantage of the i486 CHOST, this seems to be the choice. <img src='http://www.twam.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If anybody has other (free) benchmarks to suggest, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/hardware/chost-i586-vs-i486-on-amd-geode-lx/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>GPIO on ALIX.3D3</title>
		<link>http://www.twam.info/linux/gpio-on-alix3d3</link>
		<comments>http://www.twam.info/linux/gpio-on-alix3d3#comments</comments>
		<pubDate>Sun, 17 May 2009 13:41:35 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Alix]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ALIX.3D3]]></category>
		<category><![CDATA[Kernel]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=497</guid>
		<description><![CDATA[The AMD CS5536 Geode companion on the ALIX.3D3 board has several general purpose input/output pins. Most of them have different functions as well, and there are some registers to set if they should be used as special function GPIO pins. The ALIX.3D3 uses 4 GPIO pins for 3 LEDs and 1 mode switch. Accessing the [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.amd.com/us-en/ConnectivitySolutions/ProductInformation/0,,50_2330_9863_13022,00.html">AMD CS5536</a> Geode companion on the ALIX.3D3 board has several general purpose input/output pins. Most of them have different functions as well, and there are some registers to set if they should be used as special function GPIO pins. The ALIX.3D3 uses 4 GPIO pins for 3 LEDs and 1 mode switch. <a href="http://www.twam.info/hardware/alix/leds-on-alix3d3">Accessing the leds</a> is very easy using the leds-alix2 driver, but they can be addressed as GPIO as well. There is already a driver for the GPIO pins in the kernel named cs5535_gpio.c, but it uses a non standard interface to communicate with kernel. So, I wrote a new kernel driver using the GPIO interface.<span id="more-497"></span></p>
<p>Installating is very easy: Download the patch (<a href="http://www.twam.info/wp-content/uploads/2009/05/gpio.patch">GPIO drivers for AMD CS5535/CS5536 (Kernel 2.6.30-rc6)</a>), patch it and compile the kernel:</p>
<pre>wget http://www.twam.info/wp-content/uploads/2009/05/gpio.patch -O /root/gpio.patch
cd /usr/src/linux
patch -p1 &lt; /root/gpio.patch</pre>
<p>Now run kernel configuration and select</p>
<pre>Device Drivers  ---&gt;
   [*] GPIO Support  ---&gt;
   [*]   /sys/class/gpio/... (sysfs interface)
   &lt;*&gt;   AMD CS5535/CS5536 (Geode Companion Device)</pre>
<p>Compile the kernel and reboot. If you go to <em>/sys/class/gpio</em> there should be a file name <em>gpiochip0</em>. Now we can enable some pins and test them. By</p>
<pre>echo 6 &gt; /sys/class/gpio/export</pre>
<p>we tell the kernel, that we want to use pin 6 from userspace. Pin 6 is connected to led. Now we configure pin 6 as an output by</p>
<pre>echo out &gt; /sys/class/gpio/GPIO6/direction</pre>
<p>Now we can toggle the values by</p>
<pre>echo 1 &gt; /sys/class/gpio/GPIO6/value
sleep 1
echo 0 &gt; /sys/class/gpio/GPIO6/value</pre>
<div id="attachment_501" class="wp-caption alignright" style="width: 147px"><a href="http://www.twam.info/wp-content/uploads/2009/05/alix_modeswitch.jpg"><img class="size-medium wp-image-501" title="ALIX.3D3: modeswitch pins" src="http://www.twam.info/wp-content/uploads/2009/05/alix_modeswitch-196x300.jpg" alt="ALIX.3D3: modeswitch pins" width="137" height="210" /></a><p class="wp-caption-text">ALIX.3D3: modeswitch pins</p></div>
<p>Notice, that the LED is connected to 3.3V, so setting value to 0 it will be lit. The other LEDs are connected to pin 25 &amp; pin 27. On pin 24 is a switch connected. We can read the value by enabling the pin, setting it as an input and reading the value:</p>
<pre>echo 24 &gt; /sys/class/gpio/export
echo in &gt; /sys/class/gpio/GPIO24/direction
cat /sys/class/gpio/GPIO24/value</pre>
<p>As the pin has an internal pull up, it will show 1 if the switch isn&#8217;t pressed or installed. If you press the switch or connect to the metal pins, it will result in 0.</p>
<p>Don&#8217;t forget to unexport all pins after when you&#8217;re done:</p>
<pre>echo 6 &gt; /sys/class/gpio/unexport
echo 24 &gt; /sys/class/gpio/unexport</pre>
<p><strong>Any feedback on the driver is welcome!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/gpio-on-alix3d3/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Updating BIOS on ALIX.3D3 within Linux</title>
		<link>http://www.twam.info/linux/updating-bios-on-alix3d3-within-linux</link>
		<comments>http://www.twam.info/linux/updating-bios-on-alix3d3-within-linux#comments</comments>
		<pubDate>Wed, 06 May 2009 18:45:10 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Alix]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ALIX.3D3]]></category>
		<category><![CDATA[BIOS]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=414</guid>
		<description><![CDATA[Usually BIOS updating means booting DOS and running a proprietary tool from the board vendor. A few days ago, coreboot&#8217;s flashrom 0.9 has realeased. It&#8217;s an open-source tool which supports program almost all flash chips used on x86 mainboards. Its compatibility list includes Geode™ CS5530/A, which can be found on the ALIX.3D3 board. So why not [...]]]></description>
			<content:encoded><![CDATA[<p>Usually BIOS updating means booting <a href="http://en.wikipedia.org/wiki/MS-DOS">DOS</a> and running a proprietary tool from the board vendor. A few days ago, coreboot&#8217;s <a href="http://www.coreboot.org/Flashrom">flashrom</a> 0.9 has <a href="http://www.coreboot.org/News#2009.2F05.2F04_flashrom_0.9.0_has_been_released">realeased</a>. It&#8217;s an open-source tool which supports program almost all flash chips used on x86 mainboards. Its compatibility list includes Geode™ CS5530/A, which can be found on the ALIX.3D3 board. So why not using flashrom to update ALIX.3D3 BIOS.</p>
<p><span id="more-414"></span>Sadly there is no ebuild for flashrom in portage, so Gentoo users (and maybe some other) have to build it on there own, but it&#8217;s quite easy. You need to install <a href="http://subversion.tigris.org/">subversion</a>, an open-source revision control system, first:</p>
<p>emerge -va subversion</p>
<p>As there is no portage package for flashrom, we need to install it somewhere. I installed it in /root/flashrom so it can be removed easily. You can achieve this by</p>
<pre>cd root
svn co svn://coreboot.org/flashrom/trunk flashrom
cd flashrom
make</pre>
<p>You can do an optional</p>
<pre>make install</pre>
<p>to install the binaries in /usr/local/sbin and install the man page. Now we should save our old BIOS. Running</p>
<pre>flashrom -r /root/bios_save.bin</pre>
<p>should display some info on the found chipset and flash chip:</p>
<pre>Calibrating delay loop... OK.
No coreboot table found.
Found chipset "AMD CS5536", enabling flash write... OK.
Found chip "AMIC A49LF040A" (512 KB) at physical address 0xfff80000.
Reading flash... done.</pre>
<p>If you have an image of the old installed BIOS you can check, if everything went right, by</p>
<pre>diff /root/bios_save.bin /root/bios_old.bin</pre>
<p>where /root/bios_old.bin is the old BIOS version, preferable found on the manufacturer&#8217;s website. Now we can update the BIOS. Download the new BIOS version (ALIX.3D3 can be found <a href="http://www.pcengines.ch/alix3d3.htm">here</a>) and run:</p>
<pre>flashrom -wv /root/bios_new.bin</pre>
<p>flashrom should print some information, a process status and after all a VERIFIED, if everything went right:</p>
<pre>Calibrating delay loop... OK.
No coreboot table found.
Found chipset "AMD CS5536", enabling flash write... OK.
Found chip "AMIC A49LF040A" (512 KB) at physical address 0xfff80000.
Flash image seems to be a legacy BIOS. Disabling checks.
Programming page: 0007 at address: 0x00070000
Verifying flash... VERIFIED.</pre>
<p>Now your BIOS should be updated. It&#8217;s time to plug (power) and pray.</p>
<p><strong>Update</strong>: After writing a <a href="http://bugs.gentoo.org/show_bug.cgi?id=268790">Gentoo Bug report</a>, there is now an <a href="http://packages.gentoo.org/package/sys-apps/flashrom">ebuild</a> in portage. You can install it by</p>
<pre>emerge -va flashrom</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/updating-bios-on-alix3d3-within-linux/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ethernet bonding with Linux and 802.3ad</title>
		<link>http://www.twam.info/linux/ethernet-bonding-with-linux-and-8023ad</link>
		<comments>http://www.twam.info/linux/ethernet-bonding-with-linux-and-8023ad#comments</comments>
		<pubDate>Wed, 06 May 2009 16:04:30 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network/Web]]></category>
		<category><![CDATA[Switch]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=402</guid>
		<description><![CDATA[Nowadays, most desktop mainboards provide more than one gigabit ethernet port. Connecting them both to the same switch causes most Linux distros by default to get a individual IP on each device and route traffic only on the primary device (based on device metric) or round-robin. A single connection always starts at one IP and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.twam.info/wp-content/uploads/2009/05/2nic_switch.png"><img class="alignright size-full wp-image-412" title="2 NIC + Switch" src="http://www.twam.info/wp-content/uploads/2009/05/2nic_switch.png" alt="2 NIC + Switch" width="117" height="87" /></a>Nowadays, most desktop mainboards provide more than one gigabit ethernet port. Connecting them both to the same switch causes most Linux distros by default to get a individual IP on each device and route traffic only on the primary device (based on device metric) or round-robin. A single connection always starts at one IP and so all traffic goes through one device, limiting maximum bandwidth to 1 GBit.</p>
<p>Here comes bonding (sometimes called (port) trunking or link aggregation) to play. It connects two ore more ethernet ports to one virtual port with only one MAC and so mostly one IP address. Wheres earlier only two hosts (with the same OS running) or two switches (from the same vendor) could be connected, nowadays there&#8217;s a standard protocol which makes it easy: <a href="http://en.wikipedia.org/wiki/Link_Aggregation_Control_Protocol#Link_Aggregation_Control_Protocol">LACP</a> which is part of <a href="http://en.wikipedia.org/wiki/802.3ad">IEEE 802.3ad</a>. <span id="more-402"></span>Linux supports difference bonding mechanisms including 802.3ad. To enable bonding at all there are some kernel settings needed:</p>
<pre>Device Drivers  ---&gt;
[*] Network device support  ---&gt;
&lt;*&gt;   Bonding driver support</pre>
<p>After compiling and rebooting, we need a userspace tool for configuring the virtual interface. It&#8217;s called ifenslave and provided with the Linux kernel. You can either compile it by hand</p>
<pre>/usr/src/linux/Documentation/networking
gcc -Wall -O -I/usr/src/linux/include ifenslave.c -o ifenslave
cp ifenslave /sbin/ifenslave</pre>
<p>or install it by emerge if you run <a href="http://www.gentoo.org">Gentoo Linux</a>:</p>
<pre>emerge -va ifenslave</pre>
<p>Now we can configure the bonding device, called bond0. Firstofall we need to set the 802.3ad mode and the MII link monitoring frequency by</p>
<pre>echo "802.3ad" &gt; /sys/class/net/bond0/bonding/mode
echo 100 &gt;/sys/class/net/bond0/bonding/miimon</pre>
<p>Now we can up the device and add some ethernet ports:</p>
<pre>ifconfig bond0 up
ifenslave bond0 eth0
ifenslave bond0 eth1</pre>
<p>Now bond0 is ready to be used. Run a dhcp client or set an IP by</p>
<pre>ifconfig bond0 192.168.1.2 netmask 255.255.255.0</pre>
<p>These steps are needed on each reboot. If you&#8217;re running gentoo, you can use baselayout for this. Add</p>
<pre>config_eth0=( "none" )
config_eth1=( "none" )
preup() {
	# Adjusting the bonding mode / MII monitor
	# Possible modes are : 0, 1, 2, 3, 4, 5, 6,
	#     OR
	#   balance-rr, active-backup, balance-xor, broadcast,
	#   802.3ad, balance-tlb, balance-alb
	# MII monitor time interval typically: 100 milliseconds
	if [[ ${IFACE} == "bond0" ]] ; then
		BOND_MODE="802.3ad"
		BOND_MIIMON="100"
		echo ${BOND_MODE} &gt;/sys/class/net/bond0/bonding/mode
		echo ${BOND_MIIMON}  &gt;/sys/class/net/bond0/bonding/miimon
		einfo "Bonding mode is set to ${BOND_MODE} on ${IFACE}"
		einfo "MII monitor interval is set to ${BOND_MIIMON} ms on ${IFACE}"
	else
		einfo "Doing nothing on ${IFACE}"
	fi
	return 0
}
slaves_bond0="eth0 eth1"
config_bond0=( "dhcp" )</pre>
<p>to your /etc/conf.d/net. I found this nice preup part in the <a href="http://www.gentoo-wiki.info/HOWTO_Setup_Bonded_ethernet_adapters">Gentoo Wiki Archive</a>.</p>
<p>Now you have to configure the other side of the link. You can either use a Linux box and configure it the same way or a 802.3ad-capable switch. I used an <a href="http://www.hp.com/rnd/products/switches/HP_ProCurve_Switch_1800_Series/overview.htm">HP Procurve 1800-24G</a> switch. You have to enable <a href="http://en.wikipedia.org/wiki/Link_Aggregation_Control_Protocol#Link_Aggregation_Control_Protocol">LACP</a> on the ports you&#8217;re connected:</p>
<p style="text-align: left;">
<div id="attachment_403" class="wp-caption aligncenter" style="width: 220px"><a href="http://www.twam.info/wp-content/uploads/2009/05/hp1800_lacp.png"><img class="size-medium wp-image-403" title="HP Procurve 1800-24G LACP Configuration" src="http://www.twam.info/wp-content/uploads/2009/05/hp1800_lacp-210x143.png" alt="HP Procurve 1800-24G LACP Configuration" width="210" height="143" /></a><p class="wp-caption-text">HP Procurve 1800-24G LACP Configuration</p></div>
<p>Now everything should work and you can enjoy a 2 GBits (or more) link. Further details can be found in the <a href="http://www.linuxfoundation.org/en/Net:Bonding">kernel documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/ethernet-bonding-with-linux-and-8023ad/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing scheduling parameters in Linux</title>
		<link>http://www.twam.info/linux/changing-scheduling-parameters-in-linux</link>
		<comments>http://www.twam.info/linux/changing-scheduling-parameters-in-linux#comments</comments>
		<pubDate>Mon, 04 May 2009 11:36:05 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Scheduling]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=369</guid>
		<description><![CDATA[Process scheduling within Linux is done by the kernel, following different aspects. Usually it&#8217;s goal is to share all resources fairly among all running processes. Sometimes, there&#8217;s a need to tell the kernel explicitly to prior some process, bind some process to a special CPU and so on. Changing process priorities is commonly known: nice [...]]]></description>
			<content:encoded><![CDATA[<p>Process scheduling within Linux is done by the kernel, following different aspects. Usually it&#8217;s goal is to share all resources fairly among all running processes.</p>
<p>Sometimes, there&#8217;s a need to tell the kernel explicitly to prior some process, bind some process to a special CPU and so on.</p>
<p>Changing process priorities is commonly known:</p>
<pre>nice -n 10 make</pre>
<p>runs the program make with a priority of 10 (-20 meaning most favorable and 19 least favorable scheduling). If you want to change a priority of a running program, <em>renice</em> is your choice.<span id="more-369"></span></p>
<h3>schedtool</h3>
<p>Nowadays multiprocessor machines get more and more in common. So it&#8217;s sometimes desirable to bind a process to one or more CPUs. This is done by <a href="http://freequaos.host.sk/schedtool"><em>schedtool</em></a>, which is not part of common distros. You can install it on Gentoo by</p>
<pre>emerge -va schedtool</pre>
<p><em>schedtool</em> allows you to view, and change the process CPU affinity. Try</p>
<pre>schedtool PID</pre>
<p>where PID is the process ID. For example, process 6702 of my system shows:</p>
<pre>PID  6702: PRIO   0, POLICY N: SCHED_NORMAL  , NICE   0, AFFINITY 0x3</pre>
<p>meaning it&#8217;s CPU affinity mask is 0&#215;03. Each bit of the affinity mask corresponds to a CPU in the system and a bit value of 1 meaning this CPU is allowed to use. So, 0&#215;03 = 0b00000011 means that CPU0 and CPU1 are allowed to use. You can change the CPU affinity by</p>
<pre>schedtool -a AFFINITY_MASK PID</pre>
<p>where PID is the process ID and AFFINITY_MASK the affinity mask (must be in hexadecimal) or a list of (decimal) comma separated CPU numbers. Be careful not to use affinity 0&#215;00 especially on viral processes. <img src='http://www.twam.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>schedtool</em> also allows the change of schedule policy for a single job. This is useful e.g. for long-running non-interactive jobs. You can enable the SCHED_BATCH policy for them by</p>
<pre>schedtool -B PID</pre>
<p>where PID is the process ID. Notice that you need a least kernel 2.6.16 for SCHED_BATCH support. There are different schedule policies for Real Time or Idle applications. See <a href="http://linux.die.net/man/8/schedtool">man schedtool</a> for detailed information.</p>
<h3>taskset</h3>
<p>Another program for setting process&#8217;s CPU affinity is <em>taskset</em>. It&#8217;s included in <a href="http://www.kernel.org/pub/linux/utils/util-linux-ng/">util-linux-ng</a>, which is part of most common distros. taskset is only capable of changing/viewing CPU affinity, not priorities or scheduling policies.</p>
<p>To view a process CPU affinity try</p>
<pre>taskset -p PID</pre>
<p>where PID is the process ID. For the same process as above my systems shows:</p>
<pre>pid 6702's current affinity mask: 3</pre>
<p>You can change CPU affinity easily by</p>
<pre>taskset -p AFFINITY_MASK PID</pre>
<p>where PID is the process ID and AFFINITY_MASK the affinity mask. If you wish the use a command seperated CPU list you have to</p>
<pre>taskset -c -p CPU_LIST PID</pre>
<p>where PID is the process ID and CPU_LIST the CPU list like 1,3,4-6.</p>
<p>Unlike schedtool taskset is capable of starting programs with a specific CPU affinity mask by</p>
<pre>taskset AFFINITY_MASK COMMAND</pre>
<p>where AFFINITY_MASK is the affinity mask and COMMAND and command to execute. Seed <a href="http://linux.die.net/man/1/taskset">man taskset</a> for detailed information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/changing-scheduling-parameters-in-linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Gentoo on ALIX.3D3</title>
		<link>http://www.twam.info/linux/gentoo/installing-gentoo-on-alix3d3</link>
		<comments>http://www.twam.info/linux/gentoo/installing-gentoo-on-alix3d3#comments</comments>
		<pubDate>Fri, 01 May 2009 14:54:09 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Alix]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[ALIX.3D3]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=321</guid>
		<description><![CDATA[When I ordered the ALIX.3D3 board I thought installing Gentoo on this should be a piece of cake, but finally there were some stumbling blocks and that&#8217;s why I want to summarize how I got gentoo running. First of all, I recommend installing Gentoo on a normal desktop to get to know the installing process, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Gentoo Logo" src="http://www.gentoo.org/images/glogo-small.png" alt="" width="146" height="149" />When I ordered the ALIX.3D3 board I thought installing <a href="http://www.gentoo.org/">Gentoo</a> on this should be a piece of cake, but finally there were some <span class="hw">stumbling blocks and that&#8217;s why I want to summarize how I got gentoo running.</span></p>
<p>First of all, I recommend installing Gentoo on a normal desktop to get to know the installing process, which is a bit different from graphical installers of mainstream distros. The <a href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml">Gentoo Handbook</a> is a great documentation how this done.</p>
<p>To install gentoo, you have to boot a minimal or &#8220;rescue&#8221; linux usually from cd/dvd. I tried to convice the bios to boot from a usb cd-rom drive, but I hadn&#8217;t any success.<span id="more-321"></span></p>
<p>So I had to prepare a USB stick to boot from. There&#8217;s a nice tool <a href="http://unetbootin.sourceforge.net/">UNetbootin</a> which automatically copies ISO images to a usbstick and makes it bootable. I tried a lot with the Linux version of it but didn&#8217;t had any success regardless of which ISO image or USB stick I took. So I booted windows and tried it with this version. I had success on the first attempt, using the install-x86-minimal.iso from Gentoo and a 3 EUR SD-card Reader with a 4 GB SDHC card in it, formatted as FAT32 as the only partition (not in superfloppy mode).</p>
<p>If you&#8217;ve got a booting usb stick, insert it into a USB plug of the board, attach a USB keyboard and a monitor to the VGA port. Power on and press escape to select the boot menu. There should be an option for the usb stick if everything went fine.</p>
<p>Now the gentoo minimal system should boot and you can proceed with the usual installing (look into <a href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml">Gentoo Handbook</a> for details). The AMD Geode LX800 cpu is a i586 cpu, so you have to install a i386, i486 oder i586 stage (i686 or amd64 won&#8217;t work!). I installed a i486 stage 3 and updated later to i586.</p>
<p>Partitioning should follow your preferences but don&#8217;t a forget a swap partition. 256 MB of RAM is not that much and gcc will not compile without!</p>
<p>I took</p>
<pre>CFLAGS="-O2 -march=i486 -pipe"</pre>
<p>for installation as the gcc version on the stage3 archive don&#8217;t support the geode march.</p>
<p>The rest of the installation is business as usual. I installed gentoo-sources for a optimized kernel and took this configuration here: <a href="http://www.twam.info/wp-content/uploads/2009/05/config">ALIX.3D3 kernel-2.6.29-r2 config</a></p>
<p>After finishing installation and booting with the new kernel, it&#8217;s time to update the systems to i586. For this, at first update all packages to actual version, especially gcc to version 4.3. Afterwards it&#8217;s save to change</p>
<pre>CFLAGS="-march=geode -Os -fno-align-jumps -fno-align-functions -fno-align-labels -fno-align-loops -pipe -fomit-frame-pointer"</pre>
<p>and proceed with changing of the CHOST variable. There&#8217;s a nice tutorial here: <a href="http://www.gentoo.org/doc/en/change-chost.xml">Changing CHOST</a>.</p>
<p>Now you should have a nice and optimized gentoo on your ALIX.3D3</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/gentoo/installing-gentoo-on-alix3d3/feed</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>v4l2grab &#8211; Grabbing JPEGs from V4L2 devices</title>
		<link>http://www.twam.info/linux/v4l2grab-grabbing-jpegs-from-v4l2-devices</link>
		<comments>http://www.twam.info/linux/v4l2grab-grabbing-jpegs-from-v4l2-devices#comments</comments>
		<pubDate>Thu, 23 Apr 2009 13:01:51 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[V4L2]]></category>
		<category><![CDATA[WebCam]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=276</guid>
		<description><![CDATA[A friend of mine, wanted to use a standard USB WebCam as an IPCam. He used an old Media-Receiver Box (T-Online S100) and installed Gentoo Linux on an CF Card. Since Kernel 2.6.27 most of the USB webcams are supported through the Linux UVC drivers, which provides an Video4Linux2 Interface to those cams. We found [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine, wanted to use a standard USB WebCam as an IPCam. He used an old Media-Receiver Box (<a href="http://wiki.freifunk-hannover.de/T-Online_S_100">T-Online S100</a>) and installed Gentoo Linux on an CF Card.</p>
<p>Since Kernel 2.6.27 most of the USB webcams are supported through the Linux UVC drivers, which provides an Video4Linux2 Interface to those cams. We found some programs who claimed being able to grab JPEG images from V4L2 Cams, but most of them either didn&#8217;t compile, supported only V4L Version 1 or just brought up some other errors.</p>
<p>So I checked up the <a href="http://v4l2spec.bytesex.org/spec/">Video for Linux Two API Specification</a> and found there in Appendix B a small sample of howto communicate with the Cam. I adapted it to our needs and included an converter from <a href="http://en.wikipedia.org/wiki/YUV">YUV</a> colorspace to <a href="http://en.wikipedia.org/wiki/RGB">RGB</a>. Finally I added some code to support the export of JPEG images.<span id="more-276"></span></p>
<p>You can download it here: <a href="http://www.twam.info/wp-content/uploads/2009/04/v4l2grab.c">v4l2grab Version 0.1</a></p>
<p>The whole program is written in C and only needs <a href="http://www.ijg.org/">libjpeg</a> to compile. There are different ways to communicate with the camera, if you want to support all, you should go best with:</p>
<pre>gcc v4l2grab.c -o v4l2grab -Wall -ljpeg -DIO_READ -DIO_MMAP -DIO_USERPTR</pre>
<p>If you compiled the program, you can get some images with:</p>
<pre>./v4l2grab -o image.jpg</pre>
<p>With -W width -H height its possible to adjust the size of the image. If the camera doesn&#8217;t support the resolution the programs adjusts it automatically and prints an information on stderr.</p>
<p><strong>The current version of V4L2grab can be found on <a href="http://github.com/twam/v4l2grab/tree/master">github</a>.</strong> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/v4l2grab-grabbing-jpegs-from-v4l2-devices/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>commenting iptables rules</title>
		<link>http://www.twam.info/linux/commenting-iptables-rules</link>
		<comments>http://www.twam.info/linux/commenting-iptables-rules#comments</comments>
		<pubDate>Tue, 07 Apr 2009 13:29:04 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network/Web]]></category>
		<category><![CDATA[iptables]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=232</guid>
		<description><![CDATA[I often use iptables (or ip6tables, the IPv6 version of iptables) to implemented firewall rules on my linux systems. In earlier times I used a commented bash script to setup the rules after booting, but using Gentoo nowadays there is a nice init script saving and restoring my tables. Using this I stopped commenting the [...]]]></description>
			<content:encoded><![CDATA[<p>I often use iptables (or ip6tables, the IPv6 version of iptables) to implemented firewall rules on my linux systems.</p>
<p>In earlier times I used a commented bash script to setup the rules after booting, but using Gentoo nowadays there is a nice init script saving and restoring my tables. Using this I stopped commenting the firewall rules, but yesterday I found a very nice solution for this problem.</p>
<p>Iptables has a special &#8220;match&#8221; for comments. <span id="more-232"></span>You have to enable it in your kernel config like</p>
<pre>  [*] Networking support  ---&gt;
     Networking options
        [*] Network packet filtering framework (Netfilter)  ---&gt;
           Core Netfilter Configuration  ---&gt;
              -*- Netfilter Xtables support (required for ip_tables)
              &lt;*&gt;   "comment" match support</pre>
<p>or as a module.</p>
<p>Then you&#8217;re able to add rules like</p>
<pre>iptables -A INPUT -m state --state RELATED,ESTABLISHED \
  -m comment --comment "allow all established connections" -j ACCEPT</pre>
<p>And if you list your rules you get something like</p>
<pre>Chain INPUT (policy DROP)
target  prot opt source     destination
ACCEPT  all  --  anywhere   anywhere   state RELATED,ESTABLISHED
                                       /* allow all established connections */</pre>
<p>It&#8217;s a pity that I never saw this in any iptables tutorials.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/commenting-iptables-rules/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Kernel 2.6.29: Kernel Mode Setting with Intel GM965</title>
		<link>http://www.twam.info/linux/gentoo/kernel-mode-setting-with-intel-gm965</link>
		<comments>http://www.twam.info/linux/gentoo/kernel-mode-setting-with-intel-gm965#comments</comments>
		<pubDate>Sat, 04 Apr 2009 15:53:06 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Kernel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=221</guid>
		<description><![CDATA[Kernel 2.6.29 introduced the Kernel Mode Setting feature, meaning the kernel to be able to change resolution and adresse other outputs. For example kernels pre 2.6.29 always actived the external DVI device (if connected) on my macbook and showed boot screens there. This is now configurable. Also switching between X11 and console is much faster. [...]]]></description>
			<content:encoded><![CDATA[<p>Kernel 2.6.29 introduced the Kernel Mode Setting feature, meaning the kernel to be able to change resolution and adresse other outputs. For example kernels pre 2.6.29 always actived the external DVI device (if connected) on my macbook and showed boot screens there. This is now configurable. Also switching between X11 and console is much faster. <span id="more-221"></span></p>
<p>To get KMS running on my macbook, I installed the 2.6.29 with the following settings</p>
<pre>  Device Drivers  ---&gt;
    Graphics support  ---&gt;
      &lt;*&gt; Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  ---&gt;
        &lt;*&gt;   Intel 830M, 845G, 852GM, 855GM, 865G (i915 driver)  ---&gt;
          i915 driver
          [ ]    Enable modesetting on intel by default</pre>
<p>You don&#8217;t have to enable KMS by default. It&#8217;s possible to do this via i915.modeset=1 as a boot option.</p>
<p>After booting the kernel, drm should have detected your outputs and load inteldrmfb</p>
<pre>[    1.905481] [drm] TV-15: set mode NTSC 480i 0
[    2.021462] allocated 1280x800 fb: 0x00fdf000, bo ffff88013eaf2900
[    2.094941] [drm] LVDS-8: set mode 1280x800 17
[    2.191879] Console: switching to colour frame buffer device 160x50
[    2.195013] fb0: inteldrmfb frame buffer device
[    2.195038] registered panic notifier
[    2.195059] [drm] Initialized i915 1.6.0 20080730 on minor 0</pre>
<p>To use KMS within X11, I had to update the latest xorg-server, x11-libs and xf86-video-intel from the x11-overlay. In /etc/X11/xorgs.conf must</p>
<pre>        Option          "AccelMethod"   "UXA"</pre>
<p>set in the intel driver section.</p>
<p>Notice that output names may have changed, if you use a multimonitor setup oder xrandr. I had VGA,TV,LVDS,TMDS-1 prior to 2.6.29 and now it&#8217;s VGA1,TV1,LVDS1,DVI1.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/gentoo/kernel-mode-setting-with-intel-gm965/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IPv6 @ Home</title>
		<link>http://www.twam.info/linux/gentoo/ipv6-home</link>
		<comments>http://www.twam.info/linux/gentoo/ipv6-home#comments</comments>
		<pubDate>Tue, 31 Mar 2009 19:13:53 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Network/Web]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[SiXXs]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=150</guid>
		<description><![CDATA[Via SiXXs können auch Privatpersonen ohne natives IPv6 Internet Zugang zum &#8220;neuen&#8221; Netz erhalten. Registriert man sich auf der Seite kann ein IPv6 Tunnel unter anderem via AYIYA realisiert werden, welches sogar NAT unterstützt und somit auf fast allen PC funktionieren sollte. Das Programm AICCU initialisiert die Tunnel und benötigt als Konfiguration lediglich SiXXs-Benutzername und [...]]]></description>
			<content:encoded><![CDATA[<p>Via <a href="http://www.sixxs.net/">SiXXs</a> können auch Privatpersonen ohne natives IPv6 Internet Zugang zum &#8220;neuen&#8221; Netz erhalten. Registriert man sich auf der Seite kann ein IPv6 Tunnel unter anderem via AYIYA realisiert werden, welches sogar NAT unterstützt und somit auf fast allen PC funktionieren sollte.</p>
<p>Das Programm AICCU initialisiert die Tunnel und benötigt als Konfiguration lediglich SiXXs-Benutzername und Passwort sowie eine Tunnel Nummer. Das Programm gibt es als net-misc/aiccu als Ebuild für Gentoo.</p>
<p>Ist der Tunnel erfolgreich eingerichtet kann auch ein IPv6 Subnet beantragt werden und weitere PCs im Heimnetz ans IPv6 Netz zu bekommen. Der <a href="http://www.gentoo.org/doc/en/ipv6.xml">Gentoo-IPv6-Router-Guide</a> erklärt wie man radvd und dhcpv6 konfiguriert.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/gentoo/ipv6-home/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

