NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Making your own make file

August 10, 2011
by nightfall
nightfall's Avatar

Okay I'm having some trouble making my own make file. I made a simple program that turns an LED on using one pin from my microcontroller. I open MFILE and then go to the drop down menu Makefile. I then go to MCU type and select the right one (atmega 168) then i go to port and select com3 (the port I'm using). I then change the programmer to avr109. I do this because i see avr109 in the makefiles from nerdkits- also i don't see any of the other options in the makefiles. I'm not sure if this is the right thing but i can't find much help from google. I then go to programmers note pad and do Make all and get:

"make.exe" avrdude -c avr109 -p m168 -b 115200 -P COM3 -U flash:w:initialload.hex:a avrdude: ser_open(): can't open device "COM3": Access is denied.

make.exe: *** [initialload-upload] Error 1

I'm going to try to look more on google, but any help would be great. I also tried to look through the forums but couldn't find much.

August 10, 2011
by nightfall
nightfall's Avatar

Don't know how to edit post but i figured out that the programmer should be dapa- i hope. I am now getting an error: avrdude: can't open device "giveio"

avrdude: failed to open parallel port "com3"

August 10, 2011
by Rick_S
Rick_S's Avatar

If you are programming a Nerdkit mcu with their USB/serial cable, you do not want dapa to be your programmer, you want avr109. dapa is a homebrew parallel port programmer. To use this, you have to have a true parallel port on your computer, and you either have to purchase or build the programmer. It also connects to the ISP connections on the mcu for programming. It's an altogether different method than used in the Nerdkit.

Are you in a linux, mac, or windows environment? I'm assuming windows based on the line you edited in the makefile. Why are you using Mfile to edit your makefile? You can edit it with programmers notepad.

Essentially, you can use an existing nerdkit makefile for your own program. All you have to do is change the program name everywhere it is referenced in the makefile.

The error you saw is avrdude telling you it cannot find COM3 on your PC. You need to verify the com port your usb/serial cable is on and change that accordingly. Instructions for this are in the Nerdkits guide Page 42.

Rick

August 10, 2011
by Ralphxyz
Ralphxyz's Avatar

The helpful fellows over at AVRfreaks jumped all over me for not using MFile!! They were merciless.

I never could get a Mfile Makefile to work so I always use a Nerdkit Makefile with program name change as Rick suggest.

I do use bretm's ProgramName trick.

Here is my Makefile for the initialload project:

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
#AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P /dev/ttyUSB0
AVRDUDEFLAGS=-c avr109 -p m168 -F -b 115200 -P /dev/cu.PL2303-0000101D
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

ProgramName = initialload
all:    $(ProgramName)-upload

$(ProgramName).hex: $(ProgramName).c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o $(ProgramName).o $(ProgramName).c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex $(ProgramName).o $(ProgramName).hex

$(ProgramName).ass: $(ProgramName).hex
    avr-objdump -S -d $(ProgramName).o > $(ProgramName).ass

$(ProgramName)-upload:  $(ProgramName).hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:$(ProgramName).hex:a

If I wanted to use it in the TempSensor Project all I would do would be to change:

ProgramName = initialload

to

ProgramName = tempsensor

I essentially use the same Makefile for all of my projects.

Ralph

August 11, 2011
by nightfall
nightfall's Avatar

Okay Ralph, i see what you are saying about using a template for a make file. I'm trying to make a new simple program that just turns an led on. However i would like to be able to make a make file from MFILE. I have the programmer set to avr109 and the MCU set to the right one. I have the port set to com4 which is were it is plugged in - I've checked. It is giving me :

"make.exe" program avrdude -p atmega168 -P COM4 -c avr109 -U flash:w:main.hex avrdude: ser_open(): can't open device "COM4": Access is denied.

make.exe: *** [program] Error 1

Process Exit Code: 2 Time Taken: 00:00

Programmer supports the following devices: Device code: 0xffffffa7 = (unknown) Device code: 0xffffffa7 = (unknown) Device code: 0xffffffa7 = (unknown) Device code: 0xffffffa7 = (unknown) Device code: 0xffffffa7 = (unknown)

I'm still trying to google it.

August 11, 2011
by Ralphxyz
Ralphxyz's Avatar

Well it is saying that COM4 is not your Nerdkit.

So open Device Manager and see what port you are actually using.

You are on Windows 7 correct?

Mfile is really a nice script somebody really put a lot of work in to it.

Like I said I could not get Mfile to make a workable Makefile so I just went back to using the Nerdkit Makefile.

I do not remember what the problem was with Mfile.

To get specific help on using Mfile you will have to go to some different forums like AVRfreaks.net but hold on to your hat and make sure you are not thin skinned because they will jump all over you if you do not seem to know what you are doing, or talking about, there is very little tolerance of new guys.

But if you persist and have a very thick skin they can be very helpful.

Ralph

August 14, 2011
by Ralphxyz
Ralphxyz's Avatar

Hey nightfall, did you get mFile working?

I would like to have the option of using it, so what did it take?

Ralph

Post a Reply

Please log in to post a reply.

Did you know that an analog comparator can tell when one voltage input crosses another? Learn more...