Xilinx / bootgen

bootgen source code
Other
34 stars 42 forks source link

Creating aeskeys and encrypted/signed .BIN files results in hanging process #22

Closed MichaelBonnet closed 1 year ago

MichaelBonnet commented 1 year ago

I am using the most recent commit of this repo's master branch - Xilinx Bootgen v2022.2

When I attempt to create an aeskey with bootgen, the process will "hang" seemingly forever. Example:

gen_aeskey:
{
  [aeskeyfile] aeskey.nky
  [keysrc_encryption] efuse
  [bootloader, encryption=aes] zynq_fsbl.elf
}

$ bootgen -p xc7z015 -image gen_aeskey.bif

Once I run the above command, I just see the following, with the process never finishing (tested up to 6 hours):


****** Xilinx Bootgen v2022.2
  **** Build date : Feb 23 2023-20:49:42
    ** Copyright 1986-2022 Xilinx, Inc. All Rights Reserved.

The same thing happens when trying to make any encrypted/signed .BIN files where the -p option is required.

fsbl_prime:
{
  [aeskeyfile] aeskey.nky
  [keysrc_encryption] efuse

  [pskfile] psk.pem
  [sskfile] ssk.pem

  [bootloader,encryption=aes,authentication=rsa] zynq_fsbl.elf
}

$ bootgen -arch zynq -p xc7z015 -image fsbl_prime.bif -o FSBL_PRIME.BIN -w on


bootloaders:
{
  [aeskeyfile] aeskey.nky
  [keysrc_encryption] efuse

  [pskfile] psk.pem
  [sskfile] ssk.pem

  [bootloader,encryption=aes,authentication=rsa] zynq_fsbl.elf
  [encryption=aes,authentication=rsa] u-boot.elf
}

$ bootgen -arch zynq -p xc7z015 -image bootloaders.bif -o BOOT.BIN -w on


linux_image:
{
  [aeskeyfile] aeskey.nky
  [keysrc_encryption] efuse

  [pskfile] psk.pem
  [sskfile] ssk.pem

  [encryption=aes,authentication=rsa, load = 0x3000000, partition_owner=uboot] system.bit.gz
  [encryption=aes,authentication=rsa, load = 0x5000000, partition_owner=uboot] image.ub
}

$ bootgen -arch zynq -p xc7z015 -image image.bif -o IMAGE.BIN -w on


While I initially imagined that part of the issue with the last three things is that the aeskey.nky file didn't exist, it doesn't complain to me about that like it does when other files may be missing.

The common thread here appears to be providing the -p xc7z015 arguments. This part name is what my vendor mentions in their documentation, and they say that the device is "Zynq®-7015 SoC family device featuring ARM Cortex™-A9 processor". I wonder if somehow the petalinux image that was built for this Zynq device is somehow wanting a different part name, or if the part name is just straight up wrong.

Trying this with something like bootgen -p xc7z030 -image gen_aeskey.bif or from bootgen -help p's example bootgen -p xc7z020clg484 -image gen_aeskey.bif or even a nonsensical argument like bootgen -p x7148 -image gen_aeskey.bif

all result in the same behavior.

What might I be doing wrong/need to fix?

RamyaDarapuneni commented 1 year ago

The run is stuck in an infinite loop and hence bootgen hanged. Submitted the fix for this issue with https://github.com/Xilinx/bootgen/commit/1795f18361caf1536d76ffe40ae3cb66e212b020. Please check with the latest commit.

kalvdans commented 1 year ago

Why was myrand() hanging in an infinite loop?

MichaelBonnet commented 1 year ago

Issue successfully resolved, many thanks