Please refer to the following update from the AE team.
First of all, when customer does "flex-builder -c atf -m ls1046ardb -b sd -s -B uboot", it sign the ATF with secure boot process, and set the RCW SB_EN and BOOT_HO bit. This does two things, it tell the system during boot to use the secure bootrom AND put the CPU on hold so customer can put a temporary SRKH value for testing. (p.s. This trick to put temporary SRKH does not work for production system with Intent To Secure (ITS) fuse blown). In order to temporary overwrite the SRKH value, please refers to LSDKUG_Rev21.08 (or equivalent), section 6.1.1.5.2.4.1 Program SRKH mirror registers in CodeWarrior environment ##### 1. Platforms LS1021A, LS1012A, LS1043A, LS1046A (TA 2.x) a. After copying images to flash, select the boot source by changing the switch settings, then boot the board.
- When the flexbuild command is executed with -s option, the command uses secure RCW, with RCW[BOOT_HO] =
1 and RCW[SB_EN]=1, for building images.
After booting the board, core would stop at its first instruction. This is done to allow the user to write SRKH in the register. When using pre-built images, use the SRKH present in srk_hash.txt from GitHub.
If SRKH fuse is already blown, then set RCW[BOOT_HO] = 0 in RCW file in flexbuild, else write the SRKH value (displayed while signing images) in SFP mirror registers and then release the core out of boot hold off by writing to Boot Release Register in DCFG using the below commands:
ccs::config_server 0 10000
ccs::config_chain {<platform> dap sap2}
display ccs::get_config_chain
# Check Initial SNVS State and Value in SCRATCH Registers ccs::display_mem <dap position> 0x1e90014 4 0 4 ccs::display_mem <dap position> 0x1ee0200 4 0 4 #Write the SRK Hash Value in Mirror Registers ccs::write_mem <dap position> 0x1e80254 4 0 <SRKH0> ccs::write_mem <dap position> 0x1e80258 4 0 <SRKH1> ccs::write_mem <dap position> 0x1e8025c 4 0 <SRKH2> ccs::write_mem <dap position> 0x1e80260 4 0 <SRKH3> ccs::write_mem <dap position> 0x1e80264 4 0 <SRKH4> ccs::write_mem <dap position> 0x1e80268 4 0 <SRKH5> ccs::write_mem <dap position> 0x1e8026c 4 0 <SRKH6> ccs::write_mem <dap position> 0x1e80270 4 0 <SRKH7> #Get the Core Out of Boot Hold-Off ccs::write_mem <dap position> 0x1ee00e4 4 0 0x00000001 #####
In the above, when you issue:
#Get the Core Out of Boot Hold-Off
ccs::write_mem <dap position> 0x1ee00e4 4 0 0x00000001
You release the CPU from boot_ho and it will continues to boot with secure bootrom, etc. You will get the console and you will get "error 0x341 was present in SCRATCHRW2 again"
Therefore "BOOT_HO=0" does not cause secure boot to fail, it just allow the temporary SRKH to be overwritten and continue the secure boot process.
Since you already have SRKH burn into the fuse. You don't really need the BOOT_HO trick to overwritten the SRKH value. You will need this "trick" if you use different srk.pri/srk.pub pair to sign the image.
Get back to your original issue with secure boot.
The error 0x341 is
#####
RSA signature check failure. Signature provided by you in the header doesn’t match with the signature of the ESBC image generated by ISBC. The ESBC image loaded by you may be different than the image used while generating the signature(using CST) ##### There is one of two cause for this error. 1) Key signed is not the same as key use to sign the software image. 2) SRKH in the SFP register is corrupted.
Have you run:
$ flex-builder -i clean-firmware
flex-builder -i mkfw -m ls1046ardb -b sd -s flex-builder -c atf -m ls1046ardb -b sd -s flex-installer -m ls1046ardb -d /dev/mmcblk0 or flex-installer -b build/images/bootpartition_LS_arm64_lts_5.4_202011171428.tgz -r build/images/rootfs_lsdk2012_ubuntu_main_arm64_202011171437.tgz -f build/images/firmware_ls1046a rdb_uboot_sdboot_secure.img -d /dev/mmcblk0
If customer still have problem. Please provide the flex-builder and complete flex-installer log.