-
Check out this repo with
git clone --recurse-submodules <repo>. -
Ensure you have Python 3.5 or newer installed.
-
Ensure you have
makeinstalled. -
Download the Risc-V toolchain from https://www.sifive.com/products/tools/ and put it in your PATH.
-
Go to https://www.xilinx.com/support/download.html and download
All OS installer Single-File Download -
Do a minimal Xilinx install to /opt/Xilinx/, and untick everything except
Design Tools / Vivado Design Suite / VivadoandDevices / Production Devices / 7 Series -
Go to https://www.xilinx.com/member/forms/license-form.html, get a license, and place it in ~/.Xilinx/Xilinx.lic
-
Run
./betrusted-soc.py(orpython3 ./betrusted-soc.py)
To update the repo to the upstream version, including all dependencies, run:
git pull
git submodule update --recursivelxbuildenv is a Python module. It sets up the build environment and ensures you have the correct dependencies. To use it, start your program off with:
#!/usr/bin/env python3
import lxbuildenvlxbuildenv.py has some very surprising behaviors that you should be aware of:
-
In order to set environment variables such as
PYTHONHASHSEED,lxbuildenvwill actually re-exec the Python interpreter. This will, among other things, cause the pid to change. This is why lxbuildenv should be imported first. -
The environment variable
PYTHONPATHis replaced to include every directory underdeps/. If you rely onPYTHONPATHto be something else, this may surprise you. -
lxbuildenvhas several command line parameters that it can accept. To display these, run your command with the--lx-helpparameter. -
The
deps/directory includes its ownsite.pyimplementation, adapted from a Debian implementation. This is because some distros force/usr/share/python/site-packages/to be first in the dependency list, which causes confusing dependency interactions. If you’re relying on site packages being in a certain order, this may cause problems. You can try deletingdeps/site/in order to disable this behavior.
In exchange for some deviation from other build environments, lxbuildenv gives you several benefits that come in handy for hardware projects:
-
Python dicts enumerate in constant order, giving some consistency to build results.
-
You will probably be modifying code in the dependencies. By keeping them inside the project directory, this becomes much simpler.
-
Additionally, all dependencies remain under version control, which you would otherwise lose when installing dependencies as packages.
-
Hardware, moreso than software, depends on exact version numbers. By using
gitto track dependency versions, this build becomes more reproducible. -
It is cross-platform, and works anywhere Xilinx does.
-
The
lxbuildenvenvironment doesn’t rely on opaque environment variables, or otherwise have a special environment you enter. Everything is documented behind--helpflags.
Dependencies are managed through git, and managing their usage is largely an exercise
in working with git.
For example, if you would like to make a change to litex, go into deps/litex and checkout
a new branch and create a new upstream repo. If you’re working on Github, you would do
something like fork the repo to your own organization.
As an example, assume sutajiokousagi has forked upstream litex:
$ cd deps/litex
$ git checkout -b new-feature
$ git remote add kosagi [email protected]:sutajiokousagi/litex.git
$ cd -Then, make changes to deps/litex as needed.
When you want to merge changes upstream, go into deps/litex/ and push the branch to your remote:
$ cd deps/litex
$ git push kosagi new-feature
$ cd -Then you can go and open a Pull Request on Github.
Dependencies are designed to be independent, and you should update them as needed. To update a particular
dependency, go into that dependency’s subdirectory and run git pull. You may also find it easier to
pull updates from a particular dependency and merge them. For example, if you’re working on the new-feature
branch of litex and want to pull changes from upstream, run:
$ cd deps/litex
$ git fetch origin
$ git merge master
$ cd -This will merge all changes from upstream onto your own branch.
There is a wrapper script in this repo to run support programs such as litex_server and litex_term. These may be invoked either with python (python bin/litex_server udp) or on shebang-aware systems they may be executed directly (./bin/litex_server udp).
If your Xilinx install is in the default path (C:\\Xilinx on Windows, /opt/Xilinx on Linux), then the build system should be able to automatically find Xilinx.
If not, you can add the Xilinx bin directory to your PATH.
To use PyCharm, open this directory as a Project by going to the File menu and selecting Open…. Make sure you open the entire directory, and not just a single file in this directory.
When you first open this project, you’ll see lots of red squiggly lines indicating errors. PyCharm needs to know about the dependency structure in order to allow you to drill down into modules and auto-complete statements.
Open this directory in PyCharm and expand the deps/ directory. Then hold down Shift and select all subdirectories under deps/. This will include litedram, liteeth, and so on.
Then, right-click and select Mark directory as… and select Sources Root. The red squiggly lines should go away, and PyCharm should now be configured.
When running your module from within PyCharm, you may find it useful to set environment variables. You can use the --lx-print-env command. For example: ./betrusted-soc.py --lx-print-env > pycharm.env to create a .env-compatible file. There are several PyCharm plugins that can make use of this file.
Visual Studio Code needs to know where modules are. These are specified in environment variables, which are automatically read from a .env file in your project root. Create this file to enable pylint and debugging in Visual Studio Code:
$ python ./betrusted-soc.py --lx-print-env > .env[](CODE_OF_CONDUCT.md)
Please see [CONTRIBUTING](CONTRIBUTING.md) for details on how to make a contribution.
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide its terms.
Copyright © 2019
Licensed under the [CERN OHL v1.2](https://ohwr.org/project/licenses/wikis/cern-ohl-v1.2) [LICENSE](LICENSE)