polarfire-soc / polarfire-soc-bare-metal-examples

Bare metal example software projects for PolarFire SoC
25 stars 14 forks source link

Failure while programming bare metal example in User Secure Boot Mode 2 #7

Open nearly-big-endian opened 2 years ago

nearly-big-endian commented 2 years ago

Hello,

I am currently assessing the available secure boot modes of the Polarfire, and did the following test in SoftConsole:

The result is that fpgenprog did fail with error "Bitstream or data is corrupted or noisy. ERROR_CODE: 801F"

Do you have an idea of what would cause that issue ?

My environment is:

Thanks,

Last lines of "mpfs-gpio-interrupt" project build log:

Building target: mpfs-gpio-interrupt.elf
Invoking: GNU RISC-V Cross C Linker
riscv64-unknown-elf-gcc -march=rv64gc -mabi=lp64d -mcmodel=medany -msmall-data-limit=8 -mstrict-align -mno-save-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections  -g -T "C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\src\platform\platform_config_reference\linker\mpfs-lim-lma-scratchpad-vma.ld" -nostartfiles -Xlinker --gc-sections -Wl,-Map,"mpfs-gpio-interrupt.map" --specs=nano.specs --specs=nosys.specs -o "mpfs-gpio-interrupt.elf"  ./src/platform/mpfs_hal/startup_gcc/mss_entry.o ./src/platform/mpfs_hal/startup_gcc/mss_utils.o ./src/platform/mpfs_hal/startup_gcc/newlib_stubs.o ./src/platform/mpfs_hal/startup_gcc/system_startup.o  ./src/platform/mpfs_hal/common/nwc/mss_cfm.o ./src/platform/mpfs_hal/common/nwc/mss_ddr.o ./src/platform/mpfs_hal/common/nwc/mss_ddr_debug.o ./src/platform/mpfs_hal/common/nwc/mss_ddr_test_pattern.o ./src/platform/mpfs_hal/common/nwc/mss_io.o ./src/platform/mpfs_hal/common/nwc/mss_nwc_init.o ./src/platform/mpfs_hal/common/nwc/mss_pll.o ./src/platform/mpfs_hal/common/nwc/mss_sgmii.o  ./src/platform/mpfs_hal/common/mss_axiswitch.o ./src/platform/mpfs_hal/common/mss_clint.o ./src/platform/mpfs_hal/common/mss_h2f.o ./src/platform/mpfs_hal/common/mss_irq_handler_stubs.o ./src/platform/mpfs_hal/common/mss_l2_cache.o ./src/platform/mpfs_hal/common/mss_mpu.o ./src/platform/mpfs_hal/common/mss_mtrap.o ./src/platform/mpfs_hal/common/mss_peripherals.o ./src/platform/mpfs_hal/common/mss_plic.o ./src/platform/mpfs_hal/common/mss_pmp.o ./src/platform/mpfs_hal/common/mss_util.o  ./src/platform/hal/hal_irq.o ./src/platform/hal/hw_reg_access.o  ./src/platform/drivers/mss/mss_mmuart/mss_uart.o  ./src/platform/drivers/mss/mss_gpio/mss_gpio.o  ./src/application/hart4/u54_4.o  ./src/application/hart3/u54_3.o  ./src/application/hart2/u54_2.o  ./src/application/hart1/u54_1.o  ./src/application/hart0/e51.o   
Finished building target: mpfs-gpio-interrupt.elf

Invoking: GNU RISC-V Cross Create Flash Image
riscv64-unknown-elf-objcopy -O ihex "mpfs-gpio-interrupt.elf"  "mpfs-gpio-interrupt.hex"
Finished building: mpfs-gpio-interrupt.hex

Invoking: GNU RISC-V Cross Create Listing
riscv64-unknown-elf-objdump --source --all-headers --demangle --line-numbers --wide "mpfs-gpio-interrupt.elf" > "mpfs-gpio-interrupt.lst"
Finished building: mpfs-gpio-interrupt.lst

