fx2lib / lib /

# common make targets for compiling fx2 firmware
# In your Makefile, define:
# SOURCES: list of c files to compile
# A51_SOURCES: list of any a51 files.
# DEPS: list of any depedancies (like auto-generated header files) that need
#       generated prior to compiling. You must provide the target definition
#       for any DEPS you define.
# BASENAME: name of your firmware file, i.e., myfirmware, but not myfirmware.c
# Leave these alone or redefine as necessary to customize firmware.
# (Redefine after including this makefile)
# VID vendor id
# PID product id
# LIBS optional additional libraries to link with the firmware.
# SDCC build/link options
#  CODE_SIZE:    Default --code-size 0x3c00
#  XRAM_SIZE:    Default --xram-size 0x0200
#  XRAM_LOC:     Default --xram-loc 0x3c00
# BUILDDIR: build directory (default build)
# These two can be changed to be blank if no device descriptor is being used.
#  DSCR_AREA:    Default -Wl"-b DSCR_AREA=0x3e00"
#  INT2JT:		Default -Wl"-b INT2JT=0x3f00"
# Provided targets:
# default target: creates $(BASENAME).ihx
# bix: creates $(BASENAME).bix
# iic: creates $(BASENAME).iic
# load: uses fx2load to load firmware.bix onto the development board
#  (You can customize VID/PID if you need to load the firmware onto a device that has different vendor and product id
#  The default is  0x04b4, 0x8613
# clean: delete all the temp files.


DSCR_AREA?=-Wl"-b DSCR_AREA=0x3e00"
INT2JT?=-Wl"-b INT2JT=0x3f00"
CODE_SIZE?=--code-size 0x3c00
XRAM_SIZE?=--xram-size 0x0200
XRAM_LOC?=--xram-loc 0x3c00

FX2LIBDIR?=$(dir $(lastword $(MAKEFILE_LIST)))../

RELS=$(addprefix $(BUILDDIR)/, $(addsuffix .rel, $(notdir $(basename $(SOURCES) $(A51_SOURCES)))))
# these are pretty good settings for most firmwares.  
# Have to be careful with memory locations for 
# firmwares that require more xram etc.
CC = sdcc -mmcs51 \
    $(CODE_SIZE) \
    $(XRAM_SIZE) \
    $(XRAM_LOC) \

.PHONY: ihx iic bix load clean clean-all

ihx: $(BUILDDIR)/$(BASENAME).ihx
bix: $(BUILDDIR)/$(BASENAME).bix
iic: $(BUILDDIR)/$(BASENAME).iic

$(FX2LIBDIR)/lib/fx2.lib: $(FX2LIBDIR)/lib/*.c $(FX2LIBDIR)/lib/*.a51
	make -C $(FX2LIBDIR)/lib

	mkdir -p $(BUILDDIR)

# can't use default target %.rel because there is no way
# to differentiate the dependency.  (Is it %.rel: %.c or %.a51)
	for a in $(A51_SOURCES); do \
	 cp $$a $(BUILDDIR)/; \
	 cd $(BUILDDIR) && sdas8051 -logs `basename $$a` && cd ..; done
	for s in $(SOURCES); do \
	 THISREL=$$(basename `echo "$$s" | sed -e 's/\.c$$/\.rel/'`); \
	 $(CC) -c -I $(FX2LIBDIR)/include $$s -o $(BUILDDIR)/$$THISREL ; done
	$(CC) -o $@ $(RELS) fx2.lib -L $(FX2LIBDIR)/lib $(LIBS)

	objcopy -I ihex -O binary $< $@
	$(FX2LIBDIR)/utils/ -v $(VID) -p $(PID) $< $@

load: $(BUILDDIR)/$(BASENAME).bix
	fx2load -v $(VID) -p $(PID) $(BUILDDIR)/$(BASENAME).bix

	rm -f $(BUILDDIR)/*.{asm,ihx,lnk,lst,map,mem,rel,rst,sym,adb,cdb,bix}

clean-all: clean
	make -C $(FX2LIBDIR)/lib clean
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.