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 » Make file and Step 10c – Compile and Install your first program

August 09, 2010
by mikey
mikey's Avatar

How do i make a Make file for it how do i get it to work and say its working.

August 10, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Mikey,

For me to be able to help you with this question you need be much more specific about what exactly you are getting confused with, and what part is not working. Have you been able to get through the first part of the NerdKits guide? Were you able to put the initialload program on your chip successfully?

If you include screenshots of the command line, or copy paste the error you get it will help us know exactly where you are getting lost, so we can better explain the solution and help you learn.

Humberto

August 10, 2010
by mikey
mikey's Avatar

I just need to know to know what to do to make the make file to get it to program the chip

August 10, 2010
by Ralphxyz
Ralphxyz's Avatar

No you really need to answer Humberto's questions.

If you look in your downloaded folders in the CODE folder like the tempsensor folder you will see a make file.

If you search the Nerdkit forum for "make" you will see some great discussions and instructions about making a make file.

Take your time and go through the Nerdkit Guide and you will see how easy it can be.

It is very hard to answer generalized questions the more specific you can be the better we can answer them for you.

And welcome to the group.

Ralph

August 15, 2010
by ironcladmvtm
ironcladmvtm's Avatar

i was also wondering how to create make files and i can be more specific... i have built the led array and have been looking at the source code i downloaded from the tutorials page... but i am still a bit fuzzy on how i get that code compiled into a make file to get it over to my 168? if you could help me with this it may also answer some questions for mikey?

i am using the code exactly as it is downloaded and i can get other code with make files to the 168.

any help would be greatly appreciated! Thanks

August 16, 2010
by Ralphxyz
Ralphxyz's Avatar

ironcladmvtm, what do you mean "how i get that code compiled into a make file to get it over to my 168?"?

Your code is our code your make file is just a make file you do not compile one over to another.

To make a make file all you have to do is to take a make file from a project that you can get to work (I usually use the tempsensor make file) and just change tempsensor to your project's source code (C file) name.

Here is the makefile from the tempsensor project:

# tempsensor168
GCCFLAGS=-g -Os -Wall -mmcu=atmega168 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m168 -F -b 115200 -P /dev/cu.PL2303-0000101D
//AVRDUDEFLAGS=-c avr109 -p m168 -F -b 115200 -P /dev/cu.PL2303-0000205D

LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    tempsensor-upload

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

tempsensor.ass: tempsensor.hex
    avr-objdump -S -d tempsensor.o > tempsensor.ass

tempsensor-upload:  tempsensor.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:tempsensor.hex:a

And here tempsensor is changed to XYZ:

# XYZ168
GCCFLAGS=-g -Os -Wall -mmcu=atmega168 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m168 -F -b 115200 -P /dev/cu.PL2303-0000101D
//AVRDUDEFLAGS=-c avr109 -p m168 -F -b 115200 -P /dev/cu.PL2303-0000205D

LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    XYZ-upload

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

XYZ.ass:    XYZ.hex
    avr-objdump -S -d XYZ.o > XYZ.ass

XYZ-upload: XYZ.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:XYZ.hex:a

I have not done the LED array project but I don not think you really need to make a lot of changes to the make file besides setting you USB port.

Please let me know if I am missing something.

Ralph

August 16, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi ironcladmvtm,

Ralphs explanation is spot on. I also usually just copy a different Makefile and do a replace-all from tempsensor to the new project name. Remember that in order to create a completely new project you need to follow the same folder structure as the rest of our projects. You need to create a new folder for your project inside the Code folder. Then place your .c file and your new modified Makefile inside that folder. All this is so that the Makefile can find the libnerdkits folder correctly.

Humberto

August 16, 2010
by ironcladmvtm
ironcladmvtm's Avatar

Thanks, I took the one from the tempsensor as you said and made the changes seeing the flaw i had made in doing so. i now understand the makefile a good bit more... thanks for your explanation it helped. I also did some reading and got it all figured out. Thanks again.

November 03, 2012
by Steve35897
Steve35897's Avatar

I just today got my make file working for the initialload and it seems to be working

great. So I wanted to change it a little and make it into the original scrolling LCD.

When I change the file name I think I am doing it right, new folder with the c file and

the new make file with the new file name but I get alot of error messages.

change the "c" file name and change the make fle to reflect those changes but I get this

November 03, 2012
by Steve35897
Steve35897's Avatar

The last attempt I was trying to use a variable in the make file for the file name and I

apparently did not do it right. So I took that out and put in the "initialload_scrolling"

file name and I am getting different errors now. *** No rule to make target initialload_scrolling.c

initialload_scrolling make file

initialload_srolling upload attempt

November 03, 2012
by Noter
Noter's Avatar

There's more than you ever wanted to know about make in this document - http://www.gnu.org/software/make/manual/make.html. But if you're going to do anything beyond the basic makefile that comes with nerdkits you'll need to know it.

November 03, 2012
by sask55
sask55's Avatar

Steve35897

The error message you are seeing seems to be indicating that your make file cannot find a c code file with the name that you have specified it should find and use. Are you certain that you have a c code file "named initilload_scrolling.c" in the same folder as the make file that you have posted.

Inside your folder " C:NerdKits\Code\initialload_scrolling"

You need the two files

1- The c code file named iniitlload_scrolling.c that contains the code that you are compiling and writing to the micro. This must be a .c file.

2- The make file that has been modified (as in your post) to look for and use that c code file in the folder.

November 03, 2012
by Steve35897
Steve35897's Avatar

WOW- I guess I totally missed that I misspelled initial in the initialload part of the name in the make file. It WORKS now

November 03, 2012
by sask55
sask55's Avatar

Glad to hear that it is working.

Typo/Spelling errors are something I do a lot of. I find they can be difficult to track down at times. Often if I am thinking one thing and mistakenly put something else I will not notice the error even when I reread it. Somehow it seams I read what I expect to see not what is actually there.

Post a Reply

Please log in to post a reply.

Did you know that interrupts can be used to trigger pieces of code when events happen? Learn more...