yyrkoon

Code::Blocks + mspgcc how-to.

38 posts in this topic

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.

jpnorair, jsolarski and bluehash like this

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

Two videos uploaded to youtube to hopefully clarify some things I felt could be confusing in the text explanation above.

 

 

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.

 

bluehash likes this

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

Re-did the last video into two parts. It was bugging me, because it felt so rushed, and I was feeling it was not so coherent this way.

 

 

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

Step 7. A quick explanation of mspdebug, and how the user defined Upload tool from within Code::Blocks mentioned in a previous video was setup.

 

Rei Vilo likes this

Share this post


Link to post
Share on other sites

Congratulations for the Code::Blocks implementation and the nice videos!

 

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

 

 

There is a very nice Visual Studio plug-in for embedded computing called Visual Micro, alas limited to Arduino only.

 

VMLogo2SmallWithInfo.png

 

It features software debugging by code injection. Feel free to contact its developer, Tim.

 

I've developed a similar template for Xcode, called embedXcode (websiteforum)

 

1551017.png?130

 

I'm looking for solutions to bring debugging capabilities.

 

 

Share this post


Link to post
Share on other sites

So, I did a bit of research ( a tiny bit ) followed by some experimentation, and it seems that debugging from within code::blocks is not going to be as easy as I had first anticipated. I can get mspdebug to accept a connection from gdb called by code::blocks, but that is about it. No memory dump, breakpoints, or anything that debugging is supposed to do works.

 

Granted, I know nearly ziltch about gdb, and it seems there is a ton of things I have to read before I may get this to work. So, this alone may turn into a long standing project of its own. I'll ask around a little, and see if this is going to be worthwhile overall.

Share this post


Link to post
Share on other sites

I had the same experience with gdb and Xcode.

 

I manage to use gdmanually with two Terminal windows, but connection to Xcode is almost impossible.

Share this post


Link to post
Share on other sites

I had the same experience with gdb and Xcode.

 

I manage to use gdmanually with two Terminal windows, but connection to Xcode is almost impossible.

 

I think I've actually decided to write my own intermediate tool, and while at it, I may also just implement my own build tool based on msp430-GCC/G++ too. Although Rickta59 brought to my attention that there are already GUI front ends for GDB,

 

So yeah I am not 100% sure how I will approach this, but whatever I do, I am not just going to rush into things to get something out there *right now*. The end goal though, is a tool that can take a few cmd line arguments, and then build, upload, and debug *your* code, through a GUI, and have nicely formatted text to to read through.

 

Anyway a day or two ago, I wrote up a quick prototype, to give me a better idea of what I need to do, and how. Nothing that debugs and spits debug information out nicely formatted yet though.

 

Got a lot on my plate at the moment, so not sure how long it will take me. . .  Need to do a lot of reading on GDB, refresh my memory on various aspects of the .NET framework, my reflow controller code needs to be finished / polished, not to mention the every day mundane tasks of life. Not to mention the videos I plan on doing still . . .

Share this post


Link to post
Share on other sites
This IDE looks great ! Thanks for sharing.

 

But after all steps, video 1 and video 2, i got this message:

 

 

 

ld.exe                    cannot find -lstdc
 
||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|

 

 
 
Do you have any idea ?
 
thanks.

Share this post


Link to post
Share on other sites

 

This IDE looks great ! Thanks for sharing.

 

But after all steps, video 1 and video 2, i got this message:

 

 

 

 
 
Do you have any idea ?
 
thanks.

 

Sounds like you did not set up the tool chain under the toolchain executable s tabs as I described. They must be set up exactly like shown in the picture below. You do not need to worry about the debugger, and make tools. Resource compiler is also not needed.

 

msp430-gdb and Code::Blocks do not seem to play well with one another anyhow . . . which is one reason why i want to build my own intermediate tool for the toolchain.

 

toolchain-executables.jpg

bluehash likes this

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