Software for the Raspberry Pi to DE0 Nano connector
- DSP-Crowd's Raspberry Pi to DE0 Nano connector
- One of the following Raspberry Pis
- Raspberry Pi Zero
- Raspberry Pi Zero W
- Raspberry Pi 1 Model A+
- Raspberry Pi 1 Model B+
- Raspberry Pi 2 Model B
- Raspberry Pi 3 Model B
- DE0 Nano
The following steps must be done only once.
Note: This readme will be updated in the near future.
- Connect an USB Micro B cable to the connector board. We recommend the official Raspberry Pi power supply as source
- For the initial setup you also need to connect your DE0 Nano to the PC, because the initial design must be downloaded with Quartus
- If you use a Raspberry Pi 1 Model B+ you also need to connect an USB Micro B cable to the Raspberry Pi while it is booting. After that you can remove this cable
- Copy the device tree overlay file
_hello-world/raspberry_pi_zero/dts/overlays/dspc-de0_nano.dtbo
from the repository to the directory/boot/overlays
on your Raspberry Pi
pi@raspberrypi:~ $ sudo wget https://raw.githubusercontent.com/DSP-Crowd/software/master/_hello-world/raspberry_pi_zero/dts/overlays/dspc-de0_nano.dtbo -P /boot/overlays
- Add the line
dtoverlay=dspc-de0_nano
in/boot/config.txt
- Install the mtd-utils package with
sudo apt-get install mtd-utils
- Restart the Pi with
reboot
- After the reboot you should see a device called
mtd0
in the directory/dev
. Note: We assume a fresh Raspbian OS. If you already use another hardware extension it may not work as described here
pi@raspberrypi:~ $ ls -l /dev/mtd0
crw------- 1 root root 90, 0 Mar 29 23:17 /dev/mtd0
- Download the initial design file
_hello-world/de0_nano/output/rr_base.sof
- Program the design file to your DE0 Nano board with Quartus. You can use the following command
quartus_pgm --mode=jtag -o p\;rr_base.sof
- Program the flash on the DE0 Nano board. See "Programming the DE0 Nano after the initial setup"
- After that you can remove the cable on the DE0 Nano. You will never need it again
In this section, everything is done on the Raspberry Pi
- Download the hello world designs for the FPGA:
wget https://raw.githubusercontent.com/DSP-Crowd/software/master/_hello-world/de0_nano/output/rr_base.bin
.. Slow blinking hello world ledwget https://raw.githubusercontent.com/DSP-Crowd/software/master/_hello-world/de0_nano/output/rr_base-fast.bin
.. Fast blinking hello world led
- Clear the flash device, which is on the DE0 Nano FPGA board
pi@raspberrypi:~ $ sudo flash_erase /dev/mtd0 0 6
Erasing 64 Kibyte @ 50000 -- 100 % complete
- Program the flash device
pi@raspberrypi:~ $ sudo dd if=rr_base.bin of=/dev/mtd0
411+1 records in
411+1 records out
210480 bytes (210 kB) copied, 0.973143 s, 216 kB/s
- Check if the flash device contains your file from the Raspberry Pi. If you see EOF (which means End Of File), then everything is fine! :)
pi@raspberrypi:~ $ sudo cmp rr_base.bin /dev/mtd0
cmp: EOF on rr_base.bin
- If something went wrong it looks like this:
pi@raspberrypi:~ $ sudo cmp rr_base.bin /dev/mtd0
rr_base.bin /dev/mtd0 differ: byte 33, line 1
Execute the following commands on your Pi:
- Tell Linux that you want to use pin 18. This pin is used to restart the FPGA
pi@raspberrypi:~ $ echo 18 > /sys/class/gpio/export
- Tell Linux that this pin is used as output
pi@raspberrypi:~ $ echo out > /sys/class/gpio/gpio18/direction
- Finally set and then clear pin 18. Setting the pin will initiate the FPGA reconfiguration process
pi@raspberrypi:~ $ echo 1 > /sys/class/gpio/gpio18/value
pi@raspberrypi:~ $ echo 0 > /sys/class/gpio/gpio18/value
This can also be done more convenient with our helper scripts
- Download the scripts
pi@raspberrypi:~ $ wget https://raw.githubusercontent.com/DSP-Crowd/software/master/_hello-world/raspberry_pi_zero/scripts/fpga-reconf.sh
pi@raspberrypi:~ $ wget https://raw.githubusercontent.com/DSP-Crowd/software/master/_hello-world/raspberry_pi_zero/scripts/update-fpga.sh
- Make our scripts executable
pi@raspberrypi:~ $ chmod +x update-fpga.sh fpga-reconf.sh
- Run the script
update-fpga.sh [file]
. The parameter "file" is optional. The default isrr_base.bin
pi@raspberrypi:~ $ sudo ./update-fpga.sh rr_base-fast.bin
Erasing 64 Kibyte @ 50000 -- 100 % complete
411+1 records in
411+1 records out
210480 bytes (210 kB) copied, 0.966251 s, 218 kB/s
cmp: EOF on rr_base.bin