Skip to content

Commit 84389e0

Browse files
authored
LimeSDR-mini-v2 Board definition file
1 parent 5bc4e53 commit 84389e0

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

amaranth_boards/limesdr_mini_v2.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import os
2+
import subprocess
3+
4+
from amaranth.build import *
5+
from amaranth.vendor.lattice_ecp5 import *
6+
from .resources import *
7+
8+
9+
__all__ = ["LimeSDRminiv2Platform"]
10+
11+
12+
class LimeSDRminiv2Platform(LatticeECP5Platform):
13+
device = "LFE5U-45F"
14+
package = "MG285"
15+
speed = "6"
16+
default_clk = "clk40"
17+
#default_rst = "rst"
18+
19+
resources = [
20+
#Resource("rst", 0, PinsN("G2", dir="i"), Attrs(IO_TYPE="LVCMOS33")),
21+
Resource("clk40", 0, Pins("A9", dir="i"),
22+
Clock(40e6), Attrs(IO_TYPE="LVCMOS33")),
23+
24+
*LEDResources(pins="R16 M18 T17 V17 R18 R17", invert=True, # Shared with GPIO pins GPIO 4-7
25+
attrs=Attrs(IO_TYPE="LVCMOS33")),
26+
27+
# In order to use the UART as a UART you need to solder on a header,
28+
# and potentially reconfigure the onboard FTDI chip, I used Pins GPIO0 and GPIO1 on J3
29+
# Which translates to Pins FPGA N15 = FPGA_GPIO0 = TX, N18 = FPGA_GPIO1 = RX
30+
# Still needs to be done on my board to test, code is just a place holder...
31+
32+
UARTResource(0,
33+
rx="N18", tx="N15",
34+
#attrs=Attrs(IO_TYPE=bank6_iostandard, PULLMODE="UP")
35+
attrs=Attrs(IO_TYPE="LVCMOS33", PULLMODE="UP")
36+
),
37+
38+
# Have a question about RGB LEDS. Apparently the LimeSDR-mini-v2 only has 2 colour LEDS.
39+
# not 3, so it's Red and Green, but creates yellow with both green and red.
40+
# The RGB resource would need to be changed to relect that.
41+
# Commented out for now.
42+
43+
#RGBLEDResource(0, r="V17", g="R16", b=" ", attrs=Attrs(IOSTANDARD="LVCMOS33")),
44+
#RGBLEDResource(1, r="R18", g="M18", b=" ", attrs=Attrs(IOSTANDARD="LVCMOS33")),
45+
#RGBLEDResource(2, r="R17", g="T17", b=" ", attrs=Attrs(IOSTANDARD="LVCMOS33")),
46+
47+
*SPIFlashResources(0,
48+
cs_n="U17", clk="U16", cipo="U18", copi="T18", attrs=Attrs(IO_TYPE="LVCMOS33")
49+
),
50+
51+
52+
Resource("i2c", 0,
53+
Subsignal("scl", Pins("C10", dir="io")),
54+
Subsignal("sda", Pins("B9", dir="io")),
55+
#Subsignal("scl_pullup", Pins("A14", dir="o")),
56+
#Subsignal("sda_pullup", Pins("A13", dir="o")),
57+
Attrs(IOSTANDARD="LVCMOS33")
58+
)
59+
]
60+
61+
# TODO: add other resources
62+
connectors = [
63+
# Expansion connectors
64+
Connector("J", 39, "A10 A8"), #FPGA_EGIO 0 and 1 to keep Amaranth-Boards Happy..
65+
]
66+
67+
@property
68+
def file_templates(self):
69+
return {
70+
**super().file_templates,
71+
"{{name}}-openocd.cfg": r"""
72+
adapter driver ftdi
73+
#ftdi_device_desc "Lattice ECP5 Evaluation Board"
74+
ftdi_vid_pid 0x0403 0x6010
75+
ftdi_channel 0
76+
ftdi_layout_init 0xfff8 0xfffb
77+
reset_config none
78+
adapter speed 250000
79+
80+
jtag newtap ecp5 tap -irlen 8 -expected-id 0x41112043
81+
"""
82+
}
83+
84+
def toolchain_program(self, products, name):
85+
openocd = os.environ.get("OPENOCD", "openocd")
86+
with products.extract("{}-openocd.cfg".format(name), "{}.svf".format(name)) \
87+
as (config_filename, vector_filename):
88+
subprocess.check_call([openocd,
89+
"-f", config_filename,
90+
"-c", "transport select jtag; init; svf -quiet {}; exit".format(vector_filename)
91+
])
92+
93+
94+
if __name__ == "__main__":
95+
from .test.blinky import *
96+
# LimeSDRminiv2Platform().build(Blinky(), do_program=False)
97+
LimeSDRminiv2Platform().build(Blinky(), do_program=True)

0 commit comments

Comments
 (0)