Loading...
 
Skip to main content

System Workbench for STM32


cant find main.o

hey,

i have a makefile project with my own makefile.
when i try to compile it it gives the following error:

09:47:55 **** Incremental Build of configuration Default for project testeten ****
make all
Het systeem kan het opgegeven bestand niet vinden.( cant find the file)
make: *** main.o Error 1

is there a simple explanation for this error?

  1. Documentation : http://www.gnu.org/software/make/manual/make.html
  2. Description : Makefile.

SHELL = /bin/bash

  1. Project specific defines
  2. Debug option (DEBUG, NDEBUG)

DEBUG = DEBUG

  1. Project structure (source/target paths)

SRC_DIR = ./
OBJ_DIR = ./obj/ # NOT USED
LST_DIR = ./lst/ # NOT USED
DOC_DIR = ./docs/ # NOT USED
DEP_DIR = ./deps/ # NOT USED

  1. The following directories are cleaned-up by the 'clean' rule
  2. CLEAN_DIRS = $(OBJ_DIR) $(LST_DIR) $(DOC_DIR)

  3. Target

TARGET = lxn

  1. SND_FILE = U203.vox
  2. SND_FILE = ABBH8.vox
  3. SND_FILE = NS210X1.vox
  4. SND_FILE = ns_new_short.vox

SND_FILE = 229090-145-001.vox

  1. Project C source files

CSRC = $(SRC_DIR)main.c
CSRC += $(SRC_DIR)initialisation.c

  1. CSRC += $(SRC_DIR)adc.c

CSRC += $(SRC_DIR)tim.c
CSRC += $(SRC_DIR)iir.c
CSRC += $(SRC_DIR)slope.c
CSRC += $(SRC_DIR)usart.c
CSRC += $(SRC_DIR)adpcm.c
CSRC += $(SRC_DIR)dac.c
CSRC += $(SRC_DIR)audio.c
CSRC += $(SRC_DIR)io.c
CSRC += $(SRC_DIR)mic.c
CSRC += $(SRC_DIR)control.c
CSRC += $(SRC_DIR)calc.c
CSRC += $(SRC_DIR)spi.c
CSRC += $(SRC_DIR)cic.c
CSRC += $(SRC_DIR)flash.c
CSRC += $(SRC_DIR)cal.c
CSRC += $(SRC_DIR)crc.c

  1. Address Sound file

ADDR_FLASH =0x8000000
ADDR_CAL_SECTION =0x801C800
ADDR_OFFSET_SND_FILE =0x1D000
ADDR_SND_SECTION =0x801D000
ADDR_END_SND_FILE =0x2A875

ifeq (DEBUG,$(DEBUG))

  1. Debug C source files

CSRC += $(SRC_DIR)printf.c
endif

  1. CSRC += $(SRC_DIR)debug/uart.c

  2. STM Library C source files
  3. CSRC += ..

  4. ASM source files

ASRC = stm/core/startup_stm32f10x_hd.s

  1. ASRC += .....

  2. Defines for use in C code (these will be included with -D options)

CDEFS = TARGET=$(TARGET)
CDEFS += STM32F10X_HD
CDEFS += $(DEBUG)

  1. CDEFS += .....

  2. Additional libraries (these will be included with -l options)
  3. LIBS = m

LIBS +=IQmath

  1. aditional libraries directories (these will be included with -L options

INCS_LIBS =./
INCS_LIBS += lib/

  1. Additional include directories (these will be included with -I options)

INCS = ./

  1. INCS += debug/

INCS += stm/
INCS += stm/core/

  1. INCS += .....

  2. The linker script

LINK_SCRIPT = link.ld

  1. Generic defines
  2. Do not output executed commands.
  3. SILENT = @

  4. OS dependent variables.
  5. Determine operating system.

OSTYPE := $(shell echo $$OSTYPE)

ifeq (linux,$(findstring linux,$(OSTYPE)))

#
# Linux OS.
#

# Set OS dependent variables.
TMP = /tmp
INSTPATH = /edge1/programs/linux-x86/opt/CodeSourcery/arm-2010q1-188/bin/
else

#
# Windows OS.
#

# Set OS dependent variables.
TEMP ?= C:\\temp
TMP ?= $(TEMP)
INSTPATH = W:/CodeSourcery/arm-2010q1-188/bin/
endif

  1. Toolchain prefix

CROSS_COMPILE = $(INSTPATH)arm-none-eabi-

  1. Tools.

RM = rm -rf

  1. Define memory map, defines and objects.

MEMMAP =

  1. Define the objects for all source types

AOBJ = $(ASRC:.s=.o)
COBJ = $(CSRC:.c=.o)
OBJS = $(COBJ) $(AOBJ)
LSTS = $(OBJS:.o=.lst)
DEPS = $(CSRC:.c=.dep)

  1. Define common GCC stuff
  2. Architecture specific flags

ARCHFLAGS = -mcpu=cortex-m3 -mthumb

  1. Define compiler and compiler options
  2. Compiler

CC = $(CROSS_COMPILE)gcc


  1. Optional compiler flags (warnings, list files, .....)

CFLAGS = -Wall
CFLAGS += -Wimplicit
CFLAGS += -Wpointer-arith
CFLAGS += -Wswitch-default
CFLAGS += -Wshadow
CFLAGS += #-Wredundant-decls
CFLAGS += -Wundef
CFLAGS += -Wa,-adhlns=$*.lst
CFLAGS += -O3

  1. Combine all necessary and optional compiler flags

ALL_CFLAGS = $(ARCHFLAGS)
ALL_CFLAGS += $(patsubst %,-D%,$(CDEFS))
ALL_CFLAGS += $(patsubst %,-I%,$(INCS))
ALL_CFLAGS += $(CFLAGS)

  1. Compiler for generating dependencies and options

GENDEP = $(CROSS_COMPILE)gcc -MM $(ALL_CFLAGS)

  1. Define Assembler and assembler options
  2. Assembler

AS = $(CROSS_COMPILE)gcc

  1. Optional assembler flags (list files, .....)

ASFLAGS = -Wa,-adhlns=$*.lst

  1. Combine all necessary and optional assembler flags

ALL_ASFLAGS = $(ARCHFLAGS)

  1. ALL_ASFLAGS += -x assembler-with-cpp

ALL_ASFLAGS += $(ASFLAGS)

  1. Define linker and linker options
  2. Linker

LD = $(CROSS_COMPILE)gcc

  1. Optional linker flags (map file, ......)

LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -Wl,gc-sections,section-start=SND=$(ADDR_SND_SECTION)
LDFLAGS += -Wl,gc-sections,section-start=CAL=$(ADDR_CAL_SECTION)

  1. Combine all necessary and optional linker flags

ALL_LDFLAGS = $(ARCHFLAGS)
ALL_LDFLAGS += -nostartfiles
ALL_LDFLAGS += $(patsubst %,-L%,$(INCS_LIBS))
ALL_LDFLAGS += $(patsubst %,-l%,$(LIBS))

  1. ALL_LDFLAGS += -nostdlib

ALL_LDFLAGS += -T$(LINK_SCRIPT)
ALL_LDFLAGS += $(LDFLAGS)

  1. Other tools

OBJCOPY = $(CROSS_COMPILE)objcopy
HEXFORMAT = srec
BINFORMAT = binary

  1. Phony targets
  2. Build all.

.PHONY: all
all: $(TARGET).bin

  1. Check build environment and create directories if needed.

.PHONY: check_build_env
check_build_env:

$(SILENT)test -d $(OBJ_DIR)
mkdir $(OBJ_DIR)
$(SILENT)test -d $(LST_DIR)
mkdir $(LST_DIR) $(SILENT)test -d $(DEP_DIR)
mkdir $(DEP_DIR)
# Cleanup project
# Note : if the project directory itself is part of CLEAN_DIRS, it is removed
clean:
@echo " RM $(TARGET)"
$(SILENT)$(RM) $(TARGET).bin $(TARGET).map $(TARGET).hex $(TARGET).elf
$(SILENT)$(RM) $(OBJS)
$(SILENT)$(RM) $(DEPS)
$(SILENT)$(RM) $(LSTS)
# Output tool versions
tools:
@echo "********************************* GCC *************************************"
$(SILENT)$(CC) --version
# Documentation.
docs: doxygen latex
doxygen:
@echo " DOXYGEN $(TARGET)"
$(SILENT)doxygen doxygen.conf 2>&1 grep -i -v -E '\.c:.+warning'
true


latex:
@echo " LATEX $(TARGET)"
$(SILENT)make -C docs/latex/ > /dev/null 2>&1

tags: *.c *.h
@echo " CTAGS $(TARGET)"
$(SILENT)ctags *.c *.h

  1. Dependencies
  2. Include (generated) dependencies

-include $(DEPS)

  1. Additional dependencies
  2. ...


  3. Now give some rules for building the targets
  4. Retrieve version label from version.h.

GET_VERSION_STR = cat version.h |grep "\#define VERSION_STR" |sed "s/\#define[[:blank:]]*VERSION_STR[[:blank:]]*\"//" |sed "s/\"//"
GET_VCS_SOURCE = svn info . |grep URL: |cut -f 2 -d " " |sed "s/\\r//"
GET_VCS_PATH = $(GET_VCS_SOURCE) |sed "s/\/trunk\$$//" |sed "s/\/branches\/.*//"

  1. Release current version.

release: update specfile svntag version_increment

update:
$(SILENT)svn update

  1. Create specfile. (used by release)

specfile: $(TARGET).bin
@VERSION=`$(GET_VERSION_STR)`; \
SPECFILE=$(TARGET)-$$VERSION.spec; \
VCS_SOURCE=`$(GET_VCS_SOURCE)`; \
VCS_TAG=`$(GET_VCS_PATH)`/tags/$(TARGET)-$$VERSION; \
echo " SPECFILE $(TARGET)"; \
$(RM) $(TARGET)-*; \
$(RM) $(TARGET)-*.spec; \

  1. $(CP) $(TARGET).bin $(TARGET)-$$VERSION.bin; \

echo "VersionControl" >$$SPECFILE; \
echo "VCS=\"svn\"" >>$$SPECFILE; \
echo "SOURCE=\"$$VCS_SOURCE\"" >>$$SPECFILE; \
echo "TAG=\"$$VCS_TAG\"" >>$$SPECFILE; \
echo "VERSION=\"$$VERSION\"" >>$$SPECFILE; \
echo "" >>$$SPECFILE; \
echo "Tools" >>$$SPECFILE; \
echo "TOOL=\"$(CC)\"" >>$$SPECFILE; \
echo "TOOLVERSION=\"`$(CC) --version |head -1`\"" >>$$SPECFILE; \
echo "" >>$$SPECFILE; \
echo "BuildInfo" >>$$SPECFILE; \
echo "OUTPUT=\"$(TARGET)\"" >>$$SPECFILE; \
echo "DATE=\"`date`\"" >>$$SPECFILE; \
echo "HOST=\"`uname -n`\"" >>$$SPECFILE; \
echo "HOSTOS=\"`uname -rvs`\"" >>$$SPECFILE; \
echo "USER=\"`whoami`\"" >>$$SPECFILE; \
echo "COMMAND=\"make\"" >>$$SPECFILE; \
echo "" >>$$SPECFILE; \

  1. Create subversion tag. (used by release)
  2. Project is tagged as TARGET-VERSION in repository.

svntag:
@VERSION=`$(GET_VERSION_STR)`; \
VCS_SOURCE=`$(GET_VCS_SOURCE)`; \
VCS_TAG=`$(GET_VCS_PATH)`/tags/$(TARGET)-$$VERSION; \
echo " SVNTAG $(TARGET)-$$VERSION"; \
echo ""; \
echo " The created tag will be a copy of the current repository path";\
echo " $$VCS_SOURCE"; \
echo ""; \
echo -n " Is the current repository path up to date? (yes/no) "; \
read -n 1 -s USERINPUT; \
echo ""; \
if %22$$USERINPUT%22 != %22y%22 -a %22$$USERINPUT%22 != %22Y%22; then \
exit 1; \
fi; \
svn cp $$VCS_SOURCE $$VCS_TAG -m "Auto tag by make. target: release"; \
echo ""; \
echo " ***********************************************************"; \
echo " * - PROJECT RELEASED - "; \
echo " ***********************************************************"; \
echo " *"; \
echo " * Project: $(TARGET)"; \
echo " * Version: $$VERSION"; \
echo " *"; \
echo " * CVS tag: $$VCS_TAG"; \
echo " *"; \
echo " ***********************************************************"; \
echo ""

  1. Increment version. (used by release)

version_increment:
@echo " VERSION $(TARGET)"
$(SILENT)$(CP) version.h version.h.bak
@VERSION=`$(GET_VERSION_STR)`; \
MAJOR=`echo $$VERSION |cut -f 1 -d "-"`; \
MINOR=`echo $$VERSION |cut -f 2 -d "-"`; \
MINOR=$$((10#$$MINOR)); \
let MINOR++; \
MINOR=`printf "%d" $$MINOR`; \
cat version.h.bak |sed "s/\"$$VERSION\"/\"$$MAJOR-$$MINOR\"/" > version.h
$(SILENT)$(RM) version.h.bak
@VERSION=`$(GET_VERSION_STR)`; \
echo " VERSION $$VERSION"

  1. Declare phony targets.

.PHONY: all clean doxygen latex tags release update specfile svntag version_increment

  1. Create objects from c source code and update dependencies.

$(COBJ) : %.o : %.c
$(SILENT)set -e; rm -f $*.dep; \
$(GENDEP) -MF $*.dep.$$$$ $ $*.dep; \
rm -f $*.dep.$$$$
@echo " CC $@"
$(SILENT)$(CC) -c $(ALL_CFLAGS) -o $@ $<

  1. Create objects from assembly source code with dependencies.

$(AOBJ) : %.o : %.s
@echo " AS $@"
$(SILENT)$(AS) -c $(ALL_ASFLAGS) -o $@ $<

  1. Link objects and create .elf file

$(TARGET).elf : $(OBJS)
@echo " LD $@"
$(SILENT)$(LD) -o $@ $+ $(ALL_LDFLAGS)

  1. Create final output file (.hex) from ELF output file.

$(TARGET).hex : $(TARGET).elf
@echo " OBJCOPY $@"

  1. Create final output file (.bin) from ELF output file.

$(TARGET).bin : $(TARGET).elf
@echo " OBJCOPY $@"
$(SILENT)$(OBJCOPY) -O $(BINFORMAT) $< $@
$(SILENT) srec_cat '(' $(SND_FILE) -binary -offset 0x02 ')' -Little_Endian_Exclusive_Length 0x00 2 -output snd.bin -binary
$(SILENT) srec_cat snd.bin -binary -offset $(ADDR_OFFSET_SND_FILE) -output snd.bin -binary
$(SILENT) srec_cat snd.bin -binary -fill 0 -max-address snd.bin -binary $(ADDR_END_SND_FILE) -output snd.bin -binary
$(SILENT) srec_cat $(TARGET).bin -binary -crop 0x00 $(ADDR_OFFSET_SND_FILE) snd.bin -binary -crop $(ADDR_OFFSET_SND_FILE) -max-address snd.bin -binary -output $(TARGET).bin -binary
$(SILENT) rm snd.bin


this is my make fille