Skip to content

Commit

Permalink
Merge pull request #359 from mithro/small-fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
mithro committed Sep 25, 2017
2 parents c5cfc97 + d377a1b commit 040fe0e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
1 change: 1 addition & 0 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function build() {
echo "---------------------------------------------"
if [ $HAVE_XILINX_ISE -eq 0 ]; then
echo "Skipping gateware"
make gateware-fake
else
FILTER=$PWD/.travis/run-make-gateware-filter.py \
make gateware || return 1
Expand Down
36 changes: 27 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ $(IMAGE_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) $(FIRMWARE_FILEBASE).fbi
$(MISOC_EXTRA_CMDLINE) $(LITEX_EXTRA_CMDLINE) \
--override-gateware=$(GATEWARE_FILEBASE).bin \
--override-bios=$(BIOS_FILE) \
--override-firmware=$(FIRMWARE_FILEBASE).fbi
--override-firmware=$(FIRMWARE_FILEBASE).fbi \
--output-file=$(IMAGE_FILE)

$(TARGET_BUILD_DIR)/image.bin: $(IMAGE_FILE)
cp $< $@
Expand All @@ -122,16 +123,20 @@ gateware: gateware-submodules
mkdir -p $(TARGET_BUILD_DIR)
ifneq ($(OS),Windows_NT)
$(MAKE_CMD) \
2>&1 | $(FILTER) $(LOGFILE); (exit $${PIPESTATUS[0]})
2>&1 | $(FILTER) $(LOGFILE); (exit $${PIPESTATUS[0]})
else
$(MAKE_CMD)
endif

gateware-fake:
touch $(GATEWARE_FILEBASE).bit
touch $(GATEWARE_FILEBASE).bin

$(GATEWARE_FILEBASE).bit:
@touch $<
make gateware

$(GATEWARE_FILEBASE).bin:
@touch $<
make gateware

gateware-load: $(GATEWARE_FILEBASE).bit gateware-load-$(PLATFORM)
@true
Expand All @@ -146,16 +151,18 @@ gateware-clean:

# Firmware - the stuff which runs in the soft CPU inside the FPGA.
# --------------------------------------
$(BIOS_FILE):
$(FIRMWARE_FILEBASE).bin:
firmware-cmd:
mkdir -p $(TARGET_BUILD_DIR)
ifneq ($(OS),Windows_NT)
$(MAKE_CMD) --no-compile-gateware \
2>&1 | $(FILTER) $(LOGFILE); (exit $${PIPESTATUS[0]})
2>&1 | $(FILTER) $(LOGFILE); (exit $${PIPESTATUS[0]})
else
$(MAKE_CMD) --no-compile-gateware
endif

$(FIRMWARE_FILEBASE).bin: firmware-cmd
@true

$(FIRMWARE_FILEBASE).fbi: $(FIRMWARE_FILEBASE).bin
$(PYTHON) -m litex.soc.tools.mkmscimg -f $< -o $@

Expand All @@ -174,11 +181,19 @@ firmware-connect: firmware-connect-$(PLATFORM)
firmware-clean:
rm -rf $(TARGET_BUILD_DIR)/software

.PHONY: firmware firmware-load firmware-flash firmware-connect firmware-clean
.PHONY: firmware-cmd $(FIRMWARE_FILEBASE).bin firmware firmware-load firmware-flash firmware-connect firmware-clean

$(BIOS_FILE): firmware-cmd
@true

bios-flash: firmware bios-flash-$(PLATFORM)
bios: $(BIOS_FILE)
@true

bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM)
@true

.PHONY: $(FIRMWARE_FILE) bios bios-flash

# TFTP booting stuff
# --------------------------------------
# TFTP server for minisoc to load firmware from
Expand Down Expand Up @@ -233,6 +248,9 @@ prompt:
@if [ x"$(FIRMWARE)" != x"firmware" ]; then \
echo -n " F=$(FIRMWARE)"; \
fi
@if [ x"$(JIMMO)" != x"" ]; then \
echo -n " JIMMO"; \
fi
@if [ x"$(PROG)" != x"" ]; then echo -n " P=$(PROG)"; fi
@BRANCH="$(shell git symbolic-ref --short HEAD 2> /dev/null)"; \
if [ "$$BRANCH" != "master" ]; then \
Expand Down
17 changes: 12 additions & 5 deletions mkimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def main():
parser = argparse.ArgumentParser(description="SPI Flash contents tool")
make_args(parser)

parser.add_argument("--output-file", default="flash.bin")
parser.add_argument("--output-file", default='flash.bin')
parser.add_argument("--override-gateware")
parser.add_argument("--override-bios")
parser.add_argument("--override-firmware")
Expand All @@ -22,6 +22,14 @@ def main():
args = parser.parse_args()

builddir = make_builddir(args)
if os.path.sep not in args.output_file:
args.output_file = os.path.join(builddir, args.output_file)

output_file = args.output_file
output_dir = os.path.dirname(output_file)
assert os.path.exists(output_dir), (
"Directory %r doesn't exist!" % output_dir)

gateware = os.path.join(builddir, "gateware", "top.bin")
if args.override_gateware:
if args.override_gateware.lower() == "none":
Expand Down Expand Up @@ -61,9 +69,8 @@ def main():
bios_pos = platform.gateware_size
firmware_pos = platform.gateware_size + BIOS_SIZE

output = os.path.join(builddir, args.output_file)
print()
with open(output, "wb") as f:
with open(output_file, "wb") as f:
# FPGA gateware
if gateware:
gateware_data = open(gateware, "rb").read()
Expand Down Expand Up @@ -130,8 +137,8 @@ def main():
f.write(b'\xff' * (flash_size - f.tell()))

print()
print("Flash image: {}".format(output))
flash_image_data = open(output, "rb").read()
print("Flash image: {}".format(output_file))
flash_image_data = open(output_file, "rb").read()
print(" ".join("{:02x}".format(i) for i in flash_image_data[:64]))


Expand Down
5 changes: 3 additions & 2 deletions scripts/enter-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,11 @@ export HDMI2USB_ENV=1
# Set prompt
ORIG_PS1="$PS1"
hdmi2usb_prompt() {
PS1="(H2U $(cd $TOP_DIR; make prompt)) $ORIG_PS1"
P="$(cd $TOP_DIR; make prompt)"
PS1="(H2U $P) $ORIG_PS1"
case "$TERM" in
xterm*|rxvt*)
PS1="$PS1\[\033]0;$P) \w\007\]"
PS1="$PS1\[\033]0;($P) \w\007\]"
;;
*)
;;
Expand Down

0 comments on commit 040fe0e

Please sign in to comment.