Jump to content
Forum sending old emails Read more... ×
yyrkoon

Code::Blocks + mspgcc how-to.

Recommended Posts

This how-to is primarily for Windows users. However, paths aside most of this information should be applicable for Linux users as well. Technically, this should also work with OSX.

You will need Energia, and Code::Blocks. Plus a bit of time.

In this how-to I will walk through setting up a toolchain for use with Code::Blocks, and when done showing how we can use the created project as a user defined template for future projects.

Added Videos to youtube to help clarify some things I found confusing myself in this how to.

 

 

and

 



First things first, we need to setup a directory where Code::Blocks expect to find the MSP430 toolchain. This is optional, but highly recommended as it will be less hassle to set everything up. So . . .

1) Create directory C:\hightec

2) Navigate to \hardware\tools and copy the msp430 directory to C:\hightec\

3) Install code::blocks if not already installed. First time it is run the MSP430 toolchain
should be detected.

4) create a new project. -> select empty project. -> Click the go button.

5) Name the project. the name is unimportant, but needed. First time code::blocks is run, you will have to
tell it which directory projects are created in. click the next button.

6) On this page, select "GNU GCC compiler for MSP430" from the compiler dropdown box, then select the finish button. code::blocks will complain, giving ~3 message boxes saying it does not how to setup various settings for the compiler.

7) From the menu bar Select settings -> compiler.

8) At the top again we need to select the compiler from the dropdown box. select "GNU GCC compiler for MSP430"

9) Click the toolchain tab. below this should be yet another tab "Program files". Here the toolchain should already be autodetected. However. . .


Compiler: -> msp430-gcc.exe
C++ compiler: -> msp430-g++.exe
linker for dynamic libs: -> msp430-gcc.exe
linker for static libs: -> msp430-gcc.exe
Make program: -> make.exe ( keep in mind Energia uses it's own build system, and has no make)

10) Change to the Addtional paths tab. add -> C:hightec\msp430\msp430\include

11) Change to the Compiler settings main tab -> other options tab -> add
-c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=msp430g2553

12) Switch to the linker settings tab -> in the other linker options text box add ->
-Os -Wl,-gc-sections,-u,main -mmcu=msp430g2553

13) Click the ok button on the bottom.

14) From the menubar select project -> properties -> build targets. Uncheck the auto-generate filename extension. In the Output filename field change the output file name extension to elf.

15) Click ok to save and exit the dialog.

16) From the menubar select file -> new -> file C/C++ file -> go -> next -> Filename with full path: click the ... button, name the file -> click ok -> Select the All button -> and finally the finish button.

Add . . .
 

#include int main(){ return 0;}



to main.c/cpp and save.

17) From the menubar select build -> build. Output should be similar to . . .

-------------- Build: Debug in msp430 (compiler: GNU GCC Compiler for MSP430)---------------msp430-g++.exe -c -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=msp430g2553 -IC:\HighTec\Msp430\msp430\include -c main.cpp -o obj\Debug\main.omsp430-gcc.exe -LC:\HighTec\Msp430\msp430\lib\ldscripts\msp430g2553 -o bin\Debug\msp430.elf obj\Debug\main.o -Os -Wl,-gc-sections,-u,main -mmcu=msp430g2553 Output size is 6.44 KBProcess terminated with status 0 (0 minutes, 0 seconds)0 errors, 0 warnings (0 minutes, 0 seconds)


18) From the menubar select file -> save project as template name the template and click ok.


Now, when you create a new project...

File -> New -> Project -> On the left select user templates. Violoa !



Pretty sure mspdebug can be used in conjunction with this as well. However I am done with this for today, and will leave that for the next time.

Share this post


Link to post
Share on other sites

Do you mind if I update my wiki with this information?  I'll leave a citation.

 Not at all. I used your site as a rough guide on how to do this.  Along with various other experiences I've had.

 

Will also probably do a debugger supplement to go with this too, which your site seems to cover better, so no adjustments might be possible.

 

Going to be playing with Visual Studio too. Both of these exercises have taught me a lot so far.

 

JP, feel free to "port" instructions over to Linux if you wish. But would prefer you tested them if you did so. I have no Linux installed here locally at this moment, otherwise I'd do it . . .

Share this post


Link to post
Share on other sites

yyrkoon, on 27 Feb 2013 - 08:10, said:

JP, feel free to "port" instructions over to Linux if you wish. But would prefer you tested them if you did so. I have no Linux installed here locally at this moment, otherwise I'd do it . . .

I use mac & windows. Linux is great, but after college I decided I that the extra $500 for a mac was money well-spent.

 

Someone else wrote the the Linux instructions. It is a wiki after all :smile:. I've never actually used Code::Blocks, apart from once when I just tried it on an Ubuntu install. Mostly I use Eclipse, just due to familiarity.

 

Also, congratulations for recognizing that my screename is in fact my name. It's an odd name -- only a few of us on the planet. I seem to recall "Yyrkoon" as the name of a French metal band. High school... :D

Share this post


Link to post
Share on other sites

. I seem to recall "Yyrkoon" as the name of a French metal band. High school... :grin:

 

Yeah, I've heard *of* them, but don't really know any of their music. Dig deeper for where I get my name ;-)

 

I'll Give you a clue, he has an Albino cousin, who is also his King.

 

EDIT:

 

Yeah, I knew there was a reason why I did not listen to them. They need someone who can actually sing. The way they sound is something like what we used to refer to as "skin-head death metal". Either way, my online persona has been around much longer than they've been a band. And where I get my this name from comes from the 1960's I believe. Granted, I did not know the name until the mid 80's.

Share this post


Link to post
Share on other sites

JP is for John-Peter.  Anglicized, even.  In French I would be Jean-Pierre.

 

I found the source of Yyrkoon.  I still have no idea what is the intended pronunciation.  For the record, I never liked the metal band Yyrkoon.  The French suck at metal.  The nordics seem to do it best.

Share this post


Link to post
Share on other sites

Step 3: In this video I discuss invoking MSP430 command line tools from within the Code::Blocks IDE. First, by demonstrating how to create a simple tool from the tool menu, and then finally invoking the same tool as a post build step. Two different approaches to accomplishing the same end result.

 

Share this post


Link to post
Share on other sites

Two new vids. Kind of back tracking a little to be new user friendly.

 

 

Ive taken this video out as I did not like it, and have since cut it into two parts. Which makes it better since I am not talking so fast, and what I am saying hopefully will be more coherent. Going to add these once i get them edited(converted to mp4) and uploaded.

Share this post


Link to post
Share on other sites

Step 6. UART/Serial text/number output demonstrating what the previous two videos were leading up to. Demonstrated using a simple, and tiny implementation written in C++, with templates.

 

Audio setting went a little wonkey and the audio gain is a bit high, but otherwise watchable. Turn audio for this video down lower than normal.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×