Invoking: GNU RISC-V Cross Print Size
riscv64-unknown-elf-size --format=sysv --totals --radix=16 "mpfs-gpio-interrupt.elf"
mpfs-gpio-interrupt.elf  :
section                 size        addr
.text_init             0xd70   0x8000000
.text                 0x5b30   0xa000000
.sdata                  0x10   0xa005b30
.data                  0xfe0   0xa005b40
.sbss                   0x80   0xa006b20
.bss                  0x1da0   0xa006ba0
.heap                 0x2000   0xa008940
.stack_e51            0x1000   0x8007890
.stack_u54_1          0x1000   0x8008890
.stack_u54_2          0x1000   0x8009890
.stack_u54_3          0x1000   0x800a890
.stack_u54_4          0x1000   0x800b890
.app_stack_e51        0x2000   0xa00a940
.app_stack_u54_1      0x2000   0xa00c940
.app_stack_u54_2      0x2000   0xa00e940
.app_stack_u54_3      0x2000   0xa010940
.app_stack_u54_4      0x2000   0xa012940
.app_hart_common      0x1000   0xa014940
.ram_code                0x0   0x1001c00
.riscv.attributes       0x35         0x0
.comment                0x51         0x0
.debug_line          0x14cc3         0x0
.debug_info         0x2ee6d6         0x0
.debug_abbrev         0x5d68         0x0
.debug_aranges         0xf40         0x0
.debug_str           0x1b4ed         0x0
.debug_loc            0x7db4         0x0
.debug_ranges         0x1e50         0x0
.debug_frame          0x39e0         0x0
Total               0x34e248

Finished building: mpfs-gpio-interrupt.siz

11:03:02 Build Finished. 0 errors, 1 warnings. (took 1m:18s.910ms)

"Polarfire Soc program user secure boot mode 2" execution log:

11:08:11 INFO  - mpfsBootmodeProgrammer v3.3 started.
11:08:11 INFO  - "C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2" is the output folder and the previous contents of this folder will be deleted.
11:08:12 WARN  - --usk key is not specified or specifies zero so the script will use a randomly generated USK "4b2d0f7aff40bb8f1c2cb039" instead.  
11:08:12 INFO  - Selected boot mode "2 - user secure boot from sNVM" and working in directory "C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release".
11:08:12 INFO  - Generating BIN file...
11:08:13 WARN  - Ensure that --snvm_page, --usk and boot mode 2 program image size align correctly with the sNVM usage in the target design's Libero project.
11:08:13 INFO  - Generating HEX file...
11:08:13 INFO  - Preparing for bitstream generation...
11:08:13 INFO  - Generating bitstream...
11:08:27 INFO  - Programming the target...
11:08:34 INFO  - Console Mode = Software Version: 2021.2.0.11
Warning:  Unable to find file: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\target.pdb'.
Warning: [80609481]:  Using local backup copy: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb'.
PDB file 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.9
===============================================================
Programmer: Embedded FP6 '57C1507E' : Version = EF9B
===============================================================
programmer '57C1507E' : Embedded FlashPro6
Opened 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.pro'
The 'open_project' command succeeded.
Info:  Programming is already enabled for device 'target'.
The 'enable_device' command succeeded.
PPD file 'C:/Microchip/softconsole_workspace/mpfs-gpio-interrupt/LIM-Release/bootmode2/fpgenprogProject/proj_fp/target.ppd' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.0
The 'set_programming_file' command succeeded.
The 'set_programming_action' command succeeded.
programmer '57C1507E' : Scan Chain...
programmer '57C1507E' : Check Chain...
programmer '57C1507E' : Scan and Check Chain PASSED.
@@ACTIVITY 1
programmer '57C1507E' : device 'target' : Executing action PROGRAM
Performing FPGA action. Please wait...
eFP6 acceleration mode enabled with PPD file. Please wait...
@@ACTIVITY 2
CM3 Version: D1.2
Programmer '57C1507E' : JTAG TCK frequency = 4 MHz
eFP6 Messages:
@@ACTIVITY 100
CM3 Version: F4.0
================================================================================

JTAG DirectC Version: 04.07

JTAG_Frequency:  4 MHz

Identifying device...

Looking for MPF device...

ActID = 0F81A1CF

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

--- Security locks and configuration settings ---

00000001000000000000000000000000

ISC_ENABLE_RESULT: 00000000

CRCERR: 00

BITS component bitstream digest: 25295F0D1D592A90B333E26E85149708208E9F8E8BC18F6C77BD62F8AD7A6866

Security component bitstream digest: 2EED6B29FC30F1D5D7EC56C1AC9E7E0F5586AAF1DE66DC49A030478F1D647B8B

ComponentNo: 3

blockNo: 155

FRAME_DATA_RESULT: 8408

DATA_STATUS_RESULT: 0002000900008407

Bitstream or data is corrupted or noisy.

ERROR_CODE: 801F

DEBUG_INFO:

0000000000030003017E000039FF100001000000000000000000000000000000000E000007AF000000000000030000020009000084007EAAB7012DD6018100000000000000000000000000E7071009C009C009C000250025002562000000

=====================================================================

DSN: 210C11FA442BE7797318B15954629559

=====================================================================
================================================================================

Error:  programmer '57C1507E' : device 'target' : Executing action PROGRAM FAILED.
@@ACTIVITY 101
Error:  programmer '57C1507E' : Chain programming FAILED.
Chain Programming Finished: Thu Jan 20 11:08:34 2022 (Elapsed time 00:00:03)
Error:  Failed to run Action.
Exported log file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.log.
Error:  The command 'run_selected_actions' failed.
Error:  Failure when executing Tcl script. [ Line 5 ]
Error:  The Execute Script command failed.
Exported log file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject\proj_fp\proj_fp.log.
Software Version: 2021.2.0.11
Warning: Unable to find file: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\target.pdb'.
Warning: Using local backup copy: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb'.
PDB file 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.9
===============================================================
Programmer: Embedded FP6 '57C1507E' : Version = EF9B
===============================================================
programmer '57C1507E' : Embedded FlashPro6
Opened 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.pro'
The 'open_project' command succeeded.
Info: Programming is already enabled for device 'target'.
The 'enable_device' command succeeded.
PPD file 'C:/Microchip/softconsole_workspace/mpfs-gpio-interrupt/LIM-Release/bootmode2/fpgenprogProject/proj_fp/target.ppd' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.0
The 'set_programming_file' command succeeded.
The 'set_programming_action' command succeeded.
programmer '57C1507E' : Scan Chain...
programmer '57C1507E' : Check Chain...
programmer '57C1507E' : Scan and Check Chain PASSED.
programmer '57C1507E' : device 'target' : Executing action PROGRAM
Performing FPGA action. Please wait...
eFP6 acceleration mode enabled with PPD file. Please wait...
CM3 Version: D1.2
Programmer '57C1507E' : JTAG TCK frequency = 4 MHz
eFP6 Messages:
CM3 Version: F4.0
================================================================================

JTAG DirectC Version: 04.07

JTAG_Frequency:  4 MHz

Identifying device...

Looking for MPF device...

ActID = 0F81A1CF

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

--- Security locks and configuration settings ---

00000001000000000000000000000000

ISC_ENABLE_RESULT: 00000000

CRCERR: 00

BITS component bitstream digest: 25295F0D1D592A90B333E26E85149708208E9F8E8BC18F6C77BD62F8AD7A6866

Security component bitstream digest: 2EED6B29FC30F1D5D7EC56C1AC9E7E0F5586AAF1DE66DC49A030478F1D647B8B

ComponentNo: 3

blockNo: 155

FRAME_DATA_RESULT: 8408

DATA_STATUS_RESULT: 0002000900008407

Bitstream or data is corrupted or noisy.

ERROR_CODE: 801F

DEBUG_INFO:

0000000000030003017E000039FF100001000000000000000000000000000000000E000007AF000000000000030000020009000084007EAAB7012DD6018100000000000000000000000000E7071009C009C009C000250025002562000000

=====================================================================

DSN: 210C11FA442BE7797318B15954629559

=====================================================================
================================================================================

Error: programmer '57C1507E' : device 'target' : Executing action PROGRAM FAILED.
Error: programmer '57C1507E' : Chain programming FAILED.
Chain Programming Finished: Thu Jan 20 11:08:34 2022 (Elapsed time 00:00:03)
Error: Failed to run Action.
Exported log file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.log.
Error: The command 'run_selected_actions' failed.
Error: Failure when executing Tcl script. [ Line 5 ]
Error: The Execute Script command failed.

11:08:34 ERROR - Running the fpgenprog.exe PROGRAM action failed.
nearly-big-endian commented 2 years ago

Some updates on my issue.

I just found in document mpfs-bootmodes-readme.txt (located on my system at c:\Microchip\SoftConsole-v2021.1\extras\mpfs\mpfs-bootmodes-readme.txt) what seems to be an explanation for my problem.

In the "Known issues/limitations" section of that document, it is stated that the sNVM Master Key (SMK) is NOT automatically generated by mpfsBootmodeProgrammer, and that error 801F (the same I got) would be returned if no SMK key was previously generated for the target.

So I made the following changes to my design in liberoSoC (which is freshly generated from the 2021.11 Reference Design):

Here's what SmartDebug shows after that change: smartDebug

That leaves me with sNVM pages 14..200 available for use. That makes 187 pages of 236 bytes each, or 44132 bytes in total, which is enough to hold the app binary (30864 bytes).

After having re-generated the Design Initialization Data, regenerated the bitstreams then programmed the board with those changes, I went back to the SoftConsole: I edited the "PolarFire SoC program user secure boot mode 2" launcher and updated the command line to take into account:

eclips_launcher_edit

But even with these changes I get the same error as before at programming time.

Here is the content of the debugLog.txt file:


17:29:55 DEBUG - Looking for ELF file in the work directory.
17:29:55 DEBUG - ELF file found: "mpfs-gpio-interrupt.elf".
17:29:55 INFO  - Selected boot mode "2 - user secure boot from sNVM" and working in directory "C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release".
17:29:55 DEBUG - Workdir=C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release die=MPFS250T_ES diePackage=FCVG484 bm=2 - user secure boot from sNVM verify=false elf=mpfs-gpio-interrupt.elf
17:29:55 DEBUG - Invoking command: "c:\Microsemi\Program_Debug_v2021.2\Program_Debug_Tool\bin64\fpgenprog.exe new_project --location C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject --target_die MPFS250T_ES --target_package FCVG484".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 INFO  - Generating BIN file...
17:29:56 DEBUG - Invoking command: "C:\Microchip\SoftConsole-v2021.1\/riscv-unknown-elf-gcc/bin/riscv64-unknown-elf-objcopy.exe --version".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 DEBUG - Invoking command: "C:\Microchip\SoftConsole-v2021.1\/riscv-unknown-elf-gcc/bin/riscv64-unknown-elf-objcopy.exe -O binary C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/mpfs-gpio-interrupt.elf C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/mpfs-gpio-interrupt.bin ".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 DEBUG - Size of the BIN file is "30864 (decimal)" or "0x00007890 (hex)".
17:29:56 DEBUG - Invoking command: "C:\Microchip\SoftConsole-v2021.1\/riscv-unknown-elf-gcc/bin/riscv64-unknown-elf-readelf.exe --program-headers C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/mpfs-gpio-interrupt.elf ".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 DEBUG - Entry point 0x8000000
17:29:56 DEBUG - The detected entry address is "8000000".
17:29:56 WARN  - Ensure that --snvm_page, --usk and boot mode 2 program image size align correctly with the sNVM usage in the target design's Libero project.
17:29:56 INFO  - Generating HEX file...
17:29:56 DEBUG - Invoking command: "C:\Microchip\SoftConsole-v2021.1\/riscv-unknown-elf-gcc/bin/riscv64-unknown-elf-objcopy.exe -I binary -O ihex C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/mpfs-gpio-interrupt-bm2-p14-ap.bin C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/mpfs-gpio-interrupt-bm2-p14-ap.hex ".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 INFO  - Preparing for bitstream generation...
17:29:56 DEBUG - Invoking command: "c:\Microsemi\Program_Debug_v2021.2\Program_Debug_Tool\bin64\fpgenprog.exe mss_boot_info --location C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject --u_mss_bootmode 2 --u_mss_bootcfg 00000000EEEEEEEEEEEEEEEEEEEEEEEE0000000E".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 DEBUG - Invoking command: "c:\Microsemi\Program_Debug_v2021.2\Program_Debug_Tool\bin64\fpgenprog.exe snvm_client --location C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject --number_of_bytes 30924 --content_file_format intel-hex --content_file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/mpfs-gpio-interrupt-bm2-p14-ap.hex --start_page 14 --client_name bootmode2 --usk_key EEEEEEEEEEEEEEEEEEEEEEEE --authenticated --mem_file_base_address 08000000 --fabric_access_read 0 --fabric_access_write 0 --mss_access_read 1 --mss_access_write 0".
17:29:56 DEBUG - Finished with exit code: "0".
17:29:56 INFO  - Generating bitstream...
17:29:56 DEBUG - Invoking command: "c:\Microsemi\Program_Debug_v2021.2\Program_Debug_Tool\bin64\fpgenprog.exe generate_bitstream --location C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject".
17:30:15 DEBUG - Finished with exit code: "0".
17:30:15 INFO  - Programming the target...
17:30:15 DEBUG - Invoking command: "c:\Microsemi\Program_Debug_v2021.2\Program_Debug_Tool\bin64\fpgenprog.exe run_action --location C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject --action PROGRAM".
17:30:23 DEBUG - Finished with exit code: "1".
17:30:23 INFO  - Console Mode = Software Version: 2021.2.0.11
Warning:  Unable to find file: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\target.pdb'.
Warning: [80609481]:  Using local backup copy: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb'.
PDB file 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.9
===============================================================
Programmer: Embedded FP6 '57C1507E' : Version = EF9B
===============================================================
programmer '57C1507E' : Embedded FlashPro6
Opened 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.pro'
The 'open_project' command succeeded.
Info:  Programming is already enabled for device 'target'.
The 'enable_device' command succeeded.
PPD file 'C:/Microchip/softconsole_workspace/mpfs-gpio-interrupt/LIM-Release/bootmode2/fpgenprogProject/proj_fp/target.ppd' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.0
The 'set_programming_file' command succeeded.
The 'set_programming_action' command succeeded.
programmer '57C1507E' : Scan Chain...
programmer '57C1507E' : Check Chain...
programmer '57C1507E' : Scan and Check Chain PASSED.
@@ACTIVITY 1
programmer '57C1507E' : device 'target' : Executing action PROGRAM
Performing FPGA action. Please wait...
eFP6 acceleration mode enabled with PPD file. Please wait...
@@ACTIVITY 2
CM3 Version: D1.2
Programmer '57C1507E' : JTAG TCK frequency = 4 MHz
eFP6 Messages:
@@ACTIVITY 100
CM3 Version: F4.0
================================================================================

