<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Matt Merry &#187; 2008 &#187; June &#187; 13</title>
	<atom:link href="http://www.mattmerry.com/blog/2008/06/13/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mattmerry.com/blog</link>
	<description>MattMerry.com</description>
	<pubDate>Thu, 19 Feb 2009 01:19:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>matt@mattmerry.com ()</managingEditor>
		<webMaster>matt@mattmerry.com()</webMaster>
		<category></category>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>MattMerry.com</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>matt@mattmerry.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.mattmerry.com/blog/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.mattmerry.com/blog/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>Matt Merry</title>
			<link>http://www.mattmerry.com/blog</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Milestone 1: SD14 FPGA Code Decoded</title>
		<link>http://www.mattmerry.com/blog/2008/06/13/milestone-1-sd14-fpga-code</link>
		<comments>http://www.mattmerry.com/blog/2008/06/13/milestone-1-sd14-fpga-code#comments</comments>
		<pubDate>Sat, 14 Jun 2008 07:03:15 +0000</pubDate>
		<dc:creator>Matt Merry</dc:creator>
		
		<category><![CDATA[SD14 Firmware Hacking]]></category>

		<category><![CDATA[Firmware]]></category>

		<category><![CDATA[Hack]]></category>

		<category><![CDATA[SD14]]></category>

		<category><![CDATA[SD7]]></category>

		<category><![CDATA[Xilinx]]></category>

		<guid isPermaLink="false">http://www.mattmerry.com/blog/2008/06/13/milestone-1-sd14-fpga-code</guid>
		<description><![CDATA[Well, we broke down the FBIN file into some sections and validated that the section identifiers were correct by locating the size following the section identifiers. I&#8217;m assuming at this point that the section sizes are part of section headers, and I don&#8217;t know how long the headers are. Thats all about to change.
I&#8217;ve found [...]]]></description>
			<content:encoded><![CDATA[<p>Well, we broke down the FBIN file into some sections and validated that the section identifiers were correct by locating the size following the section identifiers. I&#8217;m assuming at this point that the section sizes are part of section headers, and I don&#8217;t know how long the headers are. Thats all about to change.</p>
<p>I&#8217;ve found the FPGA code that is executed on the Xilinx chip on the SD14 and it is possible to reverse engineer it to both a layout and an Verilog file. Let me explain this first milestone in my hack of the Sigma SD14 <img src='http://www.mattmerry.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>First off, we&#8217;ll examine the largest BINS section in the FBIN file. I&#8217;ll work again with the broken down s14v101.fbin file as generated in my previous post. This is the section that we want:</p>
<blockquote>
<pre><font><font color="#000080">13:	0×001e4508		1983752	0×00076e40	486976</font></font></pre>
</blockquote>
<p>Lets look at the first few bytes as hex and text, and then I&#8217;ll explain some things. the first few bytes are:</p>
<pre><font color="#339966">42 49 4E 53 24 00 00 00 00 FF 30 00 00 00 00 00</font><font color="#333399"> BINS$....ÿ0.....
</font><font color="#339966">20 00 00 00 04 00 00 00 00 00 00 00 76 B7 80 AC</font> <font color="#333399"> ...........v·.-</font>
<font color="#339966">00 00 00 00 00 09 0F F0 0F F0 0F F0 0F F0 00 00</font> <font color="#333399">.....   .ð.ð.ð.ð..</font>
<font color="#339966">01 61 00 08 73 64 37 2E 6E 63 64 00 62 00 0B 33</font> <font color="#333399">.a..<strong>sd7.ncd</strong>.b..<strong>3</strong></font>
<font color="#339966">73 32 30 30 74 71 31 34 34 00 63 00 0B 32 30 30</font> <font color="#333399"><strong>s200</strong>tq144.c..200</font>
<font color="#339966">36 2F 31 31 2F 30 32 00 64 00 09 31 38 3A 30 35</font> <font color="#333399">6/11/02.d.      18:05</font>
<font color="#339966">3A 30 37 00 65 00 01 FF 88 FF FF FF FF AA 99 55</font> <font color="#333399">:07.e..ÿ.ÿÿÿÿª.U</font>
<font color="#339966">66 30 00 80 01 00 00 00 07 30 01 60 01 00 00 00</font> <font color="#333399">f0.......0.`.... </font></pre>
<p>The green values are the hexadecimal, and the blue values are the strings. Now, we can see the BINS tag starts things off, and checking the size&#8230;wait a minute! the size is wrong! What? Well, then, what comes next? To find out, we had better figure out whatever sd7.ncd is. SD7?? Yup. there is more than one reference to the SD7 in the overall firmware file <img src='http://www.mattmerry.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Lets see if we can find anything else in that string that will help us. How about 3S200. Hm, the Xilinx chip is a XC3S200. Jackpot! A quick google confirms. NCD files are Xilinx design files. That gets us somewhere. I have the feeling that this is the file that the FPGA loads as the design. Another quick google turns up a page on FPGA-Faq.com that is entitled <a href="http://www.fpga-faq.com/FAQ_Pages/0026_Tell_me_about_bit_files.htm" title="Bit files">&#8220;Tell me about bit files.&#8221;</a> Bit files are the FPGA&#8217;s firmware file, quoting from FPGA-Faq.com:</p>
<blockquote><p><font color="#000080">The Xilinx .bit format is pretty simple.  It uses keys and lengths to<br />
divide the file. </font></p>
<p><font color="#000080">Here is an example.  Below is a hex dump from the beginning of a .bit file: </font></p>
<p><font color="#000080"><tt>00000000:  00 09 0f f0 0f f0 0f f0 0f f0 00 00 01 61 00 0a  *&#8230;&#8230;&#8230;&#8230;.a..*</tt></font></p>
<p><font color="#000080"><tt>00000010:  78 66 6f 72 6d 2e 6e 63 64 00 62 00 0c 76 31 30  *xform.ncd.b..v10*</tt></font></p>
<p><font color="#000080"><tt>00000020:  30 30 65 66 67 38 36 30 00 63 00 0b 32 30 30 31  *00efg860.c..2001*</tt></font></p>
<p><font color="#000080"><tt>00000030:  2f 30 38 2f 31 30 00 64 00 09 30 36 3a 35 35 3a  */08/10.d..06:55:*</tt></font></p>
<p><font color="#000080"><tt>00000040:  30 34 00 65 00 0c 28 18 ff ff ff ff aa 99 55 66  *04.e..(&#8230;&#8230;.Uf*</tt></font></p></blockquote>
<p>Oh, this looks just like the section that was found in the SD14 firmware file! Reading more at FPGA-FAQ.com, we see that there should be an &#8220;a&#8221;, &#8220;b&#8221;, &#8220;c&#8221;, &#8220;d&#8221;, and &#8220;e&#8221; sections, and sure enough, our &#8220;a&#8221; identifier is at offset 0X076e72 in s14v101.fbin. You can easily find the rest of the sections yourself.</p>
<p>We just found the FPGA code that runs on the Sigma SD14!</p>
<p>Googling turns up a bunch of info for these Xilinx Bin files. Here is a <a href="http://home.earthlink.net/~davesullins/software/bitinfo.html" title="BitInfo">program to decode the headers</a>. Here is some info on how this can be <a href="http://www.kamptec.de/blog/doku.php?id=hardware:xilinx-bin2h" title="Bin file to C header">converted into a C header file</a>. Good thing Sigma is cheap and didn&#8217;t use the more advanced 3A FPGA or we&#8217;d have to deal with <a href="http://www.xilinx.com/support/documentation/white_papers/wp267.pdf" title="Stupidness">this crap</a>.</p>
<p>The greatest piece of info I found however was this <a href="http://www.ulogic.org/trac" title="DeBit">brilliant site on a debit utility</a> to turn a BIN file into a netlist. For those of you who don&#8217;t know, a netlist is the list of circuit elements that make up the circuit. In this case, it takes the bin file and generates a list of logic gates for the circuit. This will also give a visual representation of the circuit, and even contains information on how to convert this back into verilog. Verilog is very easy to simulate (I&#8217;d imagine that a Xilinx bin file is as well) <img src='http://www.mattmerry.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Next steps: Convert the SD14 Xilinx bin file into a netlist, generate a graphical representation of the circuit, and convert it back to verilog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattmerry.com/blog/2008/06/13/milestone-1-sd14-fpga-code/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

