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 » Makefiles

January 24, 2013
by Obscurity
Obscurity's Avatar

I keep trying to make a make file and I fail at it every time, I don't know what I am doing wrong and I don't understand the Nerdkit guide in that section. Also whenever I type "make" into cmd it says, "*** No targets specified and no makefile found. Stop."

January 24, 2013
by pcbolt
pcbolt's Avatar

Obscurity -

From the "cmd" window you have to navigate to the correct folder that has your project code and makefile. Let us know what operating system you are using and please post the contents of your makefile to this thread so we can see if any errors jump out. Also, if you're not familiar with the "cmd" window commands, just let us know we can talk you through it.

January 24, 2013
by Noter
Noter's Avatar

I've posted this a few times now and it is still the best reference I've found:

GNU make utility

January 25, 2013
by Obscurity
Obscurity's Avatar

I am using Windows 7, I am using the code that i downloaded from nerdkits, and I am not familiar with cmd commands.

January 25, 2013
by Noter
Noter's Avatar

Here's a good place to start to learn about the command window and commands -

Command Prompt

January 25, 2013
by pcbolt
pcbolt's Avatar

Obscurity -

You can get by with using just two commands at the cmd prompt. The first is "cd" (change directory) and the second is "dir" (list directory). When you first use "cmd", you get the familiar black window with prompt that looks something like..

C:\Users\User Name>

In general, you first want to get back to the root directory (C:\>), you can go up one level by typing "cd.." or go straight to the root by typing "cd\" which will get you to this prompt...

C:\>

Then you can start navigating to the folder where your project code and make file reside. You can do this one command at a time, or all at once. So if your code was located in a folder called "C:\nerdkits\my projects\initialload" you can type...

cd nerdkits
cd my projects
cd initialload

Or you can do it all at once...

cd nerdkits\my projects\initialload

In either case you should end up with this prompt...

C:\nerdkits\my projects\initialload>

You can now verify you have a makefile by typing "dir" at the prompt and it should list all folders and files inside your current folder. If you find your make file among the listing, just type "make" and the build process should start. It is a pain to do this every time so eventually you may want to look into batch files or scripts to automate the steps.

January 25, 2013
by Obscurity
Obscurity's Avatar

PCbolt,

Thank you for your help but it didn't do much. When I take the way you said it can't find the file I have the makefile in but when I go the way of going to my documents I see the makefile. I know that the makefile is there now but when I type in the command "make" I am shown this

"make: *** No rule to make target 'initialload.c', needed by 'initialload.hex'. Stop."

What am I doing wrong and what is a .hex file?

January 25, 2013
by Noter
Noter's Avatar

In case you don't want to wait for an answer here,

this is at the top of the list with the search term "What is a .hex file"

Wikipedia - Intel HEX

January 25, 2013
by pcbolt
pcbolt's Avatar

Actually you are making progress...you didn't get the message about a make file not found, you just have something wrong inside the file itself. "initialload.hex" is a machine-readable file that gets created from the human-readable "initialload.c" file. Your error message is saying that it does not know how to create "initialload.hex" because there is no method specified to create it. I suspect there is a method specified but the make file may be corrupted. Since the make file is a text file it should be fixable.

Here is what it should look like...

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 COM3
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    initialload-upload

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

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

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

This may look like your file but be careful because every little bit of formatting is critical. On lines 9,10,11,14,17, it looks like spaces in front of the text but this has to be a tab character. If you were to cut and paste this into your own text editor, you may find the tabs converted to spaces and not even realize it. Also, on lines 6,8,13,16 you can see a statement followed by a colon (:). These are called targets and are usually (but not always) files that need to be created. The lines following the target statements cannot be blank lines so make sure the format looks the same as your file. Also, on line 3, I used COM3 as the port name...your port may be different.

January 25, 2013
by Obscurity
Obscurity's Avatar

I checked my file and everything was the way the way you said it should be and I still get the same message. Any other ideas?

January 25, 2013
by Noter
Noter's Avatar

I think make is telling you it can't find initialload.c and is therefore trying to make it but there is no recipe for that. Either it's not in the right directory or it's name in the directory doesn't match exactly it's name in the make file.

January 25, 2013
by pcbolt
pcbolt's Avatar

