How to build mspdebug with libmsp430.so (the "tilib" driver) on Mac OSX A frustrated tutorial by Brandon Lucia, circa May 2014 ----------------------------------------------------------------------- Building mspdebug on mac is straightforward -- assuming you're using something like homebrew to install all the dependences, the included build system works great. However, if you are using the newest version of the FET430 from TI, the 'fet' driver will not work (or at least it didn't for me). TI (and mspdebug) recommends using the 'tilib' driver instead. To use that driver to make mspdebug talk to your FET, you need a copy of TI's 'libmsp430.so'. This is a proprietary thing that is shipped as a .DLL on windows. Luckily, however, there is now an open source version. Unluckily, that version is a little tricky to build. This document is an account of how I got libmsp430.so to build and load into mspdebug on Mac OSX. The main thing to keep in mind is that libmsp430.so requires everything it interacts with to be 32 bit. This is not ideal, as most macs are 64 bits these days. That means homebrew isn't too useful for installing dependences and you'll need to do lots of weird library hacks to get it built. There are lots of deps: 1)Boost -- you need to build it for 32 bit 2)libiconv -- you need to build it for 32 bit and change the names of the calls in the libmsp430 source code to refer to "libiconv_" rather than just "iconv_". Lame. 3)libusb-1.0 -- this is a requirement for libmsp430.so's build 4)libusb-compat/libusb -- this is a requirement for mspdebug's build 5)hidapi -- this is documented in the libmsp430.so open source package build docs. This lib is strangely structured. It's not a lib, actually. You just want to go into the 'libusb' subdirectory and crunch through the build process using Makefile.linux. You'll have to deal with miscellaneous build failures, as this lib was not originally intended to work with OSX. Two things stand out: the first is that you'll need an api-compatible pthreads barrier implementation. I used this one: http://blog.albertarmea.com/post/47089939939/using-pthread-barrier-on-mac-os-x The second is that you'll need to rewrite calls to clock_gettime(...). I used this one: https://gist.github.com/jbenet/1087739 With those changes, this will eventually build. 6)TI's BSL430 lib -- this is included in the libmsp430.so open source package, but needs to be manually built before you can build libmsp430.so. The way I did this, which worked, was to set up a local install of each of the deps, each built with CFLAGS="-m32 -arch i386" passed to cc and ld. That is the important part here -- these all need to be 32 bit libraries. Then once the libs are all set up, you'll need to get the libmsp430.so source. It is available here: http://processors.wiki.ti.com/index.php/MSP_Debug_Stack You'll want the Open Source Release. The documentation and build system are of extremely low quality. The build process for the lib is clunky. First, copy hidapi.h from it's home in the hidapi source tree to "ThirdParty/include" in the libmsp430.so tree. Copy hid.o to ThirdParty/lib/hid-libusb.o. Then you have to hack two Makefiles. The first one is the one for the BSL library. The second one is the top level libmsp430.so Makefile. The hacking is largely just to point your compiler to the right library locations -- that means you need to add -L/path/to/lib options for each thing you built earlier. Be sure to add them at the beginning of the linker command line so they're checked before standard locations where there might be 64 bit copies of what you're trying to link to. Make in the BSL directory, then make in the top level directory. That should work (you may have to do a little debugging of, e.g., build paths). The next step is building mspdebug, which has a fine build system. You need to tell it to use CFLAGS="-m32 -arch i386" as well, so it is also 32-bits. Make sure it can find libusb or it won't build. Once that's built, be sure that any dynamically link libs are in your library path (DYLD_LIBRARY_PATH=/path/to/libs/you/built). run mspdebug tilib and you should see mspdebug connecting to your device. Woo!