<?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>Arthur Shipkowski &#187; coding</title>
	<atom:link href="http://www.fox-dreams.com/art/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fox-dreams.com/art</link>
	<description>A collection of varied items</description>
	<lastBuildDate>Wed, 07 Apr 2010 22:29:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Cross-compiling Python with _ctypes support</title>
		<link>http://www.fox-dreams.com/art/2010/04/xcompiling-python-with-ctypes/</link>
		<comments>http://www.fox-dreams.com/art/2010/04/xcompiling-python-with-ctypes/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 22:29:23 +0000</pubDate>
		<dc:creator>Arthur</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[cross-compiling]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.fox-dreams.com/art/?p=121</guid>
		<description><![CDATA[I found myself in need of a cross-compiled Python 2.6 to run some hardware test code on an MPC8315ERDB evaluation board. I found Paul Gibson&#8217;s guide and patches for cross-compiling Python useful, but they didn&#8217;t support the _ctypes module, which was needed for the hardware interface code, based around a C shared library. In fact, [...]]]></description>
			<content:encoded><![CDATA[<p>I found myself in need of a cross-compiled Python 2.6 to run some hardware test code on an MPC8315ERDB evaluation board. I found Paul Gibson&#8217;s <a href="http://randomsplat.com/id5-cross-compiling-python-for-embedded-linux.html">guide and patches</a> for cross-compiling Python useful, but they didn&#8217;t support the _ctypes module, which was needed for the hardware interface code, based around a C shared library. In fact, further searching turned up that one should not expect _ctypes to be available for cross-compilation.</p>
<p>I dug into the code, though, and discovered the issue is that _ctypes has its own configure call in setup.py. Pass in the right parameters, and all is well. In my case, my patch (atop of the pre-existing one) looks like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--- Python/setup.py 2010-04-07 15:00:28.183555632 -0400<br />
+++ Python-xcompile/setup.py    2010-04-07 15:33:35.443567686 -0400<br />
@@ -17,7 +17,7 @@<br />
from distutils.command.install_lib import install_lib<br />
<br />
# This global variable is used to hold the list of modules to be disabled.<br />
-disabled_module_list = ['_ctypes']<br />
+disabled_module_list = []<br />
<br />
def add_dir_to_list(dirlist, dir):<br />
&quot;&quot;&quot;Add the directory 'dir' to the list 'dirlist' (at the front) if<br />
@@ -1705,7 +1705,7 @@<br />
ffi_configfile):<br />
from distutils.dir_util import mkpath<br />
mkpath(ffi_builddir)<br />
-                config_args = []<br />
+                config_args = &nbsp;sysconfig.get_config_var(&quot;CONFIG_ARGS&quot;).split(&quot; &quot;)<br />
<br />
# Pass empty CFLAGS because we'll just append the resulting<br />
# CFLAGS to Python's; -g or -O2 is to be avoided.</div></div>
<p>For the curious, below are the key steps for cross-compilation of Python outside LTIB (since it was for test, there was no need to incorporate it) for the MPC8315ERDB &#8212; it may work for MPC8313-based setups as well. You probably want to look at the original post for slimming the tree down once the build is done, and if you have modules for which support isn&#8217;t found, change the add_dir_to_list lines to point at your build system&#8217;s library and include directories rather than /usr/local.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzf Python-2.6.4.tgz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> Python-2.6.4<br />
.<span style="color: #000000; font-weight: bold;">/</span>configure<br />
<span style="color: #c20cb9; font-weight: bold;">make</span> python Parser<span style="color: #000000; font-weight: bold;">/</span>pgen<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> python hostpython<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> Parser<span style="color: #000000; font-weight: bold;">/</span>pgen Parser<span style="color: #000000; font-weight: bold;">/</span>hostpgen<br />
<span style="color: #c20cb9; font-weight: bold;">make</span> distclean<br />
<span style="color: #c20cb9; font-weight: bold;">patch</span> <span style="color: #660033;">-p1</span> <span style="color: #000000; font-weight: bold;">&lt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>Python-2.6.4-xcompile.patch<br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Insert my patch here</span><br />
<span style="color: #c20cb9; font-weight: bold;">vim</span> setup.py<br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Put LTIB tools in $PATH</span><br />
<span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>freescale<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>gcc-4.1.78-eglibc-2.5.78-<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>powerpc-e300c3-linux-gnu<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #007800;">CROSS</span>=powerpc-e300c3-linux-gnu- <span style="color: #007800;">CC</span>=<span style="color: #800000;">${CROSS}</span><span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #007800;">CXX</span>=<span style="color: #800000;">${CROSS}</span><span style="color: #c20cb9; font-weight: bold;">g++</span> <span style="color: #007800;">AR</span>=<span style="color: #800000;">${CROSS}</span><span style="color: #c20cb9; font-weight: bold;">ar</span> <span style="color: #007800;">RANLIB</span>=<span style="color: #800000;">${CROSS}</span>ranlib .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--host</span>=powerpc-e300c3-linux-gnu <span style="color: #660033;">--build</span>=x86_64-pc-linux-gnu <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>python<br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">HOSTPYTHON</span>=.<span style="color: #000000; font-weight: bold;">/</span>hostpython <span style="color: #007800;">HOSTPGEN</span>=.<span style="color: #000000; font-weight: bold;">/</span>Parser<span style="color: #000000; font-weight: bold;">/</span>hostpgen <span style="color: #007800;">BLDSHARED</span>=<span style="color: #ff0000;">&quot;powerpc-e300c3-linux-gnu-gcc -shared&quot;</span> <span style="color: #007800;">CROSS_COMPILE</span>=<span style="color: #800000;">${CROSS}</span> <span style="color: #007800;">CROSS_COMPILE_TARGET</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><br />
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #007800;">HOSTPYTHON</span>=.<span style="color: #000000; font-weight: bold;">/</span>hostpython <span style="color: #007800;">BLDSHARED</span>=<span style="color: #ff0000;">&quot;powerpc-e300c3-linux-gnu-gcc -shared&quot;</span> <span style="color: #007800;">CROSS_COMPILE</span>=<span style="color: #800000;">${CROSS}</span> <span style="color: #007800;">CROSS_COMPILE_TARGET</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #007800;">prefix</span>=~<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>Python-2.6.4<span style="color: #000000; font-weight: bold;">/</span>_install</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.fox-dreams.com/art/2010/04/xcompiling-python-with-ctypes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conceptions of the Embedded Software World</title>
		<link>http://www.fox-dreams.com/art/2009/11/conceptions-of-the-embedded-software-world/</link>
		<comments>http://www.fox-dreams.com/art/2009/11/conceptions-of-the-embedded-software-world/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 17:26:06 +0000</pubDate>
		<dc:creator>Arthur</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://www.fox-dreams.com/art/?p=119</guid>
		<description><![CDATA[It often surprises me, the conceptions those outside the embedded software world have of it. At the one end is the old, hardcoded view; a good example, if a bit old, would be Joel Spolsky&#8217;s view of the Embedded Software World. At the other end, prompted by the increasing presence of Java and other applications [...]]]></description>
			<content:encoded><![CDATA[<p>It often surprises me, the conceptions those outside the embedded software world have of it.</p>
<p>At the one end is the old, hardcoded view; a good example, if a bit old, would be <a href="http://www.joelonsoftware.com/articles/FiveWorlds.html">Joel Spolsky&#8217;s view</a> of the Embedded Software World.</p>
<p>At the other end, prompted by the increasing presence of Java and other applications for cell phones, there is the idea that it&#8217;s all Java and that it&#8217;s every bit as easy as desktop development.</p>
<p>Neither of these views is entirely true, but they aren&#8217;t entirely false, either.  Joel is correct about limited programming capability in many cases, but as I bet even he is realizing there are flash updates these days even for consumer electronics like Blu-ray players. Others are correct about the increasing availability of tools that make it just like home in some embedded systems.</p>
<p>Where do I find myself in all this? Well, only recently did I find myself working on the first project for my employer where C++ can be used in a fairly embedded environment; previous projects had broken libraries, a lack of space for the generated code, or both. Of course, there&#8217;s still bootloader work in C, sometimes with a dab of assembler, too.</p>
<p>The biggest thing I&#8217;ve noticed about embedded software is that often it&#8217;s solving known-to-be-solved problems without the benefits of a full-up system. Perhaps you don&#8217;t have a shell capable of scripting &#8212; or the ability to just run Perl or Python, meaning you have to write C code that grovels over I/O that would be trivial in either. Sometimes it&#8217;s bringing up a board from scratch, and trying to get a bootloader to work &#8212; or writing your own (though, these days, it&#8217;s preferable to grab one of the pre-written ones, as you&#8217;ll get much more functionality once you get it running).</p>
<p>So what do I think of it? It can be frustrating when you&#8217;re writing many lines of code for what you know would be trivial in another language, but it&#8217;s also fun to squeeze every last drop out of a hardware solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fox-dreams.com/art/2009/11/conceptions-of-the-embedded-software-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
