]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - hw/tb/firmware-for-xmem-bug/Makefile
TUMBL firmware and gtkwave log setup which demonstrates xmem access bug.
[fpga/lx-cpu1/lx-rocon.git] / hw / tb / firmware-for-xmem-bug / Makefile
1 #===============================================================================
2 # Firmware
3
4 OUT := _build
5 BUILDDIR := _build
6
7 MB_CROSS_COMPILE ?= mbtumbl-elf-
8 TARGET_CC := $(MB_CROSS_COMPILE)gcc
9 TARGET_LD := $(MB_CROSS_COMPILE)ld
10 TARGET_OBJCOPY := $(MB_CROSS_COMPILE)objcopy
11 TARGET_OBJDUMP := $(MB_CROSS_COMPILE)objdump
12
13 C_OBJS := $(OUT)/firmware.o
14 A_OBJS :=
15 CFLAGS := -mxl-soft-div -msoft-float -Wno-main -Wl,-no-check-sections -fno-zero-initialized-in-bss
16 CFLAGS += -O2 -Wall
17 DEB_FLAGS += -g
18 AFLAGS := -D__ASSEMBLY__ $(CFLAGS)
19 LDFLAGS := -static -nostdlib -relax -defsym _STACK_SIZE=0x0200
20
21 OBJS := $(OUT)/start.o $(C_OBJS) $(A_OBJS)
22
23 REQ_FIRMWARE       := $(OUT)/imem.bin $(OUT)/imem.asm $(OUT)/dmem.bin $(OUT)/firmware.lst
24
25 FIRMWARE_DIR := .
26
27 USB_APP_VID_PID ?= 0x1669:0x1023
28
29 USB_SENDHEX := ./usb_sendhex
30
31 #===============================================================================
32
33 # Attempt to create a output directory.
34 $(shell [ -d ${OUT} ] || mkdir -p ${OUT})
35
36 # Verify if it was successful.
37 OUTPUT_DIR := $(shell cd $(OUT) && /bin/pwd)
38 $(if $(OUTPUT_DIR),,$(error output directory "$(OUT)" does not exist))
39
40 #===============================================================================
41
42 .PHONY: all
43 all: firmware
44
45 #$(OUT)/%.o: $(FIRMWARE_DIR)/%.c
46 #       $(TARGET_CC) $(CFLAGS) $(DEB_FLAGS) -c $< -o $@
47
48 $(OUT)/%.s: $(FIRMWARE_DIR)/%.c
49         $(TARGET_CC) $(CFLAGS) $(DEB_FLAGS) -S $< -o $@
50
51 .PRECIOUS: $(OUT)/%.s
52
53 $(OUT)/%.o: $(OUT)/%.s
54         $(TARGET_CC) $(AFLAGS) -fpreprocessed -c $< -o $@
55
56 $(OUT)/%.o: $(FIRMWARE_DIR)/%.S
57         $(TARGET_CC) $(AFLAGS) $(DEB_FLAGS) -c $< -o $@
58
59 $(OUT)/firmware.elf: $(OBJS)
60         $(TARGET_LD) $(LDFLAGS) -T $(FIRMWARE_DIR)/utils/tumbl.ld-script -o $@ $(OBJS)
61
62 .PHONY: re-firmware
63 re-firmware $(REQ_FIRMWARE): $(REQ_PKG) $(OUT)/firmware.elf
64         $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .text -S $(OUT)/imem.bin
65         $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .data -S $(OUT)/dmem.bin
66         $(TARGET_OBJDUMP) -DSCz $(OUT)/firmware.elf > $(OUT)/firmware.lst
67         cd $(OUT); \
68         $(TARGET_OBJDUMP) -b binary -mmbtumbl -EB -D imem.bin | sed -e 's/.data/.text/' > imem.asm
69
70 #===============================================================================
71
72 .PHONY: clean
73 clean:
74         rm -rf $(OUT)
75
76 .PHONY: firmware
77 firmware: $(REQ_FIRMWARE)
78
79 .PHONY: install-tumbl
80 install-tumbl: $(USB_SENDHEX) $(BUILDDIR)/imem.bin $(BUILDDIR)/dmem.bin
81         $(USB_SENDHEX) -d $(USB_APP_VID_PID) -c 0xF100 -a 0x0001
82         $(USB_SENDHEX) -d $(USB_APP_VID_PID) -t 3 -s 0x00000000 -f binary $(BUILDDIR)/imem.bin
83         $(USB_SENDHEX) -d $(USB_APP_VID_PID) -t 3 -s 0x00001000 -f binary $(BUILDDIR)/dmem.bin
84         $(USB_SENDHEX) -d $(USB_APP_VID_PID) -c 0xF100 -a 0x0000
85
86 # imem
87 # watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80000000 -l 0x200 -f dump -u -
88 # dmem
89 # watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80001000 -l 0x200 -f dump -u -
90 # PC
91 # watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80003008 -l 0x4 -f dump -u -