Help With Basic Directional Coding Error

by Mastermime on Thu Nov 15, 2012 9:56 pm

Hello everyone,

First I want to premise that I am a complete newbie at coding and this is the first time I've coded a project not in the Arduino IDE.

I am trying to write some simple directional code that I can test my tread configuration. Here is my flow "data of transfer". PS2 controller > Arduino > Xbee Pro > Xbee Pro > Axon > Electronics

When trying to compile my solution in AVR Studio 4 I get this error

make: *** No rule to make target `../Robot', needed by `ERA3.elf'. Stop.


As you can see the name of my project is ERA3. I know it has something to do with the makefile, but I don't know what. Below is the code in the makefile. I'd appreciate any help given. thanks
Code: Select all | TOGGLE FULL SIZE
# The name of the project
PRG            = ERA3
# Files owned by the user
OBJUSER        = ERA3.o
# Files owned by the user to create pre-compiled headers
PCHUSER        = pch/ERA3.c
# Generated files that are required
OBJREQD        =
# Generated files that are optional
OBJOPT         =

# The processor target
MCU_TARGET     = atmega640

# The processor speed
MCU_SPEED      = 16000000

# The library where WebbotLib is installed
WEBBOT         = ../Robot programming/ERA/ERA/lib

# The library to link against
WEBBOT_LIB = $(WEBBOT)/libWebbot-ATmega640.a


OPTIMIZE       = -O0
   

DEFS           = -gdwarf-2 -fpack-struct -fshort-enums  -funsigned-char -funsigned-bitfields -I"$(WEBBOT)"
DEFS         +=  -MD -MP -MT $(*F).o -MF dep/$(@F).d


LIBS           = -L"$(WEBBOT)" -lWebbot-ATmega640  -lm -lc
   


# Define the tools to be used
CC             = avr-gcc
CPP            = avr-g++
OBJCOPY        = avr-objcopy
OBJDUMP        = avr-objdump
SIZE         = avr-size
ARCHIVE         = avr-ar

# Override is only needed by avr-lib build system.
# -Wall enable most warning errors
override CFLAGS        = -g -Wall  -DF_CPU=${MCU_SPEED} -mmcu=$(MCU_TARGET) $(DEFS)  -std=gnu99
override CPPFLAGS      = -g -Wall  -DF_CPU=${MCU_SPEED} -mmcu=$(MCU_TARGET) $(DEFS) -fno-threadsafe-statics


# Use the minimal version of vfprintf
override LDFLAGS       = -Wl,-Map,$(PRG).map,-u,vfprintf -lprintf_min
   

# Default build target
all: $(PRG).elf lst text eeprom size

# Create pre-compiled headers for all the user files
pch: $(WEBBOT_LIB) $(PCHUSER)

pch/%.cpp: %.cpp
   $(CPP) -E $(CPPFLAGS) $(OPTIMIZE) -c -o $@ $<

pch/%.c: %.c
   $(CC) -E $(CFLAGS) $(OPTIMIZE) -c -o $@ $<

# How to create the elf file
$(PRG).elf:  $(WEBBOT_LIB) $(OBJUSER) $(OBJREQD)
   $(CC) -mmcu=$(MCU_TARGET) $(LDFLAGS) -o $@ $(OBJUSER) $(OBJREQD) $(LIBS)



# dependencies for compiling C files to O files

   
ERA3.o: ERA3.c
      $(CC) $(CFLAGS) $(OPTIMIZE) -c -o $@ ERA3.c

# dependencies for compiling CPP files to O files


size: $(PRG).elf
   $(SIZE) --format=avr --mcu=${MCU_TARGET} $(PRG).elf   

