-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
147 lines (112 loc) · 3.67 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# The Cypress FX2 is a programmable USB interface chip found on the Atlys and
# Opsis board (and many other devices out there).
#
# The IC is an 8051 core with a hardware support for the USB protocol. Firmware
# for the FX2 is developed using the fx2lib library and compiled with the SDCC
# compiler.
#
# The firmware can be loaded via USB using a number of tools such as fxload or
# fpgalink. Loading new firmware will cause the FX2 to disconnect and then
# reconnect to the USB bus, often causing it to change USB IDs and device
# files.
#
# Being a programmable device, the FX2 can emulate many other USB devices. We
# use it to emulate a USB UVC Webcam and a USB CDC-ACM serial port.
#
MODESWITCH_CMD = hdmi2usb-mode-switch
FX2LIBDIR = ./third_party/fx2lib
TARGETS += fx2
# conda - self contained environment.
export PATH := $(shell pwd)/conda/bin:$(PATH)
Miniconda3-latest-Linux-x86_64.sh:
@echo
@echo " Download conda..."
@echo "-----------------------------"
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
@chmod a+x Miniconda3-latest-Linux-x86_64.sh
conda: Miniconda3-latest-Linux-x86_64.sh
@echo
@echo " Setting up conda"
@echo "-----------------------------"
@./Miniconda3-latest-Linux-x86_64.sh -p $@ -b
@conda config --set always_yes yes --set changeps1 no
@conda update -q conda
@conda config --add channels timvideos
@echo
@echo " Install sdcc (compiler)"
@echo "-----------------------------"
@conda install sdcc
@echo
@echo " Install HDMI2USB-mode-switch"
@echo "-----------------------------"
@pip install --upgrade git+https://github.com/timvideos/HDMI2USB-mode-switch.git
conda-clean:
rm -rf conda
rm Miniconda3-*.sh || true
# ???
help-fx2:
@echo " make load-fx2"
@echo " make view"
gateware-generate-fx2:
@true
gateware-build-fx2:
cp gateware/streamer/vhdl/header.hex $(MSCDIR)/build/header.hex
# Firmware for the Cypress FX2
firmware-fx2: hdmi2usb/hdmi2usb.hex
@true
embed-fx2: firmware/lm32/fx2_fw_hdmi2usb.c
@true
load-fx2: hdmi2usb/hdmi2usb.hex
$(MODESWITCH_CMD) --load-fx2-firmware hdmi2usb/hdmi2usb.hex
flash-fx2:
@true
clean-fx2:
$(MAKE) -C hdmi2usb clean
hdmi2usb/hdmi2usb.hex:
$(MAKE) -C hdmi2usb
firmware/lm32/fx2_fw_hdmi2usb.c: microload/generate_2nd_stage.py hdmi2usb/hdmi2usb.hex
microload/generate_2nd_stage.py hdmi2usb/hdmi2usb.hex > firmware/lm32/fx2_fw_hdmi2usb.c
# Audio firmware for the Cypress FX2
firmware-audio-fx2: audio/audio.hex
@true
load-audio-fx2: audio/audio.hex
$(MODESWITCH_CMD) --load-fx2-firmware audio/audio.hex
clean-audio-fx2:
$(MAKE) -C audio clean
audio/audio.hex:
$(MAKE) -C audio
# Default USB VID/PID for the FX2
flash-unconfigured:
$(MAKE) -C eeprom-unconfigured flash
firmware-unconfigured:
$(MAKE) -C eeprom-unconfigured hdmi2usb_unconfigured.iic
clean-unconfigured:
$(MAKE) -C eeprom-unconfigured clean
# Microload
microload: fifo-microload i2c-microload
fifo-microload:
$(MAKE) -C microload fifo
i2c-microload:
$(MAKE) -C microload i2c
clean-microload:
$(MAKE) -C microload clean
# Utility functions
view:
./scripts/view-hdmi2usb.sh
docs: export PROJECT_NUMBER:=$(shell git describe --always --dirty --long)
docs:
doxygen docs/docs.conf
clean-docs:
rm -fr docs/html docs/latex
# Global
clean: clean-docs clean-fx2 clean-audio-fx2 clean-unconfigured clean-microload
@true
all: conda firmware-fx2 firmware-audio-fx2 microload
# We depend on the .git file inside the directory as git creates an empty dir
# for us.
$(FX2LIBDIR)/.git: .gitmodules
git submodule sync --recursive -- $$(dirname $@)
git submodule update --recursive --init $$(dirname $@)
touch $@ -r .gitmodules
.PHONY: docs clean-docs help-fx2 gateware-fx2 firmware-fx2 load-fx2 clean-fx2 view
.DEFAULT_GOAL := all