Getting started with Lattice ECP3 Versa Dev Kit - hpaluch/hpaluch.github.io GitHub Wiki
Here is an guide how to get started using Lattice ECP3 Versa Dev Kit
Hardware requirements:
- having Lattice ECP3 Versa Dev Kit card and USB to Mini cable (note that USB Mini connector is less common - today most devices have USB Micro)
- having PC (or PC with VirtualBox) with at least:
- USB 2.0 port
- 2GB RAM or more (used 1.8GB for VM in VirtualBox, to avoid warning - because ZOTAC has 3.8GB of memory and VM should use no more than 1/2 of host physical memory)
- 30GB of free disk space or more
In my case I used:
- For Host:
- ZOTAC CI327 Nano passive cooled PC with 4GB RAM, 32GB SSD, and external 1TB USB disk (for VirtualBox images)
- Windows 10 Home N, 64-bit
- SW for virtualization:
- VirtualBox 5.2.2 from VirtualBox Download Page
- VirtualBox 5.2.2 Oracle VM VirtualBox Extension Pack required for USB 2.0 Passthrough
- SW for guest OS: Windows 7, 64-bit
Software setup
Download and install Diamond 3.10 64-bit for Windows to your guest OS. Keep all components selected.
Request Diamond LatticeECP3 Versa Kit Free License.
You should receive license.dat
(valid for 1-Year) to your registration e-mail.
Copy your license.dat
to C:\lscc\diamond\3.10_x64\license\license.dat
.
NOTE: verify your own environment setting in CMD.EXE
in case of problems:
echo %lm_license_file%
C:\lscc\diamond\3.10_x64\license\license.dat;
USB Passthrough setup
If you are using VirtualBox VM (recommended for flexibility and easy backups) then you need to prepare USB 2.0 Passthrough:
- Do NOT insert Dev-Kit Card into PC (PCI Express slot!) - leave that card alone
- Connect 12V Power Supply to Dev-Kit Card (it is included in Dev-Kit)
- Connect Card to USB 2.0 port via USB Mini cable (it is included in Dev-Kit)
In VirtualBox:
- select your VM and click on
Settings
- click on
USB
- check-on
Enable USB
- select
USB 2.0 (EHCI) Controller
- click on
USB Socket
icon with+
- select device
FTDI Dual RS232-HS [0700]
(this is our Dev-Kit card)
Installing FTDI Drivers
- Disconnect your Dev-Kit Card from USB
- Start your Guest OS
- From Start Menu run
All Programs
->Lattice Diamond 3.10 (64-bit)
->Accessories
->Install&Uninstall Cable Drivers
- Use same Setup as in Getting started with ispMACH 4256ZE Breakout Board, that is:
- select radio-button
FTDI Windows USB Driver
- click on
Install
- when requested - connect your Dev-Kit card to USB
- wait for a few second (until "Driver installation failed" appears on Windows systray)
- than click on
Yes
(that you have connected USB cable) - after a while there should appear dialog that
Installation was successful
- click on
Close
button of installation dialog.
- select radio-button
Your system is now ready for Development/Programming
Programming LED demo
- Download nice tutorial from Lattice Diamond Tutorial
- you should get
LatticeDiamondTutorial310.pdf
from above link - this file contains full LED tutorial exactly for our Versa Dev-Kit board
- follow instructions in this tutorial.
Also I strongly recommend to download LatticeECP3VersaEvaluationBoardUsersGuide.pdf
from LatticeECP3 Versa Evaluation Board User's Guide.
There is lot of important information (for example how is demo hardware connected to FPGA etc.).
Notes
Make program persistent in FPGA
By default, programmed FPGA is transient (program is lost on power-off!!!). This is because FGPA itself (unlike CPLD - including ispMach) does not contain persistent Flash Memory.
Fortunately there is solution - there is connected external Flash via SPI interface.
If you referenced LED tutorial you just need to:
- Boot your Guest OS with installed software
- Connect 12V Power Supply to Dev-Kit
- Connect Dev-Kit card to USB
- Run
All Programs
->Lattice Diamond 3.10 (64-bit)
->Accessories
->Diamond Programmer
- Open XCF created by
Diamond Programmer
in LED tutorial - Just to ensure that there is correct BIT file - in my case
C:/projects/LEDtest/LEDtest/LEDtest_LEDtest.bit
- Ensure that DIPs J1 to J5 are ON.
- You may J7 also turn ON, and J6 turn OFF (counter in Up mode)
- click on
Design
->Program
to download LED demo to FPGA (again transient) It takes 5s on my hardware.
To program SPI Flash memory we try to follow When you look at LatticeECP3VersaEvaluationBoardUsersGuide.pdf
there are basic instructions on Page 5, chapter Programming Serial SPI Flash Memory
.
However we need to adapt that guide from ispVM
to Diamond Programmer
:
IMPORTANT! Do not use more than one Device line in
Programmer
- it behaves VERY strangely...
- Save/Close your current XCF project used for transient programming of FPGA - for example
to
C:\projects\LEDtest\LEDtest\fpga_ram.xcf
- in
Diamond Programmer
click onNew File...
- keep default Cable: and Port: (should be OK)
- click on
OK
- confirm close of previous XCF project
- fill in:
- Device Family:
LatticeECP3
(should be already selected) - Device:
LFE3-35EA
(must be selected manually)
- Device Family:
- Right-click on this new row and select
Device Properties...
- change Access Mode: to
SPI Flash Background Programming
- Operation: should be kept
SPI Erase, Program, Verify
- change SPI Flash Options to:
- Family:
SPI Serial Flash
(should be already selected) - Vendor:
STMicro
- Device:
SPI-M25P64
(notice missingP
in original guide) - Package:
16-lead SOIC
(should be already selected)
- Family:
- change Access Mode: to
- change
Programming File:
to same file as above - in my caseC:/projects/LEDtest/LEDtest/LEDtest_LEDtest.bit
- notice, that
SPI Programming
part of dialog box changes automatically (fields likeData file size
andEnd Address
) - click on
OK
- press
Ctrl
+S
to save your XCF configuration - name it for example
fpga_flash.xcf
To program SPI Flash do now:
- select the only row in
Diamond Programmer
( it has Operation:SPI Flash Erase, Program, Verify
) - and in menu again
Design
->Program
- it takes 30s on my hardware
How to verify that your program is in SPI Flash:
- press
PROGRAMN
button - after few seconds (3s or so) it should reset counter to default0
and start counting if DIP switch J7 is OFF - you can try to
- disconnect USB
- disconnect 12V Supply
- after few seconds connect 12V Supply
- after few seconds (3s or so) there should appear again LED Counter demo...
Uuuffff!
Here are additional documents about Lattice ECP SPI programming:
- TN1169 - LatticeECP3 sysCONFIG Usage Guide
- TN1078 - SPI Serial Flash Programming Using ispJTAG on LatticeECP/EC FPGAs
More info on LED demo
The information in LatticeDiamondTutorial310.pdf
is a bit terse, however you can easily
explore this demo. Most important files are (copied from
directory C:\lscc\diamond\3.10_x64\docs\tutorial\Diamond_tutorial\
):
pin_assignments.lpf
there you can see that:- J7 DIP Switch is
reset
signal (active when in OFF because of negative logic). Therefore counter counts up/or down when J7 is ON only.) - J6 DIP is called direction.
- J7 DIP Switch is
LEDtest.v
contains LED logic:- when
direction
is active (J6 in OFF) than counter is counting Up and is shown on 14 segment LED display only - when
direction
is inactive (J6 is ON) than counter is counting down on both 14 segment LED display and also there is "moving light" on LEDs (for some mysterious reason these pins are assigned in strange order) - this module uses 14 segment LED display like ordinary 7 segment,
so
D
hex letter looks same as0
number andB
hex letter looks same as8
number, oops.
- when
topcount.v
top-level Verilog HDL module - all input/outputs are there and also calls clock division (you can see that default FPGA clock is too fast for our eyes :-)