<?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>CoR</title>
	<atom:link href="http://blog.cor-net.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cor-net.org</link>
	<description>...</description>
	<lastBuildDate>Sat, 03 Jul 2010 19:52:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>STM32 Template Project</title>
		<link>http://blog.cor-net.org/embedded/stm32-template-project/</link>
		<comments>http://blog.cor-net.org/embedded/stm32-template-project/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 12:03:06 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[arm-gcc]]></category>
		<category><![CDATA[codesourcery]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[olimex]]></category>
		<category><![CDATA[STM32]]></category>
		<category><![CDATA[stm32-p103]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=183</guid>
		<description><![CDATA[I&#8217;ve been looking for a while for a template project to use with my STM32-P103 board. In the STM32 Standard Peripheral Library there is a template project for most IDEs used in embedded dev. However I was looking for a project to use with CodeSourcery ARM-GCC toolchain. You can find the repository here: hg clone [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for a while for a template project to use with my <a href="http://www.olimex.com/dev/stm32-p103.html">STM32-P103 board</a>.<br />
In the <a href="http://www.st.com/mcu/inchtml.php?fdir=pages&#038;fnam=stm32lib">STM32 Standard Peripheral Library</a> there is a template project for most IDEs used in embedded dev. However I was looking for a project to use with <a href="http://www.codesourcery.com/sgpp/lite/arm/portal/subscription3053">CodeSourcery ARM-GCC toolchain</a>.</p>
<p>You can find the repository here:<br />
<code>hg clone http://bitbucket.org/corfr/stm32template</code></p>
<ul>
<li>Just clone it, and you will have the &#8220;base&#8221;</li>
<li>Then edit the Makefile to specify your PROJECT_NAME</li>
<li>Eventually change TC_PREFIX to specity the path of your toolchain</li>
<li>Run <code inline>make</code> to make the project, then <code inline>make program</code> to program the target.</li>
</ul>
<p>To debug the project, you can run <code inline>make debug</code> to launch openocd. Then you will have to connect to the openocd server on port localhost:3333 .</p>
<p>Without GUI for gdb, just do:<br />
<code><br />
arm-none-eabi-gdb --eval-command="target remote localhost:3333"<br />
</code><br />
It should run gdb in command line and connect to the target (you <strong>must</strong> have openocd running along).</p>
<p>I&#8217;m used to Eclipse, so I use <a href="http://opensource.zylin.com/embeddedcdt.html">Zylin CDT plugin</a> with Galileo. Make a new debug configuration using &#8220;Zylin embedded debug (Native)&#8221; base, and in the &#8220;Commands&#8221; tab, put &#8220;target remote localhost:3333&#8243; in <em>Initialize</em>. In &#8220;C/C++ Application&#8221;, select the .axf file.</p>
<p>The project is configured to work with the <a href="http://www.amontec.com/jtagkey.shtml">Amontec JTAGkey</a> and is just setting up USART2 (on board serial port) and blinking Status LED.</p>
<p>I&#8217;m opened to any suggestion for that template, feel free to comment.</p>
<p>You can also find other templates, like that one from outroot <a href="http://outroot.com/blog/2010/02/26/stm32-project-template-for-hd-devices/">STM32 Project template for HD devices</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/stm32-template-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Hello World !&#8221; using Qt with CMake and recipe for OpenEmbedded</title>
		<link>http://blog.cor-net.org/embedded/hello-world-using-qt-with-cmake-and-recipe-for-openembedded/</link>
		<comments>http://blog.cor-net.org/embedded/hello-world-using-qt-with-cmake-and-recipe-for-openembedded/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 02:26:19 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[CMake]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[OpenEmbedded]]></category>
		<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=94</guid>
		<description><![CDATA[I just wrote a tutorial about Qt. It&#8217;s about a simple program with Qt, that gets compiled with CMake. Then I build a recipe in order to include it in a OpenEmbedded image. You can see the howto here.]]></description>
			<content:encoded><![CDATA[<p>I just wrote a tutorial about Qt. It&#8217;s about a simple program with Qt, that gets compiled with CMake.<br />
Then I build a recipe in order to include it in a OpenEmbedded image.</p>
<p>You can see the howto <a href="http://blog.cor-net.org/hello-world-in-qt-using-cmake-and-openembedded/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/hello-world-using-qt-with-cmake-and-recipe-for-openembedded/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CAN Interface for the Mini2440 Dev. Board</title>
		<link>http://blog.cor-net.org/embedded/mini2440/can-interface-for-the-mini2440-dev-board/</link>
		<comments>http://blog.cor-net.org/embedded/mini2440/can-interface-for-the-mini2440-dev-board/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 01:21:34 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Mini2440]]></category>
		<category><![CDATA[can]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[s3c2440]]></category>
		<category><![CDATA[socketcan]]></category>
		<category><![CDATA[spi]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=9</guid>
		<description><![CDATA[CAN Interface for Mini2440 using SocketCAN]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em>As part of the student project where I was using the Mini2440 board, I was also taking care of implementing a CAN network between a few PIC devices and that board.<br />
Here is a very cheap yet powerful CAN interface for that board.</em></p>
<p><img class="aligncenter size-medium wp-image-32" title="Logo-v10-black" src="http://blog.cor-net.org/wp-content/uploads/2009/07/Logo-v10-black-300x164.png" alt="Logo-v10-black" width="150" height="82" /></p>
<p>While being a very cheap board, the mini2440 has also great features, but since the MCU used (Samsung S3C2440) is made for consumer products like phones or GPS, is does not implement any CAN driver.</p>
<p>As I needed one, I built this small card. I guess the design is really easy to understand cause, well &#8230; it&#8217;s really simple, but it might be useful to some people. Feel free to comment or modify the card, just don&#8217;t sell it.</p>
<p><span style="color: #ff0000;">This article <strong>is not finished</strong>, I publish it now cause I&#8217;ve been writing it for few months (since march 2009 &#8230;) and I guess there is already some interesting informations for advanced users, but this is a WIP. I will resume it and add stuff if people are interested and when I have time, and I&#8217;ll also try to answer comments the best I CAN <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></p>
<h1>Hardware</h1>
<p>The board has a IO extension port of 34 pins, which make it possible to access to:</p>
<ul>
<li>+5V and GND : we can power something</li>
<li>an SPI interface</li>
<li>some GPIOs</li>
</ul>
<p>The S3C2440 feature an SPI interface, which is a slave-master bus that allow the MCU to drive peripherals.</p>
<p>Since I didn&#8217;t had much time to develop this, the main purpose of this card is to re-use what&#8217;s available. On linux, the socket-CAN project intend to provide a socket way to access CAN controllers. Few drivers are available, one is for Microchip MCP251x CAN drivers, which provide an SPI interface. As SPI drivers for linux are available in the kernel, and as MCP2515 drivers are provided by the socket-CAN project, I decided to use it.</p>
<p>The Mini2440 provide few IO ports in order to add peripherals, but they&#8217;re not standardized. On the Mini2440 schematic we can see that an SPI port is available on the 34 pins port, that&#8217;s the one I used.</p>
<p>The 34 pins connector is quite hard to find since it is not really a common one. I didn&#8217;t manage to find one on Farnell/RS/&#8230; : the only one I found on Farnell was a Harwin model, but really had too tiny holes, don&#8217;t order it, it won&#8217;t work. However, I did find another connector on Harwin, the M22-7141742, it&#8217;s a 2mm 34pins header which fit great with the board connector. I asked for samples on the harwin website and received it two days latter, they provide a really great service and quality products.</p>
<p>The CAN connector is not a standard one, in our bot we had another norm using a 10 pin header instead of an expansive DB-9.</p>
<p>I made the schematic and PCB under Protel DXP, cause it&#8217;s a standard in my school (hopefully not for long, we are switching to Eagle this year). I can eventually make the schematic and PCB under Eagle with a DB-9 connector if there is demand for it. I&#8217;m not yet comfortable with Eagle though, if someone can do that I would be happy to edit and add his content (and credit them of course).</p>
<p>Schematic:<br />
<a href="http://blog.cor-net.org/wp-content/uploads/2009/07/Can2440-Schem.jpg" rel="wp-prettyPhoto[g9]"><img class="aligncenter size-medium wp-image-27" title="Can2440-Schematic" src="http://blog.cor-net.org/wp-content/uploads/2009/07/Can2440-Schem-299x193.jpg" alt="Can2440-Schematic" width="299" height="193" /></a></p>
<p>PCB:<br />
<a href="http://blog.cor-net.org/wp-content/uploads/2009/07/Can2440-PCB.jpg" rel="wp-prettyPhoto[g9]"><img class="aligncenter size-medium wp-image-26" title="Can2440-PCB" src="http://blog.cor-net.org/wp-content/uploads/2009/07/Can2440-PCB-238x300.jpg" alt="Can2440-PCB" width="238" height="300" /></a></p>
<h1>Software</h1>
<p>I used Embdebian and Angstrom on my board, I guess you should not have any problem using the board with another distro as long as it has a linux kernel <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The software part relies on 2 things:</p>
<ul>
<li><a href="http://developer.berlios.de/projects/socketcan/">SocketCAN</a></li>
<li><a href="http://kernel.org/">Linux Kernel</a></li>
<p>(<a href="http://repo.or.cz/w/linux-2.6/mini2440.git">Mini2440 Kernel Repository</a> &amp; <a href="http://bliterness.blogspot.com/">news</a>)</ul>
<p>I just heard that the mini2440 repository for the kernel has been merged into the official repository, but in order to work you just need kernel sources with Mini2440 support.</p>
<p>Then you will have to modify the machine definition to configure the SPI interface. As you will see, this is not very clean as we need the driver&#8217;s header to be included, and as the SocketCAN project is not part of the kernel &#8230; But well, it works.</p>
<p>Here is some kind of patch I made, you should be really careful and understand what happens. As the kernel is in active developmental, I can&#8217;t say that it won&#8217;t broke in a few days.<br />
NB: All that somehow explain why I didn&#8217;t do a real patch, cause if you don&#8217;t understand why you&#8217;re copy/pasting this code, you&#8217;re going down.</p>
<p><a href="http://repo.or.cz/w/linux-2.6/mini2440.git?a=blob;f=arch/arm/mach-s3c2440/mach-mini2440.c"><strong><em>arch/arm/mach-s3c2440/mach-mini2440.c</em></strong></a></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// This is ugly, but I didn't find any other clean way as socketcan is external to the kernel</span>
<span style="color: #339933;">#include &quot;/path/to/socketcan/kernel/2.6/include/linux/can/platform/mcp251x.h&quot;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* SPI / CAN MCP251x support */</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> mini2440_set_cs<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> s3c2410_spi_info <span style="color: #339933;">*</span>spi<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> cs<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> pol<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #993333;">int</span> pin<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span>cs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">case</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">:</span>
pin <span style="color: #339933;">=</span> S3C2410_GPG2<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
printk<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;BUG in %s, wrong CS %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> __FUNCTION__<span style="color: #339933;">,</span> cs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
s3c2410_gpio_setpin<span style="color: #009900;">&#40;</span>pin<span style="color: #339933;">,</span> pol<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s3c2410_gpio_cfgpin<span style="color: #009900;">&#40;</span>pin<span style="color: #339933;">,</span> S3C2410_GPIO_OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> s3c2410_spi_info mini2440_spi_pd <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
.<span style="color: #202020;">num_cs</span>         <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>
.<span style="color: #202020;">set_cs</span>         <span style="color: #339933;">=</span> mini2440_set_cs<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> mcp251x_setup<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> spi_device <span style="color: #339933;">*</span>spi<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
printk<span style="color: #009900;">&#40;</span>KERN_INFO <span style="color: #ff0000;">&quot;MINI2440: Loading MCP251x setup<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
s3c2410_gpio_pullup<span style="color: #009900;">&#40;</span>S3C2410_GPG9<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> mcp251x_platform_data mcp251x_info __initdata <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
.<span style="color: #202020;">oscillator_frequency</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">8000000</span><span style="color: #339933;">,</span>
.<span style="color: #202020;">board_specific_setup</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mcp251x_setup<span style="color: #339933;">,</span>
.<span style="color: #202020;">model</span> <span style="color: #339933;">=</span> CAN_MCP251X_MCP2515<span style="color: #339933;">,</span>
.<span style="color: #202020;">power_enable</span> <span style="color: #339933;">=</span> NULL<span style="color: #339933;">,</span>
.<span style="color: #202020;">transceiver_enable</span> <span style="color: #339933;">=</span> NULL<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> spi_board_info mini2440_spi_board_info<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> __initdata <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
.<span style="color: #202020;">modalias</span>      <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;mcp251x&quot;</span><span style="color: #339933;">,</span>
.<span style="color: #202020;">platform_data</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mcp251x_info<span style="color: #339933;">,</span>
.<span style="color: #202020;">irq</span>           <span style="color: #339933;">=</span> IRQ_EINT17<span style="color: #339933;">,</span> <span style="color: #808080; font-style: italic;">/* GPG9 */</span>
.<span style="color: #202020;">max_speed_hz</span>  <span style="color: #339933;">=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">*</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">*</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">,</span>
.<span style="color: #202020;">chip_select</span>   <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>
.<span style="color: #202020;">bus_num</span>       <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>
.<span style="color: #202020;">mode</span>          <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
...
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> platform_device <span style="color: #339933;">*</span>mini2440_devices<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> __initdata <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
...<span style="color: #339933;">,</span>
<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>s3c_device_iis<span style="color: #339933;">,</span>
<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mini2440_audio<span style="color: #339933;">,</span>
<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>s3c_device_spi0
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> __init mini2440_init<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
...
&nbsp;
<span style="color: #808080; font-style: italic;">/* turn LCD on */</span>
s3c2410_gpio_cfgpin<span style="color: #009900;">&#40;</span>S3C2410_GPC0<span style="color: #339933;">,</span> S3C2410_GPC0_LEND<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Init SPI */</span>
s3c_device_spi0.<span style="color: #202020;">dev</span>.<span style="color: #202020;">platform_data</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mini2440_spi_pd<span style="color: #339933;">;</span>
i <span style="color: #339933;">=</span> spi_register_board_info<span style="color: #009900;">&#40;</span>mini2440_spi_board_info<span style="color: #339933;">,</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>mini2440_spi_board_info<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
printk<span style="color: #009900;">&#40;</span>KERN_INFO <span style="color: #ff0000;">&quot;MINI2440: SPI p_d set %i<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In order to compile the kernel, you must have a SocketCAN repo somewhere on your host computer. You must change the path of the include line to a valid mcp251x header.<br />
Then after preparing your kernel for your board as usual, you should install SocketCAN.</p>
<p>I&#8217;m not gonna enter in the details to make this piece of board, there is plenty of information on the Internet that explain how to make PCBs if you don&#8217;t already know.<br />
Check carefully that there is no short circuit or anything though, it won&#8217;t do any good to your mini2440.</p>
<p>Ok so now you should connect the board to the Mini2440. Be careful to do that before powering the board, I&#8217;m not sure hot plugging it would be a good thing =)</p>
<p>Then you have to load the mcp251x module.</p>
<p>In order to configure the can connection, you have to push your can network bitrate into the proc filesystem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/mini2440/can-interface-for-the-mini2440-dev-board/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CanArch Project</title>
		<link>http://blog.cor-net.org/embedded/canoe-project/</link>
		<comments>http://blog.cor-net.org/embedded/canoe-project/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 08:22:13 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Embedded Development]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[can]]></category>
		<category><![CDATA[CanOE]]></category>
		<category><![CDATA[LGPL]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Qt4]]></category>
		<category><![CDATA[sourceforge]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=41</guid>
		<description><![CDATA[An easy way to manage your CAN network using a C++ OpenSource library.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em>An easy way to manage your CAN network using a C++ OpenSource library.</em></p>
<p>Last year, I compete with a few teammates in the French Cup of Robotic, and our robot was extensively using CAN, because it&#8217;s a really robust and widespread network in embedded systems (and it&#8217;s true we didn&#8217;t had any trouble with it). The problem I was facing concerned how to manage all those ids and stuff in an efficient way.</p>
<p>I tried to find some solution on the Internet, but didn&#8217;t find any that would answer my problem without making me writing different code for the many few architectures we were using (PIC18F, dsPIC, ARM9 &#8230;).</p>
<p>So I wrote a small app, that used an XML file to &#8220;define&#8221; the network architecture (nodes, frames), that automatically generated IDs (using priority, node id and frame id) and exported them in a C Header using #define.</p>
<p><strong>I rewrote it from scratch, implementing a lot of things that were not possible in the first version and improving the overall architecture.</strong></p>
<p><strong>This is now provided as a library under LGPL, with a few tools to exploit it easily.</strong></p>
<p>So, if you have an existing CAN network, or a new one to design, and if you want to write not too static code for embedded systems, and analyze smartly the live feed of your network, CanArch might be helpful for you.</p>
<h1>Example</h1>
<p>So here is an XML file, it&#8217;s the &#8220;base&#8221;:</p>
<div class="aligncenter bigfileicon"><a href="http://blog.cor-net.org/wp-content/uploads/2009/08/simple.xml"><img src="http://blog.cor-net.org/wp-content/plugins/bigfiles/icons/32x32/application-xml.png" alt="simple.xml" /><br /><span>simple.xml</span></a></div>
<p>There is two parts:</p>
<ul>
<li>Configuration (conf): Network name, bitrate, types definition and id generation infos</li>
<li>Network tree (network): The network is a tree with <em>nodes</em> (devices on the network) which have <em>frames</em></li>
</ul>
<p>Hu ? Yeah, in that file you specify the nodes on your network, and the kind of frames that each node can emit.</p>
<p>Then the <em>format</em> of each frame is specified, using <em>types</em> like <em>int</em> or <em>enum</em>, with a bit size that you can specify.</p>
<p>Then you can generate IDs using the policy you specified in the definition file, and you can export it as a C Header like this one:</p>
<div class="aligncenter bigfileicon"><a href="http://blog.cor-net.org/wp-content/uploads/2009/08/graph.h"><img src="http://blog.cor-net.org/wp-content/plugins/bigfiles/icons/32x32/text-x-chdr.png" alt="graph.h" /><br /><span>graph.h</span></a></div>
<p>(well this is actually an export of <a href="http://blog.cor-net.org/wp-content/uploads/2009/08/graph.xml">that (graph.xml)</a> definition file, which is more complex than the simple previous one)</p>
<p>And to handle all the import / export / visualization, there is a nice Qt4 app called NetworkView:</p>
<div id="attachment_46" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.cor-net.org/wp-content/uploads/2009/08/Screenshot-NetworkView.png" rel="wp-prettyPhoto[g41]"><img class="size-medium wp-image-46" title="NetworkView" src="http://blog.cor-net.org/wp-content/uploads/2009/08/Screenshot-NetworkView-300x225.png" alt="Qt4 NetworkView Gui" width="300" height="225" /></a><p class="wp-caption-text">NetworkView : a Qt4 CanArch Gui</p></div>
<h1>Developers</h1>
<p>This project is fairly new, if you think you can help, I would be really glad if you do, so please contact me so we can talk about that.</p>
<p>There are lot of things that can be developed to improve this project, I&#8217;m thinking about a clean way to handle existing frames and interfaces (using <a href="http://developer.berlios.de/projects/socketcan/">socketcan</a> on Linux for example).</p>
<p>Also, a better support for existing networks, and DeviceNet and other higher level networks based on CAN are ideas I&#8217;m thinking about, and I would be glad to share the work, cause I won&#8217;t be able to do all that while studying and with my internship coming this winter.</p>
<h1>Download / Source</h1>
<p>The project page on BitBucket is <a href="http://bitbucket.org/corfr/canarch/">http://bitbucket.org/corfr/canarch/</a>, you can download the sources from there.</p>
<p><strong><br />
EDIT: CanArch has been renamed from CanOE, since this is a trademark for the <a href="http://www.vector.com/vi_canoe_en.html">Vector CANoe</a> software.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/canoe-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Qt 4.5 on mini2440</title>
		<link>http://blog.cor-net.org/embedded/mini2440/qt-45-on-mini2440/</link>
		<comments>http://blog.cor-net.org/embedded/mini2440/qt-45-on-mini2440/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 03:17:49 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Mini2440]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Qt4]]></category>
		<category><![CDATA[touchscreen]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=15</guid>
		<description><![CDATA[A quick HowTo about the setup of Qt4 and touchscreen on the Mini2440 development board.]]></description>
			<content:encoded><![CDATA[<p>Well, you didn&#8217;t bought this fresh mini2440 with a 3,5&#8243; or 7&#8243; touchscreen just for putting another dust receiver on your desk didn&#8217;t you ?</p>
<h1>Framebuffer</h1>
<p>If you compiled a kernel from the mini2440 kernel repository with the mini2440_defconfig, the framebuffer driver is loaded by default. You should see an &#8220;Armwork&#8221; logo when booting your board. If it&#8217;s not the case and you have a 7&#8243; screen, you have to pass &#8220;mini2440=1tb&#8221; as a boot argument for the kernel ( 0 is for 320&#215;240, 1 for 800&#215;480 ). This has to be done in u-boot.</p>
<p>The framebuffer for the screen should be avaiable on device /dev/fb0, if that entry does not exist, you probably want to make it by using the following command &#8220;mknod /dev/fb0 c 29 0&#8243;. If you wonder why those numbers, well, the major &#8220;29&#8243; is from the /proc/devices file, there you can see that the major 29 is reserved for fb character devices, and as there is only one fb on the system, the minor is 0, but if you want to make sure of that, all character devices are listed on /sys/dev/char.</p>
<p>If you don&#8217;t have anything in /proc or /sys or both, you should mount them by doing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>proc <span style="color: #000000; font-weight: bold;">/</span>proc <span style="color: #660033;">-t</span> proc
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>sys <span style="color: #000000; font-weight: bold;">/</span>sys <span style="color: #660033;">-t</span> sysfs</pre></div></div>

<p>If you don&#8217;t want to be bothered with than anymore, put them in /etc/fstab .</p>
<p>That should be it for the fb.</p>
<h1>Touchscreen configuration</h1>
<p>A nice &#8220;s3c2440-ts&#8221; driver should also be loaded when booting your board, it is responsible for providing the touchscreen input.</p>
<h2>Char device</h2>
<p>When booting, you can see that message: &#8220;input: s3c2410 TouchScreen as /devices/virtual/input/input1&#8243;. And indeed, if you go to the directory &#8220;/sys/devices/virtual/input/input1&#8243; (don&#8217;t forget to mount /sys), you&#8217;ll see some nice things.<br />
In this folder, 2 directories have interesting names: event1 and mouse0, and both of them have a &#8220;dev&#8221; file in their content. They contain major:minor addresses of their character devices. Hu ?<br />
event1 provide a &#8220;touchscreen&#8221; way to access to the touchscreen input while the mouse0 provide another abstraction that show the ts as a mice.<br />
To access them, we have to make a node in /dev as following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input
<span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>ts c <span style="color: #000000;">13</span> <span style="color: #000000;">65</span> <span style="color: #666666; font-style: italic;"># (from event1/dev)</span>
<span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>mice c <span style="color: #000000;">13</span> <span style="color: #000000;">32</span> <span style="color: #666666; font-style: italic;"># (from mouse0/dev)</span></pre></div></div>

<p>BTW, I kind of discovered the mouse input after doing what&#8217;s next, but I didn&#8217;t really had good results with that abstraction.</p>
<h2>tslib</h2>
<p>In order to exploit what&#8217;s coming from /dev/input/ts (if you do &#8220;cat /dev/input/ts&#8221;, you should see some weird characters when touching the screen <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ), we can use the tslib library.<br />
I followed <a href="http://linux-dvbh.blogspot.com/2006/12/tslib-download-and-cross-compile-for.html">that howto</a> to cross-compile it.</p>
<p>After the installation, you should be careful with the configuration.<br />
About the ts.conf, I just uncommented &#8220;module_raw input&#8221;.<br />
About the env variables, I exported as follow at first:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_TSEVENTTYPE</span>=INPUT
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_CONSOLEDEVICE</span>=none
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_FBDEVICE</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>fb0
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_TSDEVICE</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>ts
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_CALIBFILE</span>=
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_CONFFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ts.conf
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TSLIB_PLUGINDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ts</pre></div></div>

<p>As you can see &#8220;TSLIB_CALIBFILE&#8221; is empty, if you put something in it, all ts_* tools will quit with a nice Seg fault &#8230;<br />
Then calibrate your screen with &#8220;ts_calibrate /usr/etc/ts.calib&#8221; and a stylus. After that, calibration information&#8217;s will be stored in /usr/etc/ts.calib, data that you should put in the &#8220;TSLIB_CALIBFILE&#8221; env var.</p>
<p>If you want a more reliable configuration, put all those vars in the /etc/profile file, this will be load along with bash.</p>
<h1>Qt Embedded 4.5</h1>
<p>While the qt lib is a nice and heavy piece of work, cross-compiling is actually quite easy.</p>
<p>First you need to download the sources from Qt: <a href="http://get.qt.nokia.com/qt/source/qt-embedded-linux-opensource-src-4.5.2.tar.gz">http://get.qt.nokia.com/qt/source/qt-embedded-linux-opensource-src-4.5.2.tar.gz</a> (last version <a href="http://qt.nokia.com/downloads/embedded-linux-cpp">here</a>).</p>
<p>Untar it and then go in the directory.</p>
<p>First we need to provide what tools you&#8217;re going to use for cross-compiling the thing. On my host I use the toolchain provided by my openembedded installation, thus all my tools are starting by &#8220;arm-angstrom-linux-gnueabi-&#8221;. You have to modify the file</p>
<pre>mkspecs/qws/linux-arm-g++/qmake.conf</pre>
<p>to express what tools you want to use to cross-compile. Of course you have to do that according to your toolchain.<br />
BTW, if your toolchain is a path that&#8217;s only in your user PATH var, you might want to put the full path to your toolchain, otherwise there will be some problems when doing &#8220;sudo make install&#8221;.</p>
<p>Then, let&#8217;s configure:</p>
<pre>./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/local/Qt -qt-mouse-tslib -little-endian</pre>
<p>The -prefix is telling Qt that it&#8217;s going to be installed in /usr/local/Qt : hu ? When I first compiled Qt, I had my sd card mounted on /media/disk, so I put -prefix /media/disk/usr/local/Qt as an option. While I had no problem for the installation, I had troubles running some examples, as they we&#8217;re looking for files in the prefix path and not the real path (which is /usr/local/Qt on the board). I played a bit with the options but didn&#8217;t find a nice way to do that, that&#8217;s why I did the really ugly hack that&#8217;s following. I&#8217;m looking for a better solution, so if anyone as any, please mail me &#8230;<br />
I simply did a symbolic link from /usr/local/Qt to /media/disk/usr/local/Qt by doing :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>disk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Qt <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Qt</pre></div></div>

<p>That&#8217;s really ugly cause cross-compilation and virtual installation should be done nicely in userspace, while here I use a system wide path to do the trick.</p>
<p>Then you simply have to do :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>It&#8217;s going to take a while so go drink a coffee and remember those nice times when you had fun installing a gentoo from stage1 on a k6-2 &#8230;</p>
<p>Then unmount your sd card and boot your board.</p>
<p>You first have to register the Qt lib dir, this two lines should do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;/usr/local/Qt/lib&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ld.so.conf.d<span style="color: #000000; font-weight: bold;">/</span>qt.conf
ldconfig</pre></div></div>

<p>Then, in order to configure QWS to use the tslib driver, you have to</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">QWS_MOUSE_PROTO</span>=tslib:<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>input<span style="color: #000000; font-weight: bold;">/</span>ts</pre></div></div>

<p>as mentioned in <a href="http://doc.trolltech.com/4.5/qt-embedded-pointer.html">the Qt doc</a>.</p>
<p>And &#8230; that should be all.<br />
Have fun with Qt examples, starting by /usr/local/Qt/exemples/qws/mousecalibration in order to make sure that everything is all right.</p>
<h1>Other ressources</h1>
<ul>
<li><a href="http://labs.trolltech.com/blogs/2009/09/10/cross-compiling-qtx11/">Cross-compiling Qt/X11</a> Article on the Qt dev blog</li>
</ul>
<p></p>
<hr />
<p>Please comment this post, if you find any error or improvement I would be glad to take them in consideration <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/embedded/mini2440/qt-45-on-mini2440/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
		<item>
		<title>About this blog &#8230;</title>
		<link>http://blog.cor-net.org/blog-life/about-this-blog/</link>
		<comments>http://blog.cor-net.org/blog-life/about-this-blog/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 19:38:39 +0000</pubDate>
		<dc:creator>cor</dc:creator>
				<category><![CDATA[Blog Life]]></category>

		<guid isPermaLink="false">http://blog.cor-net.org/?p=3</guid>
		<description><![CDATA[Welcome to the CoR net space :)]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking about making my own blog lately cause, there are few things that I wanted to share and I didn&#8217;t had my own place to do it so &#8230; well, I made it.</p>
<p>I guess WordPress is pretty good for doing such thing, and it took me less than half an hour to install it, as for now I can&#8217;t say I&#8217;m really disappointed since there is also nice some cool themes available (I&#8217;ll try to customize one as soon as I have some time, which is really not any time soon) <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>BTW, I&#8217;m a French student, in my fourth year of studying at ISEN Toulon. I like few things like OpenSource, OpenHardware, Linux, OOP and embedded dev, and that&#8217;s mainly what this blog is going to talk about.</p>
<p>Hope you&#8217;ll find things interesting in it <img src='http://blog.cor-net.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cor-net.org/blog-life/about-this-blog/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