JTAG DirectC Version: 04.07

JTAG_Frequency:  4 MHz

Identifying device...

Looking for MPF device...

ActID = 0F81A1CF

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

--- Security locks and configuration settings ---

00000001000000000000000000000000

ISC_ENABLE_RESULT: 00000000

CRCERR: 00

BITS component bitstream digest: 25295F0D1D592A90B333E26E85149708208E9F8E8BC18F6C77BD62F8AD7A6866

Security component bitstream digest: EBAD4B6E1DC22E77B7727242AA1E020472B0BA52AF0EBDCBA1806E7E0487E793

ComponentNo: 3

blockNo: 155

FRAME_DATA_RESULT: 8408

DATA_STATUS_RESULT: 0002004100008407

Bitstream or data is corrupted or noisy.

ERROR_CODE: 801F

DEBUG_INFO:

0000000000030003017E000039FF1000010000000000000000000000000000000012000007AF0000000000000300000200410000840022A6DC012DD601810000000000000000000000000009070C09C309C309C3002C002C002CA7000000

=====================================================================

DSN: 210C11FA442BE7797318B15954629559

=====================================================================
================================================================================

Error:  programmer '57C1507E' : device 'target' : Executing action PROGRAM FAILED.
@@ACTIVITY 101
Error:  programmer '57C1507E' : Chain programming FAILED.
Chain Programming Finished: Thu Jan 20 17:30:23 2022 (Elapsed time 00:00:03)
Error:  Failed to run Action.
Exported log file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.log.
Error:  The command 'run_selected_actions' failed.
Error:  Failure when executing Tcl script. [ Line 5 ]
Error:  The Execute Script command failed.
Exported log file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release/bootmode2/fpgenprogProject\proj_fp\proj_fp.log.
Software Version: 2021.2.0.11
Warning: Unable to find file: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\target.pdb'.
Warning: Using local backup copy: 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb'.
PDB file 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\projectData\target.pdb' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.9
===============================================================
Programmer: Embedded FP6 '57C1507E' : Version = EF9B
===============================================================
programmer '57C1507E' : Embedded FlashPro6
Opened 'C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.pro'
The 'open_project' command succeeded.
Info: Programming is already enabled for device 'target'.
The 'enable_device' command succeeded.
PPD file 'C:/Microchip/softconsole_workspace/mpfs-gpio-interrupt/LIM-Release/bootmode2/fpgenprogProject/proj_fp/target.ppd' has been loaded successfully.
DESIGN : TOP;  CHECKSUM : 0000;  PDB_VERSION : 1.0
The 'set_programming_file' command succeeded.
The 'set_programming_action' command succeeded.
programmer '57C1507E' : Scan Chain...
programmer '57C1507E' : Check Chain...
programmer '57C1507E' : Scan and Check Chain PASSED.
programmer '57C1507E' : device 'target' : Executing action PROGRAM
Performing FPGA action. Please wait...
eFP6 acceleration mode enabled with PPD file. Please wait...
CM3 Version: D1.2
Programmer '57C1507E' : JTAG TCK frequency = 4 MHz
eFP6 Messages:
CM3 Version: F4.0
================================================================================

