Go Down

Topic: FPGA Signature Generation (Read 572 times) previous topic - next topic

jwestmoreland

Hello All,

How are the signatures generated in VidorBoot.cpp:
#include "VidorBoot.h"

__attribute__ ((used, section(".fpga_bitstream_signature")))
const unsigned char signatures[4096] = {
   //#include "signature.ttf"

   0x00, 0x00, 0x00, 0x00,
   0x4d, 0xdc, 0x03, 0x00,
   0x93, 0x86, 0xad, 0x47, 0x75, 0xb0, 0x56, 0x96, 0x79, 0x64, 0xc5, 0x36, 0x12, 0xcf, 0x18, 0xce, 0xfe, 0x8a, 0xeb, 0xa2, 0x45, 0x86, 0x44, 0xfe, 0x7c, 0x45, 0x8a, 0xa9, 0x49, 0x46, 0xa7, 0xe1,
   0x00, 0x00, 0x00, 0x00,    /* TAG 0 == BOOTLOADER */
   0x01, 0x00, 0x00, 0x00,      // Set force flag; always flash this bitstream, even if the checksums match

   0x00, 0x00, 0x06, 0x00,
   0x12, 0x33, 0x1F, 0x00,
   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
   0x01, 0x00, 0x00, 0x00,      /* TAG 1 == USER BITSTREAM */
   0x01, 0x00, 0x00, 0x00,      // Set force flag; always flash this bitstream, even if the checksums match

   0x00, 0x00, 0x10, 0x00,
   0xD7, 0xAA, 0x08, 0x00,
   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
   0x02, 0x00, 0x00, 0x00,      /* TAG 2 == USER DATA */
   0x01, 0x00, 0x00, 0x00,      // Set force flag; always flash this bitstream, even if the checksums match
};

__attribute__ ((used, section(".fpga_bitstream")))
const unsigned char bitstream[] = {
   #include "boot.ttf"
};


Thanks In Advance,
John


Limba

Usually signature is generated when you crate app.tff with makeCompositeBinary command.

In this VidorBoot case it contains FPGA boot image and it have signature for it and this seems also clear rest of the flash.


jwestmoreland

OK, I see this in the create_image.sh script:

FOLDER_NAME=${PWD##*/}
if [ x$PROJECT_NAME == x ]; then
PROJECT_NAME=$FOLDER_NAME$LITE
fi

if [ -d software/softcore ]; then
echo create ram + flash app.ttf
elf2flash --input=build/software/$FOLDER_NAME/$PROJECT_NAME.elf --output=build/output_files/$PROJECT_NAME.flash --base=0x008E0000 --end=0x008FFFFF --verbose --save
nios2-elf-objcopy --input-target srec --output-target binary build/output_files/$PROJECT_NAME.flash build/output_files/$PROJECT_NAME.bin
../../TOOLS/makeCompositeBinary/makeCompositeBinary -i build/output_files/$PROJECT_NAME.ttf:1:512,build/output_files/$PROJECT_NAME.bin:0:896 -o build/output_files/app.ttf -t 1 > build/output_files/signature.h
else
echo create ram app.ttf
../../TOOLS/makeCompositeBinary/makeCompositeBinary -i build/output_files/$PROJECT_NAME.ttf:1:512 -o build/output_files/app.ttf -t 1 > build/output_files/signature.h
fi


Is there an example of where the nios_xx.bin file is made?

Thanks,
John

Limba

If nios_xx is project name then the bin file is created from nios_xx.elf and that is compiled in build_launncher.sh, build_launcher_interna.sh or build_sw.sh.

jwestmoreland

I am seeing these bin files that have been made by the build process:

$ find ./ -name "*.bin" -print
./VidorBitstream/projects/MKRVIDOR4000_graphics/build/output_files/MKRVIDOR4000_graphics_lite.bin
./VidorBitstream/projects/MKRVIDOR4000_peripherals/build/output_files/MKRVIDOR4000_peripherals_lite.bin
./VidorBitstream/projects/MKRVIDOR4000_template_mbox/build/output_files/MKRVIDOR4000_template_mbox_lite.bin

And I see these .elf files:

 find ./ -name "*.elf" -print
./VidorBitstream/projects/MKRVIDOR4000_graphics/build/software/launcher/launcher_lite.elf
./VidorBitstream/projects/MKRVIDOR4000_graphics/build/software/MKRVIDOR4000_graphics/MKRVIDOR4000_graphics_lite.elf
./VidorBitstream/projects/MKRVIDOR4000_peripherals/build/software/launcher/launcher_lite.elf
./VidorBitstream/projects/MKRVIDOR4000_peripherals/build/software/MKRVIDOR4000_peripherals/MKRVIDOR4000_peripherals_lite.elf
./VidorBitstream/projects/MKRVIDOR4000_template_mbox/build/software/launcher/launcher_lite.elf
./VidorBitstream/projects/MKRVIDOR4000_template_mbox/build/software/MKRVIDOR4000_template_mbox/MKRVIDOR4000_template_mbox_lite.elf
But I need to verify if the scripts/build process are discerning between the lite and standard FPGA tools during the build process.

I am not sure right now how that is done via the current build scripts nor is it currently clear how the scripts determine which build to make; other than kicking this off via the Quartus build tools.

There's no current build script command that tells the scripts to use the "lite" version vs. the standard/pro version is there?  Maybe I'm just missing this right now.

Thanks,
John

Limba

This is begin of all scripts
if [ `quartus_sh --version | grep Lite | wc -l` == "1" ]; then

So it's asking version from quartus shell. That should have lite word there if it's not full version.

jwestmoreland

Limba,

OK, I see that in the "build_all.sh" script -

and

build_launcher.sh and
build_launcher_internal.sh and
build_sw.sh .

Thanks,
John
 

Go Up