HowTo use multi platform Code::Blocks for AVR document

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is my second try to use Code::Blocks developing AVR programs.

I have not found a HowTo on this subject, so I wrote this one while starting up.

As it is a powerful multi platform ( Linux, MAC and MS ), multi target IDE, I invite you to take a look at the HowTo and maybe give suggestions for the few remaining issues.

Using Ubuntu It works perfectly as an editing, compiling, and programming AVR environment, and is now close to a full debug functionality with a JTAG II.

Maybe I just missed a few details, maybe the remaining stuff is errors waiting to be corrected.

It also debugs C++. ( Most of my programs are C++ )

I tried my best to stuff the necessary in, if something is missing, please excuse me, documenting is no easy task.

Although it is dangerous to mention a few and forgetting the many who made this possible, I wish to thank Bingo for his support in many ways, and Joerg for his many contributions.

ekh

EDIT: This is the version 1.0, please download version 1.3 from my post dated May 01, 2010 - 09:03 PM below.
---

Attachment(s): 

Last Edited: Sat. May 1, 2010 - 08:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi ekh

Thank you for the kind words :oops: 8) 8)

But there is a problem unzipping the file(s) , neither winzip nor 7zip can extract the files.
I think the reason is that the file within the zipfile has :: in the name , and : is not a valid character in M$ systems. So the file can not be extracted on M$.

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah! Very interesting! I'll have a look!

Bingo: In 7zip you can rename the file in the archive and then extract it.

And... When I do so I get the document, but I dont have MS Word. Trying to open it in WordPad generates faliures for all images in the document.

ekh: Any chance that you can export/print it from Word to a PDF and post that? (Free PDF printers are available on the net, eg. http://sourceforge.net/projects/... )

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@johan

I know it's created w. OpenOffice , so go get the vers 2.4 :-)
It's free an even can save as "PDF"

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ha! OpenOffice managed to open it (and of course OO can save as a PDF). Here you go:

Attachment(s): 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well okay :-)

I am on a linux system now w Openoffice

Hmmm .... i cant upload

The pdf is 1.1MB compressed , and maxupload is 1M

So Johan , now is the time for OpenOffice , the 2.4 vers works ok even on M$

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm ... How did you make it just 868K ??

My pdf export is 1.2M linux openoffice , did you shrink the jpegs ??

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did nothing to the document. OO 2.2 on WXP. Export to PDF. Didn't bother to even look at the options when exporting.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On Ubunty 8.04 (See further down for 10.04)

To add wxwidgets and the codeblocks repository in the pdf

Add this to the end of your /etc/apt/sources.list

# wxWidgets/wxPython repository at apt.wxwidgets.org
deb http://apt.wxwidgets.org/ gutsy-wx main
deb-src http://apt.wxwidgets.org/ gutsy-wx main

#codeblocks repository http://lgp203.free.fr/spip/spip.php?article1 and http://lgp203.free.fr/spip/spip.php?article2
deb http://lgp203.free.fr/ubuntu/ hardy universe
deb-src http://lgp203.free.fr/ubuntu/ hardy universe 

import the keys from wxwidgets & codeblocks

wget -q http://apt.wxwidgets.org/key.asc -O- | sudo apt-key add -

wget -q http://lgp203.free.fr/public.key -O- | sudo apt-key add -

do an sudo apt-get update

Now you are ready to apt-get wxwidgets & codeblocks

sudo apt-get install libcodeblocks0 codeblocks libwxsmithlib0 codeblocks-contrib

sudo apt-get install libwxgtk2.8-0 libwxgtk2.8-dev wx2.8-headers wx-common

Set wxWidgets 2.8 as default version for your machine. Select number for the wxgtk2.8 version.
sudo update-alternatives --config wx-config

See
http://wiki.codeblocks.org/index...

Ohh to build avr-insight & avr-gdb see here
http://www.avrfreaks.net/index.p...

You might have to apt-get install these modules before insight will build. (I just did arm-insight , and had to install those)

libcwidget-dev
tcl8.4-dev
tk8.4-dev
libncurses5-dev
libx11-dev
texinfo
texi2html

Edit: For other versions of Ubuntu see here
http://lgp203.free.fr/spip/spip....

/Bingo

Last Edited: Sun. Jul 25, 2010 - 04:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Johan and Bingo

Thanks for filling the gaps :-)
Sorry for the :: inconvenience.

We should somehow refine the HowTo document, so the Linux and AVR guys gets an easy way to this productive and well supported IDE.

I guess that I'm not in the best position to do it as my system works now.

I will be thankful if some of you fill in the missing pieces while installing, so the next trying this HowTo follows a less stony road.

Maybe we should keep the document for editing in the .odt format and make exports to pdf for easy reading.

And maybe we should evem make separate install sections for each operating system of interest.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys

WOW there are people who want to do AVR stuff with Codeblocks, yeah I'm not the only one. I have a problem: I have created a
project like shown in the HOW TO (by the way thanks Johan).but this is what I get when I build the project:

