Skip to content

Commit 5cdadf1

Browse files
committed
Adding Ewen's detailed instructions for the MimasV2.
1 parent 38a16e5 commit 5cdadf1

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

MimasV2.md

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# MicroPython on Numato Mimas V2 FPGA
2+
3+
## Prerequisites
4+
5+
* Ubuntu 16.04 LTS `x86_64` system
6+
7+
* [Numato Mimas V2](http://numato.com/mimas-v2-spartan-6-fpga-development-board-with-ddr-sdram/) Spartan6 FPGA board, with `MimasV2Config.py` set up to be able to upload "gateware" to the FPGA board (there is also a copy of `MimasV2Config.py` installed as part of this envvironment setup below which is used for flashing the MicroPython FPGA gateware).
8+
9+
* USB A to USB Mini B cable, to connect Numato Mimas V2 to laptop
10+
11+
* Xilinx ISE WebPACK installed, reachable from `/opt/Xilinx` (or optionally installed within the `Xilinx` directory *inside* your `build` directory).
12+
13+
Before you begin it would be a very good idea to check that the [Numato Mimas v2 `sample.bin`
14+
code](http://productdata.numato.com/assets/downloads/fpga/mimasv2/mimasv2_sample_bin_file.bin) will run on your Mimas v2, and that you can successful replace it with a program of your own (eg, the [Numato tutorial synthesis example](https://docs.numato.com/kb/learning-fpga-verilog-beginners-guide-part-4-synthesis/).
15+
16+
## Gateware
17+
18+
### Setup
19+
20+
Clone repository, which originated with HDMI2USB (hence the dependencies listed):
21+
22+
git clone https://github.com/upy-fpga/upy-fpga-litex-gateware
23+
24+
Install the relevant bits of the environment in two parts, firstly as root:
25+
26+
cd upy-fpga-litex-gateware
27+
sudo bash -x scripts/download-env-root.sh
28+
29+
which will install dozens of packages as direct or indirect dependencies, including some from Tim's Ubuntu PPA.
30+
31+
And then as a *non-root* user (eg, your own user) for the remaining parts:
32+
33+
cd upy-fpga-litex-gateware
34+
bash -x scripts/download-env.sh
35+
36+
which will download a bunch more packages, and execute/install them. Among other things it installs `lm32` cross build tools (`binutils`, `gcc`, etc), as pre-built binary tools. The install process is managed with `[conda](https://conda.io/docs/intro.html)`, a Python environment management tool. (It currently actually installs a Python 3.6 environment, and then downgrades it to Python 3.5.1 for compatability, as well as a lot of other [old tools](https://github.com/upy-fpga/issues-wiki/issues/3).)
37+
38+
It also automatically `git clone`s the relevant [Enjoy Digital `litex` git modules](https://github.com/enjoy-digital/litex), as listed in the [README](https://github.com/upy-fpga/upy-fpga-litex-gateware/blob/nextgen/README).
39+
40+
The environment install process will take several minutes, mostly depending on the download speed.
41+
42+
### Build
43+
44+
From a terminal which has *not* entered the Xilinx ISE WebPack environment, set the desired `PLATFORM` and `TARGET` to select what will be built, then enter the `upy-fpga` environment:
45+
46+
cd upy-fpga-litex-gateware
47+
PLATFORM=mimasv2
48+
TARGET=base
49+
export PLATFORM TARGET
50+
source scripts/enter-env.sh
51+
52+
All going well, it should do some checking, report the directories being used, and then change the prompt to include the `PLATFORM` and `TARGET` values. Eg,
53+
54+
(H2U P=mimasv2 T=base)
55+
56+
`make help` will show you the valid `PLATFORM` and `TARGET` values, but *cannot* be run until after `scripts/enter-env.sh` has been done; to change platforms or targets it would be best to start with a fresh terminal. ([README.targets](https://github.com/upy-fpga/upy-fpga-litex-gateware/blob/nextgen/README.targets) has some information on the possible `TARGET` values.)
57+
58+
From there, you can build the "gateware" for your selected `PLATFORM`/`TARGET` combination with:
59+
60+
make gateware
61+
62+
which will result in a *lot* of output, most of it from the Xilinx ISE WebPACK tools. This step will also take a few minutes, and will keep your CPU pretty busy. All going well you should end up with a `build/mimasv2_base_lm32/gateware/top.bin` file which can be loaded onto the Mimas V2.
63+
64+
Next you can build the "firmware" to run on the softcore CPU to provide MicroPython on the FPGA. You can build this for your selected `PLATFORM`/`TARGET` combination with:
65+
66+
make firmware
67+
68+
This step appears build quite quickly. It should result in a `build/mimasv2_base_lm32//software/firmware/firmware.bin` file.
69+
70+
### Install
71+
72+
Ensure that the Numato Mimas v2 "operation mode" switch (`SW7`) is set to *program mode* -- the side nearest the USB connector is program mode (see the [Numato Mimas V2 documentation](https://docs.numato.com/doc/mimas-v2-spartan-6-fpga-development-board-with-ddr-sdram/)).
73+
74+
Install the gateware with:
75+
76+
make gateware-flash-mimasv2
77+
78+
Because the upload happens at 19200 bps, this will take a couple of minutes to complete -- it does an erase cycle, a write cycle, and a read-back verification cycle.
79+
80+
The process looks something like:
81+
82+
(H2U P=mimasv2 T=base) ewen@parthenon:~/work/naos/src/upy-fpga/upy-fpga-litex-gateware$ make gateware-flash-mimasv2
83+
python $(which MimasV2Config.py) /dev/ttyACM0 build/mimasv2_base_lm32//gateware/top.bin
84+
****************************************
85+
* Numato Lab Mimas V2 Configuration Tool *
86+
****************************************
87+
Micron M25P16 SPI Flash detected
88+
Loading file build/mimasv2_base_lm32//gateware/top.bin...
89+
Erasing flash sectors...
90+
Writing to flash 100% complete...
91+
Verifying flash contents...
92+
Flash verification successful...
93+
Booting FPGA...
94+
Done.
95+
(H2U P=mimasv2 T=base R=nextgen) ewen@parthenon:~/work/naos/src/upy-fpga/upy-fpga-litex-gateware$
96+
97+
## Get & Build MicroPython
98+
99+
It needs to be built from an in-development repository with changes for MicroPython on FPGA and the Mimas v2.
100+
101+
Get toolchain and clone the *forked* MicroPython repository, with Mimas V2 support in it:
102+
103+
(H2U P=mimasv2 T=base R=nextgen) ewen@parthenon:~/work/naos/src/upy-fpga/upy-fpga-litex-gateware$ ./scripts/build-micropython.sh
104+
105+
That should build fairly quickly, and result in a ``build/mimasv2_base_lm32/micropython.bin` file.
106+
107+
## Installing MicroPython on the Numato Mimas v2
108+
109+
Return to the gateware build top directory, with the environment set up, ie as before (possibly you still have a suitable terminal open):
110+
111+
cd upy-fpga-litex-gateware
112+
PLATFORM=mimasv2
113+
TARGET=base
114+
export PLATFORM TARGET
115+
source scripts/enter-env.sh
116+
117+
Then this custom flash image can be loaded onto the Numato Mimas v2, by ensuring that the "operation mode" switch (`SW7`) is in "program mode" (nearest to the USB connector), and then unplugging and plugging in the Numato Mimas v2 to reset it.
118+
119+
Once `/dev/ttyACM0` appears on the system again, run:
120+
121+
MimasV2Config.py /dev/ttyACM0 build/mimasv2_base_lm32/flash.bin
122+
123+
to program MicroPython onto the Mimas v2. This will take a few minutes to write, as it is uploading at 19200 bps.
124+
125+
The result should look something like:
126+
127+
(H2U P=mimasv2 T=base R=nextgen) ewen@parthenon:~/work/naos/src/upy-fpga/upy-fpga-litex-gateware$ MimasV2Config.py /dev/ttyACM0 build/mimasv2_base_lm32/flash.bin
128+
****************************************
129+
* Numato Lab Mimas V2 Configuration Tool *
130+
****************************************
131+
Micron M25P16 SPI Flash detected
132+
Loading file build/mimasv2_base_lm32/flash.bin...
133+
Erasing flash sectors...
134+
Writing to flash 100% complete...
135+
Verifying flash contents...
136+
Flash verification successful...
137+
Booting FPGA...
138+
Done.
139+
(H2U P=mimasv2 T=base R=nextgen) ewen@parthenon:~/work/naos/src/upy-fpga/upy-fpga-litex-gateware$
140+

0 commit comments

Comments
 (0)