Open nearly-big-endian opened 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:
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:
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
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 ?
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 ?
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:
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.
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 ?
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.
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
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!
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?
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:
"Polarfire Soc program user secure boot mode 2" execution log: