]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - Makefile
RoCoN: USB CDC ACM use maximal packet length - 64 bytes.
[fpga/lx-cpu1/lx-rocon.git] / Makefile
1 # TOP LEVEL Makefile for lx-rocon
2 # Files are copied to _build directory
3
4 # Installation steps are copied to this makefile
5
6 CROSS_COMPILE ?= arm-elf-gcc
7 BUILDDIR := $(CURDIR)/_build
8 PATH := $(BUILDDIR):$(PATH)
9
10 USB_BOOT_VID_PID ?= 0xdead:0x2263
11 USB_APP_VID_PID ?= 0x1669:0x1023
12
13 PROG_BASE ?= 0x00009000
14 PROG_SIZE ?= 0x00037000
15
16 # Attempt to create a build directory.
17 $(shell [ -d ${BUILDDIR} ] || mkdir -p ${BUILDDIR})
18
19 # Verify if it was successful.
20 BUILDDIR_TEST := $(shell cd $(BUILDDIR) && /bin/pwd)
21 $(if $(BUILDDIR_TEST),,$(error build directory "$(BUILDDIR)" does not exist))
22
23 .PHONY: all
24 all: ulboot sw hw host
25
26 .PHONY: ulboot
27 ulboot:
28         make -C ulboot V=1
29         cp -a ulboot/_compiled/bin/ulboot-boot.bin $(BUILDDIR)/
30
31 .PHONY: install-ulboot
32 install-ulboot: $(BUILDDIR)/lpc21isp $(BUILDDIR)/ulboot-boot.bin
33         lpc21isp -bin $(BUILDDIR)/ulboot-boot.bin /dev/ttyUSB0 38400 12000
34
35 .PHONY: sw
36 sw:
37         make -C sw V=1
38         cp -a sw/_compiled/bin/rocon-app.bin $(BUILDDIR)/
39         cp -a sw/_compiled/bin/rocon-sdram.bin $(BUILDDIR)/
40
41 .PHONY: install-app
42 install-app: $(BUILDDIR)/usb_sendhex $(BUILDDIR)/rocon-app.bin 
43         -usb_sendhex -d $(USB_APP_VID_PID) -r # Fails if we're already in bootloader
44         sleep 1
45         usb_sendhex -w -d $(USB_BOOT_VID_PID) -s $(PROG_BASE) -l $(PROG_SIZE) -e
46         sleep 2
47         usb_sendhex -d $(USB_BOOT_VID_PID) -s $(PROG_BASE) -f binary $(BUILDDIR)/rocon-app.bin
48
49 .PHONY: run-app
50 run-app:
51         -usb_sendhex -d $(USB_BOOT_VID_PID) -r # FIXME: broken pipe yo-ho
52
53 .PHONY: install-sdram
54 install-sdram: $(BUILDDIR)/usb_sendhex $(BUILDDIR)/rocon-sdram.bin 
55         -usb_sendhex -d $(USB_APP_VID_PID) -r # Fails if we're already in bootloader
56         usb_sendhex -w -d $(USB_BOOT_VID_PID) -t 1 -s 0xA0000000 -f binary $(BUILDDIR)/rocon-sdram.bin
57
58 .PHONY: run-sdram
59 run-sdram:
60         -usb_sendhex -d $(USB_BOOT_VID_PID) -g `usb_sendhex -d $(USB_BOOT_VID_PID) \
61         -s 0xA0000004 -l 4 -t 1 -u -f dump - | \
62         sed -n -e 's/^.*:\(..\) \(..\) \(..\) \(..\) */0x\4\3\2\1/p'`  # FIXME: broken pipe yo-ho
63
64 .PHONY: install-fpga
65 install-fpga: $(BUILDDIR)/usb_sendhex $(BUILDDIR)/lx-rocon.pkg
66         usb_sendhex -w -d $(USB_APP_VID_PID) -t 1 -s 0xA1C00000 -f binary $(BUILDDIR)/lx-rocon.pkg
67         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF000
68
69 .PHONY: install-tumbl
70 install-tumbl: $(BUILDDIR)/usb_sendhex $(BUILDDIR)/imem.bin $(BUILDDIR)/dmem.bin
71         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF100 -a 0x0001
72         usb_sendhex -w -d $(USB_APP_VID_PID) -t 3 -s 0x00000000 -f binary $(BUILDDIR)/imem.bin
73         usb_sendhex -w -d $(USB_APP_VID_PID) -t 3 -s 0x00001000 -f binary $(BUILDDIR)/dmem.bin
74         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF100 -a 0x0000
75
76 .PHONY: install-firmware
77 install-firmware: $(BUILDDIR)/usb_sendhex $(BUILDDIR)/fw_lxmaster.bin
78         usb_sendhex -w -d $(USB_APP_VID_PID) -t 1 -s 0xA1C00000 -f binary $(BUILDDIR)/fw_lxmaster.bin
79         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF024 -a `stat -L -c %s $(BUILDDIR)/fw_lxmaster.bin` # Upload LX MASTER firmware
80         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF011 -a 0 # Start IRC
81         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF023 -a 0 # Setup LX Master
82         usb_sendhex -d $(USB_APP_VID_PID) -c 0xF021 -a 0 # Start LX Master
83
84 .PHONY: host
85 host:
86         make -C host V=1
87         cp -a host/_compiled/bin/rocon_cmd $(BUILDDIR)/
88         cp -a host/_compiled/bin/usb_sendhex $(BUILDDIR)/
89         cp -a host/_compiled/bin/lpc21isp $(BUILDDIR)/
90
91 .PHONY: hw
92 hw:
93         make -C hw
94         cp -a hw/_build/lx-rocon.pkg $(BUILDDIR)/
95         cp -a hw/_build/imem.bin $(BUILDDIR)/
96         cp -a hw/_build/dmem.bin $(BUILDDIR)/
97         cp -a firmware/lxmaster.bin $(BUILDDIR)/fw_lxmaster.bin
98
99 .PHONY: clean
100 clean:
101         make -C sw clean
102         make -C host clean
103         make -C hw clean
104         rm -rf $(BUILDDIR)