basic out-of-tree build support (OK on PPro)
This commit is contained in:
parent
e92d00f767
commit
523377efbe
|
@ -4,8 +4,8 @@
|
|||
[submodule "misoc/cores/mor1kx/verilog"]
|
||||
path = misoc/cores/mor1kx/verilog
|
||||
url = https://github.com/openrisc/mor1kx.git
|
||||
[submodule "misoc/software/compiler-rt"]
|
||||
path = misoc/software/compiler-rt
|
||||
[submodule "misoc/software/compiler_rt"]
|
||||
path = misoc/software/compiler_rt
|
||||
url = http://llvm.org/git/compiler-rt.git
|
||||
[submodule "misoc/software/unwinder"]
|
||||
path = misoc/software/unwinder
|
||||
|
|
20
crc.py
20
crc.py
|
@ -1,20 +0,0 @@
|
|||
import binascii
|
||||
|
||||
|
||||
def insert_crc(i_filename, fbi_mode=False, o_filename=None):
|
||||
if o_filename is None:
|
||||
o_filename = i_filename
|
||||
|
||||
with open(i_filename, 'rb') as f:
|
||||
fdata = f.read()
|
||||
fcrc = binascii.crc32(fdata).to_bytes(4, byteorder="big")
|
||||
flength = len(fdata).to_bytes(4, byteorder="big")
|
||||
|
||||
with open(o_filename, 'wb') as f:
|
||||
if fbi_mode:
|
||||
f.write(flength)
|
||||
f.write(fcrc)
|
||||
f.write(fdata)
|
||||
else:
|
||||
f.write(fdata)
|
||||
f.write(fcrc)
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from migen.util.misc import autotype
|
||||
|
||||
from misoc_import import misoc_import
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Program extra data to flash memory.")
|
||||
parser.add_argument("-f", "--flash-proxy-dir", default=None, help="set search directory for flash proxy bitstreams")
|
||||
parser.add_argument("-X", "--external", default="", help="use external directory for platforms and imports")
|
||||
parser.add_argument("-Op", "--platform-option", default=[], nargs=2, action="append", help="set platform-specific option")
|
||||
parser.add_argument("platform", help="target platform")
|
||||
parser.add_argument("file", help="file to flash")
|
||||
parser.add_argument("address", help="flash address to write")
|
||||
args = parser.parse_args()
|
||||
|
||||
external_platform = ""
|
||||
if args.external:
|
||||
external_platform = os.path.join(args.external, "platforms")
|
||||
sys.path.insert(1, os.path.abspath(args.external))
|
||||
|
||||
platform_module = misoc_import("mibuild.platforms", external_platform, args.platform)
|
||||
platform_kwargs = dict((k, autotype(v)) for k, v in args.platform_option)
|
||||
platform = platform_module.Platform(**platform_kwargs)
|
||||
|
||||
prog = platform.create_programmer()
|
||||
prog.set_flash_proxy_dir(args.flash_proxy_dir)
|
||||
prog.flash(int(args.address, 0), args.file)
|
220
make.py
220
make.py
|
@ -1,220 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
import struct
|
||||
|
||||
from migen.build.tools import write_to_file
|
||||
from migen.util.misc import autotype
|
||||
from migen.fhdl import simplify
|
||||
|
||||
from misoc.integration import cpu_interface
|
||||
from misoc.integration import sdram_init
|
||||
|
||||
from misoc_import import misoc_import
|
||||
|
||||
|
||||
def _get_args():
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
description="""\
|
||||
MiSoC - a high performance and small footprint SoC based on Migen.
|
||||
|
||||
This program builds and/or loads MiSoC components.
|
||||
One or several actions can be specified:
|
||||
|
||||
clean delete previous build(s).
|
||||
build-bitstream build FPGA bitstream. Implies build-bios on targets with
|
||||
integrated BIOS.
|
||||
build-headers build software header files with CPU/CSR/IRQ/SDRAM_PHY definitions.
|
||||
build-csr-csv save CSR map into CSV file.
|
||||
build-bios build BIOS. Implies build-header.
|
||||
|
||||
load-bitstream load bitstream into volatile storage.
|
||||
flash-bitstream load bitstream into non-volatile storage.
|
||||
flash-bios load BIOS into non-volatile storage.
|
||||
|
||||
all clean, build-bitstream, build-bios, flash-bitstream, flash-bios.
|
||||
|
||||
Load/flash actions use the existing outputs, and do not trigger new builds.
|
||||
""")
|
||||
|
||||
parser.add_argument("-t", "--target", default="mlabs_video", help="SoC type to build")
|
||||
parser.add_argument("-s", "--sub-target", default="", help="variant of the SoC type to build")
|
||||
parser.add_argument("-p", "--platform", default=None, help="platform to build for")
|
||||
parser.add_argument("-Ot", "--target-option", default=[], nargs=2, action="append", help="set target-specific option")
|
||||
parser.add_argument("-Op", "--platform-option", default=[], nargs=2, action="append", help="set platform-specific option")
|
||||
parser.add_argument("-X", "--external", default="", help="use external directory for targets, platforms and imports")
|
||||
parser.add_argument("--csr_csv", default="csr.csv", help="CSV file to save the CSR map into")
|
||||
|
||||
parser.add_argument("-d", "--decorate", default=[], action="append", help="apply simplification decorator to top-level")
|
||||
parser.add_argument("-Ob", "--build-option", default=[], nargs=2, action="append", help="set build option")
|
||||
parser.add_argument("-f", "--flash-proxy-dir", default=None, help="set search directory for flash proxy bitstreams")
|
||||
|
||||
parser.add_argument("action", nargs="+", help="specify an action")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = _get_args()
|
||||
|
||||
external_target = ""
|
||||
external_platform = ""
|
||||
if args.external:
|
||||
external_target = os.path.join(args.external, "targets")
|
||||
external_platform = os.path.join(args.external, "platforms")
|
||||
sys.path.insert(0, os.path.abspath(args.external))
|
||||
|
||||
# create top-level SoC object
|
||||
target_module = misoc_import("targets", external_target, args.target)
|
||||
if args.sub_target:
|
||||
top_class = getattr(target_module, args.sub_target)
|
||||
else:
|
||||
top_class = target_module.default_subtarget
|
||||
|
||||
if args.platform is None:
|
||||
if hasattr(top_class, "default_platform"):
|
||||
platform_name = top_class.default_platform
|
||||
else:
|
||||
raise ValueError("Target has no default platform, specify a platform with -p your_platform")
|
||||
else:
|
||||
platform_name = args.platform
|
||||
platform_module = misoc_import("migen.build.platforms", external_platform, platform_name)
|
||||
platform_kwargs = dict((k, autotype(v)) for k, v in args.platform_option)
|
||||
platform = platform_module.Platform(**platform_kwargs)
|
||||
if args.external:
|
||||
platform.soc_ext_path = os.path.abspath(args.external)
|
||||
|
||||
build_name = args.target + "-" + top_class.__name__.lower() + "-" + platform_name
|
||||
top_kwargs = dict((k, autotype(v)) for k, v in args.target_option)
|
||||
soc = top_class(platform, **top_kwargs)
|
||||
soc.finalize()
|
||||
memory_regions = soc.get_memory_regions()
|
||||
csr_regions = soc.get_csr_regions()
|
||||
|
||||
# decode actions
|
||||
action_list = ["clean", "build-bitstream", "build-headers", "build-csr-csv", "build-bios",
|
||||
"load-bitstream", "flash-bitstream", "flash-bios", "all"]
|
||||
actions = {k: False for k in action_list}
|
||||
for action in args.action:
|
||||
if action in actions:
|
||||
actions[action] = True
|
||||
else:
|
||||
print("Unknown action: {}. Valid actions are:".format(action))
|
||||
for a in action_list:
|
||||
print(" "+a)
|
||||
sys.exit(1)
|
||||
|
||||
print("""\
|
||||
__ ___ _ ____ _____
|
||||
/ |/ / (_) / __/__ / ___/
|
||||
/ /|_/ / / / _\ \/ _ \/ /__
|
||||
/_/ /_/ /_/ /___/\___/\___/
|
||||
|
||||
a high performance and small footprint SoC based on Migen
|
||||
|
||||
====== Building for: ======
|
||||
Platform: {}
|
||||
Target: {}
|
||||
Subtarget: {}
|
||||
CPU type: {}
|
||||
===========================""".format(platform_name, args.target, top_class.__name__, soc.cpu_type))
|
||||
|
||||
# dependencies
|
||||
if actions["all"]:
|
||||
actions["clean"] = True
|
||||
actions["build-bitstream"] = True
|
||||
actions["build-bios"] = True
|
||||
if not actions["load-bitstream"]:
|
||||
actions["flash-bitstream"] = True
|
||||
if not soc.integrated_rom_size:
|
||||
actions["flash-bios"] = True
|
||||
if actions["build-bitstream"] and soc.integrated_rom_size:
|
||||
actions["build-bios"] = True
|
||||
if actions["build-bios"]:
|
||||
actions["build-headers"] = True
|
||||
|
||||
if actions["clean"]:
|
||||
subprocess.check_call("rm -rvf build/*", shell=True) # Need shell for the build/* globbing
|
||||
subprocess.check_call(["make", "-C", os.path.join("software", "libcompiler-rt"), "clean"])
|
||||
subprocess.check_call(["make", "-C", os.path.join("software", "libbase"), "clean"])
|
||||
subprocess.check_call(["make", "-C", os.path.join("software", "libnet"), "clean"])
|
||||
subprocess.check_call(["make", "-C", os.path.join("software", "bios"), "clean"])
|
||||
|
||||
if actions["build-headers"]:
|
||||
boilerplate = """/*
|
||||
* Platform: {}
|
||||
* Target: {}
|
||||
* Subtarget: {}
|
||||
* CPU type: {}
|
||||
*/
|
||||
|
||||
""".format(platform_name, args.target, top_class.__name__, soc.cpu_type)
|
||||
genhdir = os.path.join("software", "include", "generated")
|
||||
if soc.cpu_type != "none":
|
||||
cpu_mak = cpu_interface.get_cpu_mak(soc.cpu_type)
|
||||
write_to_file(os.path.join(genhdir, "cpu.mak"), cpu_mak)
|
||||
linker_output_format = cpu_interface.get_linker_output_format(soc.cpu_type)
|
||||
write_to_file(os.path.join(genhdir, "output_format.ld"), linker_output_format)
|
||||
|
||||
linker_regions = cpu_interface.get_linker_regions(memory_regions)
|
||||
write_to_file(os.path.join(genhdir, "regions.ld"), boilerplate + linker_regions)
|
||||
|
||||
for sdram_phy in ["sdrphy", "ddrphy"]:
|
||||
if hasattr(soc, sdram_phy):
|
||||
sdram_phy_header = sdram_init.get_sdram_phy_header(getattr(soc, sdram_phy).settings)
|
||||
write_to_file(os.path.join(genhdir, "sdram_phy.h"), boilerplate + sdram_phy_header)
|
||||
mem_header = cpu_interface.get_mem_header(memory_regions, getattr(soc, "flash_boot_address", None))
|
||||
write_to_file(os.path.join(genhdir, "mem.h"), boilerplate + mem_header)
|
||||
csr_header = cpu_interface.get_csr_header(csr_regions, sorted(soc.get_constants()))
|
||||
write_to_file(os.path.join(genhdir, "csr.h"), boilerplate + csr_header)
|
||||
|
||||
if actions["build-csr-csv"]:
|
||||
csr_csv = cpu_interface.get_csr_csv(csr_regions)
|
||||
write_to_file(args.csr_csv, csr_csv)
|
||||
|
||||
if actions["build-bios"]:
|
||||
ret = subprocess.call(["make", "-C", os.path.join("software", "bios")])
|
||||
if ret:
|
||||
raise OSError("BIOS build failed")
|
||||
|
||||
bios_file = os.path.join("software", "bios", "bios.bin")
|
||||
|
||||
if actions["build-bitstream"]:
|
||||
if soc.integrated_rom_size:
|
||||
with open(bios_file, "rb") as boot_file:
|
||||
boot_data = []
|
||||
while True:
|
||||
w = boot_file.read(4)
|
||||
if not w:
|
||||
break
|
||||
boot_data.append(struct.unpack(">I", w)[0])
|
||||
soc.init_rom(boot_data)
|
||||
|
||||
for decorator in args.decorate:
|
||||
soc = getattr(simplify, decorator)(soc)
|
||||
build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
|
||||
vns = platform.build(soc, build_name=build_name, **build_kwargs)
|
||||
soc.do_exit(vns)
|
||||
|
||||
if actions["load-bitstream"]:
|
||||
prog = platform.create_programmer()
|
||||
prog.load_bitstream(os.path.join("build", build_name + platform.bitstream_ext))
|
||||
|
||||
if actions["flash-bitstream"]:
|
||||
prog = platform.create_programmer()
|
||||
prog.set_flash_proxy_dir(args.flash_proxy_dir)
|
||||
if prog.needs_bitreverse:
|
||||
flashbit = os.path.join("build", build_name + ".fpg")
|
||||
subprocess.check_call([os.path.join("tools", "byteswap"),
|
||||
os.path.join("build", build_name + ".bin"),
|
||||
flashbit])
|
||||
else:
|
||||
flashbit = os.path.join("build", build_name + ".bin")
|
||||
prog.flash(0, flashbit)
|
||||
|
||||
if actions["flash-bios"]:
|
||||
prog = platform.create_programmer()
|
||||
prog.set_flash_proxy_dir(args.flash_proxy_dir)
|
||||
prog.flash(soc.cpu_reset_address, bios_file)
|
|
@ -1,28 +1,16 @@
|
|||
import subprocess
|
||||
|
||||
from migen import *
|
||||
|
||||
from misoc.interconnect.csr import *
|
||||
|
||||
|
||||
def get_id():
|
||||
output = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
|
||||
return int(output[:8], 16)
|
||||
|
||||
|
||||
class Identifier(Module, AutoCSR):
|
||||
def __init__(self, sysid, frequency, revision=None):
|
||||
self._sysid = CSRStatus(16)
|
||||
self._revision = CSRStatus(32)
|
||||
self._frequency = CSRStatus(32)
|
||||
|
||||
###
|
||||
|
||||
if revision is None:
|
||||
revision = get_id()
|
||||
|
||||
self.comb += [
|
||||
self._sysid.status.eq(sysid),
|
||||
self._revision.status.eq(revision),
|
||||
self._frequency.status.eq(frequency)
|
||||
]
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
import os
|
||||
import subprocess
|
||||
import struct
|
||||
|
||||
from misoc.integration import cpu_interface, sdram_init
|
||||
|
||||
|
||||
# in build order (for dependencies)
|
||||
misoc_software_packages = [
|
||||
"libbase",
|
||||
"libcompiler_rt",
|
||||
"libdyld",
|
||||
"libnet",
|
||||
"libunwind",
|
||||
"bios"
|
||||
]
|
||||
|
||||
|
||||
misoc_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
|
||||
class Builder:
|
||||
def __init__(self, soc, output_dir):
|
||||
self.soc = soc
|
||||
# From Python doc: makedirs() will become confused if the path
|
||||
# elements to create include '..'
|
||||
self.output_dir = os.path.abspath(output_dir)
|
||||
|
||||
self.software_packages = []
|
||||
for name in misoc_software_packages:
|
||||
self.add_software_package(
|
||||
name, os.path.join(misoc_directory, "software", name))
|
||||
|
||||
def add_software_package(self, name, src_dir):
|
||||
self.software_packages.append((name, src_dir))
|
||||
|
||||
def _generate_includes(self):
|
||||
cpu_type = self.soc.cpu_type
|
||||
memory_regions = self.soc.get_memory_regions()
|
||||
flash_boot_address = getattr(self.soc, "flash_boot_address", None)
|
||||
csr_regions = self.soc.get_csr_regions()
|
||||
constants = self.soc.get_constants()
|
||||
# TODO: cleanup
|
||||
sdram_phy_settings = None
|
||||
for sdram_phy in "sdrphy", "ddrphy":
|
||||
if hasattr(self.soc, sdram_phy):
|
||||
sdram_phy_settings = getattr(self.soc, sdram_phy).settings
|
||||
|
||||
buildinc_dir = os.path.join(self.output_dir, "software", "include")
|
||||
generated_dir = os.path.join(buildinc_dir, "generated")
|
||||
os.makedirs(generated_dir, exist_ok=True)
|
||||
with open(os.path.join(generated_dir, "variables.mak"), "w") as f:
|
||||
def define(k, v):
|
||||
f.write("{}={}\n".format(k, v))
|
||||
for k, v in cpu_interface.get_cpu_mak(cpu_type):
|
||||
define(k, v)
|
||||
define("MISOC_DIRECTORY", misoc_directory)
|
||||
define("BUILDINC_DIRECTORY", buildinc_dir)
|
||||
for name, src_dir in self.software_packages:
|
||||
define(name.upper() + "_DIRECTORY", src_dir)
|
||||
|
||||
with open(os.path.join(generated_dir, "output_format.ld"), "w") as f:
|
||||
f.write(cpu_interface.get_linker_output_format(cpu_type))
|
||||
with open(os.path.join(generated_dir, "regions.ld"), "w") as f:
|
||||
f.write(cpu_interface.get_linker_regions(memory_regions))
|
||||
|
||||
with open(os.path.join(generated_dir, "mem.h"), "w") as f:
|
||||
f.write(cpu_interface.get_mem_header(memory_regions, flash_boot_address))
|
||||
with open(os.path.join(generated_dir, "csr.h"), "w") as f:
|
||||
f.write(cpu_interface.get_csr_header(csr_regions, constants))
|
||||
|
||||
if sdram_phy_settings is not None:
|
||||
with open(os.path.join(generated_dir, "sdram_phy.h"), "w") as f:
|
||||
f.write(sdram_init.get_sdram_phy_header(sdram_phy_settings))
|
||||
|
||||
def _generate_software(self, compile):
|
||||
for name, src_dir in self.software_packages:
|
||||
dst_dir = os.path.join(self.output_dir, "software", name)
|
||||
os.makedirs(dst_dir, exist_ok=True)
|
||||
src = os.path.join(src_dir, "Makefile")
|
||||
dst = os.path.join(dst_dir, "Makefile")
|
||||
try:
|
||||
os.remove(dst)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
os.symlink(src, dst)
|
||||
if compile:
|
||||
subprocess.check_call(["make", "-C", dst_dir])
|
||||
|
||||
def _initialize_rom(self):
|
||||
bios_file = os.path.join(self.output_dir, "software" "bios",
|
||||
"bios.bin")
|
||||
if self.soc.integrated_rom_size:
|
||||
with open(bios_file, "rb") as boot_file:
|
||||
boot_data = []
|
||||
while True:
|
||||
w = boot_file.read(4)
|
||||
if not w:
|
||||
break
|
||||
boot_data.append(struct.unpack(">I", w)[0])
|
||||
self.soc.initialize_rom(boot_data)
|
||||
|
||||
def build(self, compile_software=True, compile_gateware=True):
|
||||
self.soc.finalize()
|
||||
|
||||
if self.soc.integrated_rom_size and not compile_software:
|
||||
raise ValueError("Software must be compiled in order to "
|
||||
"intitialize integrated ROM")
|
||||
|
||||
self._generate_includes()
|
||||
self._generate_software(compile_software)
|
||||
self._initialize_rom()
|
||||
self.soc.build(build_dir=os.path.join(self.output_dir, "gateware"),
|
||||
run=compile_gateware)
|
|
@ -3,18 +3,23 @@ from migen import *
|
|||
from misoc.interconnect.csr import CSRStatus
|
||||
|
||||
|
||||
def get_cpu_mak(cpu_type):
|
||||
if cpu_type == "lm32":
|
||||
def get_cpu_mak(cpu):
|
||||
if cpu == "lm32":
|
||||
triple = "lm32-elf"
|
||||
cpuflags = "-mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled"
|
||||
clang = ""
|
||||
elif cpu_type == "or1k":
|
||||
elif cpu == "or1k":
|
||||
triple = "or1k-linux"
|
||||
cpuflags = "-mhard-mul -mhard-div -mror -mffl1 -maddc"
|
||||
clang = "1"
|
||||
else:
|
||||
raise ValueError("Unsupported CPU type: "+cpu_type)
|
||||
return "TRIPLE={}\nCPU={}\nCPUFLAGS={}\nCLANG={}".format(triple, cpu_type, cpuflags, clang)
|
||||
raise ValueError("Unsupported CPU type: "+cpu)
|
||||
return [
|
||||
("TRIPLE", triple),
|
||||
("CPU", cpu),
|
||||
("CPUFLAGS", cpuflags),
|
||||
("CLANG", clang)
|
||||
]
|
||||
|
||||
|
||||
def get_linker_output_format(cpu_type):
|
||||
|
|
|
@ -116,7 +116,7 @@ class SoCCore(Module):
|
|||
raise NotImplementedError("More than one CPU is not supported")
|
||||
self.submodules.cpu_or_bridge = cpu_or_bridge
|
||||
|
||||
def init_rom(self, data):
|
||||
def initialize_rom(self, data):
|
||||
self.rom.mem.init = data
|
||||
|
||||
def add_wb_master(self, wbm):
|
||||
|
@ -200,3 +200,6 @@ class SoCCore(Module):
|
|||
for k, v in sorted(self.interrupt_map.items(), key=itemgetter(1)):
|
||||
if hasattr(self, k):
|
||||
self.comb += self.cpu_or_bridge.interrupt[v].eq(getattr(self, k).ev.irq)
|
||||
|
||||
def build(self, *args, **kwargs):
|
||||
self.platform.build(self, *args, **kwargs)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MSCDIR=../..
|
||||
include $(MSCDIR)/software/common.mak
|
||||
include ../include/generated/variables.mak
|
||||
include $(MISOC_DIRECTORY)/software/common.mak
|
||||
|
||||
OBJECTS=isr.o sdram.o main.o boot-helper-$(CPU).o boot.o dataflow.o
|
||||
|
||||
|
@ -11,35 +11,30 @@ all: bios.bin
|
|||
%.bin: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
chmod -x $@
|
||||
$(MSCDIR)/mkmscimg.py $@
|
||||
$(PYTHON) -m misoc.tools.mkmscimg $@
|
||||
|
||||
bios.elf: linker.ld $(OBJECTS) libs
|
||||
bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
|
||||
|
||||
%.elf:
|
||||
$(LD) $(LDFLAGS) -T $< -N -o $@ \
|
||||
$(MSCDIR)/software/libbase/crt0-$(CPU).o \
|
||||
../libbase/crt0-$(CPU).o \
|
||||
$(OBJECTS) \
|
||||
-L$(MSCDIR)/software/libnet \
|
||||
-L$(MSCDIR)/software/libbase \
|
||||
-L$(MSCDIR)/software/libcompiler-rt \
|
||||
-lnet -lbase-nofloat -lcompiler-rt
|
||||
-L../libnet \
|
||||
-L../libbase \
|
||||
-L../libcompiler_rt \
|
||||
-lnet -lbase-nofloat -lcompiler_rt
|
||||
chmod -x $@
|
||||
|
||||
main.o: main.c
|
||||
main.o: $(BIOS_DIRECTORY)/main.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: %.c
|
||||
%.o: $(BIOS_DIRECTORY)/%.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: %.S
|
||||
%.o: $(BIOS_DIRECTORY)/%.S
|
||||
$(assemble)
|
||||
|
||||
libs:
|
||||
$(MAKE) -C $(MSCDIR)/software/libcompiler-rt
|
||||
$(MAKE) -C $(MSCDIR)/software/libbase
|
||||
$(MAKE) -C $(MSCDIR)/software/libnet
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) bios.elf bios.bin .*~ *~
|
||||
|
||||
.PHONY: all main.o clean libs
|
||||
.PHONY: all main.o clean
|
||||
|
|
|
@ -377,8 +377,6 @@ static void do_command(char *c)
|
|||
else if(strcmp(token, "netboot") == 0) netboot();
|
||||
#endif
|
||||
|
||||
else if(strcmp(token, "revision") == 0) printf("%08x\n", MSC_GIT_ID);
|
||||
|
||||
else if(strcmp(token, "help") == 0) help();
|
||||
|
||||
#ifdef __lm32__
|
||||
|
@ -535,9 +533,9 @@ int main(int i, char **c)
|
|||
irq_setmask(0);
|
||||
irq_setie(1);
|
||||
uart_init();
|
||||
puts("\nMiSoC BIOS http://m-labs.hk\n"
|
||||
"(c) Copyright 2007-2014 Sebastien Bourdeauducq");
|
||||
printf("Revision %08x built "__DATE__" "__TIME__"\n\n", MSC_GIT_ID);
|
||||
puts("\nMiSoC BIOS\n"
|
||||
"(c) Copyright 2007-2015 M-Labs Limited\n"
|
||||
"Built "__DATE__" "__TIME__"\n");
|
||||
crcbios();
|
||||
id_print();
|
||||
#ifdef CSR_ETHMAC_BASE
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
include $(MSCDIR)/software/include/generated/cpu.mak
|
||||
TARGET_PREFIX=$(TRIPLE)-
|
||||
|
||||
RM ?= rm -f
|
||||
|
@ -21,8 +20,6 @@ AR_quiet = @echo " AR " $@ && $(AR_normal)
|
|||
LD_quiet = @echo " LD " $@ && $(LD_normal)
|
||||
OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(OBJCOPY_normal)
|
||||
|
||||
MSC_GIT_ID := $(shell cd $(MSCDIR) && $(PYTHON) -c "from misoc.cores.identifier import get_id; print(hex(get_id()), end='')")
|
||||
|
||||
ifeq ($(V),1)
|
||||
CC = $(CC_normal)
|
||||
CX = $(CX_normal)
|
||||
|
@ -39,11 +36,11 @@ endif
|
|||
|
||||
# Toolchain options
|
||||
#
|
||||
INCLUDES = -I$(MSCDIR)/software/include/base -I$(MSCDIR)/software/include -I$(MSCDIR)/common
|
||||
COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc -DMSC_GIT_ID=$(MSC_GIT_ID) $(INCLUDES)
|
||||
INCLUDES = -I$(MISOC_DIRECTORY)/software/include/base -I$(MISOC_DIRECTORY)/software/include -I$(MISOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY)
|
||||
COMMONFLAGS = -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES)
|
||||
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
||||
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MSCDIR)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
|
||||
LDFLAGS = -nostdlib -nodefaultlibs -L$(MSCDIR)/software/include
|
||||
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(MISOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
|
||||
LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY)
|
||||
|
||||
# compile and generate dependencies, based on
|
||||
# http://scottmcpeak.com/autodepend/autodepend.html
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MSCDIR=../..
|
||||
include $(MSCDIR)/software/common.mak
|
||||
include ../include/generated/variables.mak
|
||||
include $(MISOC_DIRECTORY)/software/common.mak
|
||||
|
||||
OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o system.o id.o uart.o time.o qsort.o strtod.o spiflash.o
|
||||
|
||||
|
@ -14,13 +14,13 @@ libbase.a: $(OBJECTS) vsnprintf.o
|
|||
libbase-nofloat.a: $(OBJECTS) vsnprintf-nofloat.o
|
||||
$(AR) crs libbase-nofloat.a $(OBJECTS) vsnprintf-nofloat.o
|
||||
|
||||
vsnprintf-nofloat.o: vsnprintf.c
|
||||
vsnprintf-nofloat.o: $(LIBBASE_DIRECTORY)/vsnprintf.c
|
||||
$(call compile-dep,-DNO_FLOAT)
|
||||
|
||||
%.o: %.c
|
||||
%.o: $(LIBBASE_DIRECTORY)/%.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: %.S
|
||||
%.o: $(LIBBASE_DIRECTORY)/%.S
|
||||
$(assemble)
|
||||
|
||||
.PHONY: clean
|
||||
|
|
|
@ -16,5 +16,5 @@ void id_print(void)
|
|||
char sysid[3];
|
||||
|
||||
get_sysid_formatted(sysid);
|
||||
printf("Running on MiSoC rev. %08x (sysid:%s) at %dMHz\n", identifier_revision_read(), sysid, identifier_frequency_read()/1000000);
|
||||
printf("Running on MiSoC (sysid:%s) at %dMHz\n", sysid, identifier_frequency_read()/1000000);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MSCDIR=../..
|
||||
include $(MSCDIR)/software/common.mak
|
||||
include ../include/generated/variables.mak
|
||||
include $(MISOC_DIRECTORY)/software/common.mak
|
||||
|
||||
CFLAGS+=-D_YUGA_LITTLE_ENDIAN=0 -D_YUGA_BIG_ENDIAN=1 -Wno-missing-prototypes
|
||||
|
||||
|
@ -7,18 +7,18 @@ OBJECTS=divsi3.o modsi3.o comparedf2.o negsf2.o negdf2.o addsf3.o subsf3.o mulsf
|
|||
floatsisf.o floatunsisf.o fixsfsi.o fixdfdi.o fixunssfsi.o adddf3.o subdf3.o muldf3.o divdf3.o floatsidf.o floatunsidf.o floatdidf.o fixdfsi.o fixunsdfsi.o \
|
||||
clzsi2.o ctzsi2.o udivdi3.o umoddi3.o moddi3.o ucmpdi2.o
|
||||
|
||||
all: libcompiler-rt.a
|
||||
all: libcompiler_rt.a
|
||||
|
||||
# pull in dependency info for *existing* .o files
|
||||
-include $(OBJECTS:.o=.d)
|
||||
|
||||
libcompiler-rt.a: $(OBJECTS)
|
||||
$(AR) crs libcompiler-rt.a $(OBJECTS)
|
||||
libcompiler_rt.a: $(OBJECTS)
|
||||
$(AR) crs libcompiler_rt.a $(OBJECTS)
|
||||
|
||||
%.o: $(MSCDIR)/software/compiler-rt/lib/builtins/%.c
|
||||
%.o: $(MISOC_DIRECTORY)/software/compiler_rt/lib/builtins/%.c
|
||||
$(compile-dep)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libcompiler-rt.a .*~ *~
|
||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libcompiler_rt.a .*~ *~
|
|
@ -1,7 +1,7 @@
|
|||
MSCDIR=../..
|
||||
include $(MSCDIR)/software/common.mak
|
||||
include ../include/generated/variables.mak
|
||||
include $(MISOC_DIRECTORY)/software/common.mak
|
||||
|
||||
COMMONFLAGS += -I$(MSCDIR)/software/include/dyld
|
||||
COMMONFLAGS += -I$(MISOC_DIRECTORY)/software/include/dyld
|
||||
|
||||
OBJECTS=dyld.o
|
||||
|
||||
|
@ -13,6 +13,9 @@ all: libdyld.a
|
|||
libdyld.a: $(OBJECTS)
|
||||
$(AR) crs libdyld.a $(OBJECTS)
|
||||
|
||||
%.o: $(LIBDYLD_DIRECTORY)/%.c
|
||||
$(compile-dep)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MSCDIR=../..
|
||||
include $(MSCDIR)/software/common.mak
|
||||
include ../include/generated/variables.mak
|
||||
include $(MISOC_DIRECTORY)/software/common.mak
|
||||
|
||||
OBJECTS=microudp.o tftp.o
|
||||
|
||||
|
@ -11,7 +11,7 @@ all: libnet.a
|
|||
libnet.a: $(OBJECTS)
|
||||
$(AR) crs libnet.a $(OBJECTS)
|
||||
|
||||
%.o: %.c
|
||||
%.o: $(LIBNET_DIRECTORY)/%.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: %.S
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
MSCDIR=../..
|
||||
include $(MSCDIR)/software/common.mak
|
||||
include ../include/generated/variables.mak
|
||||
include $(MISOC_DIRECTORY)/software/common.mak
|
||||
|
||||
COMMONFLAGS+=-integrated-as \
|
||||
-I. -I$(MSCDIR)/software/include/dyld/ -I$(MSCDIR)/software/unwinder/include/ \
|
||||
-I. -I$(MISOC_DIRECTORY)/software/include/dyld/ -I$(MISOC_DIRECTORY)/software/unwinder/include/ \
|
||||
-I$(LIBUNWIND_DIRECTORY) \
|
||||
-D__ELF__ -D__linux__ -D_LIBUNWIND_NO_HEAP -DNDEBUG
|
||||
|
||||
OBJECTS=UnwindRegistersSave.o UnwindRegistersRestore.o UnwindLevel1.o libunwind.o
|
||||
|
@ -15,16 +16,16 @@ all: libunwind.a
|
|||
libunwind.a: $(OBJECTS)
|
||||
$(AR) crs libunwind.a $(OBJECTS)
|
||||
|
||||
%.o: $(MSCDIR)/software/unwinder/src/%.cpp
|
||||
%.o: $(MISOC_DIRECTORY)/software/unwinder/src/%.cpp
|
||||
$(compilexx-dep)
|
||||
|
||||
%.o: $(MSCDIR)/software/unwinder/src/%.c
|
||||
%.o: $(MISOC_DIRECTORY)/software/unwinder/src/%.c
|
||||
$(compile-dep)
|
||||
|
||||
%.o: $(MSCDIR)/software/unwinder/src/%.S
|
||||
%.o: $(MISOC_DIRECTORY)/software/unwinder/src/%.S
|
||||
$(assemble)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libuwind.a .*~ *~
|
||||
$(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libunwind.a .*~ *~
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from fractions import Fraction
|
||||
|
||||
from migen import *
|
||||
from migen.genlib.resetsync import AsyncResetSynchronizer
|
||||
from migen.build.platforms import papilio_pro
|
||||
|
||||
from misoc.cores.sdram_settings import MT48LC4M16
|
||||
from misoc.cores.sdram_phy import GENSDRPHY
|
||||
from misoc.cores.lasmicon.core import LASMIconSettings
|
||||
from misoc.cores import spi_flash
|
||||
from misoc.integration.soc_sdram import SoCSDRAM
|
||||
from misoc.integration.builder import Builder
|
||||
|
||||
|
||||
class _CRG(Module):
|
||||
|
@ -62,8 +66,6 @@ class _CRG(Module):
|
|||
|
||||
|
||||
class BaseSoC(SoCSDRAM):
|
||||
default_platform = "papilio_pro"
|
||||
|
||||
csr_map = {
|
||||
"spiflash": 16,
|
||||
}
|
||||
|
@ -89,4 +91,12 @@ class BaseSoC(SoCSDRAM):
|
|||
self.flash_boot_address = 0x70000
|
||||
self.register_rom(self.spiflash.bus)
|
||||
|
||||
default_subtarget = BaseSoC
|
||||
|
||||
def main():
|
||||
soc = BaseSoC(papilio_pro.Platform(), cpu_type="or1k")
|
||||
builder = Builder(soc, "misoc_build")
|
||||
builder.build()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import binascii
|
||||
|
||||
|
||||
def insert_crc(i_filename, fbi_mode=False, o_filename=None):
|
||||
if o_filename is None:
|
||||
o_filename = i_filename
|
||||
|
||||
with open(i_filename, "rb") as f:
|
||||
fdata = f.read()
|
||||
fcrc = binascii.crc32(fdata).to_bytes(4, byteorder="big")
|
||||
flength = len(fdata).to_bytes(4, byteorder="big")
|
||||
|
||||
with open(o_filename, "wb") as f:
|
||||
if fbi_mode:
|
||||
f.write(flength)
|
||||
f.write(fcrc)
|
||||
f.write(fdata)
|
||||
else:
|
||||
f.write(fdata)
|
||||
f.write(fcrc)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="CRC32 computation tool and MiSoC image file writer.")
|
||||
parser.add_argument("input", help="input file")
|
||||
parser.add_argument("-o", "--output", default=None, help="output file (if not specified, use input file)")
|
||||
parser.add_argument("-f", "--fbi", default=False, action="store_true", help="build flash boot image (FBI) file")
|
||||
args = parser.parse_args()
|
||||
insert_crc(args.input, args.fbi, args.output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,17 +0,0 @@
|
|||
import sys
|
||||
import importlib
|
||||
|
||||
|
||||
def misoc_import(default, external, name):
|
||||
if external:
|
||||
try:
|
||||
del sys.modules[name] # force external path search
|
||||
except KeyError:
|
||||
pass
|
||||
loader = importlib.find_loader(name, [external])
|
||||
if loader is None:
|
||||
# try internal import
|
||||
return importlib.import_module(default + "." + name)
|
||||
return loader.load_module()
|
||||
else:
|
||||
return importlib.import_module(default + "." + name)
|
12
mkmscimg.py
12
mkmscimg.py
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import crc
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="CRC32 computation tool and MiSoC image file writer.")
|
||||
parser.add_argument("input", help="input file")
|
||||
parser.add_argument("-o", "--output", default=None, help="output file (if not specified, use input file)")
|
||||
parser.add_argument("-f", "--fbi", default=False, action="store_true", help="build flash boot image (FBI) file")
|
||||
args = parser.parse_args()
|
||||
crc.insert_crc(args.input, args.fbi, args.output)
|
|
@ -1,13 +0,0 @@
|
|||
TARGETS=byteswap
|
||||
CC=gcc
|
||||
RM ?= rm -f
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
%: %.c
|
||||
$(CC) -O2 -Wall -I../common -s -o $@ $<
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGETS)
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* MiSoC
|
||||
* Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fdi, *fdo;
|
||||
unsigned short wi;
|
||||
unsigned short wo;
|
||||
int i;
|
||||
|
||||
if(argc != 3) {
|
||||
fprintf(stderr, "Usage: byteswap <infile> <outfile>\n");
|
||||
return 1;
|
||||
}
|
||||
fdi = fopen(argv[1], "rb");
|
||||
if(!fdi) {
|
||||
perror("Unable to open input file");
|
||||
return 1;
|
||||
}
|
||||
fdo = fopen(argv[2], "w");
|
||||
if(!fdo) {
|
||||
perror("Unable to open output file");
|
||||
fclose(fdi);
|
||||
return 1;
|
||||
}
|
||||
while(1) {
|
||||
if(fread(&wi, 2, 1, fdi) <= 0) break;
|
||||
wo = 0;
|
||||
for(i=0;i<16;i++)
|
||||
if(wi & (1 << i))
|
||||
wo |= (0x8000 >> i);
|
||||
/* comment out the next line on big endian machines! */
|
||||
wo = ((wo & 0x00ff) << 8) | ((wo & 0xff00) >> 8);
|
||||
fwrite(&wo, 2, 1, fdo);
|
||||
}
|
||||
fclose(fdi);
|
||||
if(fclose(fdo) != 0) {
|
||||
perror("Unable to close output file");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue