Monday, May 19, 2014

KiCad on Mac OS X Mavericks

Eventually I want to design a new circuit that I would like to implement as a real gadget. This means, eventually, I will need to design a PCB (printed circuit board) to hold all the parts and wire them together. I looked at a few different products. There's the really expensive Altium (supposedly the best :); there's a few no cost but proprietary ones e.g. ExpressPCB; there's a few no cost for initial limited sizes (pay for unlimited) e.g. Eagle and there's a few FOSS products e.g. gEDA and KiCad. I can't explain why but I decided I liked the look of KiCad and I wanted a tool without artificial limitations. And it (supposedly) runs on Mac OS X.

So here's the story of how I spent nearly a week getting KiCad EDA (Electronic Design Automation) to work on my MacBook Air running 10.9 (Mavericks).

To give me motivation and direction for my efforts I used a series of video tutorials from Contextual Electronics called 'Getting to Blinky'. The videos seem (to me at least) to be perfectly paced so I didn't get bored or (often) lost. Obviously the first step was to install KiCad on my MBA.

Native

There are at least three different ways to run KiCad on Mac OS X. One is to run it as a native app either by compiling it yourself or downloading a compiled version. It quickly became apparent that the Mac version is very poorly supported despite a lot of community effort. The KiCad downloads page offers three different ways to install a native KiCad. The "official" way is to use the shell script (poorly) maintained on GitHub. It hasn't been updated for three months and doesn't work anymore but the comments in the Issues page do point to working solutions. In summary use this. BUT make sure you have all the prerequisites installed (using Homebrew) and then use brew to uninstall 'xz' (you can re-install it after build is complete). (Damned if I know why build crashes if 'xz' is there but it does.) And don't forget to install Doxygen which isn't mentioned in the prerequisite list. And don't use the multi-CPU option on Mac. Seems 'make' has a problem on Mac.

So after a successful install of KiCad in /usr/local/bin my troubles really began. Seems that KiCad changed it's library format sometime in the past year and most of the docos refer to the old library but all the code expects the new format. Also on Mac the "home" directory is all over the place. Sometimes it really is $HOME. Other times it is $HOME/Library. Libraries can supposedly be downloaded in realtime from GitHub but it never worked for me so then you have to install them locally. There's a script on EEVblog that will do this. Eventually I got a working version of KiCad on my MBA. Working through the Blinky videos quickly showed up the limitations of using an MBA trackpad instead of a 2-button mouse with track wheel. Zooming takes a long time to adjust to. In the end I tended to use function keys. And it takes a while to work out which keys correspond to the Linux keys. You can save yourself some grief by installing MiddleClick now. But I don't want to use a mouse. So I persisted with using the trackpad for zooming and eventually I started to get the hang of it. But it will never be as smooth as a mouse wheel.

You can also install a compiled version of KiCad from here or here but both are fairly old versions of KiCad and both use the old library format.

The deal breaker for me was when I was placing tracks on the PCB and wanted to change the grid because the steps were too coarse. You can't change the grid on the Mac version. Neither of the compiled versions worked either. End of story!

Linux VM

From all the comments I read in my searches, the Linux version appears to get the best support so a second approach is to install VirtualBox, install Ubuntu on VirtualBox then install the latest and greatest KiCad using apt-get. This is a really straightforward approach with no surprises. It simply worked. BUT Ubuntu in VirtualBox is painfully slow in swapping applications. It does a really tedious animation of drawing small windows of the running apps and then one clicks on one to display it. And the disk image takes up 7.4GB whereas the native app takes only a couple hundred MB. And VirtualBox obviously uses a lot of OS resources. Firefox in VB was particularly slow. So almost usable but not quite. An added bonus is that I subscribed to the nightly updater for KiCad so bugs were being fixed quickly.

Wine

The tediously slow Ubuntu on VB plus the sheer size of the disk image made me think that perhaps I could try running a Windows image of KiCad under Wine. I use Wineskin Winery to install Win apps on my MBA. The task in this case is to find a Win installer for KiCad. There's plenty of scripts to compile it but not many actual install .exe's. I could only find the one mentioned on KiCad's download page and it's nearly a year old which for a fast changing product like KiCad is really old. However it installed simply and it works (almost). The main problem once again is the trackpad on my MBA. I'm so used to using taps instead of clicks but this version of KiCad doesn't seem to handle the trackpad well. Sometimes I have to double tap, other times tapping won't work at all and then I have to click but sometimes I have to double-click all for the same task. Very confusing. Also when drawing the PCB I had to move components out of the way to get access to components underneath. Not sure if this is simply an old version problem or a trackpad issue. Other versions pop up a window asking me to choose which component or track I want to move/edit/etc. And sometimes this version does pop up the window. But not consistently. As for disk image size, the Wine version clocks in at 790MB. But the older version might not have used up as much space. Hard to tell.

But none works well

So I can't decide which version to go with. A recent Win installer would be worth a try if I can find one. Maybe running the Linux version under a smaller distribution would be worth a try. TinyCoreLinux in VirtualBox is currently using 2.4MB(!) on my MBA. (I've been using TCL as part of the boot2docker app.) However the nightly compiles of KiCad are done under Ubuntu so there is a lot of advantage in using the "standard" environment. Maybe I can get rid of Ubuntu's painful animations. It's the first thing I do on Mac OS X. Or maybe the Mac native app will get grid change working...

In summary, none of the Mac alternatives works well. If I were going to use KiCad seriously I think a separate machine running Ubuntu would be a good idea and a mouse with track wheel seems almost compulsory.

As for KiCad itself, I really like it. I found each of it's stages easy to follow and was (eventually) able to get to a set of Gerber files for Blinky ready for manufacture. Dave Jones of EEVblog's opinion notwithstanding, KiCad is a serious contender for Open Source hardware developers. I just wish I could get a usable version for Mac OS X.

Update

I tweaked Ubuntu using the tips here (especially the gnome-session-flashback tip) and now KiCad screams along! (Cannot understand how or why anyone would release such a crippled desktop version.) Really smooth use of all sections. Even the trackpad scrolling is usable now (barely) but I still prefer F1 and F2 keys. I'm looking forward to some productive KiCad use on my MBA now.