Platform: Add BL2 platform-specific hw initialization
Adding boot_platform_init() function.
Contrarily to SystemInit() intended for a high priority hw
initialization (for example clock and power subsystems), and
called on a very early boot stage from startup code, this
function is called from C code, hence variables and other drivers
data are protected from being cleared up by the C library init.
This function can be used for initializing platform-specific hw
resources (e.g. IPC, UART) thus freeing up application main()
function from the platform details.
Implemented as a "weak" function, it can be overwritten by a platform
specific implementation.
Signed-off-by: Andrei Narkevitch <ainh@cypress.com>
Change-Id: Id48c1443862fd52a4c11ac5071bbba8352c718b7
diff --git a/bl2/ext/mcuboot/bl2_main.c b/bl2/ext/mcuboot/bl2_main.c
index 08dccfb..01922cb 100644
--- a/bl2/ext/mcuboot/bl2_main.c
+++ b/bl2/ext/mcuboot/bl2_main.c
@@ -166,6 +166,12 @@
__set_MSPLIM(msp_stack_bottom);
#endif
+ /* Perform platform specific initialization */
+ if (boot_platform_init() != 0) {
+ while (1)
+ ;
+ }
+
#if MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF
stdio_init();
#endif
@@ -185,13 +191,6 @@
}
#endif /* CRYPTO_HW_ACCELERATOR */
- rc = FLASH_DEV_NAME.Initialize(NULL);
- if(rc != ARM_DRIVER_OK) {
- BOOT_LOG_ERR("Error while initializing Flash Interface");
- while (1)
- ;
- }
-
#ifndef MCUBOOT_USE_UPSTREAM
rc = boot_nv_security_counter_init();
if (rc != 0) {