read write in NOR flash from BL2 level

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

read write in NOR flash from BL2 level

449 Views
Jayashree
Contributor II

I am working on S32G3 (Yocto BSP 43) and trying to log secure-boot (BL2) errors into QSPI NOR.

I tried to use the MMIO read/write APIs from BL2; however, the boot process appears to halt immediately after the API call.

Jayashree_0-1767962938834.png

 


I attempted to use xspi_read() / xspi_write() APIs, but BL2 build fails with undefined reference errors. On inspection, these APIs are not implemented in ATF; same with  FSPI read/write APIs


Could you please confirm whether read/write access from BL2 is supported when secure boot is enabled? If it is supported, could you advise which APIs are recommended for this use case? Alternatively, I would appreciate your guidance on feasible approaches or recommended alternatives for logging or data persistence from BL2.


Best regards,
Jayashree

 

 

0 Kudos
Reply
3 Replies

414 Views
alejandro_e
NXP TechSupport
NXP TechSupport

Hello @Jayashree,

Thanks for contacting us again, it is always great to support you. Regarding your question, I have not seen any similar implementation in the past, however, here are my recommendatins:

to use xspi_read/xspi_write you need to include:

#include <drivers/nxp/flexspi/fspi_api.h>

in your source file, I was able to add xspi_write into bl2_main() and build. Note that I only tested the build process.

You could also use io_read/io_write as done in bl_common.c#L94.

 

When you mentioned the MMIO read/write, do you mean the functions in include/lib/mmio.h?

 

Let me know if this helps

 

0 Kudos
Reply

280 Views
Jayashree
Contributor II

Thank you for the quick response. As per your suggestion, I have included the recommended header file and attempted to call the XSPI APIs in the bl2_main.c file. However, I am still encountering an undefined reference/ symbol error during the build.

 
 

Jayashree_2-1768308318568.png

 

For your reference, I have attached the modified file below. I would appreciate it if you could please review it and let me know if I am missing any required configuration or build changes.

/*
* Copyright (c) 2013-2023, Arm Limited and Contributors.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <assert.h>
#include <stdint.h>

#include <arch_helpers.h>
#include <arch_features.h>
#include <bl1/bl1.h>
#include <bl2/bl2.h>
#include <common/bl_common.h>
#include <common/debug.h>
#include <drivers/auth/auth_mod.h>
#include <drivers/auth/crypto_mod.h>
#include <drivers/console.h>
#include <drivers/fwu/fwu.h>
#include <drivers/nxp/flexspi/fspi_api.h>
#include <lib/bootmarker_capture.h>
#include <lib/extensions/pauth.h>
#include <lib/pmf/pmf.h>
#include <plat/common/platform.h>

#include "bl2_private.h"

#ifdef __aarch64__
#define NEXT_IMAGE "BL31"
#else
#define NEXT_IMAGE "BL32"
#endif

/* ================= NOR TEST CONFIG ================= */
#define NOR_TEST_OFFSET 0x400U
#define NOR_TEST_SIZE 4U
/* ================================================== */

#if ENABLE_RUNTIME_INSTRUMENTATION
PMF_REGISTER_SERVICE(bl_svc, PMF_RT_INSTR_SVC_ID,
BL_TOTAL_IDS, PMF_DUMP_ENABLE);
#endif

#if RESET_TO_BL2
/*******************************************************************************
* Setup function for BL2 when RESET_TO_BL2=1
******************************************************************************/
void bl2_el3_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
/* Perform early platform-specific setup */
bl2_el3_early_platform_setup(arg0, arg1, arg2, arg3);

/* Perform late platform-specific setup */
bl2_el3_plat_arch_setup();

#if CTX_INCLUDE_PAUTH_REGS
/*
* Assert that the ARMv8.3-PAuth registers are present or an access
* fault will be triggered when they are being saved or restored.
*/
assert(is_armv8_3_pauth_present());
#endif /* CTX_INCLUDE_PAUTH_REGS */
}
#else /* RESET_TO_BL2 */

/*******************************************************************************
* Setup function for BL2 when RESET_TO_BL2=0
******************************************************************************/
void bl2_setup(u_register_t arg0, u_register_t arg1, u_register_t arg2,
u_register_t arg3)
{
/* Perform early platform-specific setup */
bl2_early_platform_setup2(arg0, arg1, arg2, arg3);

/* Perform late platform-specific setup */
bl2_plat_arch_setup();

#if CTX_INCLUDE_PAUTH_REGS
/*
* Assert that the ARMv8.3-PAuth registers are present or an access
* fault will be triggered when they are being saved or restored.
*/
assert(is_armv8_3_pauth_present());
#endif /* CTX_INCLUDE_PAUTH_REGS */
}
#endif /* RESET_TO_BL2 */

/*******************************************************************************
* The only thing to do in BL2 is to load further images and pass control to
* next BL. The memory occupied by BL2 will be reclaimed by BL3x stages. BL2
* runs entirely in S-EL1.
******************************************************************************/
void bl2_main(void)
{
entry_point_info_t *next_bl_ep_info;
uint32_t write_val = 0xA5A5A5A5;
uint32_t read_val = 0;
int rc;

#if ENABLE_RUNTIME_INSTRUMENTATION
PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_ENTRY, PMF_CACHE_MAINT);
#endif

NOTICE("BL2: %s\n", version_string);
NOTICE("BL2: %s\n", build_message);

/* Perform remaining generic architectural setup in S-EL1 */
bl2_arch_setup();

#if PSA_FWU_SUPPORT
fwu_init();
#endif /* PSA_FWU_SUPPORT */

crypto_mod_init();

/* Initialize authentication module */
auth_mod_init();

/* Initialize the Measured Boot backend */
bl2_plat_mboot_init();

/* Initialize boot source */
bl2_plat_preload_setup();

/* ============================================================
* XSPI / NOR DIRECT ACCESS TEST (PERSISTENT LOGGING EXPERIMENT)
* ============================================================ */
NOTICE("\n===============================================\n");
NOTICE("BL2: XSPI NOR direct access test\n");
NOTICE("BL2: NOR offset = 0x%x\n", NOR_TEST_OFFSET);
NOTICE("===============================================\n");

NOTICE("BL2: Writing 0x%08x to NOR\n", write_val);
rc = xspi_write(NOR_TEST_OFFSET, &write_val, sizeof(write_val));
if (rc != 0) {
ERROR("BL2: xspi_write FAILED (%d)\n", rc);
} else {
NOTICE("BL2: xspi_write OK\n");
}

NOTICE("BL2: Reading back from NOR\n");
rc = xspi_read(NOR_TEST_OFFSET, &read_val, sizeof(read_val));
if (rc != 0) {
ERROR("BL2: xspi_read FAILED (%d)\n", rc);
} else {
NOTICE("BL2: xspi_read OK, value = 0x%08x\n", read_val);
}

NOTICE("===============================================\n");
NOTICE("BL2: XSPI NOR test done, continuing boot\n");
NOTICE("===============================================\n\n");

/* Load the subsequent bootloader images. */
next_bl_ep_info = bl2_load_images();

/* Teardown the Measured Boot backend */
bl2_plat_mboot_finish();

#if !BL2_RUNS_AT_EL3
#ifndef __aarch64__
/*
* For AArch32 state BL1 and BL2 share the MMU setup.
* Given that BL2 does not map BL1 regions, MMU needs
* to be disabled in order to go back to BL1.
*/
disable_mmu_icache_secure();
#endif /* !__aarch64__ */

#if ENABLE_PAUTH
/*
* Disable pointer authentication before running next boot image
*/
pauth_disable_el1();
#endif /* ENABLE_PAUTH */

#if ENABLE_RUNTIME_INSTRUMENTATION
PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_EXIT, PMF_CACHE_MAINT);
#endif

console_flush();

/*
* Run next BL image via an SMC to BL1. Information on how to pass
* control to the BL32 (if present) and BL33 software images will
* be passed to next BL image as an argument.
*/
smc(BL1_SMC_RUN_IMAGE, (unsigned long)next_bl_ep_info, 0, 0, 0, 0, 0, 0);
#else /* if BL2_RUNS_AT_EL3 */

