HowTo LCA2018 FPGA Miniconf VexRiscv Renode - timvideos/litex-buildenv GitHub Wiki
Linux.conf.au 2018 FPGA Miniconf Set Up Instructions modified to use Linux 5.0 on VexRiscv and simulate in Renode
This is a modified version of the Linux.conf.au 2018 FPGA Miniconf tutorial that targets VexRiscv CPU (instead of mor1kx) and Renode (instead of qemu).
TOC:
- Aim
- Requirements
- Download & Install Vivado
- Download & Install LiteX Dependencies
- Resuming Development
- Set up at the Miniconf (on fpga hardware)
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 if:
- 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 if:
- 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 have successfully downloaded the RISC-V toolchain.
- You are able to build Linux and boot it under emulation.
For support please join #timvideos on irc.freenode.net
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)
- Tested distros include;
- Your computer must be fast enough to do the following quickly (under 10mins).
- Compile FPGA "gateware" with Vivado
- Compile the VexRiscv 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.
- Option 1
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).
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.
Install bash, wget and realpath (part of coreutils in newer Ubuntu / Debian).
git clone https://github.com/litex-hub/litex-buildenv-udev
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
git clone https://github.com/timvideos/litex-buildenv.git
cd litex-buildenv
export CPU=vexriscv PLATFORM=arty TARGET=net
./scripts/download-env.sh
source ./scripts/enter-env.sh
(LX P=arty C=vexriscv) $
You should have "(LX P=arty C=vexriscv)
" 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.
So you walked away and now need to start a new session. Here's how:
cd litex-buildenv
export CPU=vexriscv PLATFORM=arty TARGET=net
source ./scripts/enter-env.sh
(LX P=arty C=vexriscv) $
NOTE: if you see an error like "bash: lm32-elf-ld: command not found..." you probably forgot to do the exports above.
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=vexriscv) $ 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 Jul 25 11:21:13 2019 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 Thu Jul 25 11:21:18 2019...
real 3m4,473s
user 4m10,134s
sys 0m20,858s
(LX P=arty C=vexriscv) $
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.
NOTE: To use flow with Yosys and Vivado use:
(LX P=arty C=vexriscv) $ MAKE_LITEX_EXTRA_CMDLINE="--build-option synth_mode yosys" make gateware
NOTE: Get a segfault? Check dmesg for mention of vsyscall
s. If you see them, reboot with the vsyscall=emulate
kernel option.
NOTE: Get complaints about missing .so files, you need to install ncurses
NOTE: If you get an error about missing vers, that means your Vivado has not been installed correctly. The script checks for Vivado in /opt/Xilinx/Vivado. Either reinstall Vivado in that location or soft link your installation directory, if installed somewhere else, by doing the following:
(LX P=arty C=vexriscv) $ mkdir /opt/Xilinx
(LX P=arty C=vexriscv) $ ln -s $current_installation_dir_vivado /opt/Xilinx
(LX P=arty C=vexriscv) $ ls -l build/arty_net_vexriscv/gateware/top.bin
-rw-r--r-- 1 houen houen 2192012 lip 25 11:21 build/arty_net_vexriscv/gateware/top.bin
(LX P=arty C=vexriscv) $ make image
...
Gateware @ 0x00000000 ( 2192012 bytes) build/arty_net_vexriscv//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 ( 24284 bytes) build/arty_net_vexriscv//software/bios/bios.bin - LiteX BIOS with CRC
6f 00 00 0b 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 23 2e 11 fe 23 2c 51 fe 23 2a 61 fe 23 28 71 fe 23 26 a1 fe 23 24 b1 fe 23 22 c1 fe 23 20 d1 fe
Firmware @ 0x00230000 ( 57084 bytes) build/arty_net_vexriscv//software/firmware/firmware.fbi - HDMI2USB Firmware in FBI format (loaded into DRAM)
f4 de 00 00 5f f6 8a 23 6f 00 00 0b 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 13 00 00 00 23 2e 11 fe 23 2c 51 fe 23 2a 61 fe 23 28 71 fe 23 26 a1 fe 23 24 b1 fe
----------------------------------------
Remaining space 14426372 bytes (110 Megabits, 13.76 Megabytes)
Total space 16777216 bytes (128 Megabits, 16.00 Megabytes)
Flash image: build/arty_net_vexriscv//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=vexriscv) $ ls -l build/arty_net_vexriscv/*.bin
-rw-r--r-- 1 houen houen 2350844 lip 25 11:24 build/arty_net_vexriscv/image-gateware+bios+firmware.bin
After the build has completed, you should have a image-gateware+bios+firmware.bin
inside the build/arty_net_vexriscv/
directory.
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.
This tests you are able to run the firmware under emulation and thus the firmware was built correctly and your networking is working correctly.
You need atftpd net boot images inside Renode 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 policykit-1 libgtk2.0-0 screen gtk-sharp2 libc6-dev
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
You need tftpd to net boot images inside Renode
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 PolicyKit gtk2 screen gtk-sharp2 glibc-devel
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
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.
Enter the LiteX Build Environment and then type
(LX P=arty C=vexriscv) $ ./scripts/build-renode.sh
This will start Renode, and create the tap interface (shared between the host and Renode) 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=vexriscv) $ make tftpd_stop # Stop any previously run tftp server
(LX P=arty C=vexriscv) $ make tftpd_start # Start the tftp server again
After running ./scripts/build-renode.sh
and waiting untill it finishes booting up (it might take a while), if you see a new window with something like this:
__ _ __ _ __
/ / (_) /____ | |/_/
/ /__/ / __/ -_)> <
/____/_/\__/\__/_/|_|
(c) Copyright 2012-2019 Enjoy-Digital
(c) Copyright 2007-2015 M-Labs Ltd
BIOS built on Jul 25 2019 11:36:33
BIOS CRC passed (786c42e7)
--============ SoC info ================--
CPU: VexRiscv @ 100MHz
ROM: 64KB
SRAM: 32KB
L2: 8KB
MAIN-RAM: 262144KB
--========= Peripherals init ===========--
...
MDIO mode: 100Mbps / 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, and "q" in the Renode monitor window to exit.
This tests you are able to build Linux and boot it under emulation.
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
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=vexriscv) $ export CPU=vexriscv CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
(LX P=arty C=vexriscv) $ source ./scripts/enter-env.sh
(LX P=arty C=vexriscv.linux F=linux) $
(LX P=arty C=vexriscv.linux F=linux) $ ./scripts/build-linux.sh
...
AR built-in.a
LD vmlinux.o
MODPOST vmlinux.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SYSMAP System.map
OBJCOPY arch/riscv/boot/Image
GZIP arch/riscv/boot/Image.gz
make[1]: Leaving directory '/home/houen/antmicro/litex-buildenv/build/arty_net_vexriscv.linux/software/linux'
real 0m40,018s
user 6m14,887s
sys 0m18,754s
...
(LX P=arty C=vexriscv.linux F=linux) $
Please make sure the number shown next to 'user' 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_vexriscv.linux/software/linux
directory.
Enter the LiteX environment and run the ./scripts/build-renode.sh script.
(LX P=arty C=vexriscv.linux F=linux) $ ./scripts/build-renode.sh
Note that booting to Linux might take a while. It'll halt for a while in LiteX BIOS at:
--========= Peripherals init ===========--
when waiting for initializing liteeth.
Next, it'll stop at:
--========== Boot sequence =============--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
waiting for serialboot to timeout.
Finally, downloading all images over tftp might take a while.
Once at the "buildroot login:
" screen, you should be able to login with the username "root
";
...
Welcome to Buildroot
buildroot login: root
login[48]: root login on 'hvc0'
# ls /
bin init linuxrc opt run tmp
dev lib media proc sbin usr
etc lib32 mnt root sys var
#
# cat /proc/cpuinfo
processor : 0
hart : 0
isa : rv32ima
mmu : sv32
uarch : spinalhdl,vexriscv
If you need to manually stop or start the tftp server (e.g. after a reboot), then you can use;
(LX P=arty C=vexriscv.linux F=linux) $ make tftpd_stop # Stop any previously run tftp server
(LX P=arty C=vexriscv.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.
If you have exited the LiteX environment, you will need to re-enter it. See "Resuming Development" above.
$ export CPU=vexriscv CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
$ source ./scripts/enter-env.sh
(LX P=arty C=vexriscv.linux F=linux) $
This step will only work if you have a FPGA attached to your machine.
Make sure that FIRMWARE=firmware
for this test.
$ export CPU=vexriscv CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=firmware
$ source ./scripts/enter-env.sh
(LX P=arty C=vexriscv.linux) $ make gateware-load
openocd -f board/digilent_arty.cfg -c "init; pld load 0 build/arty_net_vexriscv.linux//gateware/top.bit; exit"
Open On-Chip Debugger 0.10.0+dev-00921-g263deb380-dirty (2019-07-22-22:22)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
jtagspi_program
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x0362d093 (mfg: 0x049 (Xilinx), part: 0x362d, ver: 0x0)
(LX P=arty C=vexriscv.linux) $ make firmware-load
...
make[1]: Leaving directory '/home/houen/antmicro/litex-buildenv/build/arty_net_vexriscv.linux/software/firmware'
real 0m4,703s
user 0m4,075s
sys 0m0,666s
flterm --port=/dev/ttyUSB1 --kernel=build/arty_net_vexriscv.linux//software/firmware/firmware.bin --speed=115200
[FLTERM] v2.4-29-g47d3b15 Starting...
__ _ __ _ __
/ / (_) /____ | |/_/
/ /__/ / __/ -_)> <
/____/_/\__/\__/_/|_|
(c) Copyright 2012-2019 Enjoy-Digital
(c) Copyright 2007-2015 M-Labs Ltd
BIOS built on Jul 25 2019 12:20:18
BIOS CRC passed (c4dfb2b8)
--============ SoC info ================--
CPU: VexRiscv @ 100MHz
ROM: 64KB
SRAM: 32KB
L2: 8KB
MAIN-RAM: 262144KB
--========= Peripherals init ===========--
Initializing SDRAM...
SDRAM now under software control
Read leveling:
m0, b0: |11111111110000000000000000000000| delays: 05+-05
m0, b1: |00000000000000111111111111000000| delays: 20+-06
m0, b2: |00000000000000000000000000000001| delays: 31+-00
m0, b3: |00000000000000000000000000000000| delays: -
m0, b4: |00000000000000000000000000000000| delays: -
m0, b5: |00000000000000000000000000000000| delays: -
m0, b6: |00000000000000000000000000000000| delays: -
m0, b7: |00000000000000000000000000000000| delays: -
best: m0, b1 delays: 20+-06
m1, b0: |11111111110000000000000000000000| delays: 05+-05
m1, b1: |00000000000000111111111111000000| delays: 20+-06
m1, b2: |00000000000000000000000000000001| delays: 31+-00
m1, b3: |00000000000000000000000000000000| delays: -
m1, b4: |00000000000000000000000000000000| delays: -
m1, b5: |00000000000000000000000000000000| delays: -
m1, b6: |00000000000000000000000000000000| delays: -
m1, b7: |00000000000000000000000000000000| delays: -
best: m1, b1 delays: 20+-06
SDRAM now under hardware control
Memtest OK
--========== Boot sequence =============--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
[FLTERM] Received firmware download request from the device.
[FLTERM] Uploading kernel (57232 bytes)...
[FLTERM] Upload complete (7.6KB/s).
[FLTERM] Booting the device.
[FLTERM] Done.
Executing booted program at 0x40000000
--============= Liftoff! ===============--
HDMI2USB firmware booting...
hardware version info
===============================================
DNA: 005cc54e233ef054
MAC: Unknown
gateware version info
===============================================
platform: arty
target: net
revision: 365d2d65998a80b359b904dc9244afd4df057799
firmware version info
===============================================
platform: arty
target: net
git commit: 365d2d65998a80b359b904dc9244afd4df057799
git branch: riscv_linux
git describe: v0.0.4-560-g365d2d6-dirty
git status:
--
M ../../../../Makefile
m ../../../../third_party/litex
?? ../../../../.Makefile.swp
?? ../../../../third_party/riscv-toolchain/
--
built: Jul 25 2019 12:28:34
uptime: 00:00:00
-----------------------------------------------
MDIO mode: Reserved / 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>
If you see no output, press 'Enter' a few times. You can then kick off the firmware loading process again:
BIOS> serialboot
Booting from serial...
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 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 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
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
If you need to manually stop or start the tftp server (e.g. after a reboot), then you can use
(LX P=arty C=vexriscv) $ make tftpd_stop # Stop any previously run tftp server
$ export CPU=vexriscv CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=firmware
$ source ./scripts/enter-env.sh
(LX P=arty C=vexriscv.linux) $ make tftpd_start # Start the tftp server again
(LX P=arty C=vexriscv.linux) $ make tftp # Copy firmware to tftp server directory
(LX P=arty C=vexriscv.linux) $ make gateware-load # Load gateware
(LX P=arty C=vexriscv.linux) $ make firmware-connect # Connect to the serial console
After running make firmware-connect
, if you see something like this:
--============= Liftoff! ===============--
HDMI2USB firmware booting...
hardware version info
===============================================
DNA: 005cc54e233ef054
MAC: Unknown
gateware version info
===============================================
platform: arty
target: net
revision: 365d2d65998a80b359b904dc9244afd4df057799
firmware version info
===============================================
platform: arty
target: net
git commit: 365d2d65998a80b359b904dc9244afd4df057799
git branch: riscv_linux
git describe: v0.0.4-560-g365d2d6-dirty
git status:
--
M ../../../../Makefile
m ../../../../third_party/litex
?? ../../../../.Makefile.swp
?? ../../../../third_party/riscv-toolchain/
--
built: Jul 25 2019 12:33:32
uptime: 00:00:00
-----------------------------------------------
MDIO mode: Reserved / 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, and "q" in the Renode monitor to exit Renode.
After you have configured your network, you should be able to boot Linux via tftp on your hardware!
$ export CPU=vexriscv CPU_VARIANT=linux PLATFORM=arty TARGET=net FIRMWARE=linux
$ source ./scripts/enter-env.sh
(LX P=arty C=vexriscv.linux F=linux) $
(LX P=arty C=vexriscv.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 Jul 25 12:42:45 2019 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 Thu Jul 25 12:42:50 2019...
real 3m19,477s
user 4m46,632s
sys 0m20,560s
(LX P=arty C=vexriscv.linux F=linux) $
(LX P=arty C=vexriscv.linux F=linux) $ ./scripts/build-linux.sh
...
AR lib/built-in.a
GEN .version
CHK include/generated/compile.h
AR built-in.a
LD vmlinux.o
MODPOST vmlinux.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SYSMAP System.map
OBJCOPY arch/riscv/boot/Image
GZIP arch/riscv/boot/Image.gz
make[1]: Leaving directory '/home/houen/antmicro/litex-buildenv/build/arty_net_vexriscv.linux/software/linux'
real 0m37,394s
user 6m19,952s
sys 0m18,686s
...
(LX P=arty C=vexriscv.linux F=linux) $
(LX P=arty C=vexriscv.linux F=linux) $ make tftpd_stop
(LX P=arty C=vexriscv.linux F=linux) $ make tftpd_start
(LX P=arty C=vexriscv.linux F=linux) $ make tftp # Copy Linux firmware to tftp server
(LX P=arty C=vexriscv.linux F=linux) $ make gateware-load # Load the gateware to the FPGA
(LX P=arty C=vexriscv.linux F=linux) $ make firmware-connect # Connect to the serial console
__ _ __ _ __
/ / (_) /____ | |/_/
/ /__/ / __/ -_)> <
/____/_/\__/\__/_/|_|
(c) Copyright 2012-2019 Enjoy-Digital
(c) Copyright 2007-2015 M-Labs Ltd
BIOS built on Jul 25 2019 12:39:32
BIOS CRC passed (6c05d688)
--============ SoC info ================--
CPU: VexRiscv @ 100MHz
ROM: 64KB
SRAM: 32KB
L2: 8KB
MAIN-RAM: 262144KB
--========= Peripherals init ===========--
Initializing SDRAM...
SDRAM now under software control
Read leveling:
m0, b0: |11111111110000000000000000000000| delays: 05+-05
m0, b1: |00000000000000111111111111000000| delays: 20+-06
m0, b2: |00000000000000000000000000000001| delays: 31+-00
m0, b3: |00000000000000000000000000000000| delays: -
m0, b4: |00000000000000000000000000000000| delays: -
m0, b5: |00000000000000000000000000000000| delays: -
m0, b6: |00000000000000000000000000000000| delays: -
m0, b7: |00000000000000000000000000000000| delays: -
best: m0, b1 delays: 20+-06
m1, b0: |11111111110000000000000000000000| delays: 05+-05
m1, b1: |00000000000000111111111111000000| delays: 20+-06
m1, b2: |00000000000000000000000000000001| delays: 31+-00
m1, b3: |00000000000000000000000000000000| delays: -
m1, b4: |00000000000000000000000000000000| delays: -
m1, b5: |00000000000000000000000000000000| delays: -
m1, b6: |00000000000000000000000000000000| delays: -
m1, b7: |00000000000000000000000000000000| delays: -
best: m1, b1 delays: 20+-06
SDRAM now under hardware control
Memtest OK
--========== Boot sequence =============--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
Timeout
Loading emulator.bin from flash...
Error: Invalid image length 0xffffffff
Booting from flash...
Error: Invalid image length 0xffffffff
Booting from network...
Local IP : 192.168.100.50
Remote IP: 192.168.100.100
Fetching from: UDP/6069
Jul 25 12:48:53 bakura atftpd[13320.139871515571968]: socket may listen on any address, including broadcast
Jul 25 12:48:53 bakura atftpd[13320.139871515571968]: Serving Image to 192.168.100.50:7642
Jul 25 12:48:59 bakura atftpd[13320.139871515571968]: Server thread exiting
Jul 25 12:48:59 bakura atftpd[13320.139871591372544]: socket may listen on any address, including broadcast
Jul 25 12:48:59 bakura atftpd[13320.139871591372544]: Serving rootfs.cpio to 192.168.100.50:7642
Downloaded 2726132 bytes from Image over TFTP to 0x40000000
Jul 25 12:49:07 bakura atftpd[13320.139871591372544]: Server thread exiting
Jul 25 12:49:07 bakura atftpd[13320.139871515571968]: socket may listen on any address, including broadcast
Jul 25 12:49:07 bakura atftpd[13320.139871515571968]: Serving rv32.dtb to 192.168.100.50:7642
Jul 25 12:49:07 bakura atftpd[13320.139871515571968]: Server thread exiting
Jul 25 12:49:07 bakura atftpd[13320.139871591372544]: socket may listen on any address, including broadcast
Jul 25 12:49:07 bakura atftpd[13320.139871591372544]: Serving emulator.bin to 192.168.100.50:7642
Jul 25 12:49:07 bakura atftpd[13320.139871591372544]: Server thread exiting
Downloaded 4055552 bytes from rootfs.cpio over TFTP to 0x40800000
Downloaded 1866 bytes from rv32.dtb over TFTP to 0x41000000
Downloaded 2992 bytes from emulator.bin over TFTP to 0x50000000
Executing booted program at 0x50000000
--============= Liftoff! ===============--
*** VexRiscv BIOS ***
*** Supervisor ***
No DTB passed to the kernel
Linux version 5.0.0 (houen@bakura) (gcc version 8.3.0 (GCC)) #1 Thu Jul 25 12:45:25 CEST 2019
Initial ramdisk at: 0x(ptrval) (8388608 bytes)
Zone ranges:
Normal [mem 0x00000000c0000000-0x00000000c7ffffff]
Movable zone start for each node
Early memory node ranges
node 0: [mem 0x00000000c0000000-0x00000000c7ffffff]
Initmem setup node 0 [mem 0x00000000c0000000-0x00000000c7ffffff]
elf_hwcap is 0x1101
Built 1 zonelists, mobility grouping on. Total pages: 32512
Kernel command line: mem=32M@0x40000000 rootwait console=hvc0 root=/dev/ram0 init=/sbin/init swiotlb=32
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Sorting __ex_table...
Memory: 21588K/32768K available (1955K kernel code, 94K rwdata, 317K rodata, 104K init, 184K bss, 11180K reserved, 0K cma-reserved)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 25483472618 ns
sched_clock: 32 bits at 75MHz, resolution 13ns, wraps every 28633115129ns
Console: colour dummy device 80x25
printk: console [hvc0] enabled
Calibrating delay loop (skipped), value calculated using timer frequency.. 150.00 BogoMIPS (lpj=300000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
futex hash table entries: 256 (order: -1, 3072 bytes)
clocksource: Switched to clocksource riscv_clocksource
Unpacking initramfs...
Initramfs unpacking failed: no cpio magic
workingset: timestamp_bits=30 max_order=15 bucket_order=0
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler mq-deadline registered
io scheduler kyber registered
random: get_random_bytes called from init_oops_id+0x4c/0x60 with crng_init=0
Freeing unused kernel memory: 104K
This architecture does not have kernel memory protection.
Run /init as init process
mount: mounting tmpfs on /dev/shm failed: Invalid argument
mount: mounting tmpfs on /tmp failed: Invalid argument
mount: mounting tmpfs on /run failed: Invalid argument
Starting syslogd: OK
Starting klogd: OK
Initializing random number generator... random: dd: uninitialized urandom read (512 bytes read)
done.
Starting network: ip: socket: Function not implemented
ip: socket: Function not implemented
FAIL
Welcome to Buildroot
buildroot login: root
login[48]: root login on 'hvc0'
# 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).
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 Renode 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