Command Reference
See Commands and Descriptions for the device families supported by each of these commands.
arch
Syntax
-arch [options]
Description
Xilinx® family architecture for which the boot image needs to be created.
Arguments
- zynq: Zynq®-7000 device architecture. This is the default value. family architecture for which the boot image needs to be created.
- zynqmp: Zynq® UltraScale+™ MPSoC device architecture.
- fpga: Image is targeted for other FPGA architectures.
- versal: This image is targeted to Versal™ devices
Return Value
None
Example
bootgen -arch zynq -image test.bif -o boot.bin
authenticatedjtag
Syntax
-authenticatedjtag [options] [filename]
Description
Used to enable JTAG during secure boot.
Arguments
- rsa
- ecdsa
Example
bootgen -arch versal -image boot.bif -w -o boot.bin -authenticatedjtag rsa authJtag-rsa.bin
bif_help
Syntax
bootgen -bif_help
bootgen -bif_help aeskeyfile
Description
Lists the supported BIF file attributes. For a more detailed explanation of each bif attribute, specify the attribute name as argument to -bif_help on the command line.
dual_ospi_mode
Syntax
bootgen -arch versal -dual_ospi_mode stacked <size>
Description
Generates two output files for dual OSPI stacked configuration, size (in MB) of the flash needs to be mentioned (64, 128, or 256).
Example
This example generates two output files for independently programming to both flashes in a OSPI dual stacked configuration. The first 64 MB of the actual image is written to first file and the remainder to the second file. In case the actual image itself is less than 64 MB, only one file is generated. This is only supported for Versal ACAP.
bootgen -arch versal -image test.bif -o -boot.bin -dual_ospi_mode stacked 64
Arguments
- stacked, <size>
dual_qspi_mode
Syntax
bootgen -dual_qspi_mode [parallel]|[stacked <size>]
Description
Generates two output files for dual QSPI configurations. In the case of stacked configuration, size (in MB) of the flash needs to be mentioned (16, 32, 64, 128, or 256).
Examples
This example generates two output files for independently programming to both flashes in QSPI dual parallel configuration.
bootgen -image test.bif -o -boot.bin -dual_qspi_mode parallel
This example generates two output files for independently programming to both flashes in a QSPI dual stacked configuration. The first 64 MB of the actual image is written to first file and the remainder to the second file. In case the actual image itself is less than 64 MB, only one file is generated.
bootgen -image test.bif -o -boot.bin -dual_qspi_mode stacked 64
Arguments
- parallel
- stacked <size>
dump
Syntax
-dump [options]
Description
This command dumps the contents of boot header in to a separate binary file while generating PDI.
Example
[bootgen -image test.bif -o -boot.bin -log trace -dump bh]
Arguments
- empty: Dumps the partitions as binary files.
- bh: Dumps boot header as a separate file.
dump_dir
Syntax
dump_dir <path>
Description
This option is used to specify a directory location to write the contents of -dump command.
Example
bootgen -arch versal -dump boot.bin -dump_dir <path>
efuseppkbits
Syntax
bootgen -image test.bif -o boot.bin -efuseppkbits efusefile.txt
Arguments
efusefile.txt
Description
This option specifies the name of the eFUSE file to be written to contain the PPK hash. This option generates a direct hash without any padding. The efusefile.txt file is generated containing the hash of the PPK key, where:
- Zynq®-7000 uses the
SHA2
protocol for hashing. - Zynq®
UltraScale+™ MPSoC and Versal ACAP uses the
SHA3
for hashing.
encrypt
Syntax
bootgen -image test.bif -o boot.bin -encrypt <efuse|bbram|>
Description
- This option specifies how to perform encryption and where the keys are
stored. The NKY key file is passed through the BIF file attribute
aeskeyfile
. Only the source is specified using command line.
Arguments
Key source arguments:
- efuse: The AES key is stored in eFUSE. This is the default value.
- bbram: The AES key is stored in BBRAM.
encryption_dump
Syntax
bootgen -arch zynqmp -image test.bif -encryption_dump
Description
Generates an encryption log file, aes_log.txt. The aes_log.txt generated has the details of AES Key/IV pairs used for encrypting each block of data. It also logs the partition and the AES key file used to encrypt it.
Example
all:
{
[bootloader, encryption=aes, aeskeyfile=test.nky] fsbl.elf
[encryption=aes, aeskeyfile=test1.nky] hello.elf
}
fill
Syntax
bootgen -arch zynq -image test.bif -fill 0xAB -o boot.bin
Description
This option specifies the byte to use for filling padded/reserved memory in <hex byte>
format.
Outputs
The boot.bin file in the 0xAB
byte.
Example
The output image is generated with name boot.bin. The format of the output image is determined based on the file
extension of the file given with -o
option, where
-fill:
Specifies the Byte to be padded. The
<hex byte
> is padded in the header tables
instead of 0xFF
.
bootgen -arch zynq -image test.bif -fill 0xAB -o boot.bin
generate_hashes
Syntax
bootgen -image test.bif -generate_hashes
Description
This option generates hash files for all the partitions and other components to be signed like boot header, image and partition headers. This option generates a file containing PKCS#1v1.5 padded hash for the Zynq®-7000 format:
Value | SHA-2 Hash* | T-Padding | 0x0 | 0xFF | 0x01 | 0x00 |
---|---|---|---|---|---|---|
Number of bytes | 32 | 19 | 1 | 202 | 1 | 1 |
This option generates the file containing PKCS#1v1.5 padded hash for the Zynq® UltraScale+™ MPSoC format:
Value | 0x0 | 0x1 | 0xFF | 0xFF | T-Padding | SHA-3 Hash |
---|---|---|---|---|---|---|
Number of bytes | 1 | 1 | 314 | 1 | 19 | 48 |
Example
test:
{
[pskfile] ppk.txt
[sskfile] spk.txt
[bootloader, authentication=rsa] fsbl.elf
[authentication=rsa] hello.elf
}
- bootheader hash
- spk hash
- header table hash
- fsbl.elf partition hash
- hello.elf partition hash
generate_keys
Syntax
bootgen -image test.bif -generate_keys <rsa|pem|obfuscated>
Description
This option generates keys for authentication and obfuscated key used for encryption.
Authentication Key Generation Example
Authentication key generation example. This example generates the authentication keys in the paths specified in the BIF file.
Examples
image:
{
[ppkfile] <path/ppkgenfile.txt>
[pskfile] <path/pskgenfile.txt>
[spkfile] <path/spkgenfile.txt>
[sskfile] <path/sskgenfile.txt>
}
Obfuscated Key Generation Example
This example generates the obfuscated in the same path as that of the familykey.txt.
Command:
bootgen -image test.bif -generata_keys rsa
The Sample BIF file is shown in the following example:
image:
{
[aeskeyfile] aes.nky
[bh_key_iv] bhkeyiv.txt
[familykey] familykey.txt
}
Arguments
- rsa
- pem
- obfuscated
h, help
Syntax
bootgen -help
bootgen -help arch
Description
Lists the supported command line attributes. For a more detailed explanation of each
attribute, specify the attribute name as argument to -help
on the
command line.
image
Syntax
-image <BIF_filename>
Description
This option specifies the input BIF file name. The BIF file specifies each component of the boot image in the order of boot and allows optional attributes to be specified to each image component. Each image component is usually mapped to a partition, but in some cases an image component can be mapped to more than one partition if the image component is not contiguous in memory.
Arguments
bif_filename
Example
bootgen -arch zynq -image test.bif -o boot.bin
The Sample BIF file is shown in the following example:
the_ROM_image:
{
[init] init_data.int
[bootloader] fsbl.elf
Partition1.bit
Partition2.elf
}
log
Syntax
bootgen -image test.bif -o -boot.bin -log trace
Description
Generates a log while generating the boot image. There are various options for choosing the level of information. The information is displayed on the console as well as in the log file, named bootgen_log.txt is generated in the current working directory.
Arguments
- error: Only the error information is captured.
- warning: The warnings and error information is captured. This is the default value.
- info: The general information and all the above info is captured.
- trace: More detailed information is captured along with the information above.
nonbooting
Syntax
bootgen -arch zynq -image test.bif -o test.bin -nonbooting
Description
This option is used to create an intermediate boot image. An intermediate test.bin image is generated as output even in the absence of secret key, which is required to generate an authenticated image. This intermediate image cannot be booted.
Example
all:
{
[ppkfile]primary.pub
[spkfile]secondary.pub
[spksignature]secondary.pub.sha256.sig
[bootimage,authentication=rsa,presign=fsbl_0.elf.0.sha256.sig]fsbl_e.bin
}
o
Syntax
bootgen -arch zynq -image test.bif -o boot.<bin|mcs>
Description
This option specifies the name of the output image file with a .bin or .mcs extension.
Outputs
A full boot image file in either BIN or MCS format.
Example
bootgen -arch zynq -image test.bif -o boot.mcs
The boot image is output in an MCS format.
p
Syntax
bootgen -image test.bif -o boot.bin -p xc7z020clg48 -encrypt efuse
Description
This option specifies the partname of the Xilinx® device. This is needed for generating a encryption key. It is copied verbatim to
the *.nky file in the Device
line of the nky file. This is applicable only when encryption
is enabled. If the key file is not present in the path specified in BIF file, then a
new encryption key is generated in the same path and xc7z020clg484
is copied along side the Device
field in the nky file. The
generated image is an encrypted image.
padimageheader
Syntax
bootgen -image test.bif -w on -o boot.bin -padimageheader <0|1>
Description
This option pads the Image Header Table and Partition Header Table to maximum
partitions allowed, to force alignment of following partitions. This feature is
enabled by default. Specifying a 0
disables this feature. The
boot.bin has the image header tables and
partition header tables in actual and no extra tables are padded. If nothing is
specified or if -padimageheader=1
, the total image
header tables and partition header tables are padded to max partitions.
Arguments
- 1: Pad the header tables to max partitions. This is the default value.
- 0: Do not pad the header tables.
Image or Partition Header Lengths
- For Zynq devices, the maximum partition is 14.
- For Zynq UltraScale+ MPSoCs, the maximum partition is 32.
process_bitstream
Syntax
-process_bitstream <bin|mcs>
Description
Processes only the bitstream from the BIF and outputs it as an MCS
or a BIN
file. For
example: If encryption is selected for bitstream in the BIF file, the output is an
encrypted bitstream.
Arguments
- bin: Output in BIN format.
- mcs: Output in MCS format.
Returns
Output generated is bitstream in BIN or MCS format; a processed file without any headers attached.
read
Syntax
-read [options] <filename>
Description
Used to read boot headers, image headers, and partition headers based on the options.
Arguments
- bh: To read boot header from boot image in human readable form
- iht: To read image header table from boot image
- ih: To read image headers from boot image.
- pht: To read partition headers from boot image
- ac: To read authentication certificates from boot image
Example
bootgen -arch zynqmp -read BOOT.bin
spksignature
Syntax
bootgen -image test.bif -w on -o boot.bin -spksignature spksignfile.txt
Description
This option is used to generate the SPK signature file. This option must be used only
when spkfile
and pskfile
are specified in BIF. The SPK signature file (spksignfile.txt) is generated.
Option
Specifies the name of the signature file to be generated.
split
Syntax
bootgen -arch zynq -image test.bif -split bin
Description
This option outputs each data partition with headers as a new file in MCS or BIN format.
Outputs
Output files generated are:
- Bootheader + Image Headers + Partition Headers + Fsbl.elf
- Partition1.bit
- Partition2.elf
Example
the_ROM_image:
{
[bootloader] Fsbl.elf
Partition1.bit
Partition2.elf
}
verify
Syntax
bootgen -arch zynqmp -verify boot.bin
Description
- Verify header authentication certificate:
- For Zynq UltraScale+ MPSoC: verify SPK signature and verify header signature.
- For Versal: verify SPK signature, verify IHT signature, and verify meta header signature.
- Verify bootloader authentication certificate: verify boot header signature, verify SPK signature, and verify bootloader signature.
- Verify partition authentication certificate: verify SPK signature and verify partition signature.
verify_kdf
Syntax
bootgen -arch zynqmp -verify_kdf testVec.txt
Description
L = 256
KI = d54b6fd94f7cf98fd955517f937e9927f9536caebe148fba1818c1ba46bba3a4
FixedInputDataByteLen = 60
FixedInputData = 94c4a0c69526196c1377cebf0a2ae0fb4b57797c61bea8eeb0518ca08652d14a5e1bd1b116b1794ac8a476acbdbbcd4f6142d7b8515bad09ec72f7af
Bootgen
uses the counter Mode KDF to generate the output key (KO) based on the given input
data in the test vector file. This KO will be printed on the console for the user to
compare.w
Syntax
bootgen -image test.bif -w on -o boot.bin
or
bootgen -image test.bif -w -o boot.bin
Description
This option specifies whether to overwrite an existing file or not. If the
file boot.bin already exists in the path, then
it is overwritten. Options -w on
and -w
are treated as same. If the -w
option is not specified, the file will not be overwritten by
default.
Arguments
- on: Specified with the
-w on
command with or-w
with no argument. This is the default value. - off: Specifies to not overwrite an existing file.
zynqmpes1
Syntax
bootgen -arch zynqmp -image test.bif -o boot.bin -zynqmpes1
Description
This option specifies that the image generated will be used on ES1 (1.0). This option makes a difference only when generating an Authenticated image; otherwise, it is ignored. The default padding scheme is for (2.0) ES2 and above.
Initialization Pairs and INT File Attribute
Initialization pairs let you easily initialize Processor Systems (PS) registers for the MIO multiplexer and flash clocks. This allows the MIO multiplexer to be fully configured before the FSBL image is copied into OCM or executed from flash with eXecute in place (XIP), and allows for flash device clocks to be set to maximum bandwidth speeds.
There are 256 initialization pairs at the end of the fixed portion of the boot
image header. Initialization pairs are designated as such because a pair consists of a
32-bit address value and a 32-bit data value. When no initialization is to take place,
all of the address values contain 0xFFFFFFFF
, and the
data values contain 0x00000000
. Set initialization
pairs with a text file that has an .int file
extension by default, but can have any file extension.
The[init]file attribute precedes the file name to identify it as the INIT file in the BIF file. The data format consists of an operation directive followed by:
- An address value
- an = character
- a data value
.set.
operation directive; for example:.set. 0xE0000018 = 0x00000411; // This is the 9600 uart setting.
Bootgen fills the boot header initialization from the INT file up to the 256 pair limit. When the BootROM runs, it looks at the address value. If it is not 0xFFFFFFFF, the BootROM uses the next 32-bit value following the address value to write the value of address. The BootROM loops through the initialization pairs, setting values, until it encounters a 0xFFFFFFFF address, or it reaches the 256th initialization pair.
Bootgen provides a full expression evaluator (including nested parenthesis to enforce precedence) with the following operators:
* = multiply/
= divide
% = mod
an address value
ulo divide
+ = addition
- = subtraction
~ = negation
>> = shift right
<< = shift left
& = binary and
= binary or
^ = binary nor
The numbers can be hex (0x
), octal (0o
), or
decimal digits. Number expressions are maintained as 128-bit fixed-point integers. You
can add white space around any of the expression operators for readability.