Tuesday, May 14, 2024

MSP430 development in Linux

There are a couple of options for programming an MSP430 microcontroller in Linux without having to buy a license. By programming I mean the minimum steps you need to do when developing with microcontrollers, these are:

  • Writing the code
  • Compile
  • Flashing
  • Debug

For each task you need specific tools compatible with the microcontroller you are using. 



Writing the code

Although seems obvious, you need a text editor to write your code. A simple text editor will do the job, but a special IDE can make your life easier and will help you to code precise and faster. Pure IDEs for you to choose from are Eclipse or Kdevelop, for example. Usually, you need to install an additional plugin for the architecture you are working with. Another option is to use a complete IDE which includes the complete toolchain in one place, this is the easier and safer option. These are discussed in the next section.



Compile

Here I'm grouping compiling and linking, of course. As far as I know, for the MSP430 you have three free options:

  • Energia
  • Code Composer Studio (CCStudio)
  • GCC - Open Source Compiler for MSP Microcontrollers

In short, Energia is oriented to Arduino users, it has its own set of functions to simplify common tasks at the expense of flexibility and low-level control. It seems a good option for quick and dirty projects. CCStudio is the official IDE from TI. The offline version is based on Eclipse and they also provide an online IDE with similar capabilities. To use the online version, you need to install a plugin in your browser to provide access to your development platform. The offline version is probably the best and safer option you can take but also take into account that it depends on 32 bits libraries. So, if you use a pure 64 bits distribution you will have to find a way to install the libraries or skip this IDE. In my case, I use Slackware64 without the compat32 packages from AlienBob because I don't need software that requires 32bit compatibility, then I took the third option from the list.


The GCC Compiler for MSP Microcontrollers is free and open source. It doesn't provide a text editor, so you have to find one which fits your preference. 



Flashing

Aside the flashing tools provided by the IDE there are a couple of way to load your bits to the microcontroller memory. 


...


Debug

A simplest way to debug your code is to use the peripherals of the micro to send signals and messages, but using a real time debugger provides quick access to memory and registers and allows you to dig deeper into the code to find that elusive exception. Energia and CCStudio have their own debugger embedded in the  IDE. 



Workaround:

The precompiled version of GCC-MSP430 is linked to the libtinfo.so.5 but Slackware64 is using libtinfo.so.6. Compiling the GCC-MSP430 will solve the conflict, but you have to install gdb_agent_console by yourself. The quick and dirty solution is to create a link in /lib64/ to libtinfo.so.6 with the name libtinfo.so.5.


MSPFlasher shows the error "error while loading shared libraries: libmsp430.so: cannot open shared object file: No such file or directory". The error is solved copying the file libmsp430.so in the root of the MSPFlasher installation directory to /usr/lib64/. Creating a link to the file is not sufficient, you need to copy the file. 




 References: 
1. https://43oh.com/2010/11/a-step-by-step-guide-msp430-programming-under-linux/

No comments: