target pattern contains no `%'. Makefile problem

I am trying to program the serial Arduino board using AVR studio 4 with the Makefile and trying to load the Blink LED program using a parallel port programmer. My previous attempts using the Arduino software failed and even after I loaded the bootloader directly using Ponyprog, I could get the board to work. The board should be OK as I uploaded some other software for a blinking LED and it worked.

When I try to build the .hex file from the blink.c and makefile I get the error:

makefile:178: *** target pattern contains no `%'. Stop.

This refers to the following code (lines 177-179)

Link: create ELF output file from object files.

$(TARGET).elf: $(OBJ) $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)

What is wrong and how can I change the code on 178 to build the .hex file?

Some Googling suggests that this errors happens when your target file name contains a colon ":". It sounds like AVR Studio is using an absolute paths, including drive letters. If you can get it to try the compilation using relative paths instead, it might work. Alternatively, you could try running make from the command line.

Alternatively, you could try running make from the command line.

How can I do that - I am new to programming :-/

The following is taken from another makefile (for a different project) which works with AVR studio :

Link: create ELF output file from object files.

.SECONDARY : $(TARGET).elf .PRECIOUS : $(OBJ) %.elf: $(OBJ) @echo @echo $(MSG_LINKING) $@ $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)

However substituting the first 4 lines with the first two lines of the Arduino makefile simply returns the same error!!

If the Makefile is in the same directory as your code, you should be able to just open a command prompt, cd to the right directory, and type “make” and press enter.

Do you have AVR studio on a different drive than your source code or the Arduino core?

Also, you might want to write another post describing your problems getting the Arduino environment working. If we can figure out what’s wrong, that might be an easier option than using AVR studio.

If the Makefile is in the same directory as your code, you should be able to just open a command prompt, cd to the right directory, and type "make" and press enter.

Yes the Makefile is in the same directory. I am trying some different option (exporting makefile) and try to post my progress.

Do you have AVR studio on a different drive than your source code or the Arduino core?

No AVR studio is on the same drive

Also, you might want to write another post describing your problems getting the Arduino environment working. If we can figure out what's wrong, that might be an easier option than using AVR studio.

I cannot understand what is really wrong, but I will try to find out any logical explanation and create a new post.

If the Makefile is in the same directory as your code, you should be able to just open a command prompt, cd to the right directory, and type "make" and press enter.

I did this but i got the same error in the command window, presumably I have something wrong in the file paths.

Hmm... can you post the Makefile? Or at least any of the lines you needed to edit to configure it?

I am still getting the same error when i type "make" at the cmd line. when I chang the path in the makefile in the Arduino line from c:foldername/ to /foldername/

I get a different error

make: *** No rule to make target blinky.o', needed byblinky.elf'. Stop.

Any ideas?

Try using a relative path like ../../../folder-name/.

Hmm... can you post the Makefile? Or at least any of the lines you needed to edit to configure it?

PORT = COM2 TARGET = blinky ARDUINO = c:/ROBOTS/arduino-0008/lib/targets/arduino SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c $(ARDUINO)/WInterrupts.c CXXSRC = $(TARGET).cpp $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp MCU = atmega8 F_CPU = 16000000

The highlighted lines are the ones I changed.

Yea, the problem is probably this line:

ARDUINO = c:/ROBOTS/arduino-0008/lib/targets/arduino

Try the relative path and see if that helps.

I changed the line to

ROBOTS/arduino-0008/lib/targets/arduino

but got a new error

make: *** No rule to make target ROBOTS/arduino-0008/lib/targets/arduino/pins_a rduino.o', needed byblinky.elf'. Stop.

presumably I need to look for the files in different folders. I will do that but I have to leave for the moment. Thanks

Try include the appropriate number of ../ 's. E.g. if your code and Makefile are in c:\source\blinky, you'd want:

../../ROBOTS/arduino-0008/lib/targets/arduino

Try include the appropriate number of …/ 's. E.g. if your code and Makefile are in c:\source\blinky, you’d want:

…/…/ROBOTS/arduino-0008/lib/targets/arduino

It didn’t work. I repeated the process on another win XP based computer and again I got the same errors.

Now I started again from the very beginning:

  1. Unzipped arduino-0008 to C: drive
  2. created new file “test”
  3. copied blink.cpp from c:\arduino-0008\examples\Digital\Blink\applet to c:\test\
  4. copied makefile from c:\arduino-0008\lib\targets\arduino to c:\test\
  5. modified makefile highlighted lines and saved

PORT = LPT1
TARGET = blink
ARDUINO = …/arduino-0008/lib/targets/arduino
SRC = (ARDUINO)/pins_arduino.c (ARDUINO)/wiring.c
(ARDUINO)/wiring_analog.c (ARDUINO)/wiring_digital.c
(ARDUINO)/wiring_pulse.c (ARDUINO)/wiring_serial.c
(ARDUINO)/wiring_shift.c (ARDUINO)/WInterrupts.c
CXXSRC = (ARDUINO)/HardwareSerial.cpp (ARDUINO)/WRandom.cpp
MCU = atmega8

  1. run cmd.exe changed directory to c:\test\
  2. run “make”
  3. got several warnings but no errors ! If I put the files inside a folder in another folder and entering the appropriate number of …/…/foldername I still got errors.

But at last I have the .hex file - Thanks :slight_smile:

So it works with one …/ in the path, but not with two (…/…/)? What errors do you get in the latter case? What warnings do you get in the former?

So it works with one …/ in the path, but not with two (…/…/)? What errors do you get in the latter case? What warnings do you get in the former?

Oops :o seems I get the same warnings in both but now no errors. I suspect I must have modified the file so many times that I must have messed up one of them.

The warnings are :

cc1plus.exe: warning: command line option “-Wstrict-prototypes” is valid for C/O
bjC but not for C++
cc1plus.exe: warning: command line option “-std=gnu99” is valid for C/ObjC but n
ot for C++
In file included from …/arduino-0008/lib/targets/arduino/WProgram.h:5,
from text.cpp:1:
c:/winavr/bin/…/avr/include/avr/signal.h:36:2: warning: #warning “This header f
ile is obsolete. Use <avr/interrupt.h>.”
In file included from …/arduino-0008/lib/targets/arduino/WProgram.h:7,
from text.cpp:1:
…/arduino-0008/lib/targets/arduino/wiring.h:60:1: warning: “abs” redefined
In file included from …/arduino-0008/lib/targets/arduino/WProgram.h:1,
from text.cpp:1:
c:/winavr/bin/…/avr/include/stdlib.h:116:1: warning: this is the location of th
e previous definition
avr-objcopy -O ihex -R .eeprom text.elf text.hex

Now the problem is the program doesn’t upload. I changed the port to COM2 and 9600 and tried “make upload” but I keep getting this error:

avrdude -F -p atmega8 -P COM2 -c stk500 -b 9600 -U flash:w:text.hex
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: ser_open(): can’t open device “COM2”: Access is denied.

make: *** [upload] Error 1

Cool... we're making progress. :)

The warnings shouldn't be a problem. I should clean-up the Makefile so they don't occur, but they shouldn't break anything.

Have you burned the bootloader onto the chip? Are you trying to upload the hex file over a serial cable? Are you running as an administrator? Are you logged on to the machine locally (or with network/domain credentials)? Also, is there anything else that could be using or blocking the port? Firewalls? PDA sync applications?

Also, you'll probably need to use a baud rate of 19200, not 9600, but neither will work until we fix the "Access is denied" error.

Have you burned the bootloader onto the chip?

No - I’m using the makefile as I cannot get the bootloader to work. I programmed the chip directly by using a parallel programmer using PonyProg. However during reset the LED (pin 13) doesn’t blink or light at all .
The board works with some files I used from other sites using the parallel programmer with a 6 to 10 pin homebrew ICSP adapter, so I know both the board and AVR are OK, but I’d like to get Arduino up and running.

Are you trying to upload the hex file over a serial cable?

Yes using “make upload” both on the Arduino serial board and on a prototype using the MAX232 chip; but I get the same errors in both. Unfortunately I remember getting problems occasionally with the serial port and a restart on the PC usually solved the problem but not in this case.

Are you running as an administrator? Are you logged on to the machine locally (or with network/domain credentials)? Also, is there anything else that could be using or blocking the port? Firewalls? PDA sync applications?

Yes. Locally. Not that I know of, no firewalls or PDA synch apps.

What I found frustrating was that I can load the .hex file directly into flash using Ponyprog with parallel but the LED (pin 13) doesn’t blink. I’m sure I’m doing something wrong but I cannot find out what. :’(

I'm confused.

Using PonyProg and a parallel programmer, you can burn .hex files you've downloaded from the internet onto the board and they run successfully? What happens when you do the same thing with a .hex file you generated from Arduino code with the Makefile? You can get it onto the chip with PonyProg and the parallel programmer, but it doesn't run? In that case, it's not likely to help if you use PonyProg and a parallel programmer to get the bootloader onto the board and then upload a program with avrdude and a serial cable - if the LED blink program doesn't run, I doubt the bootloader will.

What happens when you use PonyProg and a parallel programmer to put the .hex file onto the board? What's the source code of the program you're trying to run?

I'm confused. Using PonyProg and a parallel programmer, you can burn .hex files you've downloaded from the internet onto the board and they run successfully?

Yes, I use this program as a test program, actually 2 programs which blink or turn on an LED. I make a hex file from the .c using a simple makefile and AVR studio. Then I upload the .hex with ponyprog using LPT1 Avr ISP i/o setting.

What happens when you do the same thing with a .hex file you generated from Arduino code with the Makefile? You can get it onto the chip with PonyProg and the parallel programmer, but it doesn't run? In that case, it's not likely to help if you use PonyProg and a parallel programmer to get the bootloader onto the board and then upload a program with avrdude and a serial cable - if the LED blink program doesn't run, I doubt the bootloader will.

Yes that is the problem now. I'd like to get the bootloader working so I can simply program from the serial - I need the Arduino to control a number of servos and the code can simply be changed from serial.

What happens when you use PonyProg and a parallel programmer to put the .hex file onto the board? What's the source code of the program you're trying to run?

The .hex files files are programmed using the "write all" command. These are uploaded in about 5s and then verified and almost always (to date) I get a write successful message - even if the program doesn't work! The program was a modification from a file downloaded from societyofrobots.com and was the source code for the $50 robot. I am excluding some intro lines, the code for the servos and some comments at the end to shorten the code:

//SoR Include

include "SoR_Utils.h" //includes all the technical stuff

int main(void) { //declare variables here //int i=250;//a 'whatever' variable int sensor_left=0;//left photoresistor int sensor_right=0;//right photoresistor int threshold=8;//the larger this number, the more likely your robot will drive straight

/*************INITIALIZATIONS****************/ //other stuff Im experimenting with for SoR //uartInit(); // initialize the UART (serial port) //uartSetBaudRate(9600);// set the baud rate of the UART for our debug/reporting output //rprintfInit(uartSendByte);// initialize rprintf system

//timerInit(); // initialize the timer system

configure_ports(); // configure which ports are analog, digital, etc. a2dInit(); // initialize analog to digital converter (ADC) a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

//rprintf("Initialization Complete\r\n"); /**************************************************/

/******ADD YOUR CODE BELOW THIS LINE *******/ LED_on();//turn LED on

while(1) ------------several lines for servo control------

LED_off(); delay_cycles(1000); } /******ADD YOUR CODE ABOVE THIS LINE *******/

return 0; }