forked from mithro/HDMI2USB-litex-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.lm32
90 lines (75 loc) · 2.85 KB
/
Makefile.lm32
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
# The lm32 is the softcore which is embedded inside the FPGA gateware. It acts
# as a "master controller" for the firmware and responds to commands from the
# user via the UART interface. This means most of our high level logic can be
# written in C!
#
# The lm32 firmware is embedded into the gateware file. An updated firmware can
# be temporarily loaded via the UART without needing to rebuild the gateware
# making development fast!
#
# See the following links for more information;
# * https://en.wikipedia.org/wiki/LatticeMico32
# * https://github.com/m-labs/lm32
# * http://m-labs.hk/gateware.html
TARGETS += lm32
RAM_ADDR ?= 0x20000000
ifeq ($(BOARD),atlys)
SERIAL ?= /dev/ttyVIZ0
else
ifeq ($(BOARD),minispartan6)
SERIAL ?= /dev/ttyUSB1
RAM_ADDR = 0x40000000
else
ifeq ($(BOARD),pipistrello)
SERIAL ?= /dev/ttyUSB1
else
# Opsis fall through
SERIAL ?= /dev/ttyACM0
endif
endif
endif
help-lm32:
@echo " Set lm32 serial port with SERIAL=/dev/ttyXXXX"
@echo " (current: $(SERIAL))"
@echo " make load-lm32"
@echo " make connect-lm32"
# The gateware embeds the lm32 firmware, so we need to build that first.
gateware-generate-lm32: firmware-lm32
@true
gateware-build-lm32:
@true
ifeq ($(TARGET),hdmi2usb)
EXTRA_DEPS = embed-fx2
else
EXTRA_DEPS =
endif
firmware-lm32: third_party/misoc/.git $(EXTRA_DEPS)
$(MAKEPY_CMD) build-headers
$(MAKE) -C firmware/lm32 all
load-lm32: firmware-lm32
@echo "To load new firmware, reboot the running firmware and then"
@echo "select serialboot at the BIOS prompt."
$(FLTERM) --port $(SERIAL) --kernel=$(HDMI2USBDIR)/firmware/lm32/firmware.bin --kernel-adr=$(RAM_ADDR) --speed 115200
image-lm32: firmware-lm32
$(MAKEIMAGE_CMD) --fbi --output $(HDMI2USBDIR)/firmware/lm32/firmware.fbi $(HDMI2USBDIR)/firmware/lm32/firmware.bin
flash-lm32: image-lm32
@echo
@echo "Skipping writing lm32 firmware to flash."
@echo "(Loading lm32 firmware from flash is current disabled --"
@echo " see https://github.com/timvideos/HDMI2USB-misoc-firmware/issues/274)"
@echo "Booting will use lm32 firmware embedded in the gateware."
@echo
# export FIRMWARE_ADDRESS=$$($(PYTHON) -c "import platforms.$(BOARD) as b; print(b.Platform.gateware_size)"); \
# echo "Flashing to $$($(PYTHON) -c "print(hex($$FIRMWARE_ADDRESS))") ($$FIRMWARE_ADDRESS)"; \
# $(FLASHEXTRA_CMD) $(HDMI2USBDIR)/firmware/lm32/firmware.fbi $$FIRMWARE_ADDRESS
clear-flash-lm32:
export FIRMWARE_ADDRESS=$$($(PYTHON) -c "import platforms.$(BOARD) as b; print(b.Platform.gateware_size)"); \
echo "Zeroing $$($(PYTHON) -c "print(hex($$FIRMWARE_ADDRESS))") ($$FIRMWARE_ADDRESS)"; \
$(FLASHEXTRA_CMD) $(HDMI2USBDIR)/firmware/zero.bin $$FIRMWARE_ADDRESS
clean-lm32:
if [ -f $(MSCDIR)/software/include/generated/cpu.mak ]; then \
$(MAKE) -C firmware/lm32 clean; \
fi
connect-lm32:
$(FLTERM) --port $(SERIAL) --speed 115200
.PHONY: help-lm32 gateware-lm32 firmware-lm32 load-lm32 clean-lm32 connect-lm32