02 April 2008

avr vtable madness

Pretty obvious I haven't done much lately. What I did I haven't written anything about. So here goes. I'm skipping the boring stuff. Hokay, all of this is boring to everyone but me ...

After figuring out how to make the 3301 work, I added it to the bot: rewired the imu yrot pin from the arduino to the 3301, connected the 3301 to the arduino, and hacked the bejeezus out the code for the imu.

Downloaded the program, fired it up, and ... I got a couple of lines of output from setup(), then a couple of lines from loop(), and then nothing. Radio silence ...

Took some digging, but eventually figured out that somehow I'd blown the atmega168's 1K of RAM. It had been running just fine, didn't add much, and I ripped a lot out, but still boom in a big way.

Well by this point the code was hash, so I cleaned it all up. Wrote some code abstacting A2d's and the arduino's vs the 3301 and used it in the imu code. Real pretty. But still boom.

Decided to REALLY stripped things, and printed the address of a few variables. Seemed like plenty o' space.

Put most everything back, and ran nm. AHA! avr-gcc puts the vtables in RAM! A consequence of the split I/D space. Was eating up about 500 bytes. Well, I like my polymorphism, but not at the cost of crashing. Removed everything that doesn't absolutely, positively, need to be virtual, and I seem to have lot's of space again. Though I do need to restore a bit of code still ...

So tonight I plan to do a bit more space tuning, and see how much more I can hack out.