APF6 SP FPGA configuration: Difference between revisions
From ArmadeusWiki
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category: APF6_SP]] | [[Category: APF6_SP]] | ||
[[Category: FPGA]] | [[Category: FPGA]] | ||
== Introduction == | |||
On APF6_SP PCI express bus is used to configure the FPGA (cycloneV). This article describe how to do that. | |||
All Linux drivers are already selected by default in APF6's Buildroot configuration. | |||
== Configuring from Linux == | == Configuring from Linux == | ||
=== Peripheral configuration in uboot === | |||
PCIe must be activated before Linux boot. To do that, just load the peripheral bitstream with uboot : | |||
= | <pre class="apf"> | ||
BIOS> tftpboot ${loadaddr} 192.168.0.117:binary.periph.rbf | |||
BIOS> fpga load 0 ${loadaddr} ${filesize} | |||
</pre> | |||
= | Then boot Linux: | ||
<pre class="apf"> | |||
BIOS> boot | |||
</pre> | |||
=== Core configuration in Linux === | |||
The PCIe device must be seen in lspci command in Linux : | |||
<pre class="apf"> | |||
# lspci | |||
00:00.0 PCI bridge: Device 16c3:abcd (rev 01) | |||
01:00.0 Unclassified device [0013]: Altera Corporation Device e001 (rev 01) | |||
</pre> | |||
You can then download the core (192.168.0.2 should be replaced with your Host PC IP address): | |||
<pre class="apf"> | |||
$ tftp -g -r binary.core.rbf 192.168.0.2 | |||
</pre> | |||
Load the core using [[FPGA_loader | FPGA loader linux driver]]: | |||
<pre class="apf"> | |||
$ load_fpga output_file.core.rbf | |||
Altera CvP 0000:01:00.0: Now starting CvP... | |||
Altera CvP 0000:01:00.0: CvP successful, application layer now ready | |||
</pre> | |||
== Automatic FPGA configuration == | |||
To let apf configure the FPGA automatically at boot we have to configure U-boot and Linux as seen in the following. | |||
=== U-boot === | |||
* To «autoload» your firmware while U-Boot is starting, simply add your bitstream to your rootfs, for example : | * To «autoload» your firmware while U-Boot is starting, simply add your bitstream to your rootfs, for example : | ||
<pre class="apf"> | <pre class="apf"> | ||
Line 41: | Line 77: | ||
39688 bytes read in 260 ms (148.4 KiB/s) | 39688 bytes read in 260 ms (148.4 KiB/s) | ||
Hit any key to stop autoboot: 0 | Hit any key to stop autoboot: 0 | ||
</pre> | |||
=== Linux === | |||
Once Linux booted, the core must be loaded via PCIe. This can be done with an init.d script: | |||
* Copy the bitstream '''firmware.core.rbf''' in target directory : '''/lib/firmware/fpga/''' | |||
* Create a file in '''/etc/init.d/''' named '''S80firmware''' for example. | |||
* Edit it with these lines: | |||
<source lang="bash"> | |||
load_fpga /lib/firmware/fpga/firmware.core.rbf | |||
</source> | |||
* Then add execution right for the script : | |||
<pre class="apf"> | |||
$ chmod +x /etc/init.d/S80firmware | |||
</pre> | |||
* Reboot the board: | |||
<pre class="apf"> | |||
$ reboot | |||
</pre> | </pre> |
Latest revision as of 15:45, 3 October 2025
Introduction
On APF6_SP PCI express bus is used to configure the FPGA (cycloneV). This article describe how to do that. All Linux drivers are already selected by default in APF6's Buildroot configuration.
Configuring from Linux
Peripheral configuration in uboot
PCIe must be activated before Linux boot. To do that, just load the peripheral bitstream with uboot :
BIOS> tftpboot ${loadaddr} 192.168.0.117:binary.periph.rbf BIOS> fpga load 0 ${loadaddr} ${filesize}
Then boot Linux:
BIOS> boot
Core configuration in Linux
The PCIe device must be seen in lspci command in Linux :
# lspci 00:00.0 PCI bridge: Device 16c3:abcd (rev 01) 01:00.0 Unclassified device [0013]: Altera Corporation Device e001 (rev 01)
You can then download the core (192.168.0.2 should be replaced with your Host PC IP address):
$ tftp -g -r binary.core.rbf 192.168.0.2
Load the core using FPGA loader linux driver:
$ load_fpga output_file.core.rbf Altera CvP 0000:01:00.0: Now starting CvP... Altera CvP 0000:01:00.0: CvP successful, application layer now ready
Automatic FPGA configuration
To let apf configure the FPGA automatically at boot we have to configure U-boot and Linux as seen in the following.
U-boot
- To «autoload» your firmware while U-Boot is starting, simply add your bitstream to your rootfs, for example :
/lib/firmware/fpga/firmware.periph.rbf
![]() |
Note: By default, directory /lib/firmware/fpga doesn't exists, then simply create it with # mkdir /lib/firmware/fpga |
- Then reboot under U-Boot and configure your environment variables firmware_autoload and firmware_path :
BIOS> setenv firmware_path /lib/firmware/fpga/firmware.periph.rbf BIOS> setenv firmware_autoload 1
- Do not forget to save your environment variables:
BIOS> saveenv
- That's all, now your bitstream will be loaded with U-Boot at boot:
U-Boot SPL 2014.07 (Apr 23 2015 - 16:16:45) U-Boot 2014.07 (Apr 23 2015 - 16:16:45) [...] 39688 bytes read in 260 ms (148.4 KiB/s) Hit any key to stop autoboot: 0
Linux
Once Linux booted, the core must be loaded via PCIe. This can be done with an init.d script:
- Copy the bitstream firmware.core.rbf in target directory : /lib/firmware/fpga/
- Create a file in /etc/init.d/ named S80firmware for example.
- Edit it with these lines:
load_fpga /lib/firmware/fpga/firmware.core.rbf
- Then add execution right for the script :
$ chmod +x /etc/init.d/S80firmware
- Reboot the board:
$ reboot