AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
agnivesh
PostPosted: Nov 14, 2006 - 07:11 PM
Newbie


Joined: Nov 12, 2006
Posts: 2
Location: Leicester, UK

I'm using WinAVR in AVR Studio 4 for atMega128 device.

I want to generate coff file for my project. Basically, I want to do source level debugging in Proteus Simulator. I think the hex file will do only assembly level debugging and for C variable level debugging, I need coff output format. Am I right ?

Please, help.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Nov 14, 2006 - 08:13 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 34381
Location: (using avr-gcc in) Finchingfield, Essex, England

Well most folks go with the Elf/Dwarf2 format that is output to the .elf file in the default build. However this has a 64KB debug limit so if you break that barrier you probably DO need to modify your Makefile to generate ext-coff

Cliff

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
agnivesh
PostPosted: Nov 15, 2006 - 06:04 PM
Newbie


Joined: Nov 12, 2006
Posts: 2
Location: Leicester, UK

Can anybody please tell me how to modify the default makefile in AVR Studio 4 (using WinAVR) to generate COFF file in addition to hex and elf files ?
 
 View user's profile Send private message  
Reply with quote Back to top
stu_san
PostPosted: Nov 16, 2006 - 09:03 PM
Raving lunatic


Joined: Dec 30, 2005
Posts: 2093
Location: Longmont, CO USA

agnivesh wrote:
Can anybody please tell me how to modify the default makefile in AVR Studio 4 (using WinAVR) to generate COFF file in addition to hex and elf files ?

No, but I will show you how I modified a makefile generated from Mfile (a WinAVR utility) to do it.

Step 1: Use Mfile to generate a makefile for your project.

Step 2: Edit the make file. Make the following changes:

Change 1: Change the Debug format to "stabs":
Code:
# Debugging format.
#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
#     AVR Studio 4.10 requires dwarf-2.
#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
DEBUG = stabs
#DEBUG = dwarf-2

Change 2: Make sure that the values OBJCOPY and OBJDUMP are defined (I think this is normal, but just make sure). Also, be aware that I added a value WINAVR to my makefile to point at the WinAVR directory. Your mileage may vary.
Code:
# Define programs and commands.
SHELL = sh
CC = $(WINAVR)/bin/avr-gcc
OBJCOPY = $(WINAVR)/bin/avr-objcopy
OBJDUMP = $(WINAVR)/bin/avr-objdump
SIZE = $(WINAVR)/bin/avr-size
NM = $(WINAVR)/bin/avr-nm
AVRDUDE = $(WINAVR)/bin/avrdude
REMOVE = rm -f
REMOVEDIR = rm -rf
COPY = cp
WINSHELL = cmd

Change 3: Make sure MSG_COFF and MSG_EXTENDED_COFF are defined (I think MSG_COFF is already defined -- just add MSG_EXTENDED_COFF after MSG_COFF).
Code:
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:

Change 4: Add a new build target "extcoff".
Code:
# Change the build target to build a HEX file or a library.
#build: elf hex eep lss sym
#build: elf hex lss sym
build: elf hex lss sym dbginfo extcoff
#build: lib

Change 5: Add the extcoff build target rule after the "coff" build target rule (I'm including all of the COFF conversion stuff here, but I think most of it comes from Mfile).
Code:
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT = $(OBJCOPY) --debugging
COFFCONVERT += --change-section-address .data-0x800000
COFFCONVERT += --change-section-address .bss-0x800000
COFFCONVERT += --change-section-address .noinit-0x800000
COFFCONVERT += --change-section-address .eeprom-0x810000



coff: $(TARGET).elf
   @echo
   @echo $(MSG_COFF) $(TARGET).cof
   $(COFFCONVERT) -O coff-avr $< $(TARGET).cof


extcoff: $(TARGET).elf
   @echo
   @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
   $(COFFCONVERT) -v -O coff-ext-avr $< $(TARGET).cof

Step 3: Save your makefile.

Step 4: Go into AvrStudio.

Step 5: Select the menu item Project->Configuration Options

Step 6: Near the top of the option page, you find a check box labeled "Use External Makefile" -- check it.

Step 7: Use the Browse button (contains "...") to make sure that your makefile is the one AvrStudio wants to use.

Step 8: Click "OK"

Step 9: Select the menu item Build->Rebuild All.

Step 10: If your compile and link works, enjoy your new COFF file!

---------------------------------------

Now that I have told you, literally step-by-step how to do this, I want to chide you a little. I figured this out for myself about 5 months ago. It took me about an hour of looking around and trying things. Granted, in the best-of-all-possible worlds, this would be a check button somewhere. However, this is all free software maintained by volunteers. Cut them some slack by trying to work things out on your own.

You would gain far more respect (and responses) if you had said, "I tried such-and-so to create a COFF file, but I am having trouble. Here is my makefile, code, and the response I get..."

Rolling Eyes

On the other hand, I guess everyone is at a different place in their education. I hope this helps.

Stu
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits