|
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..."
On the other hand, I guess everyone is at a different place in their education. I hope this helps.
Stu |