Author Topic: Project Template For AVR GCC Compiler  (Read 30416 times)

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Project Template For AVR GCC Compiler
« on: November 03, 2010, 11:38:36 am »
Hi,
I think the project template for AVR GCC is obsolete. The 'fuse, lock & signature' information is not extracted from the resulting hex file which should be programmed into the correct areas on the ucontroller and not into the flash. I know u guys are not embedded programmers mostly but that's a serious issue for embedded programmers using AVR, GCC and Codeblocks. ;) So I modified the current template to update the scripts and added some extra stuff like defining the '$MCU' variable to be used in tools menu to automate the programming process, etc... Will it be ok if I attach the template here for some1 to verify and I'll try to help and make other changes if need be?

Also there is another important issue, can the tools menu be compiler specific? Like it shows only the tools linked to the compiler chosen. That would be great when working with lots of mcus which need their own programming and debugging command scripts. Thnx...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Project Template For AVR GCC Compiler
« Reply #1 on: November 03, 2010, 03:50:36 pm »
Will it be ok if I attach the template here for some1 to verify and I'll try to help and make other changes if need be?
Yes.

Also there is another important issue, can the tools menu be compiler specific?
this makes no sense. A tool must not be compiler related at all. In fact all tools I've embedded are not related to any compiler. So how to differ?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #2 on: November 03, 2010, 05:15:55 pm »
Also there is another important issue, can the tools menu be compiler specific?
this makes no sense. A tool must not be compiler related at all. In fact all tools I've embedded are not related to any compiler. So how to differ?

Say I'm developing with AVRGCC, I wrote the code, compiled it. Then I need to download the code into the microcontroller. Here comes the distinction. I have quite a few options here if I'm using the debugger in 'debugwire' mode then I need to download the code also in 'debugwire' mode which is specific to AVR. Or if in ISP or JTAG, those make another 2 commands for the 'avrdude' on the tools menu. Then I may decide not to program the fuse bits everytime and insert another entry for program without fuse bits. I also need to run the 'gdb-server' (avarice for AVR, gdb-proxy for msp430 or openocd for ARM maybe) before I run the debugger so add another entry. When I said compiler specific I meant target specific which in case turns out to be compiler specific. It will be a long list if these are all on the same menu for all the targets, it would be a tidy version if tools menu could be customised to the compiler like same shortcuts for same actions but target specific executables. Just an idea. ;)

I attached the script file. Need a little more work I think.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Project Template For AVR GCC Compiler
« Reply #3 on: November 03, 2010, 05:42:50 pm »
Then I need to download the code into the microcontroller. Here comes the distinction.
Are you aware that there is also a "commands only" project type, where you can in the pre- or post-compilations steps add commands using macro expansion very well. Using virtual targets you can "baind" these targets to the compiler you've chosen to compile the actual compilation. Maybe this fits your needs better than pressing everything into the tools menu.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #4 on: November 03, 2010, 06:00:06 pm »
Hmm any tutorial on this?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Project Template For AVR GCC Compiler
« Reply #5 on: November 03, 2010, 06:21:04 pm »
Hmm any tutorial on this?
I believe it's pretty straight forward. You can read the docs about virtual targets, macro expansions and project settings if you want to:
http://www.codeblocks.org/docs/main_codeblocks_en.html
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #6 on: November 04, 2010, 10:08:54 am »
Well ok, now I got what u mean but I still think using a shortcut would be easier. Just curious, whether it's logical or not, would it be easy to implement a compiler specific menu item?

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #7 on: December 30, 2010, 01:53:29 pm »
I modified the template further to make some changes related with the filename extensions and added the extraction of the signature byte. The template extracts the fuse data into seperate files for 'hex' output depending on the fuse byte so the programming of the AVR can be automated with the following command:

Code: [Select]
avrdude -c dragon_isp -P usb -p $(MCU) -u -U flash:w:${TARGET_OUTPUT_FILE}.hex -U eeprom:w:${TARGET_OUTPUT_FILE}.eep -U lfuse:w:${TARGET_OUTPUT_FILE}.lfs -U hfuse:w:${TARGET_OUTPUT_FILE}.hfs -U efuse:w:${TARGET_OUTPUT_FILE}.efs -U lock:w:${TARGET_OUTPUT_FILE}.lock
This considers an 'AVR Dragon' is used as programmer hardware. '$MCU' is the variable that contains the mcu type information which I had included in the template before. If an ATXMEGA mcu is used, the template should be further modified to extract the other fuse bytes. The current template distributed with CodeBlocks lacks the extraction of 'fuse, lock & signature' bytes from the resulting flash file which may cause problems if those bytes are used. So I request this template to be verified and used in further distributions. I only modified the original template so the thanks and credits go to the original author.

May I also request 'Project/properties/debugger/additional shell commands' option to be implemented as soon as possible. It's a very important feature for the embedded programmer. ;) And 1 last question, do I have an option to redirect standart output to say 'debugger' tab for my custom tools on the tools menu?

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #8 on: January 13, 2011, 10:59:11 pm »
I updated the script. It now has the option to extract the fuse, lock and signature files if needed. The extraction of the fuse byte into separate files needs the installation of 'srec_cat' and is only available for hex output. As said before I only modified the script, thanks and credits goes to the original author. Should I insert my name into the script to inform about the changes or leave it as it is?

Regarding my previous post I guess no one is interested in this script to be verified, is there some specific developer responsible for the embedded part of codeblocks I have to contact? Please advice!

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #9 on: January 20, 2011, 01:40:57 pm »
I managed to make a patch after a couple of hours to get used to svn. I made it for the debuggers branch located in 'svn://svn.berlios.de/codeblocks/branches/wxpropgrid_debugger', do I also have to make it for the trunk? File is attached, don't know if it requires a specific naming though. Thnx...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Project Template For AVR GCC Compiler
« Reply #10 on: January 20, 2011, 01:44:08 pm »
The wizards are the same in both branches, but you're mixing tabs and spaces for indenting, please use only spaces, as the original script
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #11 on: January 20, 2011, 02:27:05 pm »
Sorry didn't know about the tabs, I'm a newbie in svn. Here is a new 1, I hope I didn't miss any tab.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #12 on: April 10, 2011, 04:47:43 pm »
Ok I made the patch for the corrected version of the template. I've further enhanced the template to include some settings for the programmer and debugger. These settings can be used in the 'tools' commands to further automate the launching of the programmer or debugger with appropriate settings for the project like connection type, hardware type etc... I'll provide a patch for that newer version if there is interest. I also provided the actual files in case they can be used by copying directly.

I have some questions about the matter:
1-When I edit the template by right clicking in the 'new project' window, I can only edit the .script file but not the .xrc file. So when I save my work cb only copies the .script file to corresponding folder under 'documents and settings' but not the .xrc file. When I manually copy the .xrc file there it uses the default .xrc file under the codeblocks installation folder. Is there a way to make cb use the custom .xrc file in the 'docs and settings/...' path? Currently the only way I can find is to copy the custom file over the default file under the installation path.
2-When a custom variable is defined with spaces in it like '--jtag usb', cb uses it with quotes. I mean it inserts it like -> "--jtag usb". Is there a way to get rid of the quotes ""?

Online stahta01

  • Lives here!
  • ****
  • Posts: 6677
    • My Best Post
