<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.5" -->
<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/"
	>

<channel>
	<title>Openschemes Articles</title>
	<link>http://www.openschemes.com/modules/wordpress</link>
	<description>Electronics and Circuit Design Information</description>
	<pubDate>Tue, 09 Mar 2010 01:00:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<item>
		<title>Topless SPMP8000a</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/03/09/topless-spmp8000a/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/03/09/topless-spmp8000a/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 00:58:40 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>

		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/03/09/topless-spmp8000a/</guid>
		<!--<description>
			<![CDATA[

Thought you guys might like to see a gratuitous pic of the SPMP8000 after decap.  We&#8217;ll soon be posting some hi-res die photos but for now you&#8217;ll have to be satisfied by this sneak preview.  The die ID says: SunplusmM LAC005 (or perhaps LACOOS) so get your google on!

]]></description>
			-->
			<content:encoded><![CDATA[<p><!--Mime Type of File is image/jpeg -->
<div class="postie-image-div"><a onclick="window.open('http://www.openschemes.com/modules/wordpress/wp-photos/20100308-175839-1.jpg','full_size_image','toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=1,height=1220,width=1620');return false;" href="http://www.openschemes.com/modules/wordpress/wp-photos/20100308-175839-1.jpg"><img class="postie-image" style="border: medium none " src="http://www.openschemes.com/modules/wordpress/wp-photos/thumb.20100308-175839-1.jpg" /></a></div>
<p>Thought you guys might like to see a gratuitous pic of the SPMP8000 after decap.  We&#8217;ll soon be posting some hi-res die photos but for now you&#8217;ll have to be satisfied by this sneak preview.  The die ID says: SunplusmM LAC005 (or perhaps LACOOS) so get your google on!
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/03/09/topless-spmp8000a/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fun with AES-128.  Example Encryption with AES Trainer</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/03/03/fun-with-aes-128-example-encryption-with-aes-trainer/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/03/03/fun-with-aes-128-example-encryption-with-aes-trainer/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 23:24:01 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>Miscellaneous</category>

		<category>Fun &amp; Games</category>
<category>AES</category><category>encryption</category><category>Software</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/03/03/fun-with-aes-128-example-encryption-with-aes-trainer/</guid>
		<!--<description>
			<![CDATA[Hello Folks!
We are still swamped with other projects and unable to post any updates on the SPMP8k project, but not to worry - SPMP8k development will continue soon!
Until then, we have a short article about an AES encryption trainer that we had lying around and decided to spruce up for your entertainment.As you probably know, [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>Hello Folks!</p>
<p>We are still swamped with other projects and unable to post any updates on the <a href="http://www.openschemes.com/modules/wordpress/category/hacks/mp5/">SPMP8k project</a>, but not to worry - SPMP8k development will continue soon!</p>
<p>Until then, we have a short article about an AES encryption trainer that we had lying around and decided to spruce up for your entertainment.<br />As you probably know, <a target="_blank" href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">AES (the Advanced Encryption Standard)</a> is the latest encryption standard endorsed by <a target="_blank" href="http://www.nist.gov/index.html">NIST</a>, generator and owner of US standards.  It&#8217;s main advantage over the previous standard, <a target="_blank" href="http://en.wikipedia.org/wiki/Data_Encryption_Standard">DES</a>, is the ease of hardware implementation.</p>
<p>It mainly consists of byte swapping, rotation, and XOR&#8217;s and is extremely annoying to try to trace.  It&#8217;s actually not too bad up until the MixRows phase if you&#8217;re using lookup tables but can be easy to get lost in if you&#8217;re not paying attention or taking good notes.  We were once looking for a way to inspect the output of each individual operation of each round - we resorted to hacking in printf&#8217;s into someone else&#8217;s code but didn&#8217;t like their implementation in a few points.</p>
<p>What we really wanted was a printout that closely followed the round-by-round example given in the <a target="_blank" href="http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf">official AES implementation pdf (FIPS 197)</a>, including an example of the AES key expansion.  That is a beautiful document with clear and concise descriptions of all aspects of the encryption - a truly excellent read.  In addition, examples of both the AES key expansion and state data for every round is given - but not the same example, unfortunately!  What we wanted was a similar style example printout for any input and key pair we could think of, for either encryption or decryption.  And we wanted to change keys and inputs on-the-fly and watch nuances propagate through the algorithm.  Not for any hacking sense, just to verify some ideas about optimizing some implementations of AES in FPGA&#8217;s and other circuitry.  In the end, we developed our own little tiny AES-128 encryptor/decryptor that pukes out all of the internals of key expansion and encryption rounds so you can inspect them line-by-line.</p>
<p>Behold the Openschemes AES-128 Trainer!
<p align="center"><img height="382" width="638" alt="Screenshot of the Openschemes AES Encryption Trainer" id="image170" src="http://www.openschemes.com/uploads/wordpress/2010/03/screenshot.JPG" /></p>
<p>
<p align="center"><strong>Fig 1 - Screenshot of Openschemes AES128 Encryption Trainer </strong></p>
<p>The trainer is an AES encryptor/decryptor example program written in VB6.  We call it a trainer, or example program because it only works on one 16-byte block at a time so it is really no good for encryption.  In addition, the source code is optimized for readability and understanding instead of speed or efficiency.</p>
<p>Table lookups abound to avoid implementing Galois multiplication in VB - not a terrribly hard thing to understand but it really interrupts the flow of the read if you know what we&#8217;re saying&#8230;!  And the number one reason it&#8217;s unsuitable for heavy-duty encryption - it&#8217;s in VB!  It runs fast enough for our needs and still has a nice &#8220;hold on, I&#8217;m doing something&#8221; delay that makes you feel like something really important is going on.  <img src='http://www.openschemes.com/modules/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In case you&#8217;re unable to read the screenshot data, the default data filled in the key and plaintext fields are the hex data from the 00112233&#8230; example from the FIPS document.  The key expansion of hex key <strong>000102030405060708090A0B0C0D0E0F</strong> follows:</p>
<p><em><strong>Key Expansion Example: </strong></em><br />
<blockquote>00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F<br />D6 AA 74 FD D2 AF 72 FA DA A6 78 F1 D6 AB 76 FE<br />B6 92 CF 0B 64 3D BD F1 BE 9B C5 00 68 30 B3 FE<br />B6 FF 74 4E D2 C2 C9 BF 6C 59 0C BF 04 69 BF 41<br />47 F7 F7 BC 95 35 3E 03 F9 6C 32 BC FD 05 8D FD<br />3C AA A3 E8 A9 9F 9D EB 50 F3 AF 57 AD F6 22 AA<br />5E 39 0F 7D F7 A6 92 96 A7 55 3D C1 0A A3 1F 6B<br />14 F9 70 1A E3 5F E2 8C 44 0A DF 4D 4E A9 C0 26<br />47 43 87 35 A4 1C 65 B9 E0 16 BA F4 AE BF 7A D2<br />54 99 32 D1 F0 85 57 68 10 93 ED 9C BE 2C 97 4E<br />13 11 1D 7F E3 94 4A 17 F3 07 A7 8B 4D 2B 30 C5</p></blockquote>
<p>Followed by the fully annotated encryption workbook on the right side, showing the state of the ciphertext as it propagates through each round.  As in FIPS197,  the ciphertext (in hex) is <strong>00112233445566778899AABBCCDDEEFF</strong>.  Workbook data for all ten rounds of AES-128 are as follows:</p>
<p><em><strong>AES Encryption Internals Example: </strong></em><br />
<blockquote>Encryption Workbook&#8230;<br />round[0].in 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF<br />round[0].k  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F</p>
<p>round[1].in 00 10 20 30 40 50 60 70 80 90 A0 B0 C0 D0 E0 F0<br />round[1].sb 63 CA B7 04 09 53 D0 51 CD 60 E0 E7 BA 70 E1 8C<br />round[1].sr 63 53 E0 8C 09 60 E1 04 CD 70 B7 51 BA CA D0 E7<br />round[1].mc 5F 72 64 15 57 F5 BC 92 F7 BE 3B 29 1D B9 F9 1A<br />round[1].k  D6 AA 74 FD D2 AF 72 FA DA A6 78 F1 D6 AB 76 FE</p>
<p>round[2].in 89 D8 10 E8 85 5A CE 68 2D 18 43 D8 CB 12 8F E4<br />round[2].sb A7 61 CA 9B 97 BE 8B 45 D8 AD 1A 61 1F C9 73 69<br />round[2].sr A7 BE 1A 69 97 AD 73 9B D8 C9 CA 45 1F 61 8B 61<br />round[2].mc FF 87 96 84 31 D8 6A 51 64 51 51 FA 77 3A D0 09<br />round[2].k  B6 92 CF 0B 64 3D BD F1 BE 9B C5 00 68 30 B3 FE</p>
<p>round[3].in 49 15 59 8F 55 E5 D7 A0 DA CA 94 FA 1F 0A 63 F7<br />round[3].sb 3B 59 CB 73 FC D9 0E E0 57 74 22 2D C0 67 FB 68<br />round[3].sr 3B D9 22 68 FC 74 FB 73 57 67 CB E0 C0 59 0E 2D<br />round[3].mc 4C 9C 1E 66 F7 71 F0 76 2C 3F 86 8E 53 4D F2 56<br />round[3].k  B6 FF 74 4E D2 C2 C9 BF 6C 59 0C BF 04 69 BF 41</p>
<p>round[4].in FA 63 6A 28 25 B3 39 C9 40 66 8A 31 57 24 4D 17<br />round[4].sb 2D FB 02 34 3F 6D 12 DD 09 33 7E C7 5B 36 E3 F0<br />round[4].sr 2D 6D 7E F0 3F 33 E3 34 09 36 02 DD 5B FB 12 C7<br />round[4].mc 63 85 B7 9F FC 53 8D F9 97 BE 47 8E 75 47 D6 91<br />round[4].k  47 F7 F7 BC 95 35 3E 03 F9 6C 32 BC FD 05 8D FD</p>
<p>round[5].in 24 72 40 23 69 66 B3 FA 6E D2 75 32 88 42 5B 6C<br />round[5].sb 36 40 09 26 F9 33 6D 2D 9F B5 9D 23 C4 2C 39 50<br />round[5].sr 36 33 9D 50 F9 B5 39 26 9F 2C 09 2D C4 40 6D 23<br />round[5].mc F4 BC D4 54 32 E5 54 D0 75 F1 D6 C5 1D D0 3B 3C<br />round[5].k  3C AA A3 E8 A9 9F 9D EB 50 F3 AF 57 AD F6 22 AA</p>
<p>round[6].in C8 16 77 BC 9B 7A C9 3B 25 02 79 92 B0 26 19 96<br />round[6].sb E8 47 F5 65 14 DA DD E2 3F 77 B6 4F E7 F7 D4 90<br />round[6].sr E8 DA B6 90 14 77 D4 65 3F F7 F5 E2 E7 47 DD 4F<br />round[6].mc 98 16 EE 74 00 F8 7F 55 6B 2C 04 9C 8E 5A D0 36<br />round[6].k  5E 39 0F 7D F7 A6 92 96 A7 55 3D C1 0A A3 1F 6B</p>
<p>round[7].in C6 2F E1 09 F7 5E ED C3 CC 79 39 5D 84 F9 CF 5D<br />round[7].sb B4 15 F8 01 68 58 55 2E 4B B6 12 4C 5F 99 8A 4C<br />round[7].sr B4 58 12 4C 68 B6 8A 01 4B 99 F8 2E 5F 15 55 4C<br />round[7].mc C5 7E 1C 15 9A 9B D2 86 F0 5F 4B E0 98 C6 34 39<br />round[7].k  14 F9 70 1A E3 5F E2 8C 44 0A DF 4D 4E A9 C0 26</p>
<p>round[8].in D1 87 6C 0F 79 C4 30 0A B4 55 94 AD D6 6F F4 1F<br />round[8].sb 3E 17 50 76 B6 1C 04 67 8D FC 22 95 F6 A8 BF C0<br />round[8].sr 3E 1C 22 C0 B6 FC BF 76 8D A8 50 67 F6 17 04 95<br />round[8].mc BA A0 3D E7 A1 F9 B5 6E D5 51 2C BA 5F 41 4D 23<br />round[8].k  47 43 87 35 A4 1C 65 B9 E0 16 BA F4 AE BF 7A D2</p>
<p>round[9].in FD E3 BA D2 05 E5 D0 D7 35 47 96 4E F1 FE 37 F1<br />round[9].sb 54 11 F4 B5 6B D9 70 0E 96 A0 90 2F A1 BB 9A A1<br />round[9].sr 54 D9 90 A1 6B A0 9A B5 96 BB F4 0E A1 11 70 2F<br />round[9].mc E9 F7 4E EC 02 30 20 F6 1B F2 CC F2 35 3C 21 C7<br />round[9].k  54 99 32 D1 F0 85 57 68 10 93 ED 9C BE 2C 97 4E</p>
<p>round[A].in BD 6E 7C 3D F2 B5 77 9E 0B 61 21 6E 8B 10 B6 89<br />round[A].sb 7A 9F 10 27 89 D5 F5 0B 2B EF FD 9F 3D CA 4E A7<br />round[A].sr 7A D5 FD A7 89 EF 4E 27 2B CA 10 0B 3D 9F F5 9F<br />round[A].k  13 11 1D 7F E3 94 4A 17 F3 07 A7 8B 4D 2B 30 C5</p>
<p>ciphertext  69 C4 E0 D8 6A 7B 04 30 D8 CD B7 80 70 B4 C5 5A</p></blockquote>
<p>Which should give you just about all the data you&#8217;d need for debugging your own AES hardware or software.  You can input the key as 16 hex bytes (32 characters) or 16 ASCII characters, or even convert back and forth with clever misuse of the software.  So this trainer should be able to generate encryption/decryption examples for damn near any AES128 situation you can think of.</p>
<p>For continued discussion as well as the source code and binaries (and a small puzzle from us to you!), please continue on to the next page.</p>
<p><strong>Continued on Next Page         <a href="http://www.openschemes.com/modules/wordpress/2010/03/03/fun-with-aes-128-example-encryption-with-aes-trainer/2/">Jump to Page 2</a> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/03/03/fun-with-aes-128-example-encryption-with-aes-trainer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Nandoori - SPMP8k Raw USB NAND Dumper</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/02/16/nandoori-spmp8k-raw-usb-nand-dumper/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/02/16/nandoori-spmp8k-raw-usb-nand-dumper/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 08:04:20 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>firmware</category><category>Software</category><category>SPMP8k</category><category>USB</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/02/16/nandoori-spmp8k-raw-usb-nand-dumper/</guid>
		<!--<description>
			<![CDATA[There are times when the pre-packaged firmware extractor FRMorp just isn&#8217;t what you want.  In fact, we usually hate anything pre-packaged and always prefer to work with the raw data.  So if you&#8217;re like us, you&#8217;ve probably either
	
Already rewritten the FRMorp to dump raw NAND pages
	
Muttered to yourself that we&#8217;re idiots for not releasing the [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>There are times when the pre-packaged firmware extractor FRMorp just isn&#8217;t what you want.  In fact, we usually hate anything pre-packaged and always prefer to work with the raw data.  So if you&#8217;re like us, you&#8217;ve probably either
<ol>	
<li>Already rewritten the FRMorp to dump raw NAND pages</li>
<p>	
<li>Muttered to yourself that we&#8217;re idiots for not releasing the raw tool</li>
<p></ol>
<p>Well, you&#8217;re in luck.  We&#8217;re hereby releasing nandoori to the masses so high-speed raw USB nand dumping is now at your fingertips!  As we warned in previous articles, this tool can generate lots of data in a short time.  For example, if your device has 8GB of flash, you can dump the entire 8GB (2,097,152 pages at 4k per page) by using the command
<p align="center"><em>nandoori 0&#215;0 0&#215;200000 slow.bin</em></p>
<p>Yes, this will take a long time.  And will probably contain mostly blank pages ($FF) so is not terribly worthwhile.  But the important thing is that you CAN do it if you want to.  And idiot-proofing is one thing that we&#8217;re totally against here at openschemes.  We&#8217;ll warn you of potential bricks (but the SPMP8k seems brick-proof so far) but otherwise, we think you should enjoy rebuilding your system after each horrible technical mishap.  One piece of advice that we always pass to new engineers is:<br />
<blockquote><em>Make every mistake once.  From simple typos to connecting power supplies backwards - go ahead!  Boom, smoke, hooray!  From breaking the upstream build to all-layer-change disasters, feel free!  But only once.  Learn from your mistakes, fix the problem, and don&#8217;t let it happen again.</em></p></blockquote>
<p>Follow that rule, and your first few engineering years will be hellish, as they would be anyway.  But after that, you&#8217;ll rise to the top and continue in an excellent path.</p>
<p>Enough musing, let&#8217;s get back to the tech.  nandoori expects arguments of a start page, a stop page, and an output file.  It will fetch a single page if start and stop are the same number.  It expects both numbers to be hex, although it is not required for them to start with 0x.  In our examples, we will always start with 0x just to be clear and unambiguous.</p>
<p>Some interesting pages are:
<ul>	
<li><strong>0&#215;0</strong> - The RedBoot PAT table.  This page lists all the pages that contain the RedBoot.mmc file from BOOT.IMG.</li>
<p>	
<li><strong>0&#215;2</strong> - One of the INIT PAT tables.  Hardwired to 0&#215;2, so this must mean that the RedBoot PAT table cannot exceed 8k bytes, or the bootware cannot exceed 2044 pages and therefore cannot be larger than 8,372,224 bytes.  That&#8217;s pretty huge and pretty awesome if you ask us.</li>
<p>	
<li><strong>0&#215;12</strong> - The other INIT PAT Table.  For the actual DRAM init, IIRC.</li>
<p>	
<li><strong>0&#215;80, 0&#215;100, 0&#215;180</strong> - Three copies of DRAM config data plus RedBoot startup script.  Found when working on reflash.  We thought they were just used to store the ScanRam config, but it turns out the device won&#8217;t boot eCos if they&#8217;re blank.  Important enough to have three copies!</li>
<p>	
<li><strong>0&#215;2000</strong> - The ROFS PAT table for allocating SOFT.IMG.  Different format than RB&#8217;s PAT table.  Haven&#8217;t studied too much.</li>
<p>	
<li><strong>0&#215;2080</strong> - Start of SOFT.IMG.</li>
<p></ul>
<p>When we use this tool, it&#8217;s either for inspecting a single page of nand, such as..
<p align="center"><em>nandoori 0&#215;0 0&#215;0 RBPAT.bin</em></p>
<p>Or for checking the validity of our flash tools by comparing before and after for the entire boot section, such as&#8230;
<p align="center"><em>nandoori 0 0&#215;300 BOOT.bin</em></p>
<p>Your usage may vary, these are just some simple examples.</p>
<p>Please keep in mind that the SPMP8k uses block-wise nand.  In our case, one block is 0&#215;80 (128) pages.  This means that the smallest bit of flash that you can erase is one block: 0&#215;80 pages, or 512k (524,288 bytes).</p>
<p>We mention this because we will soon release a raw write tool that can be used for flashing byte-wise backups of your device for the extra paranoid.  It will take nandoori dumps as input and write them to the device.  If it does not have 0&#215;80 pages worth of data to write, you will be left with blank nand where you should have code = fail!  So if you are intending to back up your device, or parts of your device - <strong>PLEASE MAKE THEM MULTIPLES OF 0&#215;80 PAGES (512k)</strong>.</p>
<p>For general hax0ring, use any page length you want.  It&#8217;s only for backups intending to be rewritten that the 128-page multiple must be used.  OK - continue on to page 2 for the source and executables.  Enjoy your spicy and delicious nandoori!</p>
<p><code><br /></code><strong>Continued on Next Page            <a href="http://www.openschemes.com/modules/wordpress/2010/02/16/nandoori-spmp8k-raw-usb-nand-dumper/2/">Jump to Page 2</a></strong>       
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/02/16/nandoori-spmp8k-raw-usb-nand-dumper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SPMP8k FRMorp v1.1 - Improved the Linux side</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/02/09/spmp8k-frmorp-v11-improved-the-linux-side/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/02/09/spmp8k-frmorp-v11-improved-the-linux-side/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 07:40:26 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>firmware</category><category>linux</category><category>software</category><category>SPMP8k</category><category>USB</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/02/09/spmp8k-frmorp-v11-improved-the-linux-side/</guid>
		<!--<description>
			<![CDATA[Howdy all,
It looks like quite a few people have already gotten the FRMorp tool up and running, which is fantastic!  However, when we tried to compile and run it under Linux, it was less than perfect out of the box - sorry!
After a little twiddling and recompiling, we&#8217;ve got a new version that should work [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>Howdy all,</p>
<p>It looks like quite a few people have already gotten the FRMorp tool up and running, which is fantastic!  However, when we tried to compile and run it under Linux, it was less than perfect out of the box - sorry!</p>
<p>After a little twiddling and recompiling, we&#8217;ve got a new version that should work on either win or on Linux.  Some notes for the Linux side, and other improvement notes:
<ul>	
<li>You need libusb and the dev libs.  Try yum install libusb* if you can&#8217;t link.</li>
<p>	
<li>Makefile included, as we kept forgetting to type -lusb when building</li>
<p>	
<li>You must run as sudo or su in order to have authority to detach the standard USB driver and use LIBUSB.  Else you&#8217;ll die with error -1.</li>
<p>	
<li>Uncomment the #define LIN line at the top when building on Linux and the extra detach instruction will be automatically included.</li>
<p>	
<li>Made the bombout error messages a little more verbose to help those that may be debugging on Linux.</li>
<p></ul>
<p>Other than that, there&#8217;s not much else to say.  make  ./frmorp   enjoy.  Zip file on page 2.</p>
<p><strong>Continued on Next Page&#8230;    <a href="http://www.openschemes.com/modules/wordpress/2010/02/09/spmp8k-frmorp-v11-improved-the-linux-side/2/">Jump to Page 2</a> </strong>  
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/02/09/spmp8k-frmorp-v11-improved-the-linux-side/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SPMP8k FRMorp - USB IMG dumper</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/02/08/spmp8k-frmorp-usb-img-dumper/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/02/08/spmp8k-frmorp-usb-img-dumper/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 08:14:12 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>software</category><category>SPMP</category><category>SPMP8k</category><category>Sunplus</category><category>USB</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/02/08/spmp8k-frmorp-usb-img-dumper/</guid>
		<!--<description>
			<![CDATA[Well here it is folks, the long-awaited ability to dump your SPMP8k over USB!  What used to take 6-8 hours will now complete in just a few minutes.  It&#8217;s a truly beautiful thing to watch, especially if you already suffered through Fetch or our other serial tools.  We were considering releasing our USB NAND [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>Well here it is folks, the long-awaited ability to dump your SPMP8k over USB!  What used to take 6-8 hours will now complete in just a few minutes.  It&#8217;s a truly beautiful thing to watch, especially if you already suffered through Fetch or our other serial tools. <img src='http://www.openschemes.com/modules/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />We were considering releasing our USB NAND dumper tool called <em><strong>nandoori </strong></em>at the end of the week last week.  You may have even enjoyed watching our online debug session on IRC - don&#8217;t worry, we&#8217;ve got the USB packet flags right this time..  But nandoori provides so much data in the blink of an eye that it&#8217;s probably not useful for anyone except the hardcore hex-editor who wants to see the allocation tables and raw page data.</p>
<p>What is needed is the reverse of FRMPro - a tool that, via USB, can extract the Bootware IMG file and the Software IMG file quickly and simply.  That is exactly what you&#8217;ll get with
<p align="center"><em><strong>FRMorp - USB IMG Dumper for the SPMP8k</strong></em></p>
<p>
<p align="left">What, no link?  Well, we have to put it on the second page to count the article views.  It&#8217;s even gotten worse since so many people are using adblockers to remove our Google ads.  C&#8217;mon people, they pay for the cost of the site.  Or would, someday, we&#8217;re hoping.  But if you guys keep stripping the ads off this page then we can guarantee you that eventually, you&#8217;ll kill off the site.  We&#8217;re not EDN here with heinous full-page takeovers, just simple ads in between the pages of the articles.  Some of them are actually pretty good, cheap USB logic analyzers and the like.  We&#8217;ll keep weeding out the stupid ones whenever we see them, too.</p>
<p>
<p align="left">Soapbox OFF!  Back to the tech.  FRMorp - get it, the reverse of pro?  We&#8217;re hilarious, we know!  FRMorp is designed to get back the BOOT_Vxx.IMG and SKxx_yy_zz.IMG files that are programmed into the device using FRMPro.  For this and other articles, we will call this the BOOTware and the SOFTware.</p>
<p>
<p align="left">Now this data is not just two files in a directory somewhere - it&#8217;s actually broken up and placed in various locations in low flash memory.  The program does a fair bit of reconstruction, so if you want to read through the source you may want to use this article as a guide.</p>
<p>
<p align="left">There are three main functions in FRMorp.  They were written in such a manner that they *should* be easily rippable to new programs, or compiled to a lib or dll for general-purpose usage.  The main functions are:</p>
<ol>	
<li><u><em>getBOOTFSfile </em></u>-  Given a starting page in nand flash, getBOOTFS file will go searching for a PAT - page allocation table.  If it finds one, it will dump all the data that is marked in that file&#8217;s PAT to a file on your HDD.  Normally, you get RedBoot&#8217;s PAT from the first good page.  You get the first assistant program we called DRAM_Init1 from the first good page after RedBoot&#8217;s PAT.  And another assistant we called DRAM_Init2 from the first good page after 0&#215;12.  So getBOOTFSfile is called 3 times with the arguments 0, n+1, and 0&#215;12 to get three files: RedBoot.mmp, DRAM_Init1.mmp, and DRAM_Init2.mmp.  These are the constituents of BOOT_Vxx.IMG.</li>
<p>	
<li><em><u>packBOOTimg </u></em>- This was going to be a seperate tool, but we said WTF.  Give it the names of the three bootware files from getBOOTFSfile, and it will pack you up the full bootware img file BOOT.IMG.  This file contains the 3 files from above, but adds some stupid headers and a completely retarded checksum that Sunplus must have throught of after drinking melamine-tainted milk or something.  FRMPro requires these headers and checksum, so we must pack the files or learn to flash ourselves.  Soon, my friends, soon.</li>
<p>	
<li><u><em>getSOFTimg </em></u>- This one is still VERY primitive.  As far as we can tell, the device reads page 0&#215;2000 to find the length of the software partition, and then the ROFS is blindly written starting at page 0&#215;2080.  But that seems highly unreliable due to bad blocks in the nand, etc.  So for now, getSOFTimg also reads blindly.  The output that we get is a perfect binary comparison to what we flash to the device, but someday this routine may need to be updated with some additional smarts.</li>
<p></ol>
<p>That&#8217;s where we need your help.  If you dump an IMG that is not a perfect binary comparison to what you&#8217;ve programmed into your device then we REALLY want to hear from you.  We&#8217;ll send you nandoori and you&#8217;ll make us some raw data dumps that we will use to debug the issue and update the FRMorp tool.</p>
<p>But please, go easy on us.  If you see we&#8217;re already flooded with users commenting about bad dumps, please don&#8217;t post duplicate issues.  Once we address their problems with an update, then please DO post if that update does not cure your problem as well.</p>
<p>Thanks in advance!</p>
<p>Ok folks, time for the obligatory page turn and more info on FRMorp and how to use it.</p>
<p><strong>Continued on Next Page&#8230;      <a href="http://www.openschemes.com/modules/wordpress/2010/02/08/spmp8k-frmorp-usb-img-dumper/2/">Jump to Page 2 </a> </strong>  
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/02/08/spmp8k-frmorp-usb-img-dumper/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SPMP8k Serial Port Pinout</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-serial-port-pinout/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-serial-port-pinout/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 18:38:11 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>circuits</category><category>RS-232</category><category>SPMP8k</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-serial-port-pinout/</guid>
		<!--<description>
			<![CDATA[This is a quick one for the online notebook - got a request for the actual IC pins used for the UART.  Since it seemed confusing to call it something like the 334&#8242;th pin or the 8th pin on the 3rd side, we decided to post a quick pic.
It really is the 3rd pin on [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>This is a quick one for the online notebook - got a request for the actual IC pins used for the UART.  Since it seemed confusing to call it something like the 334&#8242;th pin or the 8th pin on the 3rd side, we decided to post a quick pic.</p>
<p>It really is the 3rd pin on the 4th side, but we&#8217;re not interested in counting the number of pins to see if it&#8217;s the 334th or 212th or what.  Here&#8217;s the pic.   Let us know if your device does not use this pin location, that could be very interesting info.</p>
<p><code><br /></code>
<p align="center"><img height="345" width="378" id="image161" alt="SPMP8k Serial Port Pinout" src="http://www.openschemes.com/uploads/wordpress/2010/02/8k_serial_port.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-serial-port-pinout/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SPMP8k - A door with a lock is sometimes less secure than a door without</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-a-door-with-a-lock-is-sometimes-less-secure-than-a-door-without/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-a-door-with-a-lock-is-sometimes-less-secure-than-a-door-without/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 07:53:06 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>software</category><category>Software hacks</category><category>SPMP8k</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-a-door-with-a-lock-is-sometimes-less-secure-than-a-door-without/</guid>
		<!--<description>
			<![CDATA[This all started whenwe found a serious mistake in the version of the firmware on our device.  Seems the ability to reflash from MicroSD was accidentally removed!  Sure, we&#8217;ll talk more about that later unless you guys all figure it out yourselves in the meantime&#8230;  
But back to our problem - what will we [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>This all started whenwe found a serious mistake in the version of the firmware on our device.  Seems the ability to reflash from MicroSD was accidentally removed!  Sure, we&#8217;ll talk more about that later unless you guys all figure it out yourselves in the meantime&#8230; <img src='http://www.openschemes.com/modules/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But back to our problem - what will we do?  We can try to hex edit our 8000_MMI.RAP file but boo hoo, it just gets rejected.  And that only means one thing:</p>
<p>Checksum.</p>
<p>We love &#8216;em.  Sometimes.  They&#8217;re like a lock on a door that has no reason to be there.  It just makes people wonder what&#8217;s inside.  And once certain people get to wondering what&#8217;s inside&#8230;  Well, then it&#8217;s become a challenge, hasn&#8217;t it?</p>
<p>Today we will only talk about simple checksums using summation.  XOR is not too bad, but when you get into hashing things it all becomes much more difficult, and the article would be MUCH longer.</p>
<p>We rate this one a 2 - simple , but tries to be a bit tricky.  Worth a try, and great for beginners.</p>
<p>Barring any other ability to see into the brains of the device, one way to determine the algorithm for a checksum is to investigate the differences required to pass/fail.<br />Change a byte.  It should fail.  Now make a couple educated guesses about a second byte to change, and see if any of those pass.  Use the data from those trials to extend further guesses until you have the algorithm.  Some canned guesses for you to start with are:<br />
<blockquote><strong>DIFF:</strong> If the original byte increased by 1, decrease the byte next to it by 1.  You must also try the byte 2 down, 4 down, etc  for word, dword, etc sized checksums.  This is best for the type of checksum where the entire file is summed, and then a checksum is computed that will make the sum equal to 0, or $FFFFFFFF, or some magic number.</p>
<p><strong>SUM</strong>: If the original byte increased by 1, you would also increase the &#8220;test&#8221; byte by 1 as well.  This is good for locating checksums where all bytes in the file are summed up and the sum is stored somewhere.  If you increase the sum by 1, you can increase any corresponding byte in the file by 1 and pass.</p></blockquote>
<p>For very simple patches like nopping out an instruction or two, you can probably get away with just those two techniques and compute out your new sum, where it is either + or - the value of the change you are making.</p>
<p>That&#8217;s breaking a window.  We want a key.</p>
<p>By checking which bytes we need to diff, we quickly found that this checksum was 32-bits wide.  ie - incrementing byte n required byte n+4, or n+8, etc  to be decremented in order to pass.</p>
<p>Looking at the headers of a few files showed one bunch of bytes that had no reason to be there, and was always different.  Sure we accidentally changed the time/date byte once or twice and scratched our head when our sum didn&#8217;t work.  But we got it eventually.</p>
<p>The checksum initially looked like a simple CHK32, but running that checksum on our file did not give matching data.  We began modifying single bytes further down the file until&#8230;  Bang!  We failed.  Did we give up and die, or did we crack another beer and keep going?
<p align="center">Which will YOU do?</p>
<p><strong>Continued on Next Page&#8230;      <a href="http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-a-door-with-a-lock-is-sometimes-less-secure-than-a-door-without/2/">Jump to Page 2</a> </strong> 
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/02/04/spmp8k-a-door-with-a-lock-is-sometimes-less-secure-than-a-door-without/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Building SPMP8k OS Images.</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/01/30/building-spmp8k-os-images/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/01/30/building-spmp8k-os-images/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 00:52:58 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>software hacks</category><category>SPMP</category><category>SPMP8k</category><category>Sunplus</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/01/30/building-spmp8k-os-images/</guid>
		<!--<description>
			<![CDATA[We&#8217;ll start this article by talking about SPMP8k Software images.  These are the large (>50MB) IMG files generated by the SKLOGO program or found on the interweb.  They contain the operating system of the device and consist of lots of binary executables, even more XML configuration files, and even more BMP files.  This bunch of [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>We&#8217;ll start this article by talking about SPMP8k Software images.  These are the large (>50MB) IMG files generated by the SKLOGO program or found on the interweb.  They contain the operating system of the device and consist of lots of binary executables, even more XML configuration files, and even more BMP files.  This bunch of files is the output you get from <a href="http://www.openschemes.com/modules/wordpress/2010/01/29/spmp8k-nand-overview-and-nand-file-dump-tool-beta/">the file dumper from the last article</a>, although not in a nice packed single file.</p>
<p>It seems that when people want to change their device configuration, they are opening the IMG file and hex editing the XML&#8217;s.  That will certainly work, but is probably rather difficult for the beginner.</p>
<p>Another approach would be to dump your device or dump an IMG file to the full directory of files, edit them as you please, and then repack into an IMG and reflash the device.  At that point, you are free to add/remove/replace any images, binaries, or XML you like.  I smell a lot of background image customization tools on the horizon!</p>
<p>As we mentioned, one very slow way to get a full backup of software from an unknown device is to dump it via the serial port.  It works, and today we successfully repacked a file  dump into a new IMG and flashed that image to our semi-bricked PMP to bring it back to life.  But the process takes time.</p>
<p>If you happen to have your IMG file on hand, you can dump it to your hard drive in just seconds using the <strong>sprdump </strong>tool.  This is the tool that we mentioned in the last article, and we&#8217;ve received permission from the author to release it.  But in order to estimate how many people have actually downloaded it, we must force you to go to the next page.</p>
<p><strong>Continued on Next Page&#8230;       <a href="http://www.openschemes.com/modules/wordpress/2010/01/30/building-spmp8k-os-images/2/">Jump to Page 2</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/01/30/building-spmp8k-os-images/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SPMP8k NAND Overview and NAND File Dump Tool - beta</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/01/29/spmp8k-nand-overview-and-nand-file-dump-tool-beta/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/01/29/spmp8k-nand-overview-and-nand-file-dump-tool-beta/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 08:37:57 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>firmware</category><category>Redboot</category><category>RS-232</category><category>Software</category><category>SPMP</category><category>SPMP8k</category><category>Sunplus</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/01/29/spmp8k-nand-overview-and-nand-file-dump-tool-beta/</guid>
		<!--<description>
			<![CDATA[As you probably know, we&#8217;ve been busy dumping the raw NAND page data of the SPMP8k to see what mysteries it holds.  The answer is, surprisingly: not many!  But that&#8217;s a good thing - mysteries deep in the ROM are not a good thing.
One interesting note is that there are three filesystems on the flash:
BOOTFS: [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>As you probably know, we&#8217;ve been busy dumping the raw NAND page data of the SPMP8k to see what mysteries it holds.  The answer is, surprisingly: not many!  But that&#8217;s a good thing - mysteries deep in the ROM are not a good thing.</p>
<p>One interesting note is that there are three filesystems on the flash:<br />
<blockquote><strong>BOOTFS</strong>: Bootcode (2nd stage) and Redboot.  Starts at page 0.<br /><strong>RO(M)FS</strong>: System Software.  Starts at page 0&#215;2000<br /><strong>FAT</strong>: The Mass storage you can see over USB.   Takes up the rest of the flash.</p></blockquote>
<p>The first fielsystem is BOOTFS - this is our name by the way, just calling it the first thing that comes into mind.  This filesystem resides in the first few pages of flash.  It consists of several one-page (4k) functions and then the RedBoot binary.  This is what you&#8217;d find in the firmware files such as BOOT_V15.IMG.</p>
<p>The ROM bootstrapper (+++MMP RomCode&#8230;) searches the first few NAND pages to try to find the magic bytes 33 CC AA 55.  This signifies the start of a set of very crude allocation tables which point to two binary files responsible for initializing the DRAM, and the RedBoot binary.</p>
<p>Bootstrapper loads and executes the DRAM_Init() from flash, and once it has 16MB of DRAM, it load RedBoot into that and hands off control.</p>
<p>RedBoot either gets interrupted by you for nefarious purposes, or it loads a script which tells it to boot /IMAGE/8000_MMI.RAP.   Woo, directories - now we&#8217;re getting fancy!<br />This second filesystem is called ROMFS (we saw ROFS somewhere too) but it does not seem to be compliant with the actual ROMFS that was around long before the SPMP.  It&#8217;s still a fairly simple filesystem though, and can be explored through RedBoot by mounting the device /dev/nf2 and using the ls commands as we&#8217;re sure you&#8217;ve already done.</p>
<p>ROFS/ROMFS seems to be the whole kit &#038; kaboodle of the eCos platform, containing executables, codecs and emulators as well as tons of XML files for configuration.  This filesystem is what is contained in the big (>50MB) software files generated by the SKLOGO tool.</p>
<p>But SKLOGO simply takes different binary chunks and pastes them together - other than hex editing (which seems to work pretty well <a target="_blank" href="http://www.openschemes.com/modules/wordpress/2010/01/14/full-bootup-text-of-spmp8000/">ala Jaime</a>) it is difficult to make significant changes to the file system.  And that&#8217;s something that you KNOW we&#8217;re going to want to do.</p>
<p>In order to have free reign over the filesystem, it is easiest to unpack the entire ROFS filesystem to it&#8217;s individual files and directories and modify it at well.  Then, it&#8217;s pretty easy to use the Sunplus tools to repack and reflash your new filesystem to the device.</p>
<p><strong>SIDE NOTE:</strong><br />
<blockquote>We were very disappointed/entertained to see the following entries in the directory dump:</p>
<p>/IMAGE/GAME/GAME_CONFIG.TXT 22963<br />/IMAGE/GAME/GBA_BIOS.BIN 16384<br />/IMAGE/GAME/GPSP.BIN 776004</p>
<p>Because it means that not only has Sunplus ripped off GNU/eCos, they have also ripped off Exophase as well as Nintendo.  I mean, couldn&#8217;t you have changed it to data.dat1 and data.dat2?  No shame..  Still a nice IC tho, so we&#8217;re happy to continue plugging along in the hopes of getting SOMETHING legal onto this little device. <img src='http://www.openschemes.com/modules/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p></blockquote>
<p>The bright side is that we&#8217;ve invented a new game: Take a shot whenever you find something pirated, stolen, or used without permission in the Sunplus &#8216;8k PMP.  We&#8217;ve been hammered for days.</p>
<p>OK, OK - on to the dump tool..   Let us preface this with the warning that if you already have a copy of your firmware, there are much easier ways to extract it&#8217;s goods than the following tool.  This tool is a glorified console script that can also convert ASCII to bin.  Downloading the entire software will take time.  (5.25*Size)/115.2kbaud as a rough estimate, where 5.25 is a rough multiplier based on the ascii conversion and overhead.</p>
<p>We&#8217;re talking hours, folks.  About 6-7h if your RS-232 port is reliable.  If you&#8217;re like us and want an exact copy of one device to another, then this is a little faster than a nand dump so it might be a viable option.  A more likely use would be to download all the XML config data for your device to merge into a resource directory of another firmware.  But IMO, letting an inanimate object work itself to death all night while we sleep is not a big deal.</p>
<p>If you&#8217;re not scared off yet, then please</p>
<p><strong>Continue to Next Page&#8230;   <a href="http://www.openschemes.com/modules/wordpress/2010/01/29/spmp8k-nand-overview-and-nand-file-dump-tool-beta/2/">Jump to Page 2</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/01/29/spmp8k-nand-overview-and-nand-file-dump-tool-beta/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SPMP8k Development - Hello World, parasitic version</title>
		<link>http://www.openschemes.com/modules/wordpress/2010/01/27/spmp8k-development-hello-world-parasitic-version/</link>
		<comments>http://www.openschemes.com/modules/wordpress/2010/01/27/spmp8k-development-hello-world-parasitic-version/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 06:25:56 +0000</pubDate>
		<dc:creator>openschemes</dc:creator>
		
		<category>MP5</category>
<category>disassembly</category><category>hacks</category><category>MP5</category><category>Redboot</category><category>software</category><category>SPMP8000</category><category>SPMP8k</category>
		<guid isPermaLink="false">http://www.openschemes.com/modules/wordpress/2010/01/27/spmp8k-development-hello-world-parasitic-version/</guid>
		<!--<description>
			<![CDATA[If you&#8217;ve been following our other articles on the SPMP8k-based PMP devices, then you&#8217;ve probably already disassembled your device, poked around in the RedBoot console, dumped some memory, and crashed the device in clever and interesting ways.  Congratulations!
At this point, you&#8217;re probably ready to do some actual development.  Great!  One thing you may come to [...]]]></description>
			-->
			<content:encoded><![CDATA[<p>If you&#8217;ve been following our <a target="_blank" href="http://www.openschemes.com/modules/wordpress/category/hacks/mp5/">other articles</a> on the SPMP8k-based PMP devices, then you&#8217;ve probably already disassembled your device, poked around in the RedBoot console, dumped some memory, and crashed the device in clever and interesting ways.  Congratulations!</p>
<p>At this point, you&#8217;re probably ready to do some actual development.  Great!  One thing you may come to realize (if this is your first embedded project) is that you start with NOTHING.  Absolutely nothing. You can write all the software you want, but if you are writing in C you will quickly find that even the most trivial built-in functions need to be implemented specifically for your device.  We&#8217;ll start this article with a short discussion of how to get a small toolbox full of functions, and then continue with a C example program that can use those functions.</p>
<p>The end result of all this effort will be a console interaction such as the following.<br />
<blockquote>
<p align="left"><em>RedBoot> go -c 0&#215;200000<br />+do_go<br />image sel: 0, image_sel_set: 0<br />rmvb enable!<br />Mask interrupts on all channels<br />ID-CACHE sync and invalidate<br />set up a temporary context. workspace_end=0&#215;00effdd0, entry=0&#215;00200000<br />switch context to trampoline. workspace_end=0&#215;00effd80</em></p>
<p><em>Hello World, SPMP8k is alive!<br />Enter some text to see if I can read.<br />I&#8217;ll set the timeout to about 30 seconds for you slowpokes<br />Input> I am a hax0r of ultimate skillz</em></p>
<p><em>Result was 0&#215;1, your input was<br />I am a hax0r of ultimate skillz<br />Done&#8230;  Bye!</em></p>
<p><em>Program completed with status 0<br />RedBoot> </em></p></blockquote>
<p>Awesome.  Gratuitous self indulgence using only two functions: printf and gets.  Should be a breeze.</p>
<p>Let&#8217;s first consider printf - Printf has grown to quite a sophisticated function, parsing an arbitrary number of parameters, formatting, converting variables to various types of ASCII output.  You can find printf source code online, but it always depends on another function called putc - put character.</p>
<p>This is the even lower-level guy, taking one character from your string and doing the grunt work of getting it displayed.  This is custom for each device and usually consists of things like checking a display buffer (or UART buffer in our case of serial port), setting up the device, stuffing our character into a register, and optionally marking or signalling that there is now a new character for the hardware device to display.  Whew!</p>
<p>You can certainly write the code to do this type of thing, but it takes some work and is probably not suitable for a beginner.  If you have the skills - go for it!  But if you&#8217;re just starting out and your head is already swimming, let us show you a little cheat.</p>
<p>Since we presently need to have RedBoot running to execute a program anyway, we can just call RedBoot&#8217;s printf function.  In fact, by downloading the RedBoot source code you can look up all the support functions it contains, and how to call them.  Now THAT&#8217;s a hell of a jump start.</p>
<p>The only remaining requirement is to find where those functions are located in RAM while RedBoot is running.  Our first program will act as a little parasite that will attach to Redboot and call it&#8217;s functions.  In order to call those functions, we must locate ourselves in memory close enough to call RedBoot, but far enough away that if we start making variables, buffers, our stuff does not overwrite RedBoot&#8217;s memory.  That sometimes causes spectacular crashes and interesting hangups, but is mostly just a pain in the ass.</p>
<p>Keep in mind that your device may have a different RedBoot version, or may have a different memory layout.  When you start calling memory locations directly, you&#8217;ve got to make sure you have the right one.</p>
<p>You will first need a RAM dump of the section of memory that contains RedBoot.  You get a hint during the startup text when you see the line that says:<br />
<blockquote>RAM: 0&#215;00000000-0&#215;00f00000, [0&#215;00200000-0&#215;00f00000] available</p></blockquote>
<p>It looks like RedBoot has taken the first 2MB for itself, and left the user the next 14MB.  In order to be safe, we should dump the entire section - we&#8217;ll find RedBoot&#8217;s exact location later.  Tell your terminal program to start capturing text, and fire the incredibly slow dump of the first 2MB.<br />
<blockquote><em>RedBoot> dump -b 0&#215;0 -l 0&#215;200000</em></p></blockquote>
<p>Go do something else for about ten minutes, or sit around and watch glassy-eyed as the text scrolls past.  An alternative dump method would be to use arm-elf-gdb if you have it.  Just disconnect your terminal software and use the following commands, where  is the /dev/ name or COMx name of the PC serial port you are using.<br />
<blockquote><em>arm-elf-gdb</em></p>
<p><em>(gdb) target remote<br /></em></p>
<p><em>Remote debugging using</em></p>
<p><em>0&#215;0003bcd0 in ?? ()<br />(gdb) dump binary memory myfile.bin 0&#215;0 0&#215;1fffff</em></p></blockquote>
<p>We found long dumps to be problematic in gdb, which is a bummer because we use it almost exclusively for everything else.</p>
<p><strong>Continued on Next Page&#8230;          <a href="http://www.openschemes.com/modules/wordpress/2010/01/27/spmp8k-development-hello-world-parasitic-version/2/">Jump to Page 2</a></strong>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.openschemes.com/modules/wordpress/2010/01/27/spmp8k-development-hello-world-parasitic-version/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
