The Moxie Bloghttp://moxielogic.github.io/blog/2019-12-14T00:00:00-05:00Evaluating DejaGnu results with Red Light Green Light2019-12-14T00:00:00-05:00greentag:moxielogic.github.io,2019-12-14:/blog/red-light-green-light.html/<p>Last year I hacked up a tool in frustration called <a href="https://rl.gl">Red Light Green
Light</a> (rlgl) -- a proof-of-concept effort to
demonstrate a git-centric way to manage "quality gates" in a CI/CD
pipeline.</p>
<p>A CI/CD quality gate is a process that evaluates the quality of a
software artefact before allowing …</p>Ledger launches moxie-based secure VM technology for blockchain applications2016-03-02T00:00:00-05:00greentag:moxielogic.github.io,2016-03-02:/blog/introducing-bolos.html/<p>So here's an interesting picture from <a href="https://www.ledgerwallet.com">Ledger</a>. Check out the chewy center on the right -- that APP is a <em>moxie</em> binary!</p>
<p><center>
<img alt="bolos" src="https://cdn-images-2.medium.com/max/800/1*K5LiFrZiqHWMD2QkiioIcQ.png">
<em>Image credit: Ledger's <a href="https://medium.com/@Ledger/introducing-bolos-blockchain-open-ledger-operating-system-b9893d09f333#.loy1hd3s3">blog</a></em>
</center></p>
<p><a href="https://www.ledgerwallet.com">Ledger</a>, the hardware bitcoin wallet company, just announced
<a href="https://medium.com/@Ledger/introducing-bolos-blockchain-open-ledger-operating-system-b9893d09f333#.loy1hd3s3">BOLOS</a>, the "Blockchain Open Ledger Operating Systems". What's
most interesting to me, however, is that they have …</p>Moxie Mixie: Frustrating Remote Attackers with Container Specific Instruction Sets2016-01-14T00:00:00-05:00greentag:moxielogic.github.io,2016-01-14:/blog/moxie-mixie.html/<p>While there are many existing technologies to frustrate remote
attackers, it can be fun to think up novel protections that might be
used to layer on additional defences.</p>
<p>Consider, for instance, that remote code execution through attacks
like buffer overflows depends on knowledge of the remote systems'
instruction set. Knowledge …</p>Moxie talk at Bitcoin Dev Meetup2015-02-15T15:21:00-05:00greentag:moxielogic.github.io,2015-02-15:/blog/moxie-talk-at-bitcoin-dev-meetup.html/<p><center>
<img alt="" src="http://moxielogic.github.io/images/bcdev.jpeg">
</center></p>
<p>A very meta photo of me at the Toronto Bitcoin Developer Meetup
yesterday, explaining moxie, and the value of a security oriented VM
(moxiebox).</p>
<p>Photo used by permission from Jan Miranda.</p>An ELF Machine Number for Moxie2015-01-09T15:21:00-05:00greentag:moxielogic.github.io,2015-01-09:/blog/elf-machine-number.html/<p>Moxie was assigned an official ELF machine number this week! You can
check it out here:
<a href="http://www.sco.com/developers/gabi/latest/ch4.eheader.html">http://www.sco.com/developers/gabi/latest/ch4.eheader.html</a>.</p>
<p>All ELF files start with a header describing properties of the object
at hand. One of the most important properties is the 'machine' type …</p>Compacting the code with shorter load/store offsets2014-12-28T08:47:00-05:00greentag:moxielogic.github.io,2014-12-28:/blog/shorter-load-store-offsets.html/<p>You may recall that moxie supports two instructions lengths: 16- and 48-bit.
Today I'm introducing a few 32-bit instructions as well.</p>
<p>Previously, moxie's "load and store with offset" instructions were
defined as...</p>
<blockquote>
<table width='100%'><tr><td><b>ldo.l</b></td><td align='right'><b>00001100AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</b></td></tr></table>
Load offset, long. Loads into <b>$rA</b> the 32-bit value from memory pointed at by …</blockquote>Multiplication in the Real World2014-12-24T08:47:00-05:00greentag:moxielogic.github.io,2014-12-24:/blog/real-world-multiply.html/<p>The bitcoin team has been exercising moxie in ways that it hasn't been
stressed before. For example, they've been examining the code quality
for their crypto libraries like
<a href="https://github.com/bitcoin/secp256k1">libsecp256k1</a>, an elliptical
curve crypto library in C. One of their first feedbacks here was that
moxie provides no native way to …</p>Moxiebox and bitcoin2014-12-18T05:00:00-05:00greentag:moxielogic.github.io,2014-12-18:/blog/moxiebox-and-bitcoint.html/<p><center>
<img alt="http://bitcoin.org" src="http://moxielogic.org/images/Bitcoin-logo.jpg">
</center></p>
<p>One of the more interesting developments around moxie is the adoption
of the <a href="http://moxielogic.org/blog/pages/architecture.html">moxie
architecture</a> by
the core bitcoin developers (<a href="http://garzikrants.blogspot.ca/">Jeff
Garzik</a>, in particular), for an
experimental project called
<a href="http://github.com/jgarzik/moxiebox"><code>moxiebox</code></a>.</p>
<p>To quote Jeff...</p>
<blockquote>
<p>The goal is to provide a secure, sandboxed execution mechanism that enables deterministic input, processing and output …</p></blockquote>New Site2014-12-02T00:40:00-05:00greentag:moxielogic.github.io,2014-12-02:/blog/new-site.html/<p>I had finally had enough of the wiki spammers, and decided to migrate
all of my content over to a static github hosted site. I believe all
of the blog entries migrated over now, and I'm in the process of
migrating the wiki content over to pages you can link …</p>Sign Extension2014-04-04T00:40:00-04:00greentag:moxielogic.github.io,2014-04-04:/blog/sign-extension.html/<p>Moxie zero-extends all 8 and 16-bit loads from memory. Until recently,
however, the GCC port didn't understand how loads worked, and would
always shift loaded values back and forth to either empty out the upper
bits or sign-extend the loaded value. While correct, it was overly
bloated. If we're loading …</p>NetHack in your browser2014-01-26T18:12:00-05:00greentag:moxielogic.github.io,2014-01-26:/blog/nethack-in-your-browser.html/<p>This is a moxie-rtems port of NetHack running on a modified version of
the gdb moxie simulator compiled to javascript with <a href="https://github.com/kripken/emscripten" title="emscripten">emscripten</a>.</p>
<canvas id="tty" class="screen" width="640" height="384">
Terminal uses canvas
</canvas>
<script src="http://kl7107.github.io/moxie-sim/c/terminal.js"></script>
<script src="http://kl7107.github.io/moxie-sim/c/terminal-input.js"></script>
<script src="http://kl7107.github.io/moxie-sim/c/moxie.js"></script>
<script src="http://kl7107.github.io/moxie-sim/c/nethack.js"></script>
<p><a href="http://github.com/kl7107">Krister Lagerström</a> is responsible for this marvellous hack.</p>
<p>Also, I suppose this blog entry represents a distribution of some GPL'd
source code from GDB, so …</p>The Moxie Game Console?2014-01-11T06:06:00-05:00greentag:moxielogic.github.io,2014-01-11:/blog/the-moxie-game-console.html/<p>Ok, not quite, but <a href="https://github.com/kl7107" title="Krister">Krister Lagerström</a> recently did something cool..</p>
<p><center>
<img alt="nethack" src="http://moxielogic.github.io/images/nethack.png">
</center></p>
<p>That's <a href="http://www.nethack.org/" title="NetHack">NetHack</a> ported to <a href="http://rtems.org" title="RTEMS">RTEMS</a> running on the moxie based <a href="http://github.org/atgreen/moxie-cores" title="Marin SoC">Marin
SoC</a>.</p>
<p>It runs on QEMU, via
"<code>qemu-system-moxie --nographic --machine marin --kernel nethack.elf</code>",
or on FPGA hardware. I tested with a Nexys 3 Spartan-6 board by simply
converting it …</p>Putting it together: on-chip firmware2013-12-10T03:45:00-05:00greentag:moxielogic.github.io,2013-12-10:/blog/putting-it-together-on-chip-firmware.html/<p>The on-chip <a href="https://github.com/atgreen/moxie-cores/blob/master/firmware/bootrom/tinystub.c" title="firmware">firmware</a> for the <a href="https://github.com/atgreen/moxie-cores/tree/master/soc/marin" title="Marin SoC">Marin SoC</a> has been updated with the
gdb stub, so now when you program the FPGA, you'll see the following on
the serial console:</p>
<div class="highlight"><pre><span></span><span class="nv">MOXIE</span> <span class="nv">On</span><span class="o">-</span><span class="nv">Chip</span> <span class="nv">Bootloader</span> <span class="nv">v2</span>.<span class="mi">0</span>
<span class="nv">Copyright</span> <span class="ss">(</span><span class="nv">c</span><span class="ss">)</span> <span class="mi">2013</span> <span class="nv">Anthony</span> <span class="nv">Green</span>
<span class="nv">Waiting</span> <span class="k">for</span> <span class="nv">an</span> <span class="nv">S</span><span class="o">-</span><span class="nv">Record</span> <span class="nv">Download</span> <span class="nv">or</span> <span class="nv">Remote</span> <span class="nv">GDB</span> <span class="nv">Connection …</span></pre></div>A Really Tiny GDB Remote Protocol Stub2013-11-28T18:44:00-05:00greentag:moxielogic.github.io,2013-11-28:/blog/a-really-tiny-gdb-remote-protocol-stub.html/<p>I recently trimmed the Marin SoC's on-chip memory down to 4k. The
existing firmware for downloading srecord programs into external RAM for
execution was taking up about 2k. With 2k to spare, I was wondering if
you could fit a GDB remote protocol stub in there as well. It turns …</p>Moxie on Altera's Cyclone II, and a Chance Encounter2013-08-08T18:59:00-04:00greentag:moxielogic.github.io,2013-08-08:/blog/moxie-on-alteras-cyclone-ii-and-a-chance-encounter.html/<p>I recently fired up the Altera software, Quartus II, and spent a little
time porting the Marin SoC to the popular Cyclone II based DE2 board.
There's no external memory support yet, but on-chip memory is working,
and it looks like the on-chip bootloader is coming up properly. As
usual …</p>QEMU 1.5 includes Moxie support2013-05-21T04:16:00-04:00greentag:moxielogic.github.io,2013-05-21:/blog/qemu-1-5-includes-moxie-support.html/<p>QEMU 1.5 was just released the other day, and in the <a href="http://lists.nongnu.org/archive/html/qemu-devel/2013-05/msg02557.html">"And much
more..."</a> category I'm happy to say that it includes Moxie support!</p>
<p>This release contains basic Moxie core support, with the imaginary
"moxiesim" board support. I have some local changes that provide Marin
SoC emulation, and can …</p>An On-Chip Bootloader2013-05-06T02:25:00-04:00greentag:moxielogic.github.io,2013-05-06:/blog/an-on-chip-bootloader.html/<p>Good news: we can access external memory! The logic for my pseudo-static
RAM controller is working, and big programs can finally run on hardware.</p>
<p>You may recall that I had previously only been accessing fake memory
that was configured directly out of limited FPGA resources. I could
squeeze a tiny …</p>And time ticks on...2013-03-29T20:12:00-04:00greentag:moxielogic.github.io,2013-03-29:/blog/and-time-ticks-on.html/<p>The interrupt controller <a href="https://github.com/atgreen/moxie-cores/commit/0e44d0f29a2f05ef7f99fb1fc5d670d7f99d7c0b">is working now</a>, as is the timer and my
exception handling firmware. So now I'm able to write a basic stop-watch
application, where the 7-segment display simply increments the count
every second. Yes, this sounds basic, but there's a lot of complexity
under the hood! This is …</p>Moxie ports and hardware developments2013-03-24T04:25:00-04:00greentag:moxielogic.github.io,2013-03-24:/blog/moxie-ports-and-hardware-developments.html/<p>It's been a while since my last update.. let me bring you up to speed.</p>
<p>A couple of <a href="http://sourceware.org/libffi" title="libffi">libffi</a> releases got in the way of moxie hacking
(although libffi 3.0.13 now includes full moxie support!), but things
are picking up speed again.</p>
<p>On the software side of things …</p>Native On-Chip GDB Remote Protocol Support2012-11-24T05:47:00-05:00greentag:moxielogic.github.io,2012-11-24:/blog/native-on-chip-gdb-remote-protocol-support.html/<p>A typical software debug solution for an embedded systems might involve
a <a href="http://en.wikipedia.org/wiki/Joint_Test_Action_Group">JTAG</a> connection to the board, and then some kind of protocol
translation software that handles communication between GDB's remote
serial protocol and the target JTAG port (see <a href="http://openocd.sourceforge.net/">OpenOCD</a>, for
instance). The FPGA systems I'm working with include JTAG …</p>Running a C Program on the Marin SoC2012-11-15T21:10:00-05:00greentag:moxielogic.github.io,2012-11-15:/blog/running-a-c-program-on-the-marin-soc.html/<p>I've just committed the bits required to run a <a href="https://github.com/atgreen/moxie-cores/blob/master/firmware/mdata.c">C program</a> on the
Marin SoC.</p>
<p>Rather than hook up the Nexys3 external RAM module, I'm using extra
space on the FPGA itself for RAM. Most of the hard work was sorting out
the <a href="https://github.com/atgreen/moxie-cores/blob/master/soc/marin/moxie-marin.ld">linker script</a> magic required to generate an …</p>Moxie SoC Progress2012-11-10T05:23:00-05:00greentag:moxielogic.github.io,2012-11-10:/blog/moxie-soc-progress.html/<p>Time for a quick update!</p>
<p><center>
<iframe width="560" height="315" src="http://www.youtube.com/embed/86-OkQcXEes" frameborder="0" allowfullscreen></iframe>
</center></p>
<p>"Marin" is the name of my test SoC consisting of a <a href="http://en.wikipedia.org/wiki/Wishbone_(computer_bus)" title="wishbone">wishbone</a> wrapped
75Mhz big-endian MoxieLite bus master, along with two slave devices:
embedded ROM and the Nexys3's 7-segment display. So, right now I can
write some code into FPGA embedded ROM to manipulate the …</p>Moxie and Free Software EDA at FSOSS2012-10-16T15:09:00-04:00greentag:moxielogic.github.io,2012-10-16:/blog/moxie-and-free-software-eda-at-fsoss.html/<p>I'll be speaking at <a href="http://fsoss.senecac.on.ca" title="FSOSS">FSOSS</a> in Toronto next week on moxie and Free
Software EDA tools. Check it out here:
<a href="http://fsoss.senecac.on.ca/2012/node/150">http://fsoss.senecac.on.ca/2012/node/150</a>.</p>MoxieLite in Action2012-09-22T04:40:00-04:00greentag:moxielogic.github.io,2012-09-22:/blog/moxielite-in-action.html/<p><center>
<img alt="" src="http://moxielogic.org/images/MoxieLite-400.jpg" title="First MoxieLite Shot">
</center></p>
<p>Brad Robinson just sent me this awesome shot of <a href="https://github.com/toptensoftware/MoxieLite" title="MoxieLite">MoxieLite</a> in action.
His Xilinx Spartan-6 FPGA based SoC features a moxie core handling VGA
video, keyboard and FAT-on-flash filesystem duties using custom firmware
written in C. This is all in support of a second z80-based core on the
same FPGA …</p>It's Alive!2012-09-14T14:39:00-04:00greentag:moxielogic.github.io,2012-09-14:/blog/its-alive.html/<p>There's a working hardware implementation of moxie in the wild!</p>
<p>Intrepid hacker <a href="https://twitter.com/toptensoftware" title="Brad Robinson">Brad Robinson</a> created this moxie-compatible core as
a peripheral controller for his SoC. He had been using a simple 8-bit
core, but needed to address more memory than was possible with the 8-bit
part. Moxie is a nice …</p>The case against the [L]GPL for Semiconductor Core Licensing2012-09-09T19:35:00-04:00greentag:moxielogic.github.io,2012-09-09:/blog/the-case-against-the-lgpl-for-semiconductor-core-licensing.html/<p>Eli Greenbaum wrote a terrific article for the Harvard Journal of Law &
Technology last fall called '<a href="http://jolt.law.harvard.edu/articles/pdf/v25/25HarvJLTech131.pdf">Open Source Semiconductor Core
Licensing</a>'. I'm using the GPL as a place-holder in my verilog source,
but I've always felt that the GPL/LGPL were inappropriate licenses for
digital logic. Eli's article makes clear …</p>vfork() for uClinux forces an architecture change2012-09-03T07:35:00-04:00greentag:moxielogic.github.io,2012-09-03:/blog/vfork-for-uclinux-forces-an-architecture-change.html/<p>Moxie uses a simple software interrupt instruction (<code>swi</code>) to implement
system calls. The <code>swi</code> instruction creates a call frame on the stack
and then jumps to a global exception handler routine. The exception
handler for moxie-uClinux switches to the kernel stack before jumping to
the relevant kernel routine. Returning from …</p>Forking bugs2012-08-15T20:59:00-04:00greentag:moxielogic.github.io,2012-08-15:/blog/forking-bugs.html/<p>I found some time to look at the Linux kernel port again, and discovered
a bug in the forking code (the child process must return 0 after a
fork!). What we're looking at here is the start of userland, post kernel
boot, where busybox is trying to run an init …</p>Multiported Registers, Microcode and Register Forwarding2012-07-01T14:46:00-04:00greentag:moxielogic.github.io,2012-07-01:/blog/multiported-registers-microcode-and-register-forwarding.html/<p>When I last wrote about tackling the 'pop' instruction I noted that I
needed the ability to write to multiple registers before retiring that
one instruction - something that would require extra instruction cycles
or loads more logic. I recently came across some work by Charles Eric
LaForest on <a href="http://www.eecg.utoronto.ca/~laforest/multiport/index.html" title="Efficient Multi-Ported Memories for FPGAs">Efficient Multi-Ported …</a></p>Notes on a novel in-game CPU: the dcpu-162012-04-09T07:35:00-04:00greentag:moxielogic.github.io,2012-04-09:/blog/notes-on-a-novel-in-game-cpu-the-dcpu-16.html/<p>The hacker behind the <a href="http://www.minecraft.net/">Minecraft</a> phenomena, Notch, is working on his
<a href="http://0x10c.com/">next game</a>, most likely another hit. This one is interesting in that
it includes an in-game 16-bit processor called the dcpu-16. Details are
sparse, but it seems as though gamers will use this processor to control
spacecraft and play …</p>Using the Altera USB-Blaster on Fedora2011-10-28T13:14:00-04:00greentag:moxielogic.github.io,2011-10-28:/blog/using-the-altera-usb-blaster-on-fedora.html/<p>Altera's Quartus tools include some special software to download
bitstreams to their devices over USB (a DE-2 eval board, in my case).
They require some tricky work to set up properly on Fedora - my dev host
of choice. But you're in luck! I've packaged up an RPM that takes care …</p>Fake RAM, load/store and push2011-10-11T19:00:00-04:00greentag:moxielogic.github.io,2011-10-11:/blog/fake-ram-loadstore-and-push.html/<p>Progress report time....</p>
<p>I need RAM in order to implement/test most instructions. To that end,
I've implemented a fake data cache that is always accessed within a
single cycle during the WRITE pipeline stage. Eventually this will have
to be replaced with a real data cache that reads/writes …</p>GTKWave Tip #2: Translate Filter Files2011-10-06T17:10:00-04:00greentag:moxielogic.github.io,2011-10-06:/blog/gtkwave-tip-2-translate-filter-files.html/<p>Tip #1 was about using an external process to perform dynamic
translations of signal display values. GTKWave can also perform simple
static translations of data. In the example below, for instance, moxie's
execute unit is receiving a 4-bit signal identifying "register A"
(riA_i) for whatever operation is about to happen …</p>GTKWave Tip #12011-10-04T10:34:00-04:00greentag:moxielogic.github.io,2011-10-04:/blog/gtkwave-tip-1.html/<p>GTKWave is a new tool for me, so I'll use this space to post useful tips
as I discover them.</p>
<p>The first tip comes from Tony Bybell, author of <a href="http://gtkwave.sourceforge.net" title="GTKWave">GTKWave</a>, who pointed
me at some helpful functionality in a recent <a href="http://moxielogic.org/blog/?p=511" title="blog comment">blog comment</a>. You can
enhance GTKWave's waveform display by replacing …</p>Branch delays2011-09-28T07:13:00-04:00greentag:moxielogic.github.io,2011-09-28:/blog/branch-delays.html/<p>I've coded up logic for more arithmetic instructions, register moves, as
well as direct and indirect jumps. For jumps, I simply pass a branch
signal from the execute stage back to the fetch stage, as well as the
computed target address. Here's some code that works now:</p>
<div class="highlight"><pre><span></span><span class="na">.text</span>
<span class="nf">xor</span> <span class="no">$r0 …</span></pre></div>A simulation milestone for the Muskoka SoC!2011-09-27T19:47:00-04:00greentag:moxielogic.github.io,2011-09-27:/blog/a-simulation-milestone-for-the-muskoka-soc.html/<p>A moxie-based SoC had it's first successful simulation run today....</p>
<p><center>
<img alt="gtkwave display of first code run" src="http://moxielogic.org/blog/wp-content/uploads/2011/09/gtkwave20110927-300x204.png">
</center></p>
<p>Pretty exciting! So, here's what's happening...</p>
<p>The SoC, code named "Muskoka", has three main components: the moxie
core, a wishbone switch and a ROM device. The switch was easy to
implement, as I just have a single bus master (moxie …</p>RTEMS status update2011-06-15T04:35:00-04:00greentag:moxielogic.github.io,2011-06-15:/blog/rtems-status-update.html/<p>The <a href="http://www.rtems.com">RTEMS</a> port in <a href="http://www.moxielogic.org/wiki/index.php?title=MoxieDev">moxiedev</a> is looking pretty good right now.
Here's a test of the RTEMS network loopback device running on the moxie
gdb simulator. The first two client connections fail in this test.
It's supposed to fail in the first case, but I'm not sure about the
second …</p>Bisecting GCC2011-06-06T07:23:00-04:00greentag:moxielogic.github.io,2011-06-06:/blog/bisecting-gcc.html/<p>The thing about <a href="http://gcc.gnu.org">GCC</a> is that things break when you take your eye off
the ball. And this is what happened during my months long hiatus from
the moxie project. Somewhere between early March and today, the moxie
GCC port lost the ability to compile non-trivial code, notably libgcc.
Firing …</p>On-chip communications2010-10-06T04:37:00-04:00greentag:moxielogic.github.io,2010-10-06:/blog/on-chip-communications.html/<p>I need to build real SoC infrastructure around my developing core in
order to test it on real hardware. For the most part, this means a
memory controller and IO devices. I've decided to implement a shared-bus
wishbone-style interconnect for these devices. <a href="http://en.wikipedia.org/wiki/Wishbone_%28computer_bus%29">Wishbone</a> is an open
source on chip bus …</p>Quartus II and the Cloud: Not There Yet...2010-09-20T15:55:00-04:00greentag:moxielogic.github.io,2010-09-20:/blog/quartus-ii-and-the-cloud-not-there-yet.html/<p>Altera's <a href="http://www.altera.com/products/software/quartus-ii/web-edition/qts-we-index.html">Quartus II</a> software is now running on my Fedora box, but I
was really hoping to load it into a grid of <a href="http://aws.amazon.com/ec2/">Amazon EC2 instances</a> so
I could batch out jobs for synthesis, place and route. Unfortunately the
free-beer Quartus software requires a license file that is generated
based …</p>Pipeline hazards2010-09-10T13:25:00-04:00greentag:moxielogic.github.io,2010-09-10:/blog/pipeline-hazards.html/<p>I've coded up a first go at four pipeline stages so far: <a href="http://github.com/atgreen/moxiedev/blob/master/moxie/rtl/verilog/cpu_fetch.v">Fetch</a>,
<a href="http://github.com/atgreen/moxiedev/blob/master/moxie/rtl/verilog/cpu_decode.v">Decode</a>, <a href="http://github.com/atgreen/moxiedev/blob/master/moxie/rtl/verilog/cpu_execute.v">Execute</a>, and Write. After the relative complexity of the
<a href="http://moxielogic.org/blog/?p=444">Fetch implementation</a>, the rest has been pretty straight forward, and
I've started running the first bit of compiled code through the pipline.
Here's that start of our …</p>Fetching instructions2010-09-07T13:56:00-04:00greentag:moxielogic.github.io,2010-09-07:/blog/fetching-instructions.html/<p>Moxie requires some interesting instruction fetch logic.</p>
<p>For my initial implementation I'm assuming a 32-bit path to instruction
memory. But moxie has both 16- and 48-bit instructions, so it's not like
simple RISC cores that can feed the pipeline on every cycle. My solution
is to feed 32-bit instruction memory …</p>The FPGA test board2010-08-18T14:03:00-04:00greentag:moxielogic.github.io,2010-08-18:/blog/the-fpga-test-board.html/<p>I picked up a lightly used FPGA development board from craigslist today.
It's the <a href="http://www.altera.com/education/univ/materials/boards/unv-de2-board.html">Altera DE2</a> board with a Cyclone II FPGA.</p>
<p><center>
<img alt=""The DE2\'s Cyclone II "" src="http://moxielogic.org/blog/wp-content/uploads/2010/08/P1230549-300x225.jpg">
</center></p>
<p>There are a few nice things about this board...</p>
<ul>
<li>It's loaded with real and useful peripherals: 16x2 LCD Panel, VGA
DAC, lots of LEDs, RS232, IrDA, PS/2 …</li></ul>Still hacking...2010-05-11T06:45:00-04:00greentag:moxielogic.github.io,2010-05-11:/blog/still-hacking.html/<p>...Just in case you were wondering!</p>
<p>But it's been slow going. The good news is that moxie is front and
centre for me again, so let's see what we can do over the next few
weeks. And over these next few weeks I'm promising myself not to touch a
C …</p>The Moxielyzer2009-10-14T22:05:00-04:00greentag:moxielogic.github.io,2009-10-14:/blog/the-moxielyzer.html/<p>I just committed a little binary analysis tool to <a href="http://moxielogic.org/wiki/index.php?title=MoxieDev">moxiedev</a>. You can
use it to perform simple static analysis on moxie binaries. The kinds of
things I'm looking for are compiler bugs (because I know there's still
one there that is triggered by -frerun-cse-after-loop), and instruction
statistics. For instance, which …</p>Summer is over, so put away the white pants and start submitting patches!2009-09-10T14:21:00-04:00greentag:moxielogic.github.io,2009-09-10:/blog/summer-is-over-so-put-away-the-white-pants-and-start-submitting-patches.html/<p>It's been a while since my last update. What can I say... summer was
nice.</p>
<p>But now, back to business! I've just committed some long overdue patches
to the upstream GNU tools:</p>
<ul>
<li><a href="http://sourceware.org/ml/gdb-patches/2009-09/msg00289.html">Add a device tree blob to the gdb simulator</a>. This lets us
describe the gdb sim target to …</li></ul>More hello world progress with uClibc/uClinux, and a GDB question.2009-08-18T21:49:00-04:00greentag:moxielogic.github.io,2009-08-18:/blog/more-hello-world-progress-with-uclibcuclinux-and-a-gdb-question.html/<p>Tonight I got a hello world app to use uClibc's <code>puts()</code> routine! This
is a big deal because it's the first time I've had system calls coming
in from userland. I haven't checked the changes in yet, because they're
a mess, but here's a basic run-down of what I had …</p>First moxie-linux userland app runs!2009-08-17T20:11:00-04:00greentag:moxielogic.github.io,2009-08-17:/blog/first-moxie-linux-userland-app-runs.html/<p>I've been taking advantage of the nice summer weather recently, so it's
taken me a while to get around to this... but here's the first moxie
userland app!</p>
<div class="highlight"><pre><span></span>#<span class="k">include</span> <span class="o"><</span><span class="nv">string</span>.<span class="nv">h</span><span class="o">></span>
#<span class="nv">define</span> <span class="nv">MSG</span> <span class="s2">"</span><span class="s">Hello, World!</span><span class="se">\n</span><span class="s2">"</span>
<span class="nv">void</span> <span class="nv">__attribute__</span><span class="ss">((</span><span class="nv">noinline</span><span class="ss">))</span> <span class="nv">gloss_write</span> <span class="ss">(</span><span class="nv">int</span> <span class="nv">fd</span>, <span class="nv">char</span> <span class="o">*</span><span class="nv">ptr</span>, <span class="nv">int</span> <span class="nv">len</span><span class="ss">)</span>
{
<span class="nv">asm</span><span class="ss">(</span><span class="s2">"</span><span class="s">swi 5</span><span class="s2">"</span><span class="ss">)</span><span class="c1">; // "write …</span></pre></div>Speed bumps on the road to moxie userland2009-07-30T13:46:00-04:00greentag:moxielogic.github.io,2009-07-30:/blog/speed-bumps-on-the-road-to-moxie-userland.html/<p>Sooo..... it turns out there's lots to take care of before userland apps
like BusyBox can run.</p>
<ul>
<li><strong>The root filesystem</strong>. This one is easy. I just built a short
Hello World application in C with moxie-uclinux-gcc. This produces
an executable in <a href="http://www.beyondlogic.org/uClinux/bflt.htm">BFLT format</a> which I call 'init'. The kernel
build …</li></ul>The start of a uClinux userland2009-07-28T15:24:00-04:00greentag:moxielogic.github.io,2009-07-28:/blog/the-start-of-a-uclinux-userland.html/<p>Before we can start building <a href="http://www.busybox.net">BusyBox</a>, we need a few more bits of
technology...</p>
<ul>
<li><a href="http://www.uclibc.org">uClibc</a>: this is a popular embedded C library, like newlib, but
used more often in Linux environments. I ported uClibc to the moxie
core just like every other bit of software in this project: quickly!
My …</li></ul>The first moxie linux boot output...2009-07-26T12:43:00-04:00greentag:moxielogic.github.io,2009-07-26:/blog/the-first-moxie-linux-boot-output.html/<p>Userland, here I come! Check out <a href="http://moxielogic.org/wiki/index.php?title=MoxieDev">moxiedev</a>, run "ant build", then do
the following...</p>
<div class="highlight"><pre><span></span>$ .<span class="o">/</span><span class="nv">root</span><span class="o">/</span><span class="nv">usr</span><span class="o">/</span><span class="nv">bin</span><span class="o">/</span><span class="nv">moxie</span><span class="o">-</span><span class="nv">elf</span><span class="o">-</span><span class="nv">run</span> <span class="nv">linux</span><span class="o">-</span><span class="mi">2</span>.<span class="mi">6</span><span class="o">/</span><span class="nv">vmlinux</span>
<span class="nv">Linux</span> <span class="nv">version</span> <span class="mi">2</span>.<span class="mi">6</span>.<span class="mi">31</span><span class="o">-</span><span class="nv">rc3</span><span class="o">-</span><span class="nv">gb006656</span><span class="o">-</span><span class="nv">dirty</span> <span class="ss">(</span><span class="nv">green</span>@<span class="nv">dev</span>.<span class="nv">moxielogic</span>.<span class="nv">com</span><span class="ss">)</span> <span class="ss">(</span><span class="nv">gcc</span> <span class="nv">version</span> <span class="mi">4</span>.<span class="mi">5</span>.<span class="mi">0</span> <span class="mi">20090715</span> <span class="ss">(</span><span class="nv">experimental</span><span class="ss">)</span> [<span class="nv">trunk</span> <span class="nv">revision</span> <span class="mi">149693</span>] <span class="ss">(</span><span class="nv">GCC</span><span class="ss">)</span> <span class="ss">)</span> <span class="sc">#6</span> <span class="nv">Sun</span> <span class="nv">Jul …</span></pre></div>Kernel update: device trees and kernel threads2009-07-25T04:50:00-04:00greentag:moxielogic.github.io,2009-07-25:/blog/kernel-update-device-trees-and-kernel-threads.html/<p>I've spent a lot of time in airports/planes/hotels recently, which is
good news for the moxie linux port. It runs about 6.5M instructions,
booting up to the point where a couple of kernel threads are created.
However, a few context switches later it all comes tumbling down …</p>The Moxie Linux port2009-07-23T03:50:00-04:00greentag:moxielogic.github.io,2009-07-23:/blog/the-moxie-linux-port.html/<p>I've just checked the start of the kernel port into <a href="http://www.moxielogic.org/wiki/index.php?title=MoxieDev">moxiedev</a>.
Running "ant build" will produce tools, simulators, u-boot and now a
vmlinux you can run with moxie-elf-run or in gdb. It crashes on startup
right now, but that's to be expected. I just got it to the point where …</p>Reverse debugging!2009-07-12T21:55:00-04:00greentag:moxielogic.github.io,2009-07-12:/blog/reverse-debugging.html/<p>A few weeks ago I happened to be in Palo Alto and met up with my friend
and long-time GDB hacker Michael Snyder. He told me about a new feature
in GDB called "process recording". The basic idea is that when you tell
GDB to enter into "record mode", it …</p>A Disassembler in Verilog2009-06-22T18:55:00-04:00greentag:moxielogic.github.io,2009-06-22:/blog/a-disassembler-in-verilog.html/<p>I've been playing around a little more with verilog. Here's a mostly
complete moxie <a href="http://github.com/atgreen/moxiedev/blob/fb57efc73e47e451f18951d274c41ccda337c112/moxie/rtl/verilog/iprinter.v">disassembler module</a> written in verilog.</p>
<p>And here's a little <a href="http://github.com/atgreen/moxiedev/blob/fb57efc73e47e451f18951d274c41ccda337c112/moxie/rtl/verilog/testsuite/moxie.modules/test-iprinter.v">driver</a> for it. The driver reads a hex dump file
into an array representing memory. On every clock cycle it updates the
instruction and data output registers …</p>ISA improvements2009-06-11T05:19:00-04:00greentag:moxielogic.github.io,2009-06-11:/blog/isa-improvements.html/<p>I've committed the PC-relative branch instruction changes upstream. But
this is just one of many ISA improvements that need to happen. Here are
a handful of other ideas off the top of my head. None of these projects
should be particularly difficult.</p>
<ul>
<li>Shorten load/store offsets to 16-bits. They are …</li></ul>Moxie GCC port is upstream!2009-06-09T21:41:00-04:00greentag:moxielogic.github.io,2009-06-09:/blog/moxie-gcc-port-is-upstream.html/<p>The moxie port has been <a href="http://gcc.gnu.org/ml/gcc/2009-06/msg00194.html">accepted by the GCC steering committee</a>!</p>
<p>I just <a href="http://gcc.gnu.org/viewcvs?view=rev&revision=148339">checked it in</a>.</p>
<p>That is all.</p>Everything is relative (finally!)2009-06-07T17:57:00-04:00greentag:moxielogic.github.io,2009-06-07:/blog/everything-is-relative-finally.html/<p>The Moxie ISA still needs quite a bit of tuning. Take branches, for
instance. A <code>beq</code> instruction currently encoded <a href="http://www.moxielogic.org/wiki/index.php?title=Instruction_Set#beq">like so</a>... </p>
<div class="highlight"><pre><span></span><span class="o">`</span><span class="mi">00001111</span><span class="n">xxxxxxxx</span> <span class="n">iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</span><span class="o">`</span>
</pre></div>
<p>...where the "<code>x</code>"s represent "don't care" bits, and "<code>i</code>"s are a
32-bit absolute branch target. That's right -- branch targets are not PC
relative! This …</p>An even newer git repo2009-05-29T20:05:00-04:00greentag:moxielogic.github.io,2009-05-29:/blog/an-even-newer-git-repo.html/<p>So it turns out that hosting a git repo that is only accessible via slow
http is no fun.</p>
<p>Fortunately, the great team at <a href="http://www.github.com">github.com</a> were willing to take this
on, so now the real repository is accessible via this command:</p>
<p><code>$ git clone git://github.com/atgreen/moxiedev.git …</code></p>New git repo2009-05-26T20:05:00-04:00greentag:moxielogic.github.io,2009-05-26:/blog/new-git-repo.html/<p>I'll bottom line this one quickly:</p>
<ul>
<li><a href="http://moxielogic.org/wiki/index.php?title=MoxieDev">moxiedev</a> is now maintained with git. Check it out like so..<br>
<code>$ git clone http://moxielogic.org/moxiedev.git</code></li>
<li>moxiedev now contains a partial <a href="http://moxielogic.org/blog/?p=154">u-boot port</a>. It's "partial"
because I fat fingered some commands and blew away four or five
important files. They will have …</li></ul>The Race For A New Game Machine: great book!2009-05-15T21:19:00-04:00greentag:moxielogic.github.io,2009-05-15:/blog/the-race-for-a-new-game-machine-great-book.html/<p>I just read <a href="http://raceforxbox360ps3.com/default.aspx">The Race For A New Game Machine</a> today on a cross-country
flight, and wow.. fun read!</p>
<p>If you've ever read Tracy Kidder's great book <a href="http://en.wikipedia.org/wiki/The_Soul_of_a_New_Machine">The Soul of a New
Machine</a>, you'll know what to expect. But this book chronicles the
SONY/Toshiba/IBM <a href="http://en.wikipedia.org/wiki/Cell_(microprocessor)">Cell</a> partnership, and the …</p>RPMs2009-05-07T17:37:00-04:00greentag:moxielogic.github.io,2009-05-07:/blog/rpms.html/<p>There's a little more detail on the <a href="http://moxielogic.org/wiki/index.php?title=MoxieDev">wiki</a>, but basically...</p>
<div class="highlight"><pre><span></span>$ rpm -ivh http://moxielogic.org/download/moxielogic-repo-1-1.noarch.rpm
$ yum groupinstall moxiedev
</pre></div>
<p>Your welcome.</p>
<p>Seriously though... release engineering is at times both tedious and
fascinating. But mostly tedious. Still, I was interested in tackling a
little releng work this week …</p>Quick update...2009-04-29T22:38:00-04:00greentag:moxielogic.github.io,2009-04-29:/blog/quick-update.html/<p>A few quick <a href="http://moxielogic.org/wiki/index.php?title=MoxieDev">MoxieDev</a> updates...</p>
<ul>
<li>The verilog output patch is in binutils</li>
<li>The moxie ports for binutils, newlib, libgloss and gdb are all
upstream. Waiting on sim and gcc reviews.</li>
<li>The upstream qemu team have switched to git, so I've rebased
MoxieDev's qemu against this new repository.</li>
</ul>
<p>Also, I've been …</p>Loading programs into the verilog simulation2009-04-22T13:38:00-04:00greentag:moxielogic.github.io,2009-04-22:/blog/loading-programs-into-the-verilog-simulation.html/<p>The moxie newlib port was <a href="http://sourceware.org/ml/newlib/2009/msg00520.html">just accepted</a>. The GCC port will take a
little longer to review, but I hope that it will get accepted early next
week. Already there has been some useful feedback resulting in a few
improvements. For instance, the moxie libgcc.a now provides the soft-fp …</p>Pushing Bits Upstream2009-04-16T17:55:00-04:00greentag:moxielogic.github.io,2009-04-16:/blog/pushing-bits-upstream.html/<p>If there's one thing I've learned about GNU tools development over the
years, it's that attempting to maintain a tools port outside of the
upstream tree is A Very Bad Idea! It's easy to let your private tree
fall out of sync from upstream. And the longer you wait to …</p>A Verilogical Place To Start *2009-04-07T20:31:00-04:00greentag:moxielogic.github.io,2009-04-07:/blog/a-verilogical-place-to-start.html/<p>I've written my first bit of <a href="http://en.wikipedia.org/wiki/Verilog">verilog</a> tonight. It's not much, really,
but it's a start. I'm using <a href="http://www.icarus.com/eda/verilog/">Icarus Verilog</a> (iverlog) to compile and
simulate the code. I also plan on using <a href="http://www.gpleda.org/tools/gtkwave/index.html">GTKWave</a> to examine timing
dumps from the iverilog simulator. Both of these tools are part of my
development …</p>Das U-Boot on moxie!2009-04-02T16:28:00-04:00greentag:moxielogic.github.io,2009-04-02:/blog/das-u-boot-on-moxie.html/<p>My moxie port of <a href="http://www.denx.de/wiki/U-Boot">U-Boot</a>, the Universal Boot Loader, has started
working!</p>
<div class="highlight"><pre><span></span>$ <span class="nv">qemu</span><span class="o">-</span><span class="nv">system</span><span class="o">-</span><span class="nv">moxie</span> <span class="o">-</span><span class="nv">nographic</span> <span class="o">-</span><span class="nv">kernel</span> <span class="nv">u</span><span class="o">-</span><span class="nv">boot</span>
<span class="nv">SDRAM</span> :
<span class="nv">U</span><span class="o">-</span><span class="nv">Boot</span> <span class="nv">Start</span>:<span class="mi">0</span><span class="nv">x00001000</span>
<span class="nv">Using</span> <span class="nv">default</span> <span class="nv">environment</span>
<span class="nv">U</span><span class="o">-</span><span class="nv">BOOT</span> <span class="k">for</span> <span class="s2">"</span><span class="s">moxiesim</span><span class="s2">"</span>
<span class="o">=></span> <span class="nv">version</span>
<span class="nv">U</span><span class="o">-</span><span class="nv">Boot</span> <span class="mi">2009</span>.<span class="mi">03</span><span class="o">-</span><span class="nv">rc2</span><span class="o">-</span><span class="mi">00013</span><span class="o">-</span><span class="nv">gefb4734</span><span class="o">-</span><span class="nv">dirty</span> <span class="ss">(</span><span class="nv">Apr</span> <span class="mi">02</span> <span class="mi">2009</span> <span class="o">-</span> <span class="mi">20</span>:<span class="mi">07</span>:<span class="mi">32</span><span class="ss">)</span>
<span class="o">=></span> <span class="nv">printenv</span>
<span class="nv">bootargs</span><span class="o">=</span><span class="nv">root …</span></pre></div>Processor Exceptions2009-04-02T08:33:00-04:00greentag:moxielogic.github.io,2009-04-02:/blog/processor-exceptions.html/<p>My first go at exceptions is working well. The basic idea is that moxie
will have a single exception handling routine whose address lives in
special register 1. You set the exception handler like so:</p>
<div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">install_handler</span><span class="p">(</span><span class="n">void</span> <span class="p">(</span><span class="o">*</span><span class="k">handler</span><span class="p">)(</span><span class="n">void</span><span class="p">))</span>
<span class="err">{</span>
<span class="n">printf</span> <span class="p">(</span><span class="ss">"Installing handler 0x%x\n"</span><span class="p">,</span> <span class="p">(</span><span class="n">unsigned</span><span class="p">)</span> <span class="k">handler</span><span class="p">);</span>
<span class="n">asm</span><span class="p">(</span><span class="ss">"ssr …</span></pre></div>Thinking about exceptions....2009-03-19T14:01:00-04:00greentag:moxielogic.github.io,2009-03-19:/blog/thinking-about-exceptions.html/<p>In reading about how other processors handle exceptions, they seem to be
of two sorts. Some (most?) processors look into a vector of exception
handlers based on the exception type (Divide by Zero, Software
Interrupt, IRQ, etc), and the other sort jumps to a single exception
address and lets the …</p>Adding a Real Time Clock2009-03-17T15:38:00-04:00greentag:moxielogic.github.io,2009-03-17:/blog/adding-a-real-time-clock.html/<p>After a UART, one of the most useful and interesting peripherals you can
add to a board is a Real Time Clock (RTC). Qemu comes with a simulation
of Freescale's <a href="http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC146818.pdf">MC146818</a> RTC chip. Adding it to our qemu-defined
board was as simple as....</p>
<div class="highlight"><pre><span></span> <span class="n">rtc_mm_init</span><span class="p">(</span><span class="mi">0</span><span class="n">x400</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
</pre></div>
<p>This …</p>Board Support Packages2009-03-17T14:51:00-04:00greentag:moxielogic.github.io,2009-03-17:/blog/board-support-packages.html/<p>Today we're introducing the notion of Board Support Packages (BSPs) to
the <a href="http://moxielogic.org/wiki/index.php?title=Toolchain">moxie toolchain</a>.</p>
<p>A BSP provides all of the configuration data and code requires to target
a specific hardware platform. This mostly involves linker scripts,
platform initialization code, and hardware abstraction support
libraries.</p>
<p>Until recently the gdb sim was …</p>Debugging with the moxie qemu simulator2009-03-14T06:58:00-04:00greentag:moxielogic.github.io,2009-03-14:/blog/debugging-with-the-moxie-qemu-simulator.html/<p>I've finally cracked the gdb+qemu puzzle, so now we can debug code
running on the qemu moxie simulator!</p>
<p>The last little gotcha was that the simulated $pc wasn't being updated
after single-stepping. This will get you nowhere fast! But it's all
fixed now, and here's how it works...</p>
<p><code>$ qemu-system-moxie …</code></p>A Tiny Computer2009-03-13T14:48:00-04:00greentag:moxielogic.github.io,2009-03-13:/blog/a-tiny-computer.html/<p><a href="http://lambda-the-ultimate.org/">Lambda the Ultimate</a> today posted a interesting blog entry on <a href="http://lambda-the-ultimate.org/node/3232">A Tiny
Computer</a>. It refers to 2007 paper by Chuck Thacker at Microsoft
Research describing a tiny 32-bit processor. Appendix A of the paper
includes the entire synthesizeable verilog implementation in just a page
and a half of code! Here's …</p>Progress...2009-03-12T20:34:00-04:00greentag:moxielogic.github.io,2009-03-12:/blog/progress.html/<p>I made some progress on using moxie-elf-gdb with qemu the other day.
Qemu has an integrated gdb stub, so GDB speaks to it via the remote
protocol. It's still not quite there, but getting close. I'm anxious to
get it working, as it's the last step before hacking on the …</p>MoxieDev and the Wiki2009-03-07T06:22:00-05:00greentag:moxielogic.github.io,2009-03-07:/blog/moxiedev-and-the-wiki.html/<p>Now that the project has been renamed, the mercurial source repository
has also changed from ggxdev to MoxieDev. This repository contains the
entire toolchain, simulators and benchmark programs. You can check the
entire thing out like so...</p>
<div class="highlight"><pre><span></span>$ hg clone http://mercurial.intuxication.org/hg/moxiedev
</pre></div>
<p>I've also created a <a href="http://moxielogic.org/wiki">wik …</a></p>Qemu says Hello, World!2009-03-07T06:22:00-05:00greentag:moxielogic.github.io,2009-03-07:/blog/qemu-says-hello-world.html/<p>Virtually all of the simulation done so far was with the GDB instruction
set simulator. As a basic instruction set simulator, it was limited to
executing instructions found in typical "user level" applications. And,
if you recall, all interaction with the outside world happened through
magic software interrupts that were …</p>Moxie: the ggx reboot2009-03-07T05:23:00-05:00greentag:moxielogic.github.io,2009-03-07:/blog/moxie-the-ggx-reboot.html/<p>Hola Amigos! Several months ago I experimented with a new ISA design
called <a href="http://spindazzle.org/ggx">ggx</a>. I blogged about the co-evolution of the ISA and tools,
and it was fun.</p>
<p>Now, after a short break, I'm ready to resume hacking.</p>
<p>I'm also ready to put a stake in the ground as far …</p>