I am starting this series to document all the hiccups/issues/problems, i face while doing stuff i like.This can be a log as well as a help to fellow makers.
I recently moved to Ubuntu on a new system as my Laptop had started to develop some hardware issues with the Graphics Card that require uncalled investment which i am not currently interested in! I am preparing for some exams and this post was a result of my small concentration session 🙂
PS: I am still a Linux Noob and follow the “google-when-stuck” strategy or ask for help from my friend RKS!
Now lets get started,
We need the following modules/packets to get running
- binutils-msp430- Binary Utilities for MSP430 -Linker,Assembler etc
- gcc-msp430- GCC compiler
- msp430-libc- C Libs
- mspdebug- the programmer
So, to get them all just type this in Terminal (Ctrl+Alt+T)
sudo apt-get install binutils-msp430 gcc-msp430 msp430-libc mspdebug
This will install all the required files.
To check that all went as you wanted you just type the following to get the corresponding outputs as shown:
in terminal you should get:
Now lets see how the device enumerates on the USB bus by doing
The output before and after is shown:
On connecting the Launchpad and running mspdebug as before we get:
Now lets start with the blinky here. This was written for CCS but lets see if it works for gcc as well!
A few modifications with geany IDE and save it as main.c in home !
The commands are as follows:
msp430-gcc -Os -Wall -g -mmcu=msp430g2553 -c main.c
-Os -Optimization for low space
-Wall -Warnings all (show and not supress)
g – is used to embed debug info
-mmcu -which mcu?
-c to compile
Now lets link it ! You might have noticed a .o file created in home.
msp430-gcc -g -mmcu=msp430g2553 -o main.elf main.o
-o is to give out the output file. rf2500 accepts in .elf while BSL ones take .txt. We are concerned about .elf .
Now just burn/download it to launchpad using :
sudo mspdebug rf2500 'erase' 'load main.elf' 'exit'
erase- it will erase the mcu
load will (down)load/burn the file into the mcu flash.
You can play with the commands on mspdebug and try setting breakpoints and doing most of the things that can be done in CCS !
Update: RKS tipped me with an easier recipe for GUI friendly compiing! He sent this screenshot where he configures Geany to compile the code with 2 keyboard presses and 2 button clicks! Thats FAB!
He says,Go to Menu-> Set Build Commands. You can then add a label as Flash label will not be available over there by clicking on it. and fill the fields as he mentions:
Compile: msp430-gcc -Os -Wall -g -mmcu=msp430g2553 -c “%f”
Build: msp430-gcc -g -mmcu=msp430g2553 -o “%e.elf” “%e.o”
Flash: mspdebug rf2500 ‘erase’ ‘load %e.elf’ ‘exit’
and hit OK! You are done! Thats pretty nice and cool! Thanks Champ!! 😀
Update 2: It can get easier(lasier)! Just 3(4) Keystrokes..
Add what you did for Flash menu in the execute field as in the screenshot. So now its just F8–>F9–>F5–>Enter
Comparison to CCS:
Pros: Fast and less memory intensive as everything is on the command line. Setting up is fast and most code can be cross compiled,Free as in no code limit,Geeky,Split Second Compilation 😀
Cons: Less supported, boring without a GUI, Serial/UART is not supported out of the box,Smaller community!
Sometimes you may also need to add a udev rule so that the system can identify the msp430 launchpad.Follow this
BTW my Configuration: Ubuntu 12.04LTS 64bit , Launchpad v1.5