Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP -- Modernize platforms + target files #311

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
98cb5f5
I have been trying to use litex-buildenv to make a vertexriscv image …
niklasnisbeth Dec 30, 2019
ab381da
Adding the litex-boards repository.
mithro Jan 16, 2020
a29640c
arty: Cleanup and modernize.
mithro Jan 15, 2020
eebab12
test: Fixing up ipython_etherbone.
mithro Jan 17, 2020
e565664
atlys: Cleanup and modernize.
mithro Jan 30, 2020
8c1f070
basys3: Cleanup and modernize.
mithro Jan 17, 2020
cb2b40b
cmod_a7: Cleanup and modernize.
mithro Jan 17, 2020
a3f50ca
galatea: Cleanup and modernize.
mithro Jan 17, 2020
9bc77e0
mimas_a7: Cleanup and modernize.
mithro Jan 30, 2020
e8c12dd
mimasv2: Cleanup and modernize.
mithro Jan 17, 2020
5d892a1
minispartan6: Cleanup and modernize.
mithro Jan 17, 2020
dc72870
nexys_video: Cleanup and modernize.
mithro Jan 30, 2020
2665d04
opsis: Cleanup and modernize.
mithro Jan 30, 2020
7de320c
pano_logic_g2: Cleanup and modernize.
mithro Jan 17, 2020
8c4fe7f
pipistrello: Cleanup and modernize.
mithro Jan 17, 2020
b77dd30
saturn: Cleanup and modernize.
mithro Jan 17, 2020
db9dded
waxwing: Cleanup and modernize.
mithro Jan 17, 2020
c7e5487
ice40_hx8k_b_evn
mithro Jan 30, 2020
2c19294
gateware/info: Only use DNA on Xilinx devices.
mithro Jan 30, 2020
3342ea6
Temp.
mithro Jan 30, 2020
d7d46c7
Updating submodules.
mithro Jan 30, 2020
0232bb0
Temp2
mithro Jan 30, 2020
7a56364
mkmake: Rework a bit.
mithro Jan 30, 2020
5380a92
targets/utils: Fix docstring.
mithro Jan 30, 2020
0fa467e
targets/utils: Allow rewriting the commands.
mithro Jan 30, 2020
0ba667d
ice40_hx8k_b_evn
mithro Jan 30, 2020
6f99783
ice40_hx8k_b_evn extra
mithro Feb 1, 2020
8891190
Remove old `csr_map_XXX` functions.
mithro Feb 1, 2020
455853b
arty
mithro Feb 1, 2020
113fd59
atlys
mithro Feb 1, 2020
ba756cf
ice40_up5k_b_evn
mithro Feb 1, 2020
99e3264
icebreaker
mithro Feb 1, 2020
7191420
icefun
mithro Feb 1, 2020
0789fd5
mimas_a7
mithro Feb 1, 2020
0a49b55
mimasv2
mithro Feb 1, 2020
3c0bc18
neso
mithro Feb 1, 2020
fd5c36d
netv2
mithro Feb 1, 2020
2fc57d7
nexys_video
mithro Feb 1, 2020
3cf432a
opsis
mithro Feb 1, 2020
d728db8
sim
mithro Feb 1, 2020
93b7590
tinyfpga_bx
mithro Feb 1, 2020
8a8256a
upduino_v1
mithro Feb 1, 2020
8a11af0
waxwing
mithro Feb 1, 2020
a69d1a1
mimas_a7
mithro Feb 2, 2020
e7098e0
nexys_video
mithro Feb 2, 2020
4293570
atlys
mithro Feb 2, 2020
9fe7e48
galatea
mithro Feb 2, 2020
9f481f8
mimasv2
mithro Feb 2, 2020
e9ea25b
minispartan6
mithro Feb 2, 2020
529aa9b
galatea
mithro Feb 2, 2020
a5d9925
opsis
mithro Feb 2, 2020
f32d30a
pipistrello
mithro Feb 2, 2020
84d2b92
waxwing
mithro Feb 2, 2020
bef662d
ice40_up5k_b_evn
mithro Feb 3, 2020
35355d2
icebreaker
mithro Feb 3, 2020
bac0660
icefun
mithro Feb 3, 2020
08b1759
neso
mithro Feb 3, 2020
951b684
netv2
mithro Feb 3, 2020
49d57c8
tinyfpga_bx
mithro Feb 3, 2020
165814b
upduino_v1
mithro Feb 3, 2020
61d4a85
waxwing
mithro Feb 3, 2020
2d5fbe7
atlys
mithro Feb 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@
[submodule "third_party/nmigen"]
path = third_party/nmigen
url = https://github.com/m-labs/nmigen.git
[submodule "third_party/litex-boards"]
path = third_party/litex-boards
url = https://github.com/litex-hub/litex-boards
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,14 @@ ifeq ($(FIRMWARE),none)
OVERRIDE_FIRMWARE=--override-firmware=none
FIRMWARE_FBI=
else
ifeq ($(FIRMWARE),clear)
OVERRIDE_FIRMWARE=--override-firmware=clear
FIRMWARE_FBI=
else
OVERRIDE_FIRMWARE=--override-firmware=$(FIRMWARE_FILEBASE).fbi
FIRMWARE_FBI=$(FIRMWARE_FILEBASE).fbi
endif
endif

$(IMAGE_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) $(FIRMWARE_FBI)
$(PYTHON) mkimage.py \
Expand Down
3 changes: 2 additions & 1 deletion gateware/info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

class Info(Module, AutoCSR):
def __init__(self, platform, target_name):
self.submodules.dna = dna.DNA()
self.submodules.git = git.GitInfo()
target = target_name.lower()[:-3]
self.submodules.platform = platform_info.PlatformInfo(platform.name, target)

if "xc" in platform.device:
self.submodules.dna = dna.DNA()
if "xc7" in platform.device:
self.submodules.xadc = xadc.XADC()

138 changes: 125 additions & 13 deletions mkimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,102 @@

import make

from collections import namedtuple


def round(i):
return int(i / 4) * 4


_Region = namedtuple("Region", ["name", "desc", "start", "size"])
class Region(_Region):
def __init__(self, name, desc, start, size):
#_Region.__init__(self, name, start, size, desc)
assert round(start) == start, (
"Start invalid {} != {}".format(start, round(start)))
assert round(size) == size, (
"Size invalid {} != {}".format(size, round(size)))

def __str__(self):
return "Region(0x{:06x}, 0x{:06x}, {:10s}, {})".format(
self.start, self.end, repr(self.name), repr(self.desc))

@property
def end(self):
return self.start + self.size


def get_regions(size_gw, size_bios, size_flash):
"""

>>> regions = get_regions(256, 128, 1000)
>>> for r in regions:
... print(r)
Region(0x000000, 0x000100, 'Gateware', 'FPGA bitstream')
Region(0x000100, 0x000180, 'BIOS' , 'LiteX BIOS with CRC')
Region(0x000180, 0x0003e8, 'Firmware', 'Firmware in FBI format')

"""
region_gw = Region(
"Gateware",
"FPGA bitstream",
0,
round(size_gw),
)
region_bios = Region(
"BIOS",
"LiteX BIOS with CRC",
region_gw.end,
size_bios,
)
size_fw = round(size_flash - region_bios.end)
region_fw = Region(
"Firmware",
"Firmware in FBI format",
region_bios.end,
size_fw,
)
return [region_gw, region_bios, region_fw]


def fill_region(image_fileobj, region, input_filename, fill_zero=False):
"""

Output;
-----
Gateware @ 0x00000000 (using 135100 bytes of 163840 bytes) build/ice40_hx8k_b_evn_base_vexriscv.minimal+debug//gateware/top.bin - FPGA Bitstream
ff 00 00 ff 7e aa 99 7e 51 00 01 05 92 00 21 62 03 67 72 01 10 82 00 00 11 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-----

{name } @ {start } (using {input_len} bytes of {length } bytes) {input_fn} - {desc}
{hex file data}
"""

if inputfile:
input_data = open(input_filename, "rb").read()
input_size = len(input_data)
input_result = "Loaded from {}".format(input_filename)
else:
input_data = b""
input_size = len(input_data)
input_result = "Skipped"

# "{name:08s} @ 0x{start:08x} "
# "(using {input_size:10} bytes of {:10} bytes - {:02.2)%) {:60s} - {}"

#print(
# "{:08s} @ 0x{:08x} (using {:10} bytes of {:10} bytes - {:02.2)% {:60s} - {}"
#).format()

print(" ".join("{:02x}".format(i) for i in input_data[:64]))
assert input_size < region.size
assert f.tell() < region.start, "{} < {}".format(f.tell(), region.start)
f.seek(region.start)
f.write(input_data)
if fill_zero:
while f.tell() < region.end:
f.write('\0')


def main():
parser = argparse.ArgumentParser(description=__doc__)
Expand Down Expand Up @@ -56,8 +152,9 @@ def main():

firmware = make.get_firmware(builddir, "flash")
if args.override_firmware:
if args.override_firmware.lower() == "none":
if args.override_firmware.lower() in ("none", "clear"):
firmware = None
args.firmware_name = args.override_firmware
else:
firmware = args.override_firmware
if firmware:
Expand All @@ -75,6 +172,10 @@ def main():
bios_pos = platform.gateware_size
firmware_pos = platform.gateware_size + bios_size

flash_size = platform.spiflash_total_size
if args.force_image_size and args.force_image_size.lower() not in ("true", "1"):
flash_size = int(args.force_image_size)

print()
with open(output_file, "wb") as f:
# FPGA gateware
Expand All @@ -84,9 +185,13 @@ def main():
gateware_data = b""
gateware = "Skipped"

print(("Gateware @ 0x{:08x} ({:10} bytes) {:60}"
print(("Gateware @ 0x{:08x} (using {:10} bytes of {:10} bytes) {:60}"
" - FPGA Bitstream"
).format(gateware_pos, len(gateware_data), gateware))
).format(
gateware_pos,
len(gateware_data),
bios_pos - gateware_pos,
gateware))
print(" ".join("{:02x}".format(i) for i in gateware_data[:64]))
assert len(gateware_data) < platform.gateware_size
f.seek(0)
Expand All @@ -102,22 +207,31 @@ def main():
assert len(bios_data) < bios_size
f.seek(bios_pos)
f.write(bios_data)
print((" BIOS @ 0x{:08x} ({:10} bytes) {:60}"
print((" BIOS @ 0x{:08x} (using {:10} bytes of {:10} bytes) {:60}"
" - LiteX BIOS with CRC"
).format(bios_pos, len(bios_data), bios))
).format(
bios_pos,
len(bios_data),
firmware_pos - bios_pos,
bios))
print(" ".join("{:02x}".format(i) for i in bios_data[:64]))

if firmware:
firmware_data = open(firmware, "rb").read()
else:
firmware_data = b""
firmware = "Skipped"
firmware_data = b"\xff\xff\xff\xff"
firmware = "Cleared"
#firmware_data = b""
#firmware = "Skipped"

# SoftCPU firmware
print(("Firmware @ 0x{:08x} ({:10} bytes) {:60}"
print(("Firmware @ 0x{:08x} (using {:10} bytes of {:10} bytes) {:60}"
" - {} Firmware in FBI format (loaded into DRAM)"
).format(
firmware_pos, len(firmware_data), firmware,
firmware_pos,
len(firmware_data),
flash_size - firmware_pos,
firmware,
args.firmware_name))
print(" ".join("{:02x}".format(i) for i in firmware_data[:64]))
f.seek(firmware_pos)
Expand All @@ -136,10 +250,6 @@ def main():
).format(total, int(total*8/1024/1024), total/1024/1024))

if args.force_image_size:
if args.force_image_size.lower() in ("true", "1"):
flash_size = platform.spiflash_total_size
else:
flash_size = int(args.force_image_size)
f.write(b'\xff' * (flash_size - f.tell()))

print()
Expand All @@ -149,4 +259,6 @@ def main():


if __name__ == "__main__":
import doctest
doctest.testmod()
main()
3 changes: 2 additions & 1 deletion scripts/download-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,14 @@ echo "-----------------------"
# lite
for LITE in $LITE_REPOS; do
LITE_DIR=$THIRD_DIR/$LITE
LITE_MOD=$(echo $LITE | sed -e's/-/_/g')
(
echo
cd $LITE_DIR
echo "Installing $LITE from $LITE_DIR (local python module)"
python setup.py develop
)
check_import $LITE
check_import $LITE_MOD
done

echo "-----------------------"
Expand Down
5 changes: 3 additions & 2 deletions scripts/enter-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,15 @@ echo "-----------------------"

# lite
for LITE in $LITE_REPOS; do
LITE_DIR=$THIRD_DIR/$LITE
LITE_MOD=$(echo $LITE | sed -e's/-/_/g')







check_import $LITE || return 1
check_import $LITE_MOD || return 1
done

echo "-----------------------"
Expand Down
1 change: 1 addition & 0 deletions scripts/settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ LITE_REPOS="
migen
nmigen
litex
litex-boards
litedram
liteeth
litepcie
Expand Down
Loading