<?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>coding &#187; arm</title>
	<atom:link href="http://www.coding.com.br/tag/arm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coding.com.br</link>
	<description>have you coded today?</description>
	<lastBuildDate>Fri, 23 Jul 2010 02:37:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Opcode stats</title>
		<link>http://www.coding.com.br/embarcado/opcode-stats/</link>
		<comments>http://www.coding.com.br/embarcado/opcode-stats/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 00:09:50 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[embarcado]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=1128</guid>
		<description><![CDATA[I was trying some GCC options and decided see how they affect assembly code generated. I&#8217;ve created a simple Python script that parses .s output and put in a human readable way. Suppose the classical Hello World program. The output will be something like:
$ python stats_opcodes.py file
For Cortex-m3 (check previous post):

At my laptop (x86):

 

Download the script here.
]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I was trying some GCC options and decided see how they affect assembly code generated. I&#8217;ve created a simple Python script that parses <em>.s</em> output and put in a human readable way. Suppose the classical <em>Hello World </em>program. The output will be something like:</p>
<p style="padding-left: 30px;">$ python stats_opcodes.py file</p>
<p>For Cortex-m3 (check <a href="http://www.coding.com.br/embarcado/cortex-m3-and-qemu/" target="_blank">previous</a> post):</p>
<p style="padding-left: 30px;"><img class="aligncenter size-full wp-image-1136" title="opcode-arm" src="http://www.coding.com.br/wp-content/uploads/2010/06/opcode-arm.png" alt="" width="304" height="194" /></p>
<p>At my laptop (x86):</p>
<p style="padding-left: 30px;"><img class="aligncenter size-full wp-image-1133" title="output" src="http://www.coding.com.br/wp-content/uploads/2010/06/opcodes1.png" alt="" width="306" height="194" /></p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: small;"><span style="line-height: 18px; white-space: pre;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: small;"><span style="line-height: 19px; white-space: normal;"> </span></span></span></span></p>
<p style="text-align: center;">
<p>Download the script <a href="http://gist.github.com/raw/452170/db097f735c52ffd733d2060603c203982d53b79f/stats_opcode.py" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/embarcado/opcode-stats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cortex-M3 and Qemu</title>
		<link>http://www.coding.com.br/embarcado/cortex-m3-and-qemu/</link>
		<comments>http://www.coding.com.br/embarcado/cortex-m3-and-qemu/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 15:08:10 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[embarcado]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[cortex-m3]]></category>
		<category><![CDATA[qemu]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=1115</guid>
		<description><![CDATA[Just a small tip to test code generated for ARM Cortex-M3 using QEmu:
$ arm-none-eabi-gcc main.c -ggdb -mcpu=cortex-m3 -mthumb -T generic-m-hosted.ld
$ qemu-arm -cpu cortex-m3 ./a.out
You can download Code Sourcery toolchain here and QEmu here (also available from package management system of your favorite Linux distribution). Just unpack the toolchain associating the arm-201XqX/bin with your $PATH and run qemu.
]]></description>
			<content:encoded><![CDATA[<p>Just a small tip to test code generated for ARM Cortex-M3 using QEmu:</p>
<p><span style="color: #2040a0;">$ arm</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">none</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">eabi</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">gcc</span> <span style="color: #2040a0;">main</span>.<span style="color: #2040a0;">c</span> <span style="color: #4444ff;">-</span><span style="color: #2040a0;">ggdb</span> <span style="color: #4444ff;">-</span><span style="color: #2040a0;">mcpu</span><span style="color: #4444ff;">=</span><span style="color: #2040a0;">cortex</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">m3</span> <span style="color: #4444ff;">-</span><span style="color: #2040a0;">mthumb</span> <span style="color: #4444ff;">-</span><span style="color: #2040a0;">T</span> <span style="color: #2040a0;">generic</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">m</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">hosted</span>.<span style="color: #2040a0;">ld</span><br />
<span style="color: #2040a0;">$ qemu</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">arm</span> <span style="color: #4444ff;">-</span><span style="color: #2040a0;">cpu</span> <span style="color: #2040a0;">cortex</span><span style="color: #4444ff;">-</span><span style="color: #2040a0;">m3</span> ./<span style="color: #2040a0;">a</span>.<span style="color: #2040a0;">out</span></p>
<p style="text-align: justify;">You can download Code Sourcery toolchain <a href="http://www.codesourcery.com/sgpp/lite/arm/portal/release1294" target="_blank">here</a> and QEmu <a href="http://wiki.qemu.org/Download" target="_blank">here</a> (also available from package management system of your favorite Linux distribution). Just unpack the toolchain associating the arm-201XqX/bin with your $PATH and run qemu.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/embarcado/cortex-m3-and-qemu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stellaris EKK-LM3S9b96 Evaluation Kit (1)</title>
		<link>http://www.coding.com.br/embarcado/stellaris-ekk-lm3s9b96-evaluation-kit-1/</link>
		<comments>http://www.coding.com.br/embarcado/stellaris-ekk-lm3s9b96-evaluation-kit-1/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 03:15:21 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[embarcado]]></category>
		<category><![CDATA[arm]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=864</guid>
		<description><![CDATA[O blog do Jê foi um dos canais brasileiros que anunciou o concurso promovido pela Texas Instruments e a revista Circuit Cellar. Como sempre tive curiosidade nos microcontroladores de 32bits da ARM resolvi me inscrever no concurso para receber o KIT. Com uma proposta semelhante (mas sem o concurso) a NXP, a um tempo atrás, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">O <a href="http://blogdoje.com.br/2010/01/29/texas-instruments-design-stellaris-2010-contest" target="_blank">blog do Jê</a> foi um dos canais brasileiros que anunciou o concurso promovido pela Texas Instruments e a revista Circuit Cellar. Como sempre tive curiosidade nos microcontroladores de 32bits da ARM resolvi me inscrever no concurso para <em>receber</em> o KIT. Com uma proposta semelhante (mas sem o concurso) a NXP, a um tempo atrás, distribuiu alguns microcontroladores da família LPC. Conheço muitos &#8220;hobbistas&#8221; que pediram as amostras mas assim que chegaram os custos para fazer uma placa (mesmo que um <em>design</em> simples para testar a funcionalidade) tornou o projeto inviável. A idéia do kit de desenvolvimento, na minha opinião, tende a popularizar melhor o uso (principalmente para quem gosta de fuçar).</p>
<p><a href="http://www.coding.com.br/wp-content/uploads/2010/04/4493235551_3214e1f7fd.jpg"><img class="aligncenter size-medium wp-image-865" title="Caixa com o kit" src="http://www.coding.com.br/wp-content/uploads/2010/04/4493235551_3214e1f7fd-300x225.jpg" alt="" width="300" height="225" /></a>Sinceramente já tinha esquecido da inscrição quando chegou na minha casa na semana passada&#8230; e só consegui fazer o <em>hands on</em> neste final de semana.</p>
<p style="text-align: center;"><img class="aligncenter" title="Itens dentro da caixa" src="http://www.coding.com.br/wp-content/uploads/2010/04/4493464217_41d7caa412.jpg" alt="" width="500" height="375" /></p>
<p style="text-align: justify;">Veio com todas o itens para você começar a desenvolver, a placa principal com a MCU fabricada pela <a href="http://www.luminarymicro.com/" target="_blank">Luminary</a> é a maior na foto, sendo a outra basicamente a interface USB com o computador (utiliza o chip da FTDI). Imagino que seja possível aproveitar em outros projetos. No kit há essencialmente:</p>
<ul>
<li>80-MHz LM3S9B96 MCU</li>
<li>Ethernet MAC+PHY</li>
<li>CAN</li>
<li>USB OTG,</li>
<li>SafeRTOS na ROM, com uma cópia limitada do Keil RealView Microcontroller Development Kit</li>
<li>cables (USB e rede)</li>
<li>CD com documentação e software</li>
<li>Pendrive de 256MB</li>
</ul>
<p style="text-align: justify;">Vou descrever aqui as novidades que for aprendendo. A meta é testar no final de semana o SafeRTOS.  Acredito que a presença do PHY Ethernet vai permitir implementações interessantes. Se você tiver alguma idéia sugira nos comentários.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/embarcado/stellaris-ekk-lm3s9b96-evaluation-kit-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First prototype for Beagle Board box</title>
		<link>http://www.coding.com.br/embarcado/first-prototype-for-beagle-board-box/</link>
		<comments>http://www.coding.com.br/embarcado/first-prototype-for-beagle-board-box/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 15:14:51 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[embarcado]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[beagleboard]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=533</guid>
		<description><![CDATA[After drawing a sketch for BeagleBoard this week I coud try something real. The board fit perfectly inside the box.

The whole for DVI-D would be a little bigger, the way it is the user need stick the connector well to don&#8217;t loose image quality.

The entries for USB and MMC fits together in the same whole.  I put [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">After drawing a <a href="http://www.coding.com.br/embarcado/first-sketch-for-beagle-board-box/" target="_blank">sketch</a> for BeagleBoard this week I coud try something real. The board fit perfectly inside the box.</p>
<p><a href="http://www.coding.com.br/wp-content/uploads/2010/01/bb1.jpg"><img class="aligncenter size-full wp-image-705" title="Box for BeagleBoard" src="http://www.coding.com.br/wp-content/uploads/2010/01/bb1.jpg" alt="" width="500" height="375" /></a></p>
<p style="text-align: justify;">The whole for DVI-D would be a little bigger, the way it is the user need stick the connector well to don&#8217;t loose image quality.</p>
<p><a href="http://www.coding.com.br/wp-content/uploads/2010/01/bb2.jpg"><img class="aligncenter size-full wp-image-706" title="Box for BeagleBoard" src="http://www.coding.com.br/wp-content/uploads/2010/01/bb2.jpg" alt="" width="500" height="375" /></a></p>
<p style="text-align: justify;">The entries for USB and MMC fits together in the same whole.  I put RS232 output because it&#8217;s a prototype, if you are developing something for an <em>end-user</em> you don&#8217;t need that. The box in my tests don&#8217;t heated</p>
<p style="text-align: center;"><a href="http://www.coding.com.br/wp-content/uploads/2010/01/bb3.jpg"><img class="aligncenter size-full wp-image-707" title="Box for BeagleBoard" src="http://www.coding.com.br/wp-content/uploads/2010/01/bb3.jpg" alt="" width="500" height="375" /></a></p>
<p style="text-align: justify;">I&#8217;m using this box to show a &#8220;general purpose&#8221; computer to others. Inside the memory card I had some GNU/Linux distributions like: Angstron, Ubuntu and Gentoo. But Symbian and Maemo are in the roadmap. Other tests include running <a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary" target="_blank">linus-git</a> kernel done with CodeSourcery toolchain (2009q1 and 2009q3) and playing with armv7a instructions.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">Check more photos on <a title="More photos for BeagleBoard Box" href="http://www.flickr.com/photos/maluta/sets/72157622039150085/detail/" target="_blank">Flickr!</a></p>
<p style="text-align: left;">
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/embarcado/first-prototype-for-beagle-board-box/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Byte Order</title>
		<link>http://www.coding.com.br/programacao/byte-order/</link>
		<comments>http://www.coding.com.br/programacao/byte-order/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 22:03:58 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[programação]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[intel]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=162</guid>
		<description><![CDATA[In the book about Linux Kernel Programming the author Robert Love demonstrated a trick to check your hardware endianness.

int x = 1;
if &#40;*&#40;char *&#41;&#38;x == 1&#41;
/* little endian */
else
/* big endian */

Using GCC you can use -mbig-endian or -mlittle-endian to generate appropriate endianess. Remember to check man pages section on your architecture (i.e: i386 and [...]]]></description>
			<content:encoded><![CDATA[<p>In the book about <em>Linux Kernel Programming</em> the author<em> Robert Love</em> demonstrated a trick to check your hardware <em>endianness</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> x <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span>x <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/* little endian */</span>
<span style="color: #b1b100;">else</span>
<span style="color: #808080; font-style: italic;">/* big endian */</span></pre></div></div>

<p style="text-align: justify;">Using <a href="http://gcc.gnu.org">GCC</a> you can use <strong>-mbig-endian </strong>or <strong>-mlittle-endian</strong> to generate appropriate endianess. Remember to check man pages section on your architecture (i.e: i386 and x86-64 <span style="text-decoration: underline;">don&#8217;t</span> implement this option whilst IA-64 and ARM yes)</p>
<p style="text-align: justify;">One interesting point regards on byte swapping. Suppose that you have a file that starts with 0x<span style="color: #ff0000;">aabb</span><span style="color: #000080;">ccdd</span> referring to little endian and 0x<span style="color: #000080;">ddcc</span><span style="color: #ff0000;">bbaa</span> referring to big endian (note that I took these values and order arbitrarily). In order to use one kind of byte order in your code we need check what endianness your file was generated and if necessary rectify. This C++ code exemplifies.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> Endian <span style="color: #008000;">&#123;</span>
&nbsp;
     <span style="color: #0000ff;">int</span> _byteSwapped<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
&nbsp;
     Endian<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">long</span> dw<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>0xaabbccddL <span style="color: #000080;">==</span> dw<span style="color: #008000;">&#41;</span> _byteSwapped <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>0xddccbbaaL <span style="color: #000080;">==</span> dw<span style="color: #008000;">&#41;</span>  _byteSwapped <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> 
        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">throw</span> <span style="color: #FF0000;">&quot;error&quot;</span><span style="color: #008080;">;</span>
&nbsp;
     <span style="color: #008000;">&#125;</span>
&nbsp;
     <span style="color: #0000ff;">long</span> rectify<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">long</span> dw<span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">const</span> <span style="color: #008000;">&#123;</span>
&nbsp;
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>_byteSwapped<span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">return</span> dw<span style="color: #008080;">;</span>
        <span style="color: #0000ff;">char</span> result<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #008000;">&#123;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span>dw<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span>,<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span>dw<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span>,<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span>dw<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span>,<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span>dw<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">return</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">long</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span> result<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
     <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>Another way to do byte swapping is using an macro. The following example swap two bytes:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define SwapTwoBytes(data) ( (((data) &gt;&gt; 8) &amp; 0x00FF) | (((data) &lt;&lt; 8) &amp; 0xFF00) )</span></pre></div></div>

<p style="text-align: justify;">One of the best practices is provide one software that will work correctly no matter which processor Endian-architecture the code is executed on, eliminating the need to rewrite the code. Intel has a interesting <a href="http://www.intel.com/design/intarch/papers/endian.pdf">paper</a> on Converting Endian-specific to Endian-neutral Code (pg. 15-16).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/programacao/byte-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