To double check what Noter is suggesting, do 2 things before you type "make" at the command prompt. First type in "dir" to see if "initialload.c" is in the output listing. Then type "type makefile" at the command prompt to list the contents of the make file itself. Make sure everything is as expected.

January 25, 2013
by Obscurity
Obscurity's Avatar

I did not see initialload.c and when I typed in "type makefile" I showed me the file I downloade without the COM(#) change.

January 25, 2013
by pcbolt
pcbolt's Avatar

That's odd, looks like Noter was right. You may have to download the code zip file again and unpack it. The zip file you need is located in the "Members" link at the top of this page. Then click on the link for "Downloads" and click on the "Nerdkits Sample Source Code" link. It should prompt for a download so just save it to a location that's easy to navigate to and unzip it in one shot. Make sure you keep the directory structure the same as the way it gets unzipped. You should get a folder called "initialload" that contains two files "initialload.c" and "makefile". You should also get a folder called "libnerdkits" that has the same parent folder as "initialload". After that, you have to figure out what COM port windows is using, but first things first.

January 26, 2013
by Obscurity
Obscurity's Avatar

1: How do you unzip a file?

2: What is a parent folder?

January 26, 2013
by Noter
Noter's Avatar

Do you know how to use a web browser to search the internet? I just typed in your question and picked an answer from the thousands of results. Give it a try.

How do you unzip a file? How to Unzip a File or Folder in Windows 7

What is a parent folder? Folder (computing)

January 26, 2013
by Obscurity
Obscurity's Avatar

I found out how to unzip it. I navigated over to the file and typed in "make". It started running but stopped when it it the part of "/dev/ttyUSB0". This is where I know what I am doing wrong but don't know how not to do it. When ever I open the makefile it tells me I have to open it in another program, like Microsoft Word, when I do this I have to save it to a .txt file. I don't know how to keep from having to do this and/or just leave it in the normal makefile.

January 26, 2013
by Noter
Noter's Avatar

Use the notepad editor to make changes to your makefile.

How to Use Notepad

January 26, 2013
by Obscurity
Obscurity's Avatar

Thank you Noter. I clicked on the link but it only told me what I already knew about Notepad, but it still turns the file into a .txt file that the "make" command won't read.

January 26, 2013
by Noter
Noter's Avatar

Fired up the old windows box and realized notepad is not good for editing makefiles. Use wordpad instead and after you make your changes be sure to 'save' instead of 'saveas'.

That should get you going for now but you will be much happier with a better editor. I used programmers notepad when I was on windows and I liked it. Find it on the web and install it after you get your initial program going. It will take some time to learn to use it but it will be well worth the effort.

January 26, 2013
by Ralphxyz
Ralphxyz's Avatar

Obscurity, you can always "rename" Makefile.txt just right click and select Rename and remove .txt.

I would still be leery of using Notepad because of the EOL (end of line).

Why don't you download [Notepad++] it is a very nice editor even gives you sytax highlighting and best of all vertical editing!

Ralph

January 26, 2013
by Obscurity
Obscurity's Avatar

Thank you guys for all your help. I finally made it work thanks to you all. I will look at Naotepad++ and maybe download it, and I have Programers Notepad but thank you anyways for telling me about it Noter.

January 26, 2013
by JimFrederickson
JimFrederickson's Avatar

Why not just use the "Programmer's Notepad" that Nerdkits uses to edit he c Files?

I don't see a reason to add another variable to the equation...

Plus it will show the tabs, mostly, so you can see the difference between the tabs and spaces...

Also if you use the arrow keys and arrow across tabs it will jump rather than single space.

February 20, 2013
by dhjohnf
dhjohnf's Avatar

Hi, I am very new to this and have been experiencing very similar problems at the same place these gents have. I have downloaded and unzipped the code folder, moved the initialload folder to a new folder on my desktop, opened programmers notepad, dragged the makefile into pn, changed the com port. I don't understasnd about renaming in 14 places the name of the folder I moved them to. I tried make all in pn but it couldn't find file. I went through command prompt to correct dir and discovered the makefile had gone from 635 bytes to 0. I don't know how to get the makefile I edited and saved back to the desktop folder, either. Just awfully confused.

February 20, 2013
by Ralphxyz
Ralphxyz's Avatar

dhjohnf, first what OS are you using?

You cannot move your initialload folder to your desktop!!

initialload has to be a child of Code.

Using Windows I will unzip the down load to a C:\Nerdkits folder

I will end up with C:\Nerdkits\Code\initialload

You can use the initialload makefile all you have to change is the com port.

AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P /dev/ttyUSB0

Will be come something like:

AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P com4

again if you are using Windows.

You do not have to make a lot of changes to get initialload to run it was designed by the Nerdkits guys to just work with out modification, except for the makefile com port.

Sometimes it is best to not think to much :-)

Ralph

February 21, 2013
by dhjohnf
dhjohnf's Avatar

Hi Ralph, Thanks for the reply. I am running win7. I tried what you suggested, first deleted all copies of the download, then downloaded to downloads, unzipped initialload to C:nerdkits, opened the folder to initialload.c and Makefile, opened Makefile in programmers notepad, made change to proper COM port, saved file (not saveas), went to tools and tried make all and got >Failed to create process: System cannot find file specified. I don't have to have the project running to accomplish all of this, do I? This is all preliminary to uploading this initialload program folder to the mcu. Another question I have is do replacement 168's have the original message programmed into them? I think I fried my 1st one, got a second and now just have 4 lines of black squares on lcd. I also had to change my contrast resistor to 200 ohms. If I go through the cmd prompt do I have to go as administrator? It seems while navigating out of system32 to my user dir I might lose admin in the process. I actually had board plugged in and functioning but am a little worried about burn-in as it is taking HOURS to figure this out. I did change the properties of COM3 to 115200 from 9600. I tried to move the whole initialload folder to prognot but was told I did not have permission. I am not even sure I should change the left column of prognot to a different language. Feels like I am blundering around in the dark. thanks, dhj

February 21, 2013
by Ralphxyz
Ralphxyz's Avatar

Feels like I am blundering around in the dark.

That might be a understatement :-)

Alright first thing stop thinking, please.

Well if you have to think then try thinking along these lines.

The Nerdkit guys provide sample code/projects.

These projects work. <-- PEROID

Therefore the less you "do" the more likely you will successfully run the projects.

The more you do, the more likely "you" are going to mess things up.


Now you have a whole lot of issues that I am trying to figure out how to simplify.

My head is spinning just trying to see where to start.

Your prior statements like:

I don't understasnd about renaming in 14 places the name of the folder I moved them to.

Scares me.

Lets take this one line at a time:

first deleted all copies of the download, then downloaded to downloads, unzipped initialload to C:nerdkits,

Need I say more?

Ralph

February 21, 2013
by dhjohnf
dhjohnf's Avatar

