# Makefile to assemble usart_echo.asm with avra assembler # and erase Atmel flash and upload hex code to flash. # (c) by Thomas Hoehn, October 2007 PROG=usart_echo # tty for uisp programming UISP_TTY=/dev/ttyS0 # tty for picocom PICO_TTY=/dev/ttyUSB0 # verbose output for upload? # (0 - none, 1 - normal, 2 - more, # 3 - hash marks, 4 - detailed) DEBUG=3 # uisp binary path UISP=$(HOME)/uC/tools/uisp/uisp-20050207/src/uisp HASH=8 # hash mark each 8 byte ifdef DEBUG VERBOSE=-v=$(DEBUG) endif all: assemble help: @echo @echo "Usage: make [ clean | show_fuses | init_chip | erase | upload | verify | pico | test]" @echo "show_fuses - show all fuses bit settings" @echo "init_chip - init fuse bits to use ext. quarz" @echo "clean - remove all files created by make" @echo "erase - erase Atmel uC flash memory" @echo "upload - upload .hex file to Atmel flash" @echo "verify - verify .hex file and flash content" @echo "pico - run picocom on serial port to test USART" @echo "test - assemble, upload to flash and run picocom on serial port" @echo %.hex: %.asm avra -l $*.lst -m $*.map $< | tee $*.log @# avra exits with rc=0 in case of an error @# so we have to create an error with make @grep -q "^Assembly complete with no errors" $*.log assemble: $(PROG).hex clean: rm -f *.hex *.cof *.obj *.lst *.map *.log show_fuses: $(UISP) -dprog=dasa2 -dserial=$(UISP_TTY) --rd_fuses # programm Fuse Low Byte: # (see Atmel AT2313/V preliminary, p. 25 ff., p. 163 f.) # # CKOUT = 1 (unprogrammed) # CKDIV8 = 1 (unprogrammed), i.e. no clock division # SUT1:0 = 10, startup-time 16K CK, reset delay 14CK+4.1ms # CKSEL3:0 = 1111, i.e. external crystal, 8Mhz - max. init_chip: $(UISP) -dprog=dasa2 -dserial=$(UISP_TTY) --wr_fuse_l=0xef erase: $(UISP) -dprog=dasa2 -dserial=$(UISP_TTY) --erase upload: assemble erase $(UISP) $(VERBOSE) -dprog=dasa2 -dserial=$(UISP_TTY) \ --hash=$(HASH) --upload --verify if=$(PROG).hex verify: $(UISP) $(VERBOSE) -dprog=dasa2 -dserial=$(UISP_TTY) \ --hash=$(HASH) --verify if=$(PROG).hex pre_upload_test: ifeq ($(UISP_TTY),$(PICO_TTY)) @echo "Make sure the $(UISP_TTY) is connected to the" @echo "ISP connector on the Pollin Evaluation Board." @read -p "Press enter key to continue..." endif pico: ifeq ($(UISP_TTY),$(PICO_TTY)) @echo "Make sure the $(PICO_TTY) is connected to the" @echo "RS232 port on the Pollin Evaluation Board." @read -p "Press enter key to continue..." endif picocom $(PICO_TTY) # Tidy up, assemble file, upload to uC # and run picocom to test serial port test: clean assemble pre_upload_test upload ifeq ($(UISP_TTY),$(PICO_TTY)) @echo "Make sure the $(PICO_TTY) is connected to the" @echo "RS232 port on the Pollin Evaluation Board." @read -p "Press enter key to continue..." endif picocom $(PICO_TTY)