boot: nuttx: main: add suport for board late

initialization.

When using nuttx MCUBoot app as a main entry point in
place of nsh_main it is necesary to perform board-specific
driver initialization through boardctl().

Signed-off-by: Andrés Sánchez Pascual <tito97_sp@hotmail.com>

boot: nuttx: main: fix minor errors according

Signed-off-by: Andrés Sánchez Pascual <tito97_sp@hotmail.com>
This commit is contained in:
Andrés Sánchez Pascual 2022-08-28 18:43:02 +02:00 committed by Gustavo Henrique Nihei
parent a93188e7bb
commit 414ac87cfd
1 changed files with 33 additions and 0 deletions

View File

@ -32,6 +32,27 @@
#include "flash_map_backend/flash_map_backend.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Should we perform board-specific driver initialization? There are two
* ways that board initialization can occur: 1) automatically via
* board_late_initialize() during bootupif CONFIG_BOARD_LATE_INITIALIZE
* or 2).
* via a call to boardctl() if the interface is enabled
* (CONFIG_BOARDCTL=y).
* If this task is running as an NSH built-in application, then that
* initialization has probably already been performed otherwise we do it
* here.
*/
#undef NEED_BOARDINIT
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
# define NEED_BOARDINIT 1
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@ -79,6 +100,18 @@ int main(int argc, FAR char *argv[])
struct boot_rsp rsp;
fih_int fih_rc = FIH_FAILURE;
#ifdef NEED_BOARDINIT
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
#endif
#endif
syslog(LOG_INFO, "*** Booting MCUboot build %s ***\n", CONFIG_MCUBOOT_VERSION);
FIH_CALL(boot_go, fih_rc, &rsp);