Ok, [URL=http://www.hostpic.org/view.php?filename=1302212058450102.jpg][img]http://www.hostpic.org/images/1302212058450102.jpg[/img][/URL] [URL=http://www.hostpic.org/view.php?filename=1302212100090093.jpg][img]http://www.hostpic.org/images/1302212100090093.jpg[/img][/URL] [URL=http://www.hostpic.org/view.php?filename=1302212100430087.jpg][img]http://www.hostpic.org/images/1302212100430087.jpg[/img][/URL] [URL=http://www.hostpic.org/view.php?filename=1302212101210106.jpg][img]http://www.hostpic.org/images/1302212101210106.jpg[/img][/URL] [URL=http://www.hostpic.org/view.php?filename=1302212102040093.jpg][img]http://www.hostpic.org/images/1302212102040093.jpg[/img][/URL]

These are screen shots of what I have accomplished and where I am in cmd prompt.
February 21, 2013
by dhjohnf
dhjohnf's Avatar

Hi, trying again ![alt text]http://www.hostpic.org/images/1302212117400091.jpg ![alt text]http://www.hostpic.org/images/1302212119480090.jpg ![alt text]http://www.hostpic.org/images/1302212120500119.jpg ![alt text]http://www.hostpic.org/images/1302212121310102.jpg ![alt text]http://www.hostpic.org/images/1302212122140101.jpg There, that should do it.

February 21, 2013
by Ralphxyz
Ralphxyz's Avatar

Stop thinking and trying things you are just wasting your time!!

You have have NOT responded to your FIRST error so any subsequent errors are meaningless!!

Oh by the way you embed images by following the instructions at the bottom of this page.

Your AVR-GCC Toolchain is not installed correctly!

Re install "WinAVR for Windows",you might download again.

Ralph

February 21, 2013
by dhjohnf
dhjohnf's Avatar

http://www.hostpic.org/view.php?filename=1302212122140101.jpg

February 21, 2013
by dhjohnf
dhjohnf's Avatar

Hi, If by my first error you mean the reference to deleting all known copies of Code in my system, I was responding to your statement that I can't save it to a folder on my desktop. So I wanted to remove the folder from all locations that were not C:nerdkitsinitialload so it wasn't found where it wasn't supposed to be. As for photos I tried to follow instructions to embed the direct link. The backslashes don't seem to be translating to preview.

February 21, 2013
by dhjohnf
dhjohnf's Avatar

trying imgur ![trying imgur]http://www.hostpic.org/view.php?filename=1302212122140101.jpg

February 21, 2013
by Noter
Noter's Avatar

Getting an image to display in a post is a lot easier than getting anything to work on the AVR. Try reading the directions again and study the examples.

February 21, 2013
by dhjohnf
dhjohnf's Avatar

Hello, If you were referring to the comment about finding 14 places to change file names that was refering to Microcontroller Programming forum page 11 "Locating makefile" entry. Still can't seem to embed image correctly.

thanks

February 21, 2013
by Noter
Noter's Avatar

No, I was referring to embedding an image. Stick with it until you get it figured out. Go read the directions again and look at the examples.

February 21, 2013
by Ralphxyz
Ralphxyz's Avatar

<Hi, If by my first error you mean the reference to deleting all known copies of Code in my system

NO!!

Your first error is that you do not have a working MAKE.

Without that it doesn't matter what you do.

Ralph

February 21, 2013
by dhjohnf
dhjohnf's Avatar

hi, Reloading win-avr seems to have done the trick. Now it seems I may have a wiring problem. I noticed that the buffered memory problem may be related to low battery. I have a 7.2 volt power supply hooked up to my board which is delivering a steady 4.931 volts through the regulator. I hadn't appreciated the importance of the parenthesis in the photo.

February 21, 2013
by Ralphxyz
Ralphxyz's Avatar

I hadn't appreciated the importance of the parenthesis in the photo.

Yup, all of the little details will get excruciating at times.

Search the forum for Butterfly that is a very common error.

Do yourself a favor, go get a fresh battery or use a wall wart, it not worth the bother to chinse out.

Ralph

February 22, 2013
by dhjohnf
dhjohnf's Avatar

Hi, I seem to be making progress, albeit 2 steps forward, one back. I found a good 12v regulated supply down in the cellar and rigged it up this morning. In reading through the micro-controller programming forum I noticed a means of testing the usb communications. It stated that if you de-powered the mcu, plugged yellow and green wires from usb into the same unused row and loaded a program called PUttY you could test the cable. Mine worked fine. Then it suggested testing the bootloader with the same program. De-power mcu, plug usb back into 2 and 3, set up PUttY and re-power mcu with the result being a ba on putty screen. Mine came back with a bp. Just wondering if that might be related to this or am I still having problems with the makefile?

February 22, 2013
by dhjohnf
dhjohnf's Avatar

Hi, I seem to be making progress, albeit 2 steps forward, one back. I found a good 12v regulated supply down in the cellar and rigged it up this morning. In reading through the micro-controller programming forum I noticed a means of testing the usb communications. It stated that if you de-powered the mcu, plugged yellow and green wires from usb into the same unused row and loaded a program called PUttY you could test the cable. Mine worked fine. Then it suggested testing the bootloader with the same program. De-power mcu, plug usb back into 2 and 3, set up PUttY and re-power mcu with the result being a ba on putty screen. Mine came back with a bp. Just wondering if that might be related to this or am I still having problems with the makefile?

March 19, 2013
by wmaz
wmaz's Avatar

Thank you for posting what the makefile should look like. My mistake was not using caps when I changed it to read COM2. Then I wasn't sure what position the switch should be in for program mode. My last glitch was I had to pull the program cable from the USB port and plug it back in. I can't believe I'm using DOS commands again! That was a blast from the past.

Post a Reply

Please log in to post a reply.

Did you know that microcontrollers have two different kinds of memory, program space (flash) and SRAM? Learn more...