NOTICE("BL2: Booting " NEXT_IMAGE "\n");
print_entry_point_info(next_bl_ep_info);

#if ENABLE_RUNTIME_INSTRUMENTATION
PMF_CAPTURE_TIMESTAMP(bl_svc, BL2_EXIT, PMF_CACHE_MAINT);
#endif

console_flush();

#if ENABLE_PAUTH
/*
* Disable pointer authentication before running next boot image
*/
pauth_disable_el3();
#endif /* ENABLE_PAUTH */

bl2_run_next_image(next_bl_ep_info);
#endif /* BL2_RUNS_AT_EL3 */
}

0 Kudos
Reply

227 Views
alejandro_e
NXP TechSupport
NXP TechSupport

Hello @Jayashree,

I am sorry, I might have been compiling an unsaved version of the file, I retried now and I as not able to compile it, and after many attempts I was not able to do it. For now I have only two recommendations, either try to use io_read/io_writ as I mentioned in my first reply or use the recently added demo project using RTD on the A53 core as base to port the SPI driver to ATF.

To access the second one, log into FlexNet and Follow this path:

Automotive SW – S32G Reference Software > Automotive SW – S32G RTD on A53 > RTD_ON_S32G A53_0.1.0 Solution demo

If you are not able to see one of the options, log into flex net and use this link.

Please note that this is only a recommendations and none were tested on my side, both may come with unrecoverable issues, being that ATF is a very early stage of booting for the A53 cores.

 

