forked from timvideos/HDMI2USB-litex-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
192 lines (151 loc) · 4.65 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
ifneq ($(OS),Windows_NT)
ifeq ($(HDMI2USB_ENV),)
$(error "Please enter environment. 'source scripts/enter-env.sh'")
endif
endif
PYTHON ?= python
export PYTHON
PLATFORM ?= opsis
export PLATFORM
# Default board
ifeq ($(PLATFORM),)
$(error "PLATFORM not set, please set it.")
endif
# Include platform specific targets
include targets/$(PLATFORM)/Makefile.mk
ifeq ($(TARGET),)
$(error "Internal error: TARGET not set.")
endif
export TARGET
ifeq ($(CPU),)
$(error "Internal error: CPU not set.")
endif
export CPU
# We don't use CLANG
CLANG = 0
export CLANG
TARGET_BUILD_DIR = build/$(PLATFORM)_$(TARGET)_$(CPU)/
IPRANGE ?= 192.168.100
export IPRANGE
TFTPD_DIR ?= build/tftpd/
# Couple of Python settings.
# ---------------------------------
# Turn off Python's hash randomization
PYTHONHASHSEED := 0
export PYTHONHASHSEED
# ---------------------------------
MAKE_CMD=\
time $(PYTHON) -u ./make.py \
--platform=$(PLATFORM) \
--target=$(TARGET) \
--cpu-type=$(CPU) \
--iprange=$(IPRANGE) \
$(MISOC_EXTRA_CMDLINE) \
$(LITEX_EXTRA_CMDLINE) \
# We use the special PIPESTATUS which is bash only below.
SHELL := /bin/bash
FILTER ?= tee -a
LOGFILE ?= $(PWD)/$(TARGET_BUILD_DIR)/output.$(shell date +%Y%m%d-%H%M%S).log
# Initialize submodules automatically
third_party/%/.git: .gitmodules
git submodule sync --recursive -- $$(dirname $@)
git submodule update --recursive --init $$(dirname $@)
touch $@ -r .gitmodules
# Image - a combination of multiple parts (gateware+bios+firmware+more?)
# --------------------------------------
image:
$(PYTHON) mkimage.py
image-load: image image-load-$(PLATFORM)
@true
image-flash: image image-flash-$(PLATFORM)
@true
.PHONY: image image-load image-flash
# Gateware - the stuff which configures the FPGA.
# --------------------------------------
GATEWARE_MODULES=litex litedram liteeth litepcie litesata litescope liteusb litevideo litex
gateware-submodules: $(addsuffix /.git,$(addprefix third_party/,$(GATEWARE_MODULES)))
@true
gateware: gateware-submodules
mkdir -p $(TARGET_BUILD_DIR)
ifneq ($(OS),Windows_NT)
$(MAKE_CMD) \
2>&1 | $(FILTER) $(LOGFILE); (exit $${PIPESTATUS[0]})
else
$(MAKE_CMD)
endif
gateware-load: gateware-load-$(PLATFORM)
@true
gateware-flash: gateware-flash-$(PLATFORM)
@true
gateware-clean:
rm -rf $(TARGET_BUILD_DIR)/gateware
.PHONY: gateware gateware-load gateware-flash gateware-clean
# Firmware - the stuff which runs in the soft CPU inside the FPGA.
# --------------------------------------
firmware:
mkdir -p $(TARGET_BUILD_DIR)
ifneq ($(OS),Windows_NT)
$(MAKE_CMD) --no-compile-gateware \
2>&1 | $(FILTER) $(LOGFILE); (exit $${PIPESTATUS[0]})
else
$(MAKE_CMD) --no-compile-gateware
endif
firmware-load: firmware firmware-load-$(PLATFORM)
@true
firmware-flash: firmware firmware-flash-$(PLATFORM)
@true
firmware-connect: firmware-connect-$(PLATFORM)
@true
firmware-clean:
rm -rf $(TARGET_BUILD_DIR)/software
.PHONY: firmware firmware-load firmware-flash firmware-connect firmware-clean
# TFTP booting stuff
# --------------------------------------
# TFTP server for minisoc to load firmware from
tftp: firmware
mkdir -p $(TFTPD_DIR)
cp $(TARGET_BUILD_DIR)/software/firmware/firmware.bin $(TFTPD_DIR)/boot.bin
tftpd_stop:
sudo true
sudo killall atftpd || true # FIXME: This is dangerous...
tftpd_start:
mkdir -p $(TFTPD_DIR)
sudo true
sudo atftpd --verbose --bind-address $(IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) $(TFTPD_DIR) &
.PHONY: tftp tftpd_stop tftpd_start
# Extra targets
# --------------------------------------
flash: flash-$(PLATFORM)
@true
help:
@echo "Environment:"
@echo " PLATFORM=$(shell ls targets/ | grep -v ".py" | grep -v "common" | sed -e"s+targets/++" -e's/$$/ OR/')" | sed -e's/ OR$$//'
@echo " (current: $(PLATFORM))"
@echo " TARGET=$(shell ls targets/$(PLATFORM)/ | grep ".py" | grep -v "__" | sed -e"s+targets/$(PLATFORM)/++" -e's/.py/ OR/')" | sed -e's/ OR$$//'
@echo " (current: $(TARGET))"
@echo ""
@if [ ! -z "$(TARGETS)" ]; then echo " Extra firmware needed for: $(TARGETS)"; echo ""; fi
@echo "Targets avaliable:"
@echo " make help"
@echo " make all"
@echo " make gateware"
@echo " make firmware"
@echo " make flash"
@for T in $(TARGETS); do make -s help-$$T; done
@echo " make clean"
clean:
rm -rf $(TARGET_BUILD_DIR)
py3clean . || rm -rf $$(find -name __pycache__)
dist-clean:
rm -rf build
.PHONY: flash help clean dist-clean
# Tests
# --------------------------------------
TEST_MODULES=edid-decode
test-submodules: $(addsuffix /.git,$(addprefix third_party/,$(TEST_MODULES)))
@true
test-edid: test-submodules
$(MAKE) -C test/edid check
test:
true
.PHONY: test test-edid