Firmware Creation
Firmware Guide - Home
Download the Project
Telescan - Guide: Extract the Donor Card Data
Vivado - Guide: Create Project & Fill in Telescan Data
VS Code Vivado Telescan pcileech-fpga Python Script Python 3.12
Download the Project
Download Ulf's pcileech-fpga project, extract it and copy the folder you need for your DMA device to another location.
*I have a Captain DMA v4 35T, I will therefor use the
PCIeSquirrel
folder
Sometimes Vivado will fail to generate the project files or fail when generating the Bitstream
copy the folder to a location that doesn't have any special characters in the folder names and isn't too long, keep it simple.
Example
C:/PCIeSquirrel
This is where you'll be working on the firmware
Shadow Configuration Copy
Note
Download Telescan
Saving the donor device with Telescan:
To copy the configuration space from a real donor device, start Telescan and go step by step as shown below.
example:
C:/Users/Simonrak/Desktop/Donor.tlscan
Note
Before closing Telescan we should retrieve some important values needed in Vivado later
click on Next step
below
ID's needed for Vivado
To get the IDs needed in Vivado
We need these values to make the DMA show up as our donor device.
At the top of the header in your device, we need to write down:
Vendor ID
Device ID
Command
Revision ID
Class Code
Note
Write these down and save them, we will need them later in Vivado
Bar Sizing
Get the BAR sizing from Telescan
The ¹BARs
( Base Address Registers
) has a specified size assigned to them from the donor device, to make our DMA firmware look like the real donor card we will also copy the sizing
To the right, we can see
Base Address Register 0
Right click on the white section in
Base Address Register 0
:Write
Dword at offset 010h
(Doing this will deactivate the device, it's normal)
If a bar ends in:
01
= IO
04
= 64-bit
0C
= 64-bit, prefetchable
The bar after a 64-bit bar (ending in 04
and 0C
) is always FFFFFFFF
Example:
BAR0: FFFFE004
BAR1: FFFFFFFF
If you want to insert your BAR0 data into pcileech_bar_zero4k.coe
, it won't work if you set BAR0 to 01
(IO)
Note
Repeat this with all BARs, write down what each bar has in sizing
BARs
When the firmware is finished and flashed to our DMA, the address will not be the same as the real donor device. This address is assigned by the donor device and it's driver.
¹There is no way to get same address as the donor device to my knowledge, so the sizing
will have to do for now
Max Payload Size Supported
Max Payload Size
This is the last step using Telescan,
we need the bits
value (1s and 0s) for Max_Payload_Size_Supported
,found in our donor devices Device Capabilities Register
found in the PCI Express Capability
*¹We need this value to avoid Tiny pcie
Note
Tiny pcie causes slow speeds, and firmware failures
Convert the Telescan
Convert the Telescan file to use it with Vivado
Now we will convert our Telescan file donor.tlscan
to a format that Vivado can handle, this is done automatically by the script.
Open CMD
If the script ran without any issues, it has now generated a file called
output.coe
on your desktopRename the file to
pcileech_cfgspace.coe
Copy it to into the
/ip/
folder in your project folder and replace the current file
Change Values
Recommended tools
Use VS Code for this part
Changing values before opening Vivado GUI
Now we will change the "code" in the /src/
folder, to make it possible to generate a firmware using the shadow configuration file
we copied into the /ip/
folder in the previous step.
Open the file src/pcileech_fifo.sv
Change:
rw[203] <- 1'b1;
to -> 1'b0;
Open src/pcileech_pcie_cfg_a7.sv
Change
rw[20] <- 0;
to 1;
rw[21] <- 0;
to 1;
rw[143:128] <- 16'h0007;
to your donor devices command
value
Note
Replace the 0;
not the entire line
If your donors command
value doesn't work, try 0407;
, 0406;
or 0006;
Batch file
Making a batch file
Make a batch file by creating a new document (.txt
) and rename it to Generate.bat
Right click it and click on edit, copy the text below into the .bat
The batch (Generate.bat
) should be moved to your projects main folder.
When you're done with all the changes in the /src/
and /ip/
folders in the previous step, run the batch file to launch Vivado and generate the project.
Vivado GUI Generating
Vivado Project Generation
After we run the batch, Vivado will start generating the project, this takes a minute or so depending on what PC you have.
Open Re-customize IP
How to find and open the Re-customize IP
window
After the project is done generating, we will open the Re-customize IP
window and fill out the information we saved from Telescan earlier IDs
& Class Code
To open the Re-customize IP
window:
Change ID's & Class Code in Re-customize IP
Adding ID's & Class Code in Re-customize IP
Inside Re-customize IP
on the top :
Filling in the Class Code
Still inside the IDs tab, look further down to see Class Code
Class Code
is filled out from up to down/left to right(explanation below)
If our
Class Code
is as below, it will be:Base Class Value
->01
Sub Class Value
->08
Interface Value
->02
Save Changes in Re-customize IP
Leave Re-customize IP
and generate
To close the Re-customize IP
window:
A new window will appear (
Generate Output Products
)Select
Global
¹
Lock the Core
Locking the core
Now we will lock the core to prevent values from overwriting, it also allows us to make some manual changes not available in the Vivado GUI
Paste
set_property is_managed false [get_files pcie_7x_0.xci]
into theTcl Console
and press enter
Change Values in core_top.v
The last step
This is the last step before we can generate the firmware, we will use the BAR sizing
and Max_Payload_Size_Supported
we saved from earlier.
Go to line 87 to 92 and fill in the
BAR sizings
from earlierFill in the
BARs
you have, leave the others as00000000
(Only remove the pink text)
Go to line 125 and 126 and change it to
0A
EXT_CFG_CAP_PTR = 6'h2A,
->EXT_CFG_CAP_PTR = 6'h0A,
EXT_CFG_XP_CAP_PTR = 10'h043,
->EXT_CFG_XP_CAP_PTR = 10'h0A,
(¹This moves the starting position of the shadow configuration)
Go to line 384 and set
MPS_FORCE
toTRUE
Change
MPS_FORCE = "FALSE",
->MPS_FORCE = "TRUE",
Note
¹We moved the starting position of the shadow configuration to start after the BARs
, this will let the core generate the BARs
instead of the shadow configuration
*If we let the shadow configuration
generate them, it will cause illegal vendor ID's
Generate the Firmware
Generate the firmware
Now we're finally ready to generate our firmware.
This will open a window called
Launch Runs
Depending on your PC, you can change
Number of jobs
(I have
32 GB
RAM and aRyzen 5800x
, 12jobs
maxes out my RAM)
A message box will appear after 10-30 minutes, telling us that the build was completed
The firmware can be found in:
/pcileech_squirrel/pcileech_squirrel.runs/impl_1/
Named:
pcileech_squirrel_top.bin
example:
C:/pcileech_squirrel/pcileech_squirrel.runs/impl_1/pcileech_squirrel_top.bin
Last updated