Skip to content

Instantly share code, notes, and snippets.

@Ruinland
Last active May 20, 2020 13:25
Show Gist options
  • Save Ruinland/f07eaf8a651b441fd4ac4c2341616af2 to your computer and use it in GitHub Desktop.
Save Ruinland/f07eaf8a651b441fd4ac4c2341616af2 to your computer and use it in GitHub Desktop.
Short note for LiteX/Vexriscv netboot on ECP5-5G Versa Dev Board

LiteX/Vexriscv netboot on ECP5-5G Versa Dev Board

Firstly, please connect your board to your computer with a network cable. Even though most of modern ethernet cards supports direct connection between each other, if you're not sure about whether you need a crossover cable, you can hook your computer and the dev board to an inexpensive switch like the following picture - -

Photo on imgur.

After the hooking up, you need to configure the network to match Litex bootloader's expectation :

# If you're using 'user-friendly' Linux distros, e.g. Ubuntu, Fedora ......
# it's better to disable NetworkManager to mitigate interferenece.
sudo systemctl stop NetworkManager
# Change the NIC dev name to match your platform
sudo ip link set dev enp0s20u2u4 down
sudo ip addr add dev enp0s20u2u4 192.168.1.100/24
sudo ip link set dev enp0s20u2u4 up

The ip address above could be configured via modifying source code.

Then you need to setup tftp server. If you prefer a quick and oneshot only solution, tftpy is simple enough.

#!/usr/bin/python
import tftpy

server = tftpy.TftpServer('/tmp/tftpboot')
server.listen('0.0.0.0', 69)

You need to put

  • emulator.bin : the M-mode firmware that implements SBI
  • Image : Linux kernel
  • rootfs.cpio : rootfs image
  • rv32.dtb : compiled device tree into /tmp/tftpboot which the python script configured above.

Then, we can fire up a command which loads bitstream to the dev board and launch a console :

openocd -f /usr/share/trellis/misc/openocd/ecp5-versa5g.cfg -c "transport select jtag; init; svf build/versa_ecp5/gateware/top.svf; exit" && \
lxterm --speed=1e6 /dev/ttyUSB1

You should be able to see that LiteX bootloader requested its needed file and boots now. Here's a recored footage booting an Alpine Linux :-) https://asciinema.org/a/332286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment