]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blobdiff - hw/tb/firmware-for-rx-crc/Makefile
Testbed for receiver CRC processing check.
[fpga/lx-cpu1/lx-rocon.git] / hw / tb / firmware-for-rx-crc / Makefile
diff --git a/hw/tb/firmware-for-rx-crc/Makefile b/hw/tb/firmware-for-rx-crc/Makefile
new file mode 100644 (file)
index 0000000..ca45489
--- /dev/null
@@ -0,0 +1,94 @@
+#===============================================================================
+# Firmware
+
+OUT := _build
+BUILDDIR := _build
+
+MB_CROSS_COMPILE ?= mbtumbl-elf-
+TARGET_CC := $(MB_CROSS_COMPILE)gcc
+TARGET_LD := $(MB_CROSS_COMPILE)ld
+TARGET_OBJCOPY := $(MB_CROSS_COMPILE)objcopy
+TARGET_OBJDUMP := $(MB_CROSS_COMPILE)objdump
+
+C_OBJS := $(OUT)/firmware.o
+A_OBJS :=
+CFLAGS := -mxl-soft-div -msoft-float -Wno-main -Wl,-no-check-sections -fno-zero-initialized-in-bss
+CFLAGS += -O2 -Wall
+DEB_FLAGS += -g
+AFLAGS := -D__ASSEMBLY__ $(CFLAGS)
+LDFLAGS := -static -nostdlib -relax -defsym _STACK_SIZE=0x0200
+
+OBJS := $(OUT)/start.o $(C_OBJS) $(A_OBJS)
+
+REQ_FIRMWARE       := $(OUT)/imem.bin $(OUT)/imem.asm $(OUT)/dmem.bin $(OUT)/firmware.lst
+
+FIRMWARE_DIR := .
+
+USB_APP_VID_PID ?= 0x1669:0x1023
+
+USB_SENDHEX := ./usb_sendhex
+
+#===============================================================================
+
+# Attempt to create a output directory.
+$(shell [ -d ${OUT} ] || mkdir -p ${OUT})
+
+# Verify if it was successful.
+OUTPUT_DIR := $(shell cd $(OUT) && /bin/pwd)
+$(if $(OUTPUT_DIR),,$(error output directory "$(OUT)" does not exist))
+
+#===============================================================================
+
+.PHONY: all
+all: firmware
+
+#$(OUT)/%.o: $(FIRMWARE_DIR)/%.c
+#      $(TARGET_CC) $(CFLAGS) $(DEB_FLAGS) -c $< -o $@
+
+$(OUT)/%.s: $(FIRMWARE_DIR)/%.c
+       $(TARGET_CC) $(CFLAGS) $(DEB_FLAGS) -S $< -o $@
+
+.PRECIOUS: $(OUT)/%.s
+
+$(OUT)/%.o: $(OUT)/%.s
+       $(TARGET_CC) $(AFLAGS) -fpreprocessed -c $< -o $@
+
+$(OUT)/%.o: $(FIRMWARE_DIR)/%.S
+       $(TARGET_CC) $(AFLAGS) $(DEB_FLAGS) -c $< -o $@
+
+$(OUT)/firmware.elf: $(OBJS)
+       $(TARGET_LD) $(LDFLAGS) -T $(FIRMWARE_DIR)/utils/tumbl.ld-script -o $@ $(OBJS)
+
+$(OUT)/bin2mem: $(FIRMWARE_DIR)/utils/bin2mem.c
+       gcc $< -o $@
+
+.PHONY: re-firmware
+re-firmware $(REQ_FIRMWARE): $(REQ_PKG) $(OUT)/bin2mem $(OUT)/firmware.elf
+       $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .text -S $(OUT)/imem.bin
+       $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .data -S $(OUT)/dmem.bin
+       $(TARGET_OBJDUMP) -DSCz $(OUT)/firmware.elf > $(OUT)/firmware.lst
+       cd $(OUT); \
+       $(TARGET_OBJDUMP) -b binary -mmbtumbl -EB -D imem.bin | sed -e 's/.data/.text/' > imem.asm
+
+#===============================================================================
+
+.PHONY: clean
+clean:
+       rm -rf $(OUT)
+
+.PHONY: firmware
+firmware: $(REQ_FIRMWARE)
+
+.PHONY: install-tumbl
+install-tumbl: $(USB_SENDHEX) $(BUILDDIR)/imem.bin $(BUILDDIR)/dmem.bin
+       $(USB_SENDHEX) -d $(USB_APP_VID_PID) -c 0xF100 -a 0x0001
+       $(USB_SENDHEX) -d $(USB_APP_VID_PID) -t 3 -s 0x00000000 -f binary $(BUILDDIR)/imem.bin
+       $(USB_SENDHEX) -d $(USB_APP_VID_PID) -t 3 -s 0x00001000 -f binary $(BUILDDIR)/dmem.bin
+       $(USB_SENDHEX) -d $(USB_APP_VID_PID) -c 0xF100 -a 0x0000
+
+# imem
+# watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80000000 -l 0x200 -f dump -u -
+# dmem
+# watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80001000 -l 0x200 -f dump -u -
+# PC
+# watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80003008 -l 0x4 -f dump -u -