Tuesday Aug 11, 2009

Good news (i.e. progress):

Those last few errors are resolved, and Squawk now builds and deploys to the Luminary Micro Development Kit board.  I have console out, and thereby basic debug information.

For those interested:
The strsignal function seems to be one of those non-standard, standard functions, which fortunately had been implemented for another port of Squawk.  Yay for "cut & paste".
As for the memory overlap error, I believe it had to do with the ".ARM.exidx" section being implicitly allocated at a location already occupied by other data.  That then was a simple matter of allocating the region explicitly.

Bad news (i.e. TODO):

Not all stdlib functions seem to be working.  Specifically, I've tried malloc, calloc, printf, and fprintf.  Of those, only malloc returns normally (I have yet to identify whether or not it works correctly).  The others do not return at all; instead causing Squawk to halt abruptly.  I've done minimal implementations for all the underlying functions, like _sbrk, but according to a lack of print statements, they do not appear to be being called (in case you're wondering, I'm using a printf-like statement to do all my debug printing, which does in fact work).  And preliminary research has thus far yielded no useful information, nor records of similar experiences.

So tomorrow's agenda: research, experiment, scratch my head, and research some more.  That said, I am still hopeful that I will be able to get this all working in the very near future, i.e. before I leave.


Update 8/12/09: so it seems that the functions that fail do so by immediately dropping into the FaultISR, and I haven't the faintest idea why.  I've seen references to increasing the stack size, but that seems to have no effect.  And I can't get the embedded gdb working either; all I get is this most-informative message:

(gdb) Remote communication error: No error.

Real useful.  Back to the drawing board (or Google).

Friday Aug 07, 2009

The title says it: we're putting Java on the new Luminary Micro boards equipped with the ARMv7 Cortex-M3 processor.

(Unfortunately, by "we" I mostly mean "I", and by "I" I mean an intern with only two more weeks to go.  But by then I believe I'll have a good foundation for others to continue the process—and with any luck, the core Squawk J2ME VM will be running too.)

Suffice to say, these past few weeks have been a bit of a grind.  And I'm beginning to appreciate Java more and more.

After installing all the tools and getting them to work together (which honestly took a few days in its own right), and after brushing up on my C, and getting the example demos to compile, link, deploy, and run (another few days), I made a sample project of my own inside the standard build area, then moved it out to a remote location to get a good understanding of the required files and dependencies.

Now I'm taking a stab at getting Squawk to build using the StellarWare + CodeSourcery G++ tool chain.  First attempts: a few hundred lines of compile errors.  A couple days later, those are all resolved—well, if you count stubs as resolutions.  I'll work on getting it to build first, then worry about getting it to actually run.

Finally, I figured out that last compilation error.  Which was promptly replaced with around 800 lines of linker errors.  Delightful.

A few more days pass, and now I'm down to three linker errors (hopefully no more will crop up in the meantime): something about two sections overlapping (probably an error somewhere in the linker script I'm using); a function that should exist but doesn't (strsignal, may have to implement that one myself); and an undefined reference to some "_fini", which has turned out to be very difficult to find out any useful information on.

With regards to that last one, _fini, it seems like it may be involved with some vector/array allocation, and maybe should be defined in some linker script; I'm not sure.  For that matter, I'm not even sure if it is in fact a variable or a function.  Thus far, the only comment I've seen in direct regards to it said approximately, "Can't figure it out.  Workaround: just cut things until it's not called any more."  Honestly, a day spent trying to find a better solution, and right now I myself am falling back on that plan for now, if only to get an idea for what it does.  Or stub it for now and see what breaks later.

(Oh, it appears to be some function that's called on a shutdown process for additional clean-up: a do-nothing stub will apparently suffice.  Whew.)

And so I am reminded of the good days programming in Java, and why we're going through all the trouble to stick it on such a small, resource-constrained device.  In short: so that other developers don't have to go through all the headache I am.  With Java's interfaces and abstract classes, when a library fails because it's referencing a function that has not yet been defined, the result is an error in your code, not the library itself (and you don't need to figure out what was calling the darn thing in the first place, say by digging through all their source that they didn't give you).  Moreover, the libraries are standardized and well-documented (the javadoc tool makes that easy), so instead of spending most of my time researching the implementations for common (or especially rarely-used) functions on the internet to copy and paste, I have everything right at my fingertips.  Automatic memory management, and no assembly.  And, let's not forget: no naked pointers, or for that matter, pointers in general.  Yea, that's nice (even if I have to do a few extra bit shifts).

Sure, maybe you're awesome and like to do all that low-level stuff yourself—go have fun writing in C.  This is for all of us who like to be able to quickly and painlessly put together a quality implementation that works.

—Java on Cortex M3—

Wednesday Jul 23, 2008

So, after sleeping on it, I finally resolved just to rewrite the darn code.

Took me the better part of a day, but here I have it, a straight-forward iterative command-line interpreter.  What it lacks in object-oriented abstraction, it makes up in simplicity: a couple hundred lines later, I was able to remove a dozen extra classes.  And it works.

Tuesday Jul 22, 2008

Command line handling can get real nasty.  Maybe it's kinda fun at first... but jeeze, that don't last too long.

I must've spent the last hour pondering the best way to approaching it--and the hour before that trying to figure out why the guy before me tried to do it mock-recursively.  Suffice to say, it's not quite working, and nor is it too flexible.  I think I'm going to try and come at it from a different angle...

Monday Jul 21, 2008

Well...

I have a blog. 

This blog copyright 2009 by Stephen Giandomenico