]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - Makefile
Update top level Makefile
[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: host
70 host:
71         make -C host V=1
72         cp -a host/_compiled/bin/rocon_cmd $(BUILDDIR)/
73         cp -a host/_compiled/bin/usb_sendhex $(BUILDDIR)/
74         cp -a host/_compiled/bin/lpc21isp $(BUILDDIR)/
75
76 .PHONY: hw
77 hw:
78         make -C hw
79         cp -a hw/_build/lx-rocon.pkg $(BUILDDIR)/
80
81 .PHONY: clean
82 clean:
83         make -C sw clean
84         make -C host clean
85         make -C hw clean
86         rm -rf $(BUILDDIR)