this happens although i was able to set the mcu to: at90usb162
I`m usin ubuntu gutsy

anyone idea?

Compiling[i]: main.c
In file included from main.c:15:
/usr/lib/gcc/avr/4.2.1/../../../../avr/include/avr/io.h:332:6: warning: #warning "device type not defined"
main.c: In function ‘main’:
main.c:26: error: ‘DDRB’ undeclared (first use in this function)
main.c:26: error: (Each undeclared identifier is reported only once
main.c:26: error: for each function it appears in.)
main.c:27: error: ‘DDRC’ undeclared (first use in this function)
main.c:28: error: ‘PORTC’ undeclared (first use in this function)
main.c:33: error: ‘PORTB’ undeclared (first use in this function)
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 1 warnings 


problem solved:

my avrlibc is to old, the synaptic package manager of ubuntu installed a to old version of avrlibc

Last Edited: Mon. Jun 2, 2008 - 10:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please post your project .cbp file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is an updated version 1.1 of my HOWTO.

More install instructions added.
Variable readout now works with avr-elf-gdb 6.8

I now append the document in .odt format ( Open Document Text )
and pdf

Everyone can read the .odt format by installing Open Office.

Please observe that Acrobat Reader is a phone-home program.

May I suggest that .odt is added to the allowed extensions for attached files in this forum.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

this happens although i was able to set the mcu to: at90usb162
I`m usin ubuntu gutsy

anyone idea?

No, not yet. Same thing happends to me (on WXP).

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have solved my problem: my avrlibc (io.h) is to old, the synaptic package manager of ubuntu installed a to old version of avrlibc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build your own AVR-GCC on ubuntu

http://www.avrfreaks.net/index.p...

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been using Code::Blocks since the first post in this thread, and besides the missing nice port window in Studio, it does the job quite well.

It can program the AVR right after a successful compilation and then start debugging after an avarice command and a button click.

It can also debug using debugWire, I have used both the Dragon and the JTAGICEII

For an easy start I have included a project file for a recent tiny85 project. You have to change the files in the project to be your own files.

Directory structure I use:

project_dir
 |
 |-codeblocks
    |
    |-test.cbp

What I miss is debugging on the XMEGA, anyone knowing what happens here ?

OBS: after download rename test.pdf to test.cbp

ekh
.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've modified the C lexer to highlight AVR assembler. If anyone is interested it's attached to this message. Place these files in the CodeBlocks\share\CodeBlocks\lexers directory. It isn't perfect but it's better than nothing.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On Ubuntu 10.04

Don't install wxwidgets from wxwidgets.org , you will get problems
The wxwidget from the Ubuntu "universe" is the one you want , so enable universe in the System->Administration->Software Sources

To add codeblocks repository in the apt

Add this to the end of your /etc/apt/sources.list

#codeblocks repository http://lgp203.free.fr/spip/spip.php?article1 and http://lgp203.free.fr/spip/spip.php?article2
deb http://lgp203.free.fr/ubuntu/ jaunty universe
deb-src http://lgp203.free.fr/ubuntu/ jaunty universe 

import the keys from codeblocks

wget -q http://lgp203.free.fr/public.key -O- | sudo apt-key add -

do a sudo apt-get update

Now you are ready to apt-get wxwidgets & codeblocks

sudo apt-get install libcodeblocks0 codeblocks libwxsmithlib0 codeblocks-contrib

sudo apt-get install libwxgtk2.8-0 libwxgtk2.8-dev wx2.8-headers wx-common

This wasn't needed on my 10.04 , but is left if you have problems

Set wxWidgets 2.8 as default version for your machine. Select number for the wxgtk2.8 version. 
sudo update-alternatives --config wx-config

See
http://wiki.codeblocks.org/index...

Ohh to build avr-insight & avr-gdb see here
http://www.avrfreaks.net/index.p...

You might have to apt-get install these modules before insight will build. (I just did arm-insight , and had to install those)

libcwidget-dev
tcl8.4-dev
tk8.4-dev
libncurses5-dev
libx11-dev
texinfo
texi2html

Edit: For other versions of Ubuntu see here
http://lgp203.free.fr/spip/spip....

If you have unresolved library errors , have a look here
http://forums.codeblocks.org/ind...

Edit2: Corrected reops to pint to jaunty not hardy


At: Jul-2011 i have begun to use this repos for CB on ubuntu 10.04
, note he has main & release repos.
I'd suggestthe release repos unless you want to get the latest svn , all the time
http://apt.jenslody.de/

/Bingo

Last Edited: Sun. Jul 24, 2011 - 03:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the "How to" file. Tried to use it and got as far as page 4. CB doesn't display a compiler and it won't let me choose any options. The compiler pull down, instead of displaying AVR GCC is just blank. Clicking on it doesn't do anything.

I'm on a MacBook running 10.5.8 and the current version of CB. Any insights?

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cant help much (I'm on Linux)

But maybe this can give a hint
http://forums.codeblocks.org/ind...

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

i am trying to write a simple program for blinking leds with avr in Code::Blocks… as follows:

#include<avr/io.h>
int main(void)
{
DDRC = 0b11111111;
while(1)
{
PORTC = 0b10101010;
PORTC = 0b01010101;
}
return 0;
}

however, i keep getting fatal error for #include<bits/predefs.h>

i am beginner for micro-controller programming and i am fade up with it!

Please Help
Edit: This is a cross post from his own thread

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Update 23-mar-2016

I'm using this repos on my Linux Mint 17 -  (Ubuntu derivative)

 

deb http://lgp203.free.fr/ubuntu trusty universe
deb-src http://lgp203.free.fr/ubuntu trusty universe

 

/Bingo