# Clean the compiled stuff but leave any codegen'd files in place
clean:
   rm -rf *.o dep/* pch/* lib/*.o lib/*.a $(PRG).elf example.txt 
   rm -r dep
   rm -r pch
   rm -rf $(PRG).lst $(PRG).map $(EXTRA_CLEAN_FILES)

# Clean out everything - including any codegen'd files
cleanall:
   rm -rf *.o dep/* pch/* $(PRG).elf example.txt hardware.h 
   rm -r lib
   rm -rf $(PRG).lst $(PRG).map $(EXTRA_CLEAN_FILES)

lst:  $(PRG).lst

%.lst: %.elf
   $(OBJDUMP) -h -S $< > $@

# Rules for building the .text rom images
text: hex bin srec

hex:  $(PRG).hex
bin:  $(PRG).bin
srec: $(PRG).srec

%.hex: %.elf
   $(OBJCOPY) -j .text -j .data -O ihex $< $@

%.srec: %.elf
   $(OBJCOPY) -j .text -j .data -O srec $< $@

%.bin: %.elf
   $(OBJCOPY) -j .text -j .data -O binary $< $@

# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec

ehex:  $(PRG)_eeprom.hex
ebin:  $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec

%_eeprom.hex: %.elf
   $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \
   || { echo empty $@ not generated; exit 0; }

%_eeprom.srec: %.elf
   $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \
   || { echo empty $@ not generated; exit 0; }

%_eeprom.bin: %.elf
   $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \
   || { echo empty $@ not generated; exit 0; }

EXTRA_CLEAN_FILES       = $(PRG).hex $(PRG)_eeprom.hex *.bin *.srec

## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
-include $(shell mkdir pch 2>/dev/null)

   
Mastermime
 
Posts: 49
Joined: Mon Oct 22, 2012 6:46 pm

Re: Help With Basic Directional Coding Error

by mwilson on Fri Nov 16, 2012 11:14 am

It's that WEBBOT and WEBBOT_LIB. If you follow the chain of those symbols when you edit your Makefile, you finally find the lines
Code: Select all | TOGGLE FULL SIZE
    # How to create the elf file
    $(PRG).elf:  $(WEBBOT_LIB) $(OBJUSER) $(OBJREQD)
       $(CC) -mmcu=$(MCU_TARGET) $(LDFLAGS) -o $@ $(OBJUSER) $(OBJREQD) $(LIBS)


and make can't go any further.
mwilson
 
Posts: 46
Joined: Sun Oct 23, 2011 10:17 am
Location: Maynooth, Canada

Re: Help With Basic Directional Coding Error

by Mastermime on Sat Nov 17, 2012 12:12 pm

So how do I solve this?
Mastermime
 
Posts: 49
Joined: Mon Oct 22, 2012 6:46 pm

Re: Help With Basic Directional Coding Error

by adafruit_support_mike on Sat Nov 17, 2012 9:56 pm

This chunk:

Code: Select all | TOGGLE FULL SIZE
# The library where WebbotLib is installed
WEBBOT         = ../Robot programming/ERA/ERA/lib

is looking for a directory that A) doesn't exist, or B) is badly named. My guess is B.

Command line tools like 'make' (the part that's reading the instructions, calling the compiler to build all sorts of files, then combining them into a finished product) get confused when they run into filenames that contain spaces. In command-line world, spaces are the separators that tell a program how to read the control options.. `ls -l Robots` has three space-delimited chunks: the command name ('ls'), the option ('-l') and the target ('Robots').

If the command line sees `ls -l Robot programming`, it will assume you mean `ls -l [a directory named "Robot"] ; ls -l [a directory named "programming"]`, not `ls -l [a single directory named "Robot programming"]`.

The trivial fix is:
Code: Select all | TOGGLE FULL SIZE
WEBBOT         = ../Robot\ programming/ERA/ERA/lib

where the backslash says, "this space is part of the filename, not a separator".

You'd be better off giving the directory a name that doesn't contain spaces though.. escaped spaces tend to become whack-a-mole issues that keep popping up over and over again.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 8715
Joined: Thu Feb 11, 2010 1:51 pm