> On 21 Jul 2017, at 23:07, Raphael Neider <rnei...@web.de> wrote: > > Regarding the second issue: Do you link main.o twice by any chance? Maybe by > compiling main.c once as part of the sources and again to trigger linking > with all .o files including main.o? > Could you post all relevant build output - with verbose enabled to see the > files being linked? > If the error occurs during compilation - could you provide the .asm file? > (sdcc with -S and -o foo.asm could do the trick)? >
I don't think I link main twice, here is my Makefile: #------------------------------------------------------------------------------- # Everyone should have this .SUFFIXES: UPLOADER := java -cp ~/EazyCNC-Project/classes:/Users/nyholku/PureJavaHidApi/bin/purejavahidapi.jar:/Users/Nyholku/PureJavaHidApi/lib/jna-4.0.0.jar diolanupdater.UpdateFirmware ENCODER := /Users/nyholku/diolan-plus2/encoder/build/encoder HEXMATE := /Applications/microchip/mplabx/v3.55/mplab_ide.app/Contents/Resources/mplab_ide/bin/hexmate # The output file name TARGET = toad4 # The source files that make up the project go here SRCS = main.c toad4.c usb_hid.c usb_core.c usb_pic_defs.c usb_user_config.c command_queue.c crt0iz_toad4.c # The libraries that are used go here LIBS = libc18f.lib libio18f45k50.lib libm18f.lib libsdcc.lib # Where to find the compiler SDCC = /Users/nyholku/sdcc-3.4.0/bin/sdcc # Compiler flags go here # --use-crt=crt0.o SDCCFLAGS = "-Wl -f 0xffff" --no-crt --ivt-loc=0x800 -V -L /Users/nyholku/sdcc-3.4.0/share/sdcc/non-free/lib/pic16 -Wa,-S,0 -Wl,-m,-s18f45k50.lkr -mpic16 -p18f45k50 --disable-warning 85 --std-sdcc99 --obanksel=3 --use-non-free # Where to store the target/intermediate/temporary/object files OBJDIR = ../obj # #------------------------------------------------------------------------------- # # This ensures that the object directory exists and re-creates it if necessary # # This requires make 3.81 or later, delete this section and all expressions that # refer to .f if you have an older make # .SECONDEXPANSION: # Uses a .f file as a flag file in each directory %/.f: mkdir -p $(dir $@) touch $@ # dont' let make remove the flag files automatically .PRECIOUS: %/.f # #------------------------------------------------------------------------------- # # Actual rules # # Compile the C-files $(OBJDIR)/%.o: %.c $$(@D)/.f @echo $(PATH) $(SDCC) -c $(SDCCFLAGS) $< -o $@ # Link the compiled files and libraries $(OBJDIR)/$(TARGET).hex: $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) $(OBJDIR)/hi_speed_irq.o $(SDCC) $(SDCCFLAGS) -o $(OBJDIR)/$(TARGET).hex $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) $(LIBS) $(OBJDIR)/hi_speed_irq.o # normalize the code filling un-used code memory with 0xFF so that encoding always works on known data $(HEXMATE) -o$(OBJDIR)/$(TARGET)-normalized.hex -fill=0xFF@0x0800:0x7FFF r0800-7FFF,$(OBJDIR)/$(TARGET).hex # sanitise the bootloader by keeping only the first 2kB (there is an extra jump code at 0x800 which overlaps with firmware code) $(HEXMATE) -o$(OBJDIR)/bootloader-normalized.hex -fill=0xFF@0x0000:0x07FF r0000-07FF,../diolan-plus2/bootloader.hex r000802-FFFFFF,../diolan-plus2/bootloader.hex # combine the bootloader and firmware to one hex file that can be programmed with pickit ready to run $(HEXMATE) -o$(OBJDIR)/$(TARGET)-pickit.hex -fill=0xFFFF@0xF00001:0xF000FF -fill=0xA5@0xF00000:0xF00000 -fill=0x00@0x300000:0x30000D $(OBJDIR)/$(TARGET)-normalized.hex ../obj/bootloader-normalized.hex # encode the bootloader for bootloading purposes, suppress output so as NOT to reveal the secret key @$(ENCODER) -ix $(OBJDIR)/$(TARGET)-normalized.hex -ox $(OBJDIR)/$(TARGET)-encoded.hex -e ${TOAD4PLUS_DIALON_KEY2} # upload the encoded hex file using the bootload process $(UPLOADER) $(OBJDIR)/$(TARGET)-encoded.hex # Compile the high speed interrupt asm file $(OBJDIR)/hi_speed_irq.o: hi_speed_irq.asm gpasm -DSTACK_MODEL_SMALL -D__STACK_MODEL_SMALL -o $(OBJDIR)/hi_speed_irq.o -c "hi_speed_irq.asm" # #------------------------------------------------------------------------------- # # Automatic generation of dependencies # # This magic code fragment from GNU make manual uses the SDCC compiler -M option # to create a Makefile fragment for each C-source file describing the dependencies. # # Traditionally these fragments have the type '.d' but SDCC seems to delete them # when it compiles files, so I use '.dep' here. # # Also SDCC '-M' option produces wrong dependency for the file being compiled # in the sense that it does not contain the path, only the filename. Hence # the 'sed' command has been mangled to inject the missing path to the fragment. # # First include the dependencies include $(addprefix $(OBJDIR)/, $(SRCS:.c=.dep)) # Then recreate them $(OBJDIR)/%.dep: %.c $$(@D)/.f @set -e; rm -f $@; \ $(SDCC) -c -M $(SDCCFLAGS) $< > $@.$$$$; \ sed -e '1 s,^,$(OBJDIR)/,' -e 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ #------------------------------------------------------------------------------ # # pretty standard default target # all: $(OBJDIR)/$(TARGET).hex # #------------------------------------------------------------------------------- # # pretty standard clean that attempts to delete all that this Makefile may left behind # clean: rm -f $(OBJDIR)/*.rel rm -f $(OBJDIR)/*.lnk rm -f $(OBJDIR)/*.S19 rm -f $(OBJDIR)/*.map rm -f $(OBJDIR)/*.mem rm -f $(OBJDIR)/*.asm rm -f $(OBJDIR)/*.rst rm -f $(OBJDIR)/*.sym rm -f $(OBJDIR)/*.lst rm -f $(OBJDIR)/*.o rm -f $(OBJDIR)/*.dep rm -f $(OBJDIR)/*.hex rm -f $(OBJDIR)/$(TARGET).hex # # cleanall deletes all in the object directory, do not use this if target dir == source dir cleanall: rm $(OBJDIR)/* #------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user