Re: Project Template For AVR GCC Compiler
« Reply #13 on: April 10, 2011, 06:14:26 pm »
I have reformatted your patch to more closely match the CB team formatting standard. (Removed Tabs from Script Code)
And, I made a proper SVN patch out of it. (Removed the path to your local hard drive)

 
« Last Edit: April 10, 2011, 06:25:23 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #14 on: April 11, 2011, 12:30:42 am »
I apologize for the errors. I'm very new to SVN or any other version control system, it took about an hour to make that patch. ;) I tried to not to use tabs in the .script file but there were already tabs in the .xrc file so I used them where appropriate. I'll try to be more careful with the .script file next time. I have definitely no idea how to create a proper match. I use subcommander (sc) for svn. First I made sc download the debuggers branch on my hard drive then I copied the modified files into that path and then I right clicked somewhere and chose the 'diff' option. It seems I need to investigate more when I have the time.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline twgray

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: Project Template For AVR GCC Compiler
« Reply #16 on: August 03, 2011, 01:06:36 am »
I am running Ubuntu and have it set up to get updates to CB automatically.  Will this be part of the updates now, or do I have to do something else to implement?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Project Template For AVR GCC Compiler
« Reply #17 on: August 03, 2011, 06:57:05 am »
I am running Ubuntu and have it set up to get updates to CB automatically.  Will this be part of the updates now, or do I have to do something else to implement?
Most likely you'll need to add Jens' repo to the Ubuntu package sources (see http://apt.jenslody.de/).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #18 on: August 03, 2011, 10:07:36 am »
I am running Ubuntu and have it set up to get updates to CB automatically.  Will this be part of the updates now, or do I have to do something else to implement?
Most likely you'll need to add Jens' repo to the Ubuntu package sources (see http://apt.jenslody.de/).

I guess he's talking about the modified template. If I didn't get it wrong, the linux version is updated with the modified template at least Jens repository. So what about windows version?

Offline twgray

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: Project Template For AVR GCC Compiler
« Reply #19 on: August 04, 2011, 12:13:49 am »
Exactly right, thanks. 

Now, I know it is slightly off topic, but has anyone gotten avr-gdb to work with C::B?  I searched this forum and only saw a single post from 2007.  Hopefully things have improved since then?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Project Template For AVR GCC Compiler
« Reply #20 on: August 04, 2011, 12:35:45 am »
If you have to use gdbserver, you'll have to try a debugger's branch nightly build.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline twgray

  • Multiple posting newcomer
  • *
  • Posts: 30
Re: Project Template For AVR GCC Compiler
« Reply #21 on: August 04, 2011, 04:18:31 am »
I guess I should start a new topic, but I don't understand the last reply.  Do I understand you to say that in order to use avr-gdb with avarice I need the debugger nightly build of C::B?  Where is the information about how to do that?  I have the http://Http://apt/jenslody.de Ubuntu packages and get updates as they become available, but how do I get the debugger updates?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Project Template For AVR GCC Compiler
« Reply #22 on: August 04, 2011, 10:28:17 am »
I guess I should start a new topic, but I don't understand the last reply.  Do I understand you to say that in order to use avr-gdb with avarice I need the debugger nightly build of C::B?  Where is the information about how to do that?  I have the http://Http://apt/jenslody.de Ubuntu packages and get updates as they become available, but how do I get the debugger updates?
See here: http://forums.codeblocks.org/index.php/topic,15024.msg100522.html#msg100522

Offline kenzanin

  • Single posting newcomer
  • *
  • Posts: 5
  • solderen.co.cc/forum
    • Forum electronika indonesia
Re: Project Template For AVR GCC Compiler
« Reply #23 on: October 25, 2011, 09:59:40 am »
sorry English is not my primary language and iam not programmer :).

iam also make some modification on AVR wizard by
  • making some option default
  • adding ALF, COFF and EXT-COFF debug format
  • adding linker option for printf int or printf float
  • adding linker option for scanf int or scanf float

this the screenshot
BeforeAfter

please notify me for any error

<todo> adding option for programmer avrdude
thanks

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #24 on: October 25, 2011, 10:08:16 am »
I also added options for programmer and debugger but no one was interested in. And CB doesn't get updated with templates.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Project Template For AVR GCC Compiler
« Reply #25 on: October 25, 2011, 10:31:08 am »
I'm not embedded programmer, but if you two collaborate and produce a patch
to the template you both agree on, I can commit it. The patch will be reverted if
there is a user complaining and you don't provide him with support, of course.

In the screen shot I see removed check boxes, are they really useless?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kenzanin

  • Single posting newcomer
  • *
  • Posts: 5
  • solderen.co.cc/forum
    • Forum electronika indonesia
Re: Project Template For AVR GCC Compiler
« Reply #26 on: October 25, 2011, 11:22:01 am »
I also added options for programmer and debugger but no one was interested in. And CB doesn't get updated with templates.
i guest that not true, iam here because i never knew someone has already make modification, otherwise i will used it rather than goggling(to much) and for hours reading codeblock wiki about wizard scripting. and i believe there many user will agree that CB default wizard for AVR is to simple for their need.
sorry if iam mistake.

In the screen shot I see removed check boxes, are they really useless?
i make that modification based on what i need most, i believe someone feel that check box is necessary otherwise it wont be there
this what iam remove form the check box and the reason
 ->create hex file
i remove the check box and make that default, because AVR simulator that i use VMLab, only support for hex and coff. as far as i knew
 ->run avr-size after build
i remove the check box and make that default, i guest i never meet someone that never care about the code size.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #27 on: October 25, 2011, 11:28:14 am »
Providing a patch won't be a problem as I've provided every patch i made. But it should be the users who will decide if a patch is ok or need enhancing and I don't know how it will be possible if they are not even committed? Anyway I'll try it again. ;)

oBFusCATed: Check boxes are not useless and have to be made optional imo.

kenzanin: U can browse the history of my patches and enhancements to the template on this thread.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12127
    • Travis build status
Re: Project Template For AVR GCC Compiler
« Reply #28 on: October 25, 2011, 12:32:05 pm »
oBFusCATed: Check boxes are not useless and have to be made optional imo.
I've not said it is useless, I've asked why it is removed.

kenzanin: Keep in mind that all the different systems/boards have very different requirements, thus the argument I don't need it, so I'll remove it is invalid.

separate suggestion:
Have thought of making default profiles for different systems?
A combobox with the most common ones?
Maybe you need different wizard templates?

If you agree on something I have no problem with committing it, as I've already said...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kenzanin

  • Single posting newcomer
  • *
  • Posts: 5
  • solderen.co.cc/forum
    • Forum electronika indonesia
Re: Project Template For AVR GCC Compiler
« Reply #29 on: October 25, 2011, 12:55:44 pm »
kenzanin: U can browse the history of my patches and enhancements to the template on this thread.
ok thanks you

oBFusCATed: i think different wizard is the most easy option :D. and i agree with combo box with most common one but i still prefer using hex rather than bin. thanks you

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #30 on: October 25, 2011, 01:25:44 pm »
oBFusCATed: Check boxes are not useless and have to be made optional imo.
I've not said it is useless, I've asked why it is removed.
Sry I didn't mean that, I was talking about the ones kenzanin removed.

I had added a 4th page to the current template I'm using for programmer and debugger options. Tonight (I hope) I'll create a patch and submit it for u to review. I think there won't be a separate template needed for different systems by that cuz the tools use the same options for every system afaik. It's just that current template lacks space for every option.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #31 on: October 25, 2011, 06:16:22 pm »
I attached my latest modified version of the AVR template for review. Changes are below as many as I can remember them:

-Added programmer and debugger options to use with the Tools+ or tools plugins on an extra options page.
-Added generation of separate fuse (high, low, extended), signature and lock bytes.
-Changed the project type from 'console' to 'native'.
-I find the '.elf.eep, elf.hex etc...' like file extensions confusing so I modified the template to generate '.elf, .eep, .hex etc...' instead.

That's all I can remember.

I'm submitting this patch and also the 'MCS51' template patch to the patch tracker if appropriate.

Edit: Also submitted to the patch tracker.
« Last Edit: October 26, 2011, 11:49:16 am by scarphin »

Offline kenzanin

  • Single posting newcomer
  • *
  • Posts: 5
  • solderen.co.cc/forum
    • Forum electronika indonesia
Re: Project Template For AVR GCC Compiler
« Reply #32 on: October 26, 2011, 08:14:23 am »
scarphin: thanks you i am studying your patch :D

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Project Template For AVR GCC Compiler
« Reply #33 on: October 26, 2011, 09:37:20 am »