Sam Jacoby

Using Arscons

Posted . [Last updated . ]

This is a post about me & my computer. Get excited.

Arch Linux & Thinkpad X40: A love story

I’ve used Arch Linux for years — always a bit ineptly, I must admit — and a while back, mostly because of a new job (and the allure of ditching my open-source sensibilities and using Adobe CS), I switched to a Mac. I’ve been happy enough, but there’s something about coding in Snow Leopard or Lion or Cat or whatever we’re on, that I’ve never really liked. Too slick, maybe. I find I work better in heavily constrained environments.

So I’ve always had another machine around for my “real” coding work. That lot falls to an old Thinkpad X40 that I hauled around on a six-month jaunt in Nicaragua, when I was taking some time off from college and working for The Tico Times. I was running Ubuntu then. It was like a rock—it’s still going strong. Over the years, I’ve amassed a small armada of X40s: you can get one in working-order on Ebay for under $65 bucks. How can you resist?

Arch + Arduino

On my latest X40, I’m running Arch off’ve a charming 4GB USB stick (the X40s on Ebay are almost always stripped of their hard-drives). It’s a little pokey, particularly on writing to disk, but I couldn’t be happier. And my little, cranky, skull-bucket of a Thinkpad feels as roomy as the glossy 13” MacBook Pro I usually work and the keyboard has none of the mushy play. (Read up on Mako’s great post on the great swindle that is the 16:9 screen ratio — which is why the X40 is actually as large as the MBP).

At any rate, all of that doesn’t change the fact that it’s an antiquated machine and I use it primarily for text editing. Not much else. I like coding on it—there’s no electro-peace like a tiling windows manager (Awesome) and someone else’s fantastic .vimrc.

I’ve been using Brian Mayton’s Makefile (file) to compile my avr programs—but honestly, I love the convenience of the Arduino libraries and all the rest, even if they’re anathema to Assembly Cowboys.

Not growing up on embedded programming, the whole (1 << PB4), alas, does not quite feel like first nature. One sore spot has been the Arduino IDE, which in all its muscular Java-ness, is a bit much for the X40 to handle.

So—how do you use the Arduino libraries in the comfort of your own vim config? There are a couple of ways. I use Arscons, a python build script, that makes the process relatively painless.

First, install the necessaries:

sudo pacman -S install python-pyserial scons

Then grab the SConstruct file and copy it into your sketch folder. Run scons, and let the magic unfold. Maybe. Didn’t work for me outt’ve the box. Because I have several versions of avr-gcc, a conflict prevented programs from compiling correctly. I edited the SConstruct file to make it work right—in my case, I just modified the AVR_BIN_PREFIX setting to point to the actual Arduino install of avr-gcc. That broke avrdude, but such is life. I don’t know exactly what was amiss, but it seemed to have worked fine.

So that’s that—not so grand. Scons is basically Make—or does the same things, at least—and lets you use Python rather than all of that gibberish. There are Makefiles for Arduino that do the exact same thing—but they are even more of a code soup.

UPDATE: I checked in with Dave and Arduino ships with its own version of avr-gcc with a number of necessary tweaks.

NOTE: Yes, yes, I know I can use an external editor with Arduino, but I don’t like doing that for some reason. I end up being confused about where I should be editing.