JTAG DirectC Version: 04.07

JTAG_Frequency:  4 MHz

Identifying device...

Looking for MPF device...

ActID = 0F81A1CF

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

ActID = 0F81A1CF ExpID = 0F81A1CF

Device Rev = 00

--- Security locks and configuration settings ---

00000001000000000000000000000000

ISC_ENABLE_RESULT: 00000000

CRCERR: 00

BITS component bitstream digest: 25295F0D1D592A90B333E26E85149708208E9F8E8BC18F6C77BD62F8AD7A6866

Security component bitstream digest: EBAD4B6E1DC22E77B7727242AA1E020472B0BA52AF0EBDCBA1806E7E0487E793

ComponentNo: 3

blockNo: 155

FRAME_DATA_RESULT: 8408

DATA_STATUS_RESULT: 0002004100008407

Bitstream or data is corrupted or noisy.

ERROR_CODE: 801F

DEBUG_INFO:

0000000000030003017E000039FF1000010000000000000000000000000000000012000007AF0000000000000300000200410000840022A6DC012DD601810000000000000000000000000009070C09C309C309C3002C002C002CA7000000

=====================================================================

DSN: 210C11FA442BE7797318B15954629559

=====================================================================
================================================================================

Error: programmer '57C1507E' : device 'target' : Executing action PROGRAM FAILED.
Error: programmer '57C1507E' : Chain programming FAILED.
Chain Programming Finished: Thu Jan 20 17:30:23 2022 (Elapsed time 00:00:03)
Error: Failed to run Action.
Exported log file C:\Microchip\softconsole_workspace\mpfs-gpio-interrupt\LIM-Release\bootmode2\fpgenprogProject\proj_fp\proj_fp.log.
Error: The command 'run_selected_actions' failed.
Error: Failure when executing Tcl script. [ Line 5 ]
Error: The Execute Script command failed.

17:30:23 ERROR - Running the fpgenprog.exe PROGRAM action failed.

Thanks for your time

nearly-big-endian commented 2 years ago

Another update to my issue which I kind of partly solved.

I managed to get mpfsBootmodeProgrammer to successfully program the test application in User Secure Boot mode (mode 2).

Steps were:

The log of the SoftConsole launcher is now:

08:25:20 INFO  - mpfsBootmodeProgrammer v3.3 started.
08:25:20 INFO  - "C:\Microchip\polarfire-soc-bare-metal-examples\driver-examples\mss\mss-gpio\mpfs-gpio-interrupt\LIM-Release\bootmode2" is the output folder and the previous contents of this folder will be deleted.
08:25:21 INFO  - Selected boot mode "2 - user secure boot from sNVM" and working in directory "C:\Microchip\polarfire-soc-bare-metal-examples\driver-examples\mss\mss-gpio\mpfs-gpio-interrupt\LIM-Release".
08:25:22 INFO  - Generating BIN file...
08:25:23 WARN  - Ensure that --snvm_page, --usk and boot mode 2 program image size align correctly with the sNVM usage in the target design's Libero project.
08:25:23 INFO  - Generating HEX file...
08:25:23 INFO  - Preparing for bitstream generation...
08:25:23 INFO  - Generating bitstream...
08:25:46 INFO  - Programming the target...
08:25:57 INFO  - mpfsBootmodeProgrammer completed successfully.

So, it seems it was not necessary to worry about the sNVM Master Key (SMK) in the end, which seems to have been automatically handled or generated at some point, unlike what the documentation was suggesting.

Anyway. Now, the issue is that the test application ("mpfs-gpio-interrupt") does not seem to run upon rebooting the board.

I can successfully run it in Debug mode (in non-secure boot mode 1) and see its effect (LED1 is blinking).

But when the same program, compiled in LIM-Release build configuration and programmed in the User Secure Boot mode 2, nothing happens (LED1 does not blink).