Sorry for the inconveniences.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2291027%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Eread%20write%20in%20NOR%20flash%20from%20BL2%20level%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291027%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20working%20on%20%3CSTRONG%3ES32G3%3C%2FSTRONG%3E%20%3CSTRONG%3E(Yocto%20BSP%2043)%3C%2FSTRONG%3E%20and%20trying%20to%20%3CSTRONG%3Elog%20secure-boot%20(BL2)%20errors%20into%20QSPI%20NOR%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20tried%20to%20use%20the%20MMIO%20read%2Fwrite%20APIs%20from%20BL2%3B%20however%2C%20the%20boot%20process%20appears%20to%20halt%20immediately%20after%20the%20API%20call.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jayashree_0-1767962938834.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jayashree_0-1767962938834.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jayashree_0-1767962938834.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jayashree_0-1767962938834.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372325iA778CFEDD26B8BDE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jayashree_0-1767962938834.png%22%20alt%3D%22Jayashree_0-1767962938834.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CBR%20%2F%3EI%20attempted%20to%20use%20xspi_read()%20%2F%20xspi_write()%20APIs%2C%20but%20BL2%20build%20fails%20with%20%3CSTRONG%3Eundefined%20reference%20errors%3C%2FSTRONG%3E.%20On%20inspection%2C%20these%20APIs%20are%20%3CSTRONG%3Enot%20implemented%20in%20ATF%3C%2FSTRONG%3E%3B%20same%20with%26nbsp%3B%20FSPI%20read%2Fwrite%20APIs%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3ECould%20you%20please%20confirm%20whether%20read%2Fwrite%20access%20from%20BL2%20is%20supported%20when%20secure%20boot%20is%20enabled%3F%20If%20it%20is%20supported%2C%20could%20you%20advise%20which%20APIs%20are%20recommended%20for%20this%20use%20case%3F%20Alternatively%2C%20I%20would%20appreciate%20your%20guidance%20on%20feasible%20approaches%20or%20recommended%20alternatives%20for%20logging%20or%20data%20persistence%20from%20BL2.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EBest%20regards%2C%3CBR%20%2F%3EJayashree%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2291182%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20read%20write%20in%20NOR%20flash%20from%20BL2%20level%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291182%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F235643%22%20target%3D%22_blank%22%3E%40Jayashree%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EThanks%20for%20contacting%20us%20again%2C%20it%20is%20always%20great%20to%20support%20you.%20Regarding%20your%20question%2C%20I%20have%20not%20seen%20any%20similar%20implementation%20in%20the%20past%2C%20however%2C%20here%20are%20my%20recommendatins%3A%3C%2FP%3E%0A%3CP%3Eto%20use%26nbsp%3Bxspi_read%2Fxspi_write%20you%20need%20to%20include%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23include%20%3CDRIVERS%3E%3C%2FDRIVERS%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ein%20your%20source%20file%2C%20I%20was%20able%20to%20add%20xspi_write%20into%20bl2_main()%20and%20build.%20Note%20that%20I%20only%20tested%20the%20build%20process.%3C%2FP%3E%0A%3CP%3EYou%20could%20also%20use%20io_read%2Fio_write%20as%20done%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-auto-linux%2Farm-trusted-firmware%2Fblob%2Fc834244b9c54c79e80315aecc9807f5b0eb79342%2Fcommon%2Fbl_common.c%23L94%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ebl_common.c%23L94%3C%2FA%3E.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EWhen%20you%20mentioned%20the%20MMIO%20read%2Fwrite%2C%20do%20you%20mean%20the%20functions%20in%26nbsp%3Binclude%2Flib%2Fmmio.h%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ELet%20me%20know%20if%20this%20helps%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2292593%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20read%20write%20in%20NOR%20flash%20from%20BL2%20level%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2292593%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20the%20quick%20response.%20As%20per%20your%20suggestion%2C%20I%20have%20included%20the%20recommended%20header%20file%20and%20attempted%20to%20call%20the%20XSPI%20APIs%20in%20the%20bl2_main.c%20file.%20However%2C%20I%20am%20still%20encountering%20an%20%3CEM%3Eundefined%20reference%2F%20symbol%3C%2FEM%3E%20error%20during%20the%20build.%3C%2FP%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jayashree_2-1768308318568.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jayashree_2-1768308318568.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Jayashree_2-1768308318568.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372666iF4A1A9973431E43B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jayashree_2-1768308318568.png%22%20alt%3D%22Jayashree_2-1768308318568.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EFor%20your%20reference%2C%20I%20have%20attached%20the%20modified%20file%20below.%20I%20would%20appreciate%20it%20if%20you%20could%20please%20review%20it%20and%20let%20me%20know%20if%20I%20am%20missing%20any%20required%20configuration%20or%20build%20changes.%3C%2FP%3E%3CP%3E%2F*%3CBR%20%2F%3E*%20Copyright%20(c)%202013-2023%2C%20Arm%20Limited%20and%20Contributors.%3CBR%20%2F%3E*%3CBR%20%2F%3E*%20SPDX-License-Identifier%3A%20BSD-3-Clause%3CBR%20%2F%3E*%2F%3C%2FP%3E%3CP%3E%23include%20%3CASSERT.H%3E%3CBR%20%2F%3E%23include%20%3CSTDINT.H%3E%3C%2FSTDINT.H%3E%3C%2FASSERT.H%3E%3C%2FP%3E%3CP%3E%23include%20%3CARCH_HELPERS.H%3E%3CBR%20%2F%3E%23include%20%3CARCH_FEATURES.H%3E%3CBR%20%2F%3E%23include%20%3CBL1%3E%3CBR%20%2F%3E%23include%20%3CBL2%3E%3CBR%20%2F%3E%23include%20%3CCOMMON%3E%3CBR%20%2F%3E%23include%20%3CCOMMON%3E%3CBR%20%2F%3E%23include%20%3CDRIVERS%3E%3CBR%20%2F%3E%23include%20%3CDRIVERS%3E%3CBR%20%2F%3E%23include%20%3CDRIVERS%3E%3CBR%20%2F%3E%23include%20%3CDRIVERS%3E%3CBR%20%2F%3E%23include%20%3CDRIVERS%3E%3CBR%20%2F%3E%23include%20%3CLIB%3E%3CBR%20%2F%3E%23include%20%3CLIB%3E%3CBR%20%2F%3E%23include%20%3CLIB%3E%3CBR%20%2F%3E%23include%20%3CPLAT%3E%3C%2FPLAT%3E%3C%2FLIB%3E%3C%2FLIB%3E%3C%2FLIB%3E%3C%2FDRIVERS%3E%3C%2FDRIVERS%3E%3C%2FDRIVERS%3E%3C%2FDRIVERS%3E%3C%2FDRIVERS%3E%3C%2FCOMMON%3E%3C%2FCOMMON%3E%3C%2FBL2%3E%3C%2FBL1%3E%3C%2FARCH_FEATURES.H%3E%3C%2FARCH_HELPERS.H%3E%3C%2FP%3E%3CP%3E%23include%20%22bl2_private.h%22%3C%2FP%3E%3CP%3E%23ifdef%20__aarch64__%3CBR%20%2F%3E%23define%20NEXT_IMAGE%20%22BL31%22%3CBR%20%2F%3E%23else%3CBR%20%2F%3E%23define%20NEXT_IMAGE%20%22BL32%22%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3E%2F*%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20NOR%20TEST%20CONFIG%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20*%2F%3CBR%20%2F%3E%23define%20NOR_TEST_OFFSET%200x400U%3CBR%20%2F%3E%23define%20NOR_TEST_SIZE%204U%3CBR%20%2F%3E%2F*%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20*%2F%3C%2FP%3E%3CP%3E%23if%20ENABLE_RUNTIME_INSTRUMENTATION%3CBR%20%2F%3EPMF_REGISTER_SERVICE(bl_svc%2C%20PMF_RT_INSTR_SVC_ID%2C%3CBR%20%2F%3EBL_TOTAL_IDS%2C%20PMF_DUMP_ENABLE)%3B%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3E%23if%20RESET_TO_BL2%3CBR%20%2F%3E%2F*******************************************************************************%3CBR%20%2F%3E*%20Setup%20function%20for%20BL2%20when%20RESET_TO_BL2%3D1%3CBR%20%2F%3E******************************************************************************%2F%3CBR%20%2F%3Evoid%20bl2_el3_setup(u_register_t%20arg0%2C%20u_register_t%20arg1%2C%20u_register_t%20arg2%2C%3CBR%20%2F%3Eu_register_t%20arg3)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%2F*%20Perform%20early%20platform-specific%20setup%20*%2F%3CBR%20%2F%3Ebl2_el3_early_platform_setup(arg0%2C%20arg1%2C%20arg2%2C%20arg3)%3B%3C%2FP%3E%3CP%3E%2F*%20Perform%20late%20platform-specific%20setup%20*%2F%3CBR%20%2F%3Ebl2_el3_plat_arch_setup()%3B%3C%2FP%3E%3CP%3E%23if%20CTX_INCLUDE_PAUTH_REGS%3CBR%20%2F%3E%2F*%3CBR%20%2F%3E*%20Assert%20that%20the%20ARMv8.3-PAuth%20registers%20are%20present%20or%20an%20access%3CBR%20%2F%3E*%20fault%20will%20be%20triggered%20when%20they%20are%20being%20saved%20or%20restored.%3CBR%20%2F%3E*%2F%3CBR%20%2F%3Eassert(is_armv8_3_pauth_present())%3B%3CBR%20%2F%3E%23endif%20%2F*%20CTX_INCLUDE_PAUTH_REGS%20*%2F%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%23else%20%2F*%20RESET_TO_BL2%20*%2F%3C%2FP%3E%3CP%3E%2F*******************************************************************************%3CBR%20%2F%3E*%20Setup%20function%20for%20BL2%20when%20RESET_TO_BL2%3D0%3CBR%20%2F%3E******************************************************************************%2F%3CBR%20%2F%3Evoid%20bl2_setup(u_register_t%20arg0%2C%20u_register_t%20arg1%2C%20u_register_t%20arg2%2C%3CBR%20%2F%3Eu_register_t%20arg3)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%2F*%20Perform%20early%20platform-specific%20setup%20*%2F%3CBR%20%2F%3Ebl2_early_platform_setup2(arg0%2C%20arg1%2C%20arg2%2C%20arg3)%3B%3C%2FP%3E%3CP%3E%2F*%20Perform%20late%20platform-specific%20setup%20*%2F%3CBR%20%2F%3Ebl2_plat_arch_setup()%3B%3C%2FP%3E%3CP%3E%23if%20CTX_INCLUDE_PAUTH_REGS%3CBR%20%2F%3E%2F*%3CBR%20%2F%3E*%20Assert%20that%20the%20ARMv8.3-PAuth%20registers%20are%20present%20or%20an%20access%3CBR%20%2F%3E*%20fault%20will%20be%20triggered%20when%20they%20are%20being%20saved%20or%20restored.%3CBR%20%2F%3E*%2F%3CBR%20%2F%3Eassert(is_armv8_3_pauth_present())%3B%3CBR%20%2F%3E%23endif%20%2F*%20CTX_INCLUDE_PAUTH_REGS%20*%2F%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%23endif%20%2F*%20RESET_TO_BL2%20*%2F%3C%2FP%3E%3CP%3E%2F*******************************************************************************%3CBR%20%2F%3E*%20The%20only%20thing%20to%20do%20in%20BL2%20is%20to%20load%20further%20images%20and%20pass%20control%20to%3CBR%20%2F%3E*%20next%20BL.%20The%20memory%20occupied%20by%20BL2%20will%20be%20reclaimed%20by%20BL3x%20stages.%20BL2%3CBR%20%2F%3E*%20runs%20entirely%20in%20S-EL1.%3CBR%20%2F%3E******************************************************************************%2F%3CBR%20%2F%3Evoid%20bl2_main(void)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eentry_point_info_t%20*next_bl_ep_info%3B%3CBR%20%2F%3Euint32_t%20write_val%20%3D%200xA5A5A5A5%3B%3CBR%20%2F%3Euint32_t%20read_val%20%3D%200%3B%3CBR%20%2F%3Eint%20rc%3B%3C%2FP%3E%3CP%3E%23if%20ENABLE_RUNTIME_INSTRUMENTATION%3CBR%20%2F%3EPMF_CAPTURE_TIMESTAMP(bl_svc%2C%20BL2_ENTRY%2C%20PMF_CACHE_MAINT)%3B%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3ENOTICE(%22BL2%3A%20%25s%5Cn%22%2C%20version_string)%3B%3CBR%20%2F%3ENOTICE(%22BL2%3A%20%25s%5Cn%22%2C%20build_message)%3B%3C%2FP%3E%3CP%3E%2F*%20Perform%20remaining%20generic%20architectural%20setup%20in%20S-EL1%20*%2F%3CBR%20%2F%3Ebl2_arch_setup()%3B%3C%2FP%3E%3CP%3E%23if%20PSA_FWU_SUPPORT%3CBR%20%2F%3Efwu_init()%3B%3CBR%20%2F%3E%23endif%20%2F*%20PSA_FWU_SUPPORT%20*%2F%3C%2FP%3E%3CP%3Ecrypto_mod_init()%3B%3C%2FP%3E%3CP%3E%2F*%20Initialize%20authentication%20module%20*%2F%3CBR%20%2F%3Eauth_mod_init()%3B%3C%2FP%3E%3CP%3E%2F*%20Initialize%20the%20Measured%20Boot%20backend%20*%2F%3CBR%20%2F%3Ebl2_plat_mboot_init()%3B%3C%2FP%3E%3CP%3E%2F*%20Initialize%20boot%20source%20*%2F%3CBR%20%2F%3Ebl2_plat_preload_setup()%3B%3C%2FP%3E%3CP%3E%2F*%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3CBR%20%2F%3E*%20XSPI%20%2F%20NOR%20DIRECT%20ACCESS%20TEST%20(PERSISTENT%20LOGGING%20EXPERIMENT)%3CBR%20%2F%3E*%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20*%2F%3CBR%20%2F%3ENOTICE(%22%5Cn%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%5Cn%22)%3B%3CBR%20%2F%3ENOTICE(%22BL2%3A%20XSPI%20NOR%20direct%20access%20test%5Cn%22)%3B%3CBR%20%2F%3ENOTICE(%22BL2%3A%20NOR%20offset%20%3D%200x%25x%5Cn%22%2C%20NOR_TEST_OFFSET)%3B%3CBR%20%2F%3ENOTICE(%22%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%5Cn%22)%3B%3C%2FP%3E%3CP%3ENOTICE(%22BL2%3A%20Writing%200x%2508x%20to%20NOR%5Cn%22%2C%20write_val)%3B%3CBR%20%2F%3Erc%20%3D%20xspi_write(NOR_TEST_OFFSET%2C%20%26amp%3Bwrite_val%2C%20sizeof(write_val))%3B%3CBR%20%2F%3Eif%20(rc%20!%3D%200)%20%7B%3CBR%20%2F%3EERROR(%22BL2%3A%20xspi_write%20FAILED%20(%25d)%5Cn%22%2C%20rc)%3B%3CBR%20%2F%3E%7D%20else%20%7B%3CBR%20%2F%3ENOTICE(%22BL2%3A%20xspi_write%20OK%5Cn%22)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3ENOTICE(%22BL2%3A%20Reading%20back%20from%20NOR%5Cn%22)%3B%3CBR%20%2F%3Erc%20%3D%20xspi_read(NOR_TEST_OFFSET%2C%20%26amp%3Bread_val%2C%20sizeof(read_val))%3B%3CBR%20%2F%3Eif%20(rc%20!%3D%200)%20%7B%3CBR%20%2F%3EERROR(%22BL2%3A%20xspi_read%20FAILED%20(%25d)%5Cn%22%2C%20rc)%3B%3CBR%20%2F%3E%7D%20else%20%7B%3CBR%20%2F%3ENOTICE(%22BL2%3A%20xspi_read%20OK%2C%20value%20%3D%200x%2508x%5Cn%22%2C%20read_val)%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3ENOTICE(%22%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%5Cn%22)%3B%3CBR%20%2F%3ENOTICE(%22BL2%3A%20XSPI%20NOR%20test%20done%2C%20continuing%20boot%5Cn%22)%3B%3CBR%20%2F%3ENOTICE(%22%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%5Cn%5Cn%22)%3B%3C%2FP%3E%3CP%3E%2F*%20Load%20the%20subsequent%20bootloader%20images.%20*%2F%3CBR%20%2F%3Enext_bl_ep_info%20%3D%20bl2_load_images()%3B%3C%2FP%3E%3CP%3E%2F*%20Teardown%20the%20Measured%20Boot%20backend%20*%2F%3CBR%20%2F%3Ebl2_plat_mboot_finish()%3B%3C%2FP%3E%3CP%3E%23if%20!BL2_RUNS_AT_EL3%3CBR%20%2F%3E%23ifndef%20__aarch64__%3CBR%20%2F%3E%2F*%3CBR%20%2F%3E*%20For%20AArch32%20state%20BL1%20and%20BL2%20share%20the%20MMU%20setup.%3CBR%20%2F%3E*%20Given%20that%20BL2%20does%20not%20map%20BL1%20regions%2C%20MMU%20needs%3CBR%20%2F%3E*%20to%20be%20disabled%20in%20order%20to%20go%20back%20to%20BL1.%3CBR%20%2F%3E*%2F%3CBR%20%2F%3Edisable_mmu_icache_secure()%3B%3CBR%20%2F%3E%23endif%20%2F*%20!__aarch64__%20*%2F%3C%2FP%3E%3CP%3E%23if%20ENABLE_PAUTH%3CBR%20%2F%3E%2F*%3CBR%20%2F%3E*%20Disable%20pointer%20authentication%20before%20running%20next%20boot%20image%3CBR%20%2F%3E*%2F%3CBR%20%2F%3Epauth_disable_el1()%3B%3CBR%20%2F%3E%23endif%20%2F*%20ENABLE_PAUTH%20*%2F%3C%2FP%3E%3CP%3E%23if%20ENABLE_RUNTIME_INSTRUMENTATION%3CBR%20%2F%3EPMF_CAPTURE_TIMESTAMP(bl_svc%2C%20BL2_EXIT%2C%20PMF_CACHE_MAINT)%3B%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3Econsole_flush()%3B%3C%2FP%3E%3CP%3E%2F*%3CBR%20%2F%3E*%20Run%20next%20BL%20image%20via%20an%20SMC%20to%20BL1.%20Information%20on%20how%20to%20pass%3CBR%20%2F%3E*%20control%20to%20the%20BL32%20(if%20present)%20and%20BL33%20software%20images%20will%3CBR%20%2F%3E*%20be%20passed%20to%20next%20BL%20image%20as%20an%20argument.%3CBR%20%2F%3E*%2F%3CBR%20%2F%3Esmc(BL1_SMC_RUN_IMAGE%2C%20(unsigned%20long)next_bl_ep_info%2C%200%2C%200%2C%200%2C%200%2C%200%2C%200)%3B%3CBR%20%2F%3E%23else%20%2F*%20if%20BL2_RUNS_AT_EL3%20*%2F%3C%2FP%3E%3CP%3ENOTICE(%22BL2%3A%20Booting%20%22%20NEXT_IMAGE%20%22%5Cn%22)%3B%3CBR%20%2F%3Eprint_entry_point_info(next_bl_ep_info)%3B%3C%2FP%3E%3CP%3E%23if%20ENABLE_RUNTIME_INSTRUMENTATION%3CBR%20%2F%3EPMF_CAPTURE_TIMESTAMP(bl_svc%2C%20BL2_EXIT%2C%20PMF_CACHE_MAINT)%3B%3CBR%20%2F%3E%23endif%3C%2FP%3E%3CP%3Econsole_flush()%3B%3C%2FP%3E%3CP%3E%23if%20ENABLE_PAUTH%3CBR%20%2F%3E%2F*%3CBR%20%2F%3E*%20Disable%20pointer%20authentication%20before%20running%20next%20boot%20image%3CBR%20%2F%3E*%2F%3CBR%20%2F%3Epauth_disable_el3()%3B%3CBR%20%2F%3E%23endif%20%2F*%20ENABLE_PAUTH%20*%2F%3C%2FP%3E%3CP%3Ebl2_run_next_image(next_bl_ep_info)%3B%3CBR%20%2F%3E%23endif%20%2F*%20BL2_RUNS_AT_EL3%20*%2F%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2293647%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20read%20write%20in%20NOR%20flash%20from%20BL2%20level%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2293647%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F235643%22%20target%3D%22_blank%22%3E%40Jayashree%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EI%20am%20sorry%2C%20I%20might%20have%20been%20compiling%20an%20unsaved%20version%20of%20the%20file%2C%20I%20retried%20now%20and%20I%20as%20not%20able%20to%20compile%20it%2C%20and%20after%20many%20attempts%20I%20was%20not%20able%20to%20do%20it.%20For%20now%20I%20have%20only%20two%20recommendations%2C%20either%20try%20to%20use%20io_read%2Fio_writ%20as%20I%20mentioned%20in%20my%20first%20reply%20or%20use%20the%20recently%20added%20demo%20project%20using%20RTD%20on%20the%20A53%20core%20as%20base%20to%20port%20the%20SPI%20driver%20to%20ATF.%3C%2FP%3E%0A%3CP%3ETo%20access%20the%20second%20one%2C%20log%20into%20FlexNet%20and%20Follow%20this%20path%3A%3C%2FP%3E%0A%3CP%3EAutomotive%20SW%20%E2%80%93%20S32G%20Reference%20Software%20%26gt%3B%26nbsp%3BAutomotive%20SW%20%E2%80%93%20S32G%20RTD%20on%20A53%20%26gt%3B%20RTD_ON_S32G%20A53_0.1.0%20Solution%20demo%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20not%20able%20to%20see%20one%20of%20the%20options%2C%20log%20into%20flex%20net%20and%20use%20this%20%3CA%20href%3D%22https%3A%2F%2Fnxp.flexnetoperations.com%2Fcontrol%2Ffrse%2Fdownload%3Felement%3D7763151%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Elink%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EPlease%20note%20that%20this%20is%20only%20a%20recommendations%20and%20none%20were%20tested%20on%20my%20side%2C%20both%20may%20come%20with%20unrecoverable%20issues%2C%20being%20that%20ATF%20is%20a%20very%20early%20stage%20of%20booting%20for%20the%20A53%20cores.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ESorry%20for%20the%20inconveniences.%3C%2FP%3E%3C%2FLINGO-BODY%3E