need a bit of help converting a make file.

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

Hi, I'm trying to use a make file created for avrdude (linux) and make it run on avr studio. It complies ok and reports..

Build started 12.8.2008 at 23:07:33
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -o main.bin usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o snes.o snesmouse.o nes.o db9.o devdesc.o -Wl,-Map=main.map
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
./checksize main.bin
ROM: 5128 bytes (data=116)
RAM: 215 bytes
Build succeeded with 0 Warnings...

But the start debug is gray'd out. I'm lead to believe it is do to the make file.. It seems the device is configured right as far as I can tell..?

Can anyone tell me what may have to change, I first thought the linux commands would need to come out but apparently the avr-gcc understands them.


UISP = uisp -dprog=stk500 -dpart=atmega8 -dserial=/dev/ttyS1
COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L #-DDEBUG_LEVEL=1
COMMON_OBJS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
HEXFILE=main.hex

OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o snes.o snesmouse.o nes.o db9.o devdesc.o


# symbolic targets:
all:	$(HEXFILE)

.c.o:
	$(COMPILE) -c $< -o $@

.S.o:
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.

.c.s:
	$(COMPILE) -S $< -o $@


clean:
	rm -f $(HEXFILE) main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s

# file targets:
main.bin:	$(COMMON_OBJS)	snes.o nes.o snesmouse.o db9.o devdesc.o 
	$(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map=main.map

$(HEXFILE):	main.bin
	rm -f $(HEXFILE) main.eep.hex
	avr-objcopy -j .text -j .data -O ihex main.bin $(HEXFILE)
	./checksize main.bin

flash:	all
	$(UISP) --erase --upload --verify if=$(HEXFILE)

flash_usb:
	sudo avrdude -p m8 -P usb -c avrispmkII -Uflash:w:$(HEXFILE) -B 1.0

# Fuse high byte:
# 0xc9 = 1 1 0 0   1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
#        ^ ^ ^ ^   ^ ^ ^------ BOOTSZ0
#        | | | |   | +-------- BOOTSZ1
#        | | | |   + --------- EESAVE (don't preserve EEPROM over chip erase)
#        | | | +-------------- CKOPT (full output swing)
#        | | +---------------- SPIEN (allow serial programming)
#        | +------------------ WDTON (WDT not always on)
#        +-------------------- RSTDISBL (reset pin is enabled)
# Fuse low byte:
# 0x9f = 1 0 0 1   1 1 1 1
#        ^ ^ \ /   \--+--/
#        | |  |       +------- CKSEL 3..0 (external >8M crystal)
#        | |  +--------------- SUT 1..0 (crystal osc, BOD enabled)
#        | +------------------ BODEN (BrownOut Detector enabled)
#        +-------------------- BODLEVEL (2.7V)
fuse:
	$(UISP) --wr_fuse_h=0xc9 --wr_fuse_l=0x9f

fuse_usb:
	sudo avrdude -p m8 -P usb -c avrispmkII -Uhfuse:w:0xc9:m -Ulfuse:w:0x9f:m -B 10.0


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

Near the top, change

COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L

to

COMPILE = avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L

"-g" is the compiler flag to generate information for the debugger.

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

Cool, that was the line I suspected. Thx so much i'll try it out soon.

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

I do get the out put with "-g" in there now but no debugger, could I be missing something else?

Build started 13.8.2008 at 19:25:40
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -x assembler-with-cpp -c usbdrv/usbdrvasm.s -o usbdrv/usbdrvasm.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c usbdrv/oddebug.c -o usbdrv/oddebug.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c main.c -o main.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c snes.c -o snes.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c nes.c -o nes.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c snesmouse.c -o snesmouse.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c db9.c -o db9.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -c devdesc.c -o devdesc.o
avr-gcc -g -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=12000000L  -o main.bin usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o snes.o snesmouse.o nes.o db9.o devdesc.o -Wl,-Map=main.map
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
./checksize main.bin
ROM: 5128 bytes (data=116)
RAM: 215 bytes
Build succeeded with 0 Warnings...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wouldn't the easy answer here simply be to create a new GCC project "main" within Studio and add the source files that lead to:

OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o snes.o snesmouse.o nes.o db9.o devdesc.o

Within the project config setting "mega8" and "frequency: 12000000" and also going to the include directory options and adding "usbdrv"

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

clawson, so your suggesting omitting the make file and using the project settings. I start out that way but got a lot of warnings/errors and figure I was just missing something that the make file was telling the project. I'll try the above. thx

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

Your other option is to adapt the makefile to the rules documented for external makefiles (this is documented in the AVRStudio help for the avr-gcc plugin):

Quote:
The name of the elf file to debug must be projectname.elf

To enable clean or rebuild, the clean target must be defined in the makefile.

The makefile must reside in the same directory as the output elf file.


/Lars

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

Lars, This spawns a bit of interest... I would guess based on that, the missing elf file and/or missing elf directive is the problem.

I found a template.

#####         Target Specific Details          #####
#####     Customize these for your project     #####

# Name of target controller 
# (e.g. 'at90s8515', see the available avr-gcc mmcu 
# options for possible values)
MCU=at90s8515

# Name of our project
# (use a single word, e.g. 'myproject')
PROJECTNAME=myproject

# Source files
# List C/C++/Assembly source files:
# (list all files to compile, e.g. 'a.c b.cpp as.S'):
# Use .cc, .cpp or .C suffix for C++ files, use .S 
# (NOT .s !!!) for assembly source code files.
PRJSRC=main.c myclass.cpp lowlevel.S

- But what bothers me is that none of these are set? So I would guess my make file is completely worthless. Plus I would not think windows would know who to sudo anything, nor what tty?? means since its all linux based. I may just have to use the GUI for a make file, since converting this is a bigger task that i thought.

--- actually i just found mfile ---

but I dont know the

c standard level
printf or scanf options

the rest I think i have figured out.

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

S_K_U_N_X wrote:
but I don't know the

c standard level

If you don't know, let MFile choose the default for you. I go with gnu99 == ISO C 99 Standard (not fully implemented) plus GCC extensions. If you are running ANSI code you might want to choose gnu89 (ANSI "C" with GCC extensions).
S_K_U_N_X wrote:
printf or scanf options
For more on printf/scanf options and why they are important, check out the vsprintf section of Avr-libC Standard IO Facilities

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, thx so much!! I may have this yet...

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

Can someone help me understand what "oops, asrc not found" error is? I get it when putting in the asm source files in mFile. Not much in the order of information out there on this.

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

Can you quote the EXACT message you are receiving. Remember that Makefiles are case sensitive so if you used:

ASRC = aFile.S

and the file was called afile.S on disk then it would not be found. Also don't forget that the asm files MUST be .S and not .s !

Cliff

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

Well that may answer my question. I dont have any s files.

I have source files in c and object files o but no asm files of any kind. So perhaps I dont need to fill in that box? Keep in mind I'm using mFile. I dont see where to specify the objects.

When I try to compile from this make file I get

Quote:
make: *** No rule to make target `main.elf', needed by `elf'. Stop.
-
My make file has "TARGET = main" my file is main.c and has an int main(void) function.

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

ASRC is only for listing asm source files - leave it blank if you don't have any.

Are you building inside Studio or at the command line? If in studio, when you see the error switch to the "Build" tab to see the actual error.

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

Thank you.
This is in fact in avr-studio and that is where I see the message

Build started 15.8.2008 at 20:44:48

-------- begin --------
avr-gcc (WinAVR 20080610) 4.3.0
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

make: *** No rule to make target `main.elf', needed by `elf'.  Stop.
Build failed with 1 errors and 0 warnings...

Ok the usbdrv files are in there own directory and have .S files. If I try adding them it still complains.
usbdrv/usbdrvasm.S
usbdrv/usbdrvasm165.S
usbdrv/usbdrvasm16.S
usbdrv/usbdrvasm15.S
usbdrv/usbdrvasm12.S
?

I'm not sure if these are need at run time or build? I'm guessing its ok to still leave this blank. Could my error be related to the fact it can find these files?

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

Ok this was in fact a dependency issue. Contrary to what I read I had to add the .c ? and add a "." to my object line.

I also had to add the usbdrv ams S file, that I didnt know about before..

all working well thx for your help.