How to make .COF in WinAVR example stdiodemo

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

How to make .COF in WinAVR example stdiodemo

C:\WinAVR\doc\avr-libc\examples\stdiodemo

.rar arhive in http://slil.ru/27011869

I’ve read c:\WinAVR\doc\avr-libc\avr-libc-user-manual.pdf

22.36.3 Compiling and Linking page 303 but not fing anything reffer .cof

Text from C:\WinAVR\sample\Makefile
don’t help me too.

Please edit makefile from stdiodemo for .cof output.

PRG            = stdiodemo
OBJ            = stdiodemo.o hd44780.o lcd.o uart.o
MCU_TARGET     = atmega16
OPTIMIZE       = -Os

DEFS           =
LIBS           =

# You should not have to change anything below here.

CC             = avr-gcc

CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
LDFLAGS       = -Wl,-Map,$(PRG).map

OBJCOPY        = avr-objcopy
OBJDUMP        = avr-objdump

all: $(PRG).elf lst text eeprom

$(PRG).elf: $(OBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

clean:
	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)

lst:  $(PRG).lst

%.lst: %.elf
	$(OBJDUMP) -h -S $< > $@

# Rules for building the .text rom images

text: hex bin srec

hex:  $(PRG).hex
bin:  $(PRG).bin
srec: $(PRG).srec

%.hex: %.elf
	$(OBJCOPY) -j .text -j .data -O ihex $< $@

%.srec: %.elf
	$(OBJCOPY) -j .text -j .data -O srec $< $@

%.bin: %.elf
	$(OBJCOPY) -j .text -j .data -O binary $< $@

# Rules for building the .eeprom rom images

eeprom: ehex ebin esrec

ehex:  $(PRG)_eeprom.hex
ebin:  $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec

%_eeprom.hex: %.elf
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@

%_eeprom.srec: %.elf
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@

%_eeprom.bin: %.elf
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@

# Every thing below here is used by avr-libc's build system and can be ignored
# by the casual user.

JPEGFILES               = stdiodemo-setup.jpg

JPEG2PNM                = jpegtopnm
PNM2EPS                 = pnmtops
JPEGRESOLUTION          = 180
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec *.eps

dox: ${JPEGFILES:.jpg=.eps}

%.eps: %.jpg
	$(JPEG2PNM) $< |\
	$(PNM2EPS) -noturn -dpi $(JPEGRESOLUTION) -equalpixels \
	> $@

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

If you've found something that mentions COFF then it is very, very old. The preferred debugging format these days is Elf/Dwarf2 which is generated by the compiler when -gdwarf-2 is used.

If this is the WinAVR/avr-libc stdiodemo:

http://www.gnu.org/savannah-chec...

then, when you install WinAVR, \winavr\doc\avr-libc\examples\stdiodemo\ already includes a suitable Makefile (that generates dwarf-2)

Cliff

PS moving this to GCC forum

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

clawson wrote:
If you've found something that mentions COFF then it is very, very old. The preferred debugging format these days is Elf/Dwarf2 which is generated by the compiler when -gdwarf-2 is used.

Thanks ! I've known it. VMLAB needs in .COF

Last Edited: Tue. Mar 3, 2009 - 11:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK then create a Makefile for the project using Mfile then use "make extcoff"

(or just look at the Mfile template to see how it's done there)

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

I've done it and then project stdiodemo not compiled with heap of errors.

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

a3v2r wrote:
I've done it and then project stdiodemo not compiled with heap of errors.
Care to give us a sampling of the errors? Our mind-reading machines are all broken.

Please read Help, My "..." Doesn't Work!

Stu

Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.

Newbie? Be sure to read the thread Newbie? Start here!

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

stu_san wrote:
Our mind-reading machines are all broken.

:lol: :lol: :lol:

stu_san wrote:
Please read Help, My "..." Doesn't Work!

Please read my post carefuly ! I do not ask to fix errors !

I ask just to add .cof generation to makefile that compiled good. Makefile that is been in all WinAVR in

WinAVR\doc\avr-libc\examples\stdiodemo

or WinAVR-õõõõõõ\doc\avr-libc\examples\stdiodemo

IMHO mind-reading machines is not need for this task.

Sory for my ugly english.

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

Look at the WinAVR Makefile Template under the \sample directory. It has rules to generate COFF files.

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

EW wrote:
Look at the WinAVR Makefile Template under the \sample directory. It has rules to generate COFF files.

In the 1-st post I've mantion it !

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

I have just tried "make coff" and "make extcoff" from an old Makefile.

Neither seems to work. Just a message:

avr-objcopy: project.elf: no recognised debugging information.

So perhaps avr-objcopy has a problem in avr-gcc 081205.

David.

p.s. it might be helpful if the OP said what he wanted to do. The .elf format is superior to the .coff format, but perhaps he wants to use a debugger that only recognises .coff

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

Quote:

it might be helpful if the OP said what he wanted to do.

David, before he bites your head off for having the temerity to offer advice I can't help noticing he did say:
Quote:

VMLAB needs in .COF

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

Oops. I missed that.

Perhaps you might try to "make coff" with a current avr-gcc. or perhaps even with an historic avr-gcc.

David.

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

david.prentice wrote:
but perhaps he wants to use a debugger that only recognises .coff

That is rigth ! VMLAB eats only COF.

david.prentice wrote:
I have just tried "make coff" and "make extcoff" from an old Makefile.

Neither seems to work. Just a message:

avr-objcopy: project.elf: no recognised debugging information.

So perhaps avr-objcopy has a problem in avr-gcc 081205.

I've use just it - WinAVR-081205

When I compiled throgh VMLAB with "aoutomake" another C project in WinAVR-081205 .cof performed well !

But VMLAB use win noutepad editor.I try chanched it in option? but it has no effect!

Thats way I need makefile mod for compiling in WinAVR in programmers notepad.

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

I just went to a project that uses an Mfile created Makefile and typed "make coff" it built and output the file just as expected.

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

What is the Mfile created commandline ?

I have just changed some paths and cannot make coff even with some older avr-gcc.

And I have created a brand new MFile to drive it.
Cliff. Are you sure you get no messages ?

You get a .coff file tha you can load into Studio. But it has no source information.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Linking: sounds.elf
avr-gcc -mmcu=atmega16 -I. -gdwarf-2 -DF_CPU=8000000UL  -Os -funsigned-char -fun
signed-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhl
ns=main.o  -std=gnu99 -MD -MP -MF .dep/sounds.elf.d main.o global.o adpcm.o calc
rc.o dflash.o init.o purge.o receive.o record.o recv_wait.o respond.o sendc.o ti
mer1.o transmit.o uart.o validate_packet.o --output sounds.elf -Wl,-Map=sounds.m
ap,--cref -Wl,--section-start=.bootloader=0x3800     -lm

Converting to AVR COFF: sounds.cof
avr-objcopy --debugging --change-section-address .data-0x800000 --change-section
-address .bss-0x800000 --change-section-address .noinit-0x800000 --change-sectio
n-address .eeprom-0x810000  -O coff-avr sounds.elf sounds.cof
avr-objcopy: sounds.elf: no recognized debugging information
avr-objcopy: --change-section-vma .eeprom+0xff7f0000 never used
avr-objcopy: --change-section-lma .eeprom+0xff7f0000 never used
avr-objcopy: --change-section-vma .noinit+0xff800000 never used
avr-objcopy: --change-section-lma .noinit+0xff800000 never used

Then as long as I have edited the Makefile to change "DBEUG = dwarf-2" to be "DEBUG = stabs" I not only get the binary loaded but also (after selecting the source folder) I get a source view I can debug too.

So, yup, everything seems to be working fine over here though I wouldn't rely on this (using COFF between avr-gcc and Studio) when all the recent work has been on ensuring that 32bit Elf/Dwarf2 is correctly supported. But I guess this .cof would work fine in VMLab

Cliff

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

Yes. I can set DEBUG=stabs and the .elf file is still produced but with a different flavour.

The generated .cof file then seems to load into Studio.

So the answer is to use the "-gstabs" switch for "avr-ld" and then generate the "coff"

The bad news being that in Studio, the project_cof.aps will work ok, but project_elf.aps no longer does.

David.

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

Quote:

The bad news being that in Studio, the project_cof.aps will work ok, but project_elf.aps no longer does.

Yeah but no one in their right mind is going to use the deprecated COFF in AVR Studio unless they have to (GCC users don't). It may be fine in programs (such as VMlab) where there's no other option.

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

clawson wrote:
I just went to a project that uses an Mfile created Makefile and typed "make coff" it built and output the file just as expected.

This project ?
WinAVR\doc\avr-libc\examples\stdiodemo

i'cant buil it with my Mfile created Makefile with .cof output (this is the 3-d line in output format menu).

And what avrstudio say :?:

Please zip project folder and attache to next post. Thanks !

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

Yeah I can get a COFF project of the stdiodemo to work in Studio IFF I ditch the Makefile supplied in the project directory, run Mfile, fill in the blanks (including changing DEBUG = to stabs), save the newly created Makefile, "make coff" and then File-open the resultant .cof file.

The Makefile I used is attached. If you want to use it rename it to drop the .txt extension (I have to add that as Freaks won't allow "typeless" files to be uploaded).

Cliff

Attachment(s): 

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

I've juat tryed your makefile but I don see .COF !!!

Full project folder in attachnment.

Attachment(s): 

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

Well I downloaded your project, unpacked it to a junk directory, started a command prompt, switched to that directory and typed:

C:\junk>make coff

Compiling C: stdiodemo.c
avr-gcc -c -mmcu=atmega16 -I. -gstabs -DF_CPU=8000000UL -Os -funsigned-char -fun
signed-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhl
ns=./stdiodemo.lst  -std=gnu99 -MMD -MP -MF .dep/stdiodemo.o.d stdiodemo.c -o st
diodemo.o
In file included from stdiodemo.c:14:
defines.h:15:1: warning: "F_CPU" redefined
: warning: this is the location of the previous definition

Linking: stdiodemo.elf
avr-gcc -mmcu=atmega16 -I. -gstabs -DF_CPU=8000000UL -Os -funsigned-char -funsig
ned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=
stdiodemo.o  -std=gnu99 -MMD -MP -MF .dep/stdiodemo.elf.d stdiodemo.o hd44780.o
lcd.o uart.o --output stdiodemo.elf -Wl,-Map=stdiodemo.map,--cref     -lm

Converting to AVR COFF: stdiodemo.cof
avr-objcopy --debugging --change-section-address .data-0x800000 --change-section
-address .bss-0x800000 --change-section-address .noinit-0x800000 --change-sectio
n-address .eeprom-0x810000 -O coff-avr stdiodemo.elf stdiodemo.cof
avr-objcopy: --change-section-vma .eeprom+0xff7f0000 never used
avr-objcopy: --change-section-lma .eeprom+0xff7f0000 never used
avr-objcopy: --change-section-vma .noinit+0xff800000 never used
avr-objcopy: --change-section-lma .noinit+0xff800000 never used

C:\junk>dir *.cof
 Volume in drive C is ACER
 Volume Serial Number is C6B0-75D7

 Directory of C:\junk

03/03/2009  17:49            11,804 stdiodemo.cof
               1 File(s)         11,804 bytes
               0 Dir(s)  59,224,473,600 bytes free

I'm guessing you just used "make" and not "make coff" ?

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

Oh, and MFile uses the WinAVR Makefile Template to generate the Makefile. So my suggestion still stands. The WinAVR Makefile Template has the rules to build a COFF file.

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

EW wrote:
Oh, and MFile uses the WinAVR Makefile Template to generate the Makefile. So my suggestion still stands. The WinAVR Makefile Template has the rules to build a COFF file.

I've mentioned my problem with it above, in 1 page of this topic.

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

I can confirm Cliff's result.

If the .elf is built with -gstabs, "make extcoff" or "make coff" work just fine.

Why not just use Cliff's "makefile" ?

I have only loaded the .cof file into Studio, so there may still be a problem with your debugger. But surely it is worth trying.

David.

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

How to comple from comand line ?

I compile from programmers noutped commonly.

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

On the Start menu go to Programs-Accessories and there should be a link there called "command prompt". Start that and you'll see a prompt like:

C:\>

Switch to the directory where the project and Makefile are located with the CD command: Something like:

C:\> CD \AVR\projects\test

then simply give the command "make coff":

C:\AVR\projects\test> make coff

Alternatively in PN you probably initially followed a procedure to set up an entry on the Tools menu to invoke "make" you could just change this to invoke "make coff" instead.

Cliff

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

Sorry, I rather assumed that you were using Linux and knew how to work things.

Operating a command line is obviously too complicated for you.

I do not use Programmers Notepad, but I would assume that you just copy Cliff's Makefile.txt to replace your existing Makefile.

However this will only allow you to do some limited commands like "make all". You will have to read the manual to see how to do any other operations.

Adding "coff" or "extcoff" to the "all" target will make the whole process transparent i.e. "make all" will do everything for you. But you will obviously have to learn how to locate and edit your Makefile.

David.

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

David has probably the easiest solution for you. Just edit the Makefile I provided and find this segment:

# Change the build target to build a HEX file or a library.
build: elf hex eep lss sym

Simply add coff into that:

# Change the build target to build a HEX file or a library.
build: elf coff hex eep lss sym

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

I use Studio4 with Windows XP. Simple timer events work very well. Not all sub-systems are simulated.

Some while ago I downloaded Proteus evaluation, but have never succeeded in simulating any AVR from a COFF or ELF file.

I briefly looked at Rowley debugger. It makes no attempt to simulate peripherals. However it is very pleasant for stepping through program logic. Rowley do not and will not produce Studio compatible output.

I know nothing about VMLAB. Does it work ? Is it better at simulation than Studio ?

I am probably more interested in simulation than JTAG control. ( which is less arduous )

From a JTAG point of view, which debuggers are both functional and easy to use ?

David.

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

david.prentice wrote:
I know nothing about VMLAB. Does it work ? Is it better at simulation than Studio ?

For me More More better then studio ! But list of AVR narrow (anogth for me) - http://amctools.com

see picture ! and TOOLs section avrfreaks.net

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

VMLAB integrates w WinAVR like AVRstudio. Simulate some electroniv parts and ...

Supported AVR models: ATiny11, ATiny12, ATiny15, ATiny22, AT90S2343, AT90S2323, AT90S1200, AT90S2313, AT90S4433, AT90S4414, AT90S8515, AT90S4434, AT90S8535, ATmega8, ATmega16, ATmega161, ATmega162, ATmega32, ATmega64, ATmega128, ATmega48, ATmega88, ATmega168, ATmega8515, ATmega8535.

Supported ST62 models: ST6200, 01, 03, 08, 09, 10, 15, 20, 25.

Size only 4 Mb ! Fully free. Very awersome IMHO.

Very good support .cof from CVAVR and from WinAVR (but not for this topic WinAVR sample project ... sad).

Test it - http://www.amctools.com/download...

Support two AVR in one shematic, user defined component.

New components for VMLAB -
http://sites.google.com/site/thv...

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

ALL hardware AVR realy suported by VMLAB.

Start from sample project in folders

C:\VMLAB\tutorial
C:\VMLAB\AVR_demo
C:\VMLAB\WinAVRdemo

And HELP reading for hardware components list.