Could it be that the "mpfs-gpio-interrupt" example is not meant to be runnable with that boot mode ?

Still, the presence of a linker file for the LIM memory model (located at polarfire-soc-bare-metal-examples\driver-examples\mss\mss-gpio\mpfs-gpio-interrupt\src\platform\platform_config_reference\linker\mpfs-lim.ld) makes me believe that it is supposed to work.

Any ideas ?

nearly-big-endian commented 2 years ago

Still answering myself, as I made some progress.

I managed to get gdb to attach to the running target, and noticed that the process on hart E51 was stuck in a trap (infinite loop in _trap_from_machinecode() function).

I did reset the target from within gdb, and went in instruction stepping mode in order to find out what the trap origin was.

It turns out the issue is caused by the DDR initialization (optional but enabled by default).

If commented out the line #define DDR_SUPPORT in file mss_sw_config.h, re-compiled the application, and it ran as expected after that (LED1 blinking in User Secure Boot Mode 2, that is).

Could anybody confirm that situation and/or comment on that behaviour ?

AntonKrug commented 2 years ago

On the USK settings you figure it out, but just in case some other users will find this issue, then the online SoftConsole documentation should be slightly easier to read than the readme TXT files:

https://mi-v-ecosystem.github.io/SoftConsole-Documentation/SoftConsole-v2021.3/using_softconsole/mpfs.html#polarfire-soc-boot-mode-programming-support-in-softconsole

nitindeshpande commented 2 years ago

It turns out the issue is caused by the DDR initialization (optional but enabled by default).

If commented out the line #define DDR_SUPPORT in file mss_sw_config.h, re-compiled the application, and it ran as expected after that (LED1 blinking in User Secure Boot Mode 2, that is).

Could anybody confirm that situation and/or comment on that behaviour ?

Apologies for the delay. You are correct there. Ideally, src\boards\icicle-kit-es\platform_config\mpfs_hal_config\mss_sw_config.h should have defined IMAGE_LOADED_BY_BOOTLOADER 1 which would avoid the HW initializations that are already taken care by the bootloader (HSS). We will have this corrected. Thank you.

nearly-big-endian commented 2 years ago

Apologies for the delay. You are correct there. Ideally, src\boards\icicle-kit-es\platform_config\mpfs_hal_config\mss_sw_config.h should have defined IMAGE_LOADED_BY_BOOTLOADER 1 which would avoid the HW initializations that are already taken care by the bootloader (HSS). We will have this corrected. Thank you.

Thanks for replying.

I'm not sure to get your answer though.

My understanding is that, in User Secure Boot Mode 2, the HSS is NOT used; it's just the System Controller that copies my code from the sNVM to the LIM, then wakes up the MSS Complex. So, in principle, no bootloader has been running before my bare-metal application.

Am I not getting this right ?

mallynch commented 2 years ago

Hi, Yes, you are correct, there is no HSS involvement. I am not sure why the DDR init is failing when this program is loaded using mode2. Let me investigate, I will respond early next week.

mallynch commented 1 year ago

Hi, On this issue I believe there was an issue with the DDR settings in the mpfs-gpio-interrupt program. Can you check with the latest mpfs-gpio-interrupt release. Thanks

utku1998 commented 1 year ago

Hello, I am getting the same Error "Bitstream or data is corrupted or noisy: ERROR_CODE: 801F" on "PolarFire SoC Icicle Kit". You can also find the „debugLog.txt“ within this post.

PS: I have tried the solutions of @nearly-big-endian, but unfortunately they did not work in my case. I would be really happy, if you could help or provide me a documentation. There is no information or documentation that shows which configurations or steps need to be done in order to boot the device in Boot Mode = 2 (User Secure Boot).

Thanks in advance!

TommyMurphyTM1234 commented 1 year ago

Hello, I am getting the same Error "Bitstream or data is corrupted or noisy: ERROR_CODE: 801F" on "PolarFire SoC Icicle Kit". You can also find the „debugLog.txt“ within this post.

PS: I have tried the solutions of @nearly-big-endian, but unfortunately they did not work in my case. I would be really happy, if you could help or provide me a documentation. There is no information or documentation that shows which configurations or steps need to be done in order to boot the device in Boot Mode = 2 (User Secure Boot).

Thanks in advance!

Are you absolutely sure that you have initialised the sNVM Master Key (SMK) as required for boot mode 2 to work and be programmable from SoftConsole?