Skip to content

HowTo LCA2018 FPGA Miniconf

Mateusz Hołenko edited this page Mar 4, 2020 · 43 revisions

Linux.conf.au 2018 FPGA Miniconf Set Up Instructions

TOC:

Aim

This aim of these instructions is to get your machine prepped: packages installed, repos cloned, permissions set, firewalls configured, etc. Learning about FPGAs and all the tools will come later.

If you are not ready when the event starts, you may be asked to leave to make room for someone who is ready.

  • Make sure that your hardware is fast enough.
  • Get the Xilinx Vivado FPGA toolchain downloaded, installed and set up. The process will check;
    • You have successfully installed the toolchain and gotten a license.
    • You are able to produce stuff which can be loaded onto an FPGA.
  • Get LiteX build environment downloaded, installed and set up. The process will check;
    • The environment set up was successful.
    • You are able to build basic firmware.
    • You are able to run the firmware under emulation (and thus the firmware was built correctly).
    • You are able to netboot the system under emulation (checking your network setup / firewall / etc).
    • You are able to build Linux and boot it under emulation.

For support please join #timvideos on irc.freenode.net



Requirements

To do this tutorial you will need;

  • A x86-64bit computer running modern Linux Distro (ARM and x86-32bit is not supported),
    • Tested distros include;
      • Ubuntu 16.04, 17.04 & Ubuntu 18.04
      • Arch Linux
      • Fedora 26
      • Debian "testing" on 2017-11-11 (Debian Sid /may/ also work)
    • Your shell must be bash (for now)
  • Your computer must be fast enough to do the following quickly (under 10mins).
    • Compile FPGA "gateware" with Vivado
    • Compile the openrisc Linux kernel configuration from scratch
  • ~50gb of free disk space
  • 8gb of RAM
  • Either
    • Option 1
      • 1 * free USB-C port
      • Ordered kit for USB-C computer.
    • Option 2
      • 1 * free USB-A (3.0 compatible) port
      • Ordered kit for USB-A computer.


Pre-work for the Miniconf

Everyone attending the tutorial must have completed this pre-work before the tutorial. The pre-work will be checked at the start of the tutorial and anyone who hasn't done the pre-work will be asked to leave, even if they have a valid ticket (no refund will be given).

Download & Install Vivado

The Xilinx Vivado toolchain is 16GB and may take many hours to download.

Follow the instructions on the LiteX BuildEnv Wiki to download, install and get a license to Vivado.

NOTE: The scripts checks for Vivado in /opt/Xilinx/Vivado. Either install Vivado in that location or soft link your installation directory, if installed somewhere else, by doing the following:

(LX P=arty C=mor1kx) $ mkdir /opt/Xilinx
(LX P=arty C=mor1kx) $ ln -s $current_installation_dir_vivado /opt/Xilinx

Download & Install LiteX Dependencies

Install bash, wget and realpath (part of coreutils in newer Ubuntu / Debian).

Download & setup udev rules

git clone https://github.com/litex-hub/litex-buildenv-udev.git
cd litex-buildenv-udev
make install

Reload udev rules:

sudo udevadm control --reload-rules

Get the right permissions

sudo adduser $USER video
sudo adduser $USER dialout
sudo reboot

Download & setup the LiteX Build Environment

git clone https://github.com/timvideos/litex-buildenv.git
cd litex-buildenv
export CPU=mor1kx PLATFORM=arty TARGET=net
./scripts/download-env.sh
source ./scripts/enter-env.sh
(LX P=arty C=mor1kx) $

You should have "(LX P=arty C=mor1kx)" in your bash prompt now.

NOTE: if you see an error like "bash: lm32-elf-ld: command not found..." you probably forgot to do the exports above.

Resuming Development

So you walked away and now need to start a new session. Here's how:

cd litex-buildenv
export CPU=mor1kx PLATFORM=arty TARGET=net
source ./scripts/enter-env.sh
(LX P=arty C=mor1kx) $

