Moved some code around.
Implemented the flash-writing code to test out.
I haven't been able to make this a proper just-main() program yet. There's something causing crashing badness to happen.
Also, in the threaded version, as soon as the thread entry point is hit, the flash registers are wrong and can't be righted.
I'm checking this in as an interim to do some more strip-down and digging around.
Ok, this one now works!
Woohoo! I'll try to track down the exact reason tomorrow, but i have a feeling it's something to do with stack sizes corrupting stacks.
This version is now not threaded, which makes the blinking not too nice, though I may change the blinking a bit so that you can see progress.