NOTE: if you see an error like "bash: lm32-elf-ld: command not found..." you probably forgot to do the exports above.

Test building gateware

This tests that you have Vivado successfully installed and are able to build gateware for the FPGA within a reasonable amount of time.

Enter the LiteX Build Environment and then type;

(LX P=arty C=mor1kx) $ make gateware
...
Creating bitstream load up from address 0x00000000
Loading bitfile top.bit
Writing file ./top.bin
Writing log file ./top.prm
===================================
Configuration Memory information
===================================
File Format        BIN
Interface          SPIX4
Size               16M
Start Address      0x00000000
End Address        0x00FFFFFF

Addr1         Addr2         Date                    File(s)
0x00000000    0x0021728B    Nov 14 23:11:26 2017    top.bit
0 Infos, 0 Warnings, 0 Critical Warnings and 0 Errors encountered.
write_cfgmem completed successfully
# quit
INFO: [Common 17-206] Exiting Vivado at Tue Nov 14 23:11:28 2017...

real    10m29.385s
user    25m22.864s
sys     1m47.932s
(LX P=arty C=mor1kx) $

Please make sure the real time shown above is less than 15 minutes. If this takes more than that, you're going to spend a lot of time 'compiling' which might be frustrating and cause you take more than a day to get through the whole tutorial.

After the build has completed, you should have a top.bin inside the build/arty_net_mor1kx/gateware directory. See example below;

(LX P=arty C=mor1kx) $ ls -l build/arty_net_mor1kx/gateware/top.bin
-rw-rw-r-- 1 mithro mithro 2192111 Nov  2 05:17 build/arty_net_mor1kx/gateware/top.bin

After building the gateware, now build an image using make image. An image includes all of the gateware + firmware + BIOS into one file which can be flashed.

(LX P=arty C=mor1kx) $ make image
…
Gateware @ 0x00000000 (   2192012 bytes) build/arty_net_mor1kx//gateware/top.bin                        - Xilinx FPGA Bitstream
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 bb 11 22 00 44 ff ff ff ff ff ff ff ff aa 99 55 66 20 00 00 00 30 03 e0 01 00 00 02 6b
    BIOS @ 0x00220000 (     32600 bytes) build/arty_net_mor1kx//software/bios/bios.bin                  - LiteX BIOS with CRC
18 00 00 00 18 20 00 00 18 40 00 00 18 60 00 00 18 80 00 00 18 a0 00 00 18 c0 00 00 18 e0 00 00 19 00 00 00 19 20 00 00 19 40 00 00 19 60 00 00 19 80 00 00 19 a0 00 00 19 c0 00 00 19 e0 00 00
Firmware @ 0x00228000 (     74816 bytes) build/arty_net_mor1kx//software/firmware/firmware.fbi          - HDMI2USB Firmware in FBI format (loaded into DRAM)
00 01 24 38 29 45 bc 39 18 00 00 00 18 20 00 00 18 40 00 00 18 60 00 00 18 80 00 00 18 a0 00 00 18 c0 00 00 18 e0 00 00 19 00 00 00 19 20 00 00 19 40 00 00 19 60 00 00 19 80 00 00 19 a0 00 00
----------------------------------------
       Remaining space   14441408 bytes (110 Megabits, 13.77 Megabytes)
           Total space   16777216 bytes (128 Megabits, 16.00 Megabytes)

Flash image: build/arty_net_mor1kx//image-gateware+bios+firmware.bin
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 bb 11 22 00 44 ff ff ff ff ff ff ff ff aa 99 55 66 20 00 00 00 30 03 e0 01 00 00 02 6b
(LX P=arty C=mor1kx) $

After the build has completed, you should have a image-gateware+bios+firmware.bin inside the build/arty_net_mor1kx/ directory. See example below;

(LX P=arty C=mor1kx) $ ls -l build/arty_net_mor1kx/*.bin
-rw-rw-r-- 1 mithro mithro 2334580 Nov  2 05:17 build/arty_net_mor1kx/image-gateware+bios+firmware.bin

Building the gateware will be run multiple times during the miniconf. It will be impossible to complete the tasks required during the day if this process takes too long. There is also no form of "incremental" build for FPGA gateware at the moment.

Try running test firmware inside QEMU

This tests you are able to run the firmware under emulation and thus the firmware was built correctly and your networking is working correctly.

Dependencies

Ubuntu / Debian

You need atftpd net boot images inside QEMU, qemu build dependencies, and some other stuff.

sudo apt-get install atftpd libpixman-1-dev pkg-config libglib2.0-dev python-minimal libftdi-dev uml-utilities openvpn net-tools bison flex
sudo apt build-dep qemu

If you are running the ufw firewall (or whatever firewall) you may need to add an app exclusion to allow inbound tftp connections:

sudo ufw allow tftp
sudo ufw allow 6069

Fedora

You need tftpd to net boot images inside QEMU

sudo dnf install tftp-server

You also need some build dependencies;

sudo dnf install glib2-devel pixman-devel libftdi-devel uml_utilities openvpn bison flex

On Fedora you may need to configure your firewall with;

sudo firewall-cmd --zone=FedoraWorkstation --add-service tftp
sudo firewall-cmd --zone=FedoraWorkstation --add-port 6069/udp

Note about tftp setup

If you already have a tftpd installed and configured, you're going to have problems here. This can include things started by inetd. You'll know this is the case if you get a "cannot bind to 192.168.100.100 port 69 udp" error from the below steps.

If you get this error, check out the contents of your /etc/inetd.conf and comment out the line (by prepending it with '#') which might look similar to this:

    tftp          dgram   udp4    wait    nobody /usr/sbin/tcpd /usr/sbin/in.tftpd --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /srv/tftp

If you needed to edit /etc/inetd.conf (or similar) then you will also need to reload the inetd configuration, eg, "service inetutils-inetd reload" to cause it to re-read the changed configuration.

NOTE: A Litex BIOS change around 2018-01-18 allowed it to support both TFTP boot from a high-numbered port (UDP/6069 was chosen in timvideos/litex-buildenv) and also to fall back to the well known UDP/69. If you installed/updated your litex-buildenv on/after 2018-01-18 try checking for tftpd running on UDP/6069 instead (which will hopefully reduce the conflicts with tftpd running as a system daemon).

FIXME: We need better detection and set up of tftpd. See this github issue.

Net booting HDMI2USB bare metal firmware in QEMU

Enter the LiteX Build Environment and then type

(LX P=arty C=mor1kx) $ ./scripts/build-qemu.sh

This will build QEMU, and create the tap interface (shared between the host and QEMU) the first time, and then start the tftp server on that interface.

If you need to manually stop or start the tftp server (e.g. after a reboot), then you can use

(LX P=arty C=mor1kx) $ make tftpd_stop          # Stop any previously run tftp server
(LX P=arty C=mor1kx) $ make tftpd_start         # Start the tftp server again

After running ./scripts/build-qemu.sh, If you see something like this:

    Reading value 00000000 fr MDIO PHY 00000000 REG 0000001f
    reg 31: 0000
    Datasync
    Reading value 0000bc00 fr MDIO PHY 00000000 REG 00000011
    MDIO mode: 1000Mbps / link: up
    uIP init done with ip 192.168.100.50
    Etherbone listening on port 1234
    Telnet listening on port 23
    H2U 00:00:00>

Then you're good to go. Now you should check that you can telnet to the firmware:

    $ telnet 192.168.100.50 23
    Trying 192.168.100.50...
    Connected to 192.168.100.50.
    Escape character is '^]'.

    <hit enter a couple of times>
    H2U 00:00:42>

Exit telnet by typing "ctrl-] q" in the telnet session to exit telnet, and "ctrl-c" in the build-qemu session to exit qemu.

Try downloading and building Linux for OpenRISC 1000

This tests you are able to build Linux and boot it under emulation.

Dependencies

Install the tools required to build the Linux kernel on your computer.

On Ubuntu, you can get these tools by running:

sudo apt-get install build-essential libncurses5-dev gcc make git exuberant-ctags bc libssl-dev

On Red Hat based systems like Fedora, Scientific Linux, and CentOS you can run:

sudo yum install gcc make git ctags ncurses-devel openssl-devel

And on SUSE based systems (like SLES and Leap), you can run:

sudo zypper in git gcc ncurses-devel libopenssl-devel ctags cscope

Doing the build of Linux

Enter the environment and run the ./scripts/build-linux.sh, notice the two new exports: CPU_VARIANT=linux and FIRMWARE=linux!

Note: If you already have a local Linux git checkout, you can make this step faster by doing a "export LINUX_GITLOCAL=<.git directory of Linux checkout>" - otherwise the script below will clone you a new Linux repo from scratch.

(LX P=arty C=mor1kx) $ export CPU=mor1kx CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
(LX P=arty C=mor1kx.linux F=linux) $
(LX P=arty C=mor1kx.linux F=linux) $ ./scripts/build-linux.sh
...
  AR      built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  LD      vmlinux
  SYSMAP  System.map
  OBJCOPY arch/openrisc/boot/vmlinux.bin
  Kernel: arch/openrisc/boot/vmlinux.bin is ready
make[1]: Leaving directory '/home/tansell/github/timvideos/HDMI2USB-litex-firmware/build/arty_net_mor1kx.linux/software/linux'

real	1m20.355s
user	3m35.120s
sys	0m15.816s
+ ls -l .../build/arty_net_mor1kx.linux//software/linux/arch/openrisc/boot/vmlinux.bin
-rwxr-xr-x 1 tansell eng 3739100 Jan  3 18:12 .../build/arty_net_mor1kx.linux//software/linux/arch/openrisc/boot/vmlinux.bin
+ ln -sf .../build/arty_net_mor1kx.linux//software/linux/arch/openrisc/boot/vmlinux.bin .../build/arty_net_mor1kx.linux//software/linux/firmware.bin
(LX P=arty C=mor1kx.linux F=linux) $

Please make sure the real time shown above is less than 5 minutes. If this takes more than that, you're going to spend a lot of time 'compiling' which might be frustrating and cause you take more than a day to get through the whole tutorial.

After the build has completed, you should have a firmware.bin inside the build/arty_net_mor1kx.linux/software/linux directory.

Then try making an image by running make image like so;

(LX P=arty C=mor1kx.linux F=linux) $ make image
...
Gateware @ 0x00000000 (   2192012 bytes) build/arty_net_mor1kx.linux//gateware/top.bin                  - Xilinx FPGA Bitstream
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 bb 11 22 00 44 ff ff ff ff ff ff ff ff aa 99 55 66 20 00 00 00 30 03 e0 01 00 00 02 6b
    BIOS @ 0x00220000 (     32600 bytes) build/arty_net_mor1kx.linux//software/bios/bios.bin            - LiteX BIOS with CRC
18 00 00 00 18 20 00 00 18 40 00 00 18 60 00 00 18 80 00 00 18 a0 00 00 18 c0 00 00 18 e0 00 00 19 00 00 00 19 20 00 00 19 40 00 00 19 60 00 00 19 80 00 00 19 a0 00 00 19 c0 00 00 19 e0 00 00
Firmware @ 0x00228000 (   3739108 bytes) build/arty_net_mor1kx.linux//software/linux/firmware.fbi       - HDMI2USB Firmware in FBI format (loaded into DRAM)
00 39 0d dc 8b a5 25 11 00 00 00 40 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
----------------------------------------
       Remaining space   10777116 bytes (82 Megabits, 10.28 Megabytes)
           Total space   16777216 bytes (128 Megabits, 16.00 Megabytes)

Flash image: build/arty_net_mor1kx.linux//image-gateware+bios+linux.bin
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 bb 11 22 00 44 ff ff ff ff ff ff ff ff aa 99 55 66 20 00 00 00 30 03 e0 01 00 00 02 6b
(LX P=arty C=mor1kx.linux F=linux) $

After the image creation has completed, you should have a image-gateware+bios+linux.bin inside the build/arty_net_mor1kx.linux/ directory.

Run Linux in QEMU

Enter the LiteX environment and run the ./scripts/build-qemu.sh script

(LX P=arty C=mor1kx.linux F=linux) $ ./scripts/build-qemu.sh
...
[    1.050000] Freeing unused kernel memory: 3168K
[    1.050000] This architecture does not have kernel memory protection.
Starting logging: OK
Initializing random number generator... done.
Starting network: OK
Starting dropbear sshd: OK

Once at the "buildroot login:" screen, you should be able to login with the username "root";

...
Welcome to Buildroot
buildroot login: root
Jan  1 00:00:08 login[63]: root login on 'console'
# ls /
bin      init     linuxrc  opt      run      tmp
dev      lib      media    proc     sbin     usr
etc      lib32    mnt      root     sys      var
#
# cat /proc/cpuinfo 
cpu			: OpenRISC-0

If you need to manually stop or start the tftp server (e.g. after a reboot), then you can use;

(LX P=arty C=mor1kx.linux F=linux) $ make tftpd_stop    # Stop any previously run tftp server
(LX P=arty C=mor1kx.linux F=linux) $ make tftpd_start   # Start the tftp server again


The instructions from here can only be done after you receive hardware. You can stop here if completing the prework.



Set up at the Miniconf

Re-enter LiteX Environment

If you have exited the LiteX environment, you will need to re-enter it. See "Resuming Development" above.

$ export CPU=mor1kx CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
$ source ./scripts/enter-env.sh
(LX P=arty C=mor1kx.linux F=linux) $

Test loading the gateware and HDMI2USB bare metal firmware via serial

This step will only work if you have a FPGA attached to your machine.

Make sure that FIRMWARE=firmware for this test.

$ export CPU=mor1kx CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=firmware
$ source ./scripts/enter-env.sh
(LX P=arty C=mor1kx.linux) $ make gateware-load
openocd -f board/digilent_arty.cfg -c "init; pld load 0 build/arty_net_mor1kx//gateware/top.bit; exit"
...
Info : clock speed 10000 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x0362d093 (mfg: 0x049 (Xilinx), part: 0x362d, ver: 0x0)
loaded file build/arty_net_mor1kx//gateware/top.bit to pld device 0 in 1s 838755us

(LX P=arty C=mor1kx.linux) $ make firmware-load
…
make[1]: Leaving directory '/home/joel/dev/timvideos/HDMI2USB-litex-firmware/build/arty_net_mor1kx/software/firmware'

real	0m1.302s
user	0m1.228s
sys	0m0.083s
flterm --port=/dev/ttyUSB1 --kernel=build/arty_net_mor1kx//software/firmware/firmware.bin --speed=115200
[FLTERM] Starting...
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
[FLTERM] Received firmware download request from the device.
[FLTERM] Uploading kernel (73524 bytes)...
[FLTERM] Upload complete (7.7KB/s).
[FLTERM] Booting the device.
[FLTERM] Done.
Executing booted program at 0x40000000
HDMI2USB firmware booting...


hardware version info
===============================================
           DNA: 014c75483229085c
           MAC: Unknown

gateware version info
===============================================
      platform: arty
        target: net
      revision: 0611a4881c6912b761014eb696f591859f477a7c

FIXME: Put the full output here.

If you see no output, press 'Enter' a few times. You should see the H2U 00:00:42> prompt as shown below;

    <hit enter a couple of times>
    H2U 00:00:42>

If you see the BIOS> prompt, you can then kick off the firmware loading process using serialboot like shown below:

BIOS> serialboot
Booting from serial...

Get Ethernet to HDMI2USB bare metal firmware working

Due to the Ethernet link being reset multiple times during the FPGA programming and booting sequence, your network needs to be manually configured to remain up rather than using automated management with network manager or systemd.

You have been provided a USB Hub with an inbuilt Ethernet controller for connecting to the Arty. This should mean you don't need to break or affect your normal networking set up.

Debian Network Setup

Debian uses /etc/network/interfaces to control static configurations.

Add the following to your /etc/network/interfaces file.

Note: Your interface name (enx00e04c680b24 in the example below) is unique to each USB hub. Make sure you are using your own value.

iface enx00e04c680b24 inet static
	address 192.168.100.100
	netmask 255.255.255.0

After changing this file, restart Network Manager with;

sudo service network-manager restart

You should then check that network manager is not managing the enx00e04c680b24 interface using the following and look for a status of "unmanaged"; if you see a status of "connected" or "unavailable" that means that Network Manager is trying to manage that interface (and it either has ethernet carrier or does not have carrier respectively).

$ nmcli dev status
DEVICE           TYPE      STATE         CONNECTION
docker0          bridge    connected     docker0
wlp4s0           wifi      disconnected  --
enp0s31f6        ethernet  unavailable   --
enx00e04c680b24  ethernet  unmanaged     --
lo               loopback  unmanaged     --
tap0             tun       unmanaged     --

Delete the tap interface (or reboot)

sudo ip link delete dev tap0

Bring up the Ethernet device with ifup;

sudo ifup enx00e04c680b24

RedHat / Fedora Setup

Redhat / Fedora uses /etc/sysconfig/network-scripts/ifcfg-INTERFACE script files to control static network interface configurations.

Create an /etc/sysconfig/network-scripts/ifcfg-enx00e04c680b24 file.

Note: Your interface name (enx00e04c680b24 in the example below) is unique to each USB hub. Make sure you are using your own value in the name of the file, and below.

    DEVICE=enx00e04c680b24
    NM_CONTROLLED=no
    ONBOOT=no
    BOOTPROTO=static
    IPADDR=192.168.100.100
    NETMASK=255.255.255.0

After creating (or changing) this file, restart Network Manager with:

sudo systemctl restart NetworkManager

You should then check that network manager is not managing the enx00e04c680b24 interface using the following and look for a status of "unmanaged"; if you see a status of "connected" or "unavailable" that means that Network Manager is trying to manage that interface (and it either has ethernet carrier or does not have carrier respectively).

$ nmcli dev status
DEVICE           TYPE      STATE         CONNECTION
docker0          bridge    connected     docker0
wlp4s0           wifi      disconnected  --
enp0s31f6        ethernet  unavailable   --
enx00e04c680b24  ethernet  unmanaged     --
lo               loopback  unmanaged     --
tap0             tun       unmanaged     --

Delete the tap interface (or reboot)

sudo ip link delete dev tap0

Bring up the Ethernet device with ifup;

sudo ifup enx00e04c680b24

Manual Network Configuration

If you don't have network manager installed, you can just manually configure the network interface using ifconfig or ip.

Note: Your interface name (enx00e04c680b24 in the example below) is unique to each USB hub. Make sure you are using your own value.

Using ifconfig

sudo ifconfig enx00e04c680b24 inet 192.168.100.100 up

Using IP

sudo ip addr add 192.168.100.100/24 dev enx00e04c680b24
sudo ip link set enx00e04c680b24 up

Boot HDMI2USB bare metal firmware via tftp

If you need to manually stop or start the tftp server (e.g. after a reboot), then you can use

(LX P=arty C=mor1kx) $ make tftpd_stop          # Stop any previously run tftp server
$ export CPU=mor1kx CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=firmware
$ source ./scripts/enter-env.sh
(LX P=arty C=mor1kx.linux) $ make tftpd_start         # Start the tftp server again
(LX P=arty C=mor1kx.linux) $ make tftp                # Copy firmware to tftp server directory
(LX P=arty C=mor1kx.linux) $ make gateware-load       # Load gateware
(LX P=arty C=mor1kx.linux) $ make firmware-connect    # Connect to the serial console

After running make firmware-connect, if you see something like this:

    Reading value 00000000 fr MDIO PHY 00000000 REG 0000001f
    reg 31: 0000
    Datasync
    Reading value 0000bc00 fr MDIO PHY 00000000 REG 00000011
    MDIO mode: 1000Mbps / link: up
    uIP init done with ip 192.168.100.50
    Etherbone listening on port 1234
    Telnet listening on port 23
    H2U 00:00:00>

Then you're good to go. Now you should check that you can telnet to the firmware:

    $ telnet 192.168.100.50 23
    Trying 192.168.100.50...
    Connected to 192.168.100.50.
    Escape character is '^]'.

    <hit enter a couple of times>
    H2U 00:00:42>

Exit telnet by typing "ctrl-] q" in the telnet session to exit telnet, and "ctrl-c" in the build-qemu session to exit qemu.

Boot Linux via tftp

After you have configured your network, you should be able to boot Linux via tftp on your hardware!

Enter the environment

$ export CPU=mor1kx CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
(LX P=arty C=mor1kx.linux F=linux) $

Build the gateware

(LX P=arty C=mor1kx.linux F=linux) $ make gateware
...
Creating bitstream load up from address 0x00000000
Loading bitfile top.bit
Writing file ./top.bin
Writing log file ./top.prm
===================================
Configuration Memory information
===================================
File Format        BIN
Interface          SPIX4
Size               16M
Start Address      0x00000000
End Address        0x00FFFFFF

Addr1         Addr2         Date                    File(s)
0x00000000    0x0021728B    Nov 14 23:11:26 2017    top.bit
0 Infos, 0 Warnings, 0 Critical Warnings and 0 Errors encountered.
write_cfgmem completed successfully
# quit
INFO: [Common 17-206] Exiting Vivado at Tue Nov 14 23:11:28 2017...

real    10m29.385s
user    25m22.864s
sys     1m47.932s
(LX P=arty C=mor1kx.linux F=linux) $

Build the Linux kernel

(LX P=arty C=mor1kx.linux F=linux) $ ./scripts/build-linux.sh
...
...
  AR      built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  LD      vmlinux
  SYSMAP  System.map
  OBJCOPY arch/openrisc/boot/vmlinux.bin
  Kernel: arch/openrisc/boot/vmlinux.bin is ready
make[1]: Leaving directory '/home/tansell/github/timvideos/HDMI2USB-litex-firmware/build/arty_net_mor1kx.linux/software/linux'

real	1m20.355s
user	3m35.120s
sys	0m15.816s
+ ls -l .../build/arty_net_mor1kx.linux//software/linux/arch/openrisc/boot/vmlinux.bin
-rwxr-xr-x 1 tansell eng 3739100 Jan  3 18:12 .../build/arty_net_mor1kx.linux//software/linux/arch/openrisc/boot/vmlinux.bin
+ ln -sf .../build/arty_net_mor1kx.linux//software/linux/arch/openrisc/boot/vmlinux.bin .../build/arty_net_mor1kx.linux//software/linux/firmware.bin
(LX P=arty C=mor1kx.linux F=linux) $

Restart tftpd server

(LX P=arty C=mor1kx.linux F=linux) $ make tftpd_stop
(LX P=arty C=mor1kx.linux F=linux) $ make tftpd_start
(LX P=arty C=mor1kx.linux F=linux) $ make tftp			# Copy Linux firmware to tftp server

Load the build

(LX P=arty C=mor1kx.linux F=linux) $ make gateware-load		# Load the gateware to the FPGA
(LX P=arty C=mor1kx.linux F=linux) $ make firmware-connect	# Connect to the serial console

        __   _ __      _  __
       / /  (_) /____ | |/_/
      / /__/ / __/ -_)>  <
     /____/_/\__/\__/_/|_|
 SoC BIOS / CPU: MOR1K / 100MHz
(c) Copyright 2012-2018 Enjoy-Digital
(c) Copyright 2007-2018 M-Labs Limited
Built Sep 30 2018 15:46:25

BIOS CRC passed (49bfb887)
Timer with delta zero, disabling
Timer with delta zero, disabling
Timer with delta zero, disabling
Initializing SDRAM...
SDRAM now under software control
Best read bitslip: 0
Read delays scan:
m0: 00000000000000000000000000000000
m1: 00000000000000000000000000000000
Read delays: 1:32-33  0:32-33  completed
SDRAM now under hardware control
Memtest OK
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timer with delta zero, disabling
Timeout
Booting from network...
Local IP : 192.168.100.50
Remote IP: 192.168.100.100
Fetching from: UDP/6069
Sep 30 15:46:28 tansell-glaptop atftpd[116596.140139553613568]: socket may listen on any address, including broadcast
Sep 30 15:46:28 tansell-glaptop atftpd[116596.140139553613568]: Serving boot.bin to 192.168.100.50:7642
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: Server thread exiting
Successfully downloaded 7885172 bytes from boot.bin over TFTP
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: socket may listen on any address, including broadcast
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: Serving cmdline.txt to 192.168.100.50:7642
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: File build/tftpd//cmdline.txt not found
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: Server thread exiting
Unable to download cmdline.txt over TFTP
No command line parameters found
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: socket may listen on any address, including broadcast
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: Serving initrd.bin to 192.168.100.50:7642
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: File build/tftpd//initrd.bin not found
Sep 30 15:46:30 tansell-glaptop atftpd[116596.140139553613568]: Server thread exiting
Unable to download initrd.bin over TFTP
No initial ramdisk found
Executing booted program at 0x40000000
[    0.000000] Compiled-in FDT at c04903c0
[    0.000000] Linux version 4.15.0-rc1-00020-g29dad80f9179 (tansell@tansell-glaptop) (gcc version 5.4.0 (5.4.0_4334_g9310fdc97ee)) #5 Sun Sep 30 07:51:47 CDT 2018
[    0.000000] CPU: OpenRISC-0 (revision 0) @100 MHz
[    0.000000] -- dcache disabled
[    0.000000] -- icache disabled
...
[    1.050000] Freeing unused kernel memory: 3168K
[    1.050000] This architecture does not have kernel memory protection.
Starting logging: OK
Initializing random number generator... done.
Starting network: OK
Starting dropbear sshd: OK

Welcome to Buildroot
buildroot login: root
Jan  1 00:00:08 login[63]: root login on 'console'
# ls /
bin      init     linuxrc  opt      run      tmp
dev      lib      media    proc     sbin     usr
etc      lib32    mnt      root     sys      var
#

You should get to a buildroot: login prompt. You can login as "root" with no password.

Note that the disk image served over TFTP does not include IP networking, telnetd, etc, so you will not be able to telnet to the Linux image booted via TFTP (only log in on the console).

Advanced Setup

These set up instructions are optional and should only be attempted by advanced users!

Setting up Bridge Config

If can be useful to have the 192.168.100.100 on both your ethernet interface and inside QEMU so you can quickly switch back and forth between them. You can do this by using the Linux bridge interface.

Create a bridge

$ sudo brctl addbr br0 \

Add interfaces to the bridge

sudo brctl addif br0 tap0
sudo brctl addif br0 enx00e04c680b24

Configure the bridge to be 192.168.100.100

sudo ifconfig br0 192.168.100.100 netmask 255.255.255.0

original doc: https://j.mp/pre-fpga-lca2018

Coming soon: FPGA_Linux_module

Clone this wiki locally