!apps: Simplify NuttX initialization

BREAKING: In an effort to simplify board initialization logic for NuttX,
NSH will no longer support architecture initialization. This will happen
during boot via the BOARD_LATE_INITIALIZE option. The boardctl command
BOARDIOC_INIT is also no longer available from user-space.

Quick fix:
Any application relying on BOARDIOC_INIT should now enable
BOARD_LATE_INITIALIZE to have initialization performed by the kernel in
advance of the application running. If control over initialization is
still necessary, BOARDIOC_FINALINIT should be implemented and used.
Boards relying on NSH for initialization should also enable
BOARD_LATE_INITIALIZE instead.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
This commit is contained in:
Matteo Golin 2026-02-16 13:41:27 -05:00 committed by Lup Yuen Lee
parent a9881037ea
commit 5b0cae9ab0
22 changed files with 13 additions and 209 deletions

View file

@ -39,7 +39,7 @@
* Name: miniboot_main
*
* Description:
* Minimal bootlaoder entry point.
* Minimal bootloader entry point.
*
****************************************************************************/
@ -49,10 +49,6 @@ int main(int argc, FAR char *argv[])
syslog(LOG_INFO, "*** miniboot ***\n");
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */

View file

@ -264,16 +264,10 @@ int main(int argc, FAR char *argv[])
FAR struct boardioc_reset_cause_s cause;
#endif
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
/* 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, "*** nxboot ***\n");

View file

@ -142,7 +142,7 @@ struct args_s g_args =
}
};
/* Start allowed at defaule */
/* Start allowed at default */
static bool g_start_allowed = true;
static pthread_mutex_t g_start_allowed_lock = PTHREAD_MUTEX_INITIALIZER;
@ -294,16 +294,10 @@ int main(int argc, char *argv[])
goto errout_no_nxscope;
}
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
# ifdef CONFIG_BOARDCTL_FINALINIT
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
# endif
#endif
PRINTF("\nStart foc_main application!\n\n");

View file

@ -38,23 +38,6 @@
* 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 Types
****************************************************************************/
@ -122,13 +105,6 @@ int main(int argc, FAR char *argv[])
return -1;
}
#ifdef NEED_BOARDINIT
/* Perform board-specific driver initialization */
boardctl(BOARDIOC_INIT, 0);
#endif
lv_init();
lv_nuttx_dsc_init(&info);

View file

@ -63,23 +63,6 @@
* 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
/* How often to poll for output from NSH Shell (milliseconds) */
#define TIMER_PERIOD_MS 100
@ -550,16 +533,10 @@ int main(int argc, FAR char *argv[])
uv_loop_t ui_loop;
#endif
#ifdef NEED_BOARDINIT
/* Perform board-specific driver initialization */
boardctl(BOARDIOC_INIT, 0);
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
#endif
#endif
/* LVGL initialization */

View file

@ -255,12 +255,6 @@ int main(int argc, FAR char *argv[])
ble_hci_sock_set_device(atoi(argv[1]));
}
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization */
boardctl(BOARDIOC_INIT, 0);
#endif
#ifndef CONFIG_NSH_NETINIT
/* Bring up the network */

View file

@ -412,7 +412,7 @@ static int blecent_gap_event(FAR struct ble_gap_event *event, FAR void *arg)
return 0;
}
/* An advertisment report was received during GAP discovery. */
/* An advertisement report was received during GAP discovery. */
print_adv_fields(&fields);
@ -632,12 +632,6 @@ int main(int argc, FAR char **argv)
ble_hci_sock_set_device(atoi(argv[1]));
}
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization */
boardctl(BOARDIOC_INIT, 0);
#endif
#ifndef CONFIG_NSH_NETINIT
/* Bring up the network */

View file

@ -140,7 +140,7 @@ static void bleprph_advertise(void)
BLE_HS_ADV_F_BREDR_UNSUP;
/* Indicate that the TX power level field should be included; have the
* stack fill this value automatically. This is done by assiging the
* stack fill this value automatically. This is done by assigning the
* special value BLE_HS_ADV_TX_PWR_LVL_AUTO.
*/
@ -372,12 +372,6 @@ int main(int argc, FAR char *argv[])
ble_hci_sock_set_device(atoi(argv[1]));
}
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization */
boardctl(BOARDIOC_INIT, 0);
#endif
#ifndef CONFIG_NSH_NETINIT
/* Bring up the network */

View file

@ -527,16 +527,10 @@ int main(int argc, FAR char *argv[])
printf("stream interval = %d\n", env.interval);
printf("main interval = %d\n", interval);
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
# ifdef CONFIG_BOARDCTL_FINALINIT
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
# endif
#endif
#ifdef CONFIG_EXAMPLES_NXSCOPE_CDCACM

View file

@ -439,16 +439,10 @@ int main(int argc, char *argv[])
goto errout;
}
#ifndef CONFIG_NSH_ARCHINIT
/* 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
/* Set LED current limit */

View file

@ -476,16 +476,10 @@ int main(int argc, char *argv[])
goto errout;
}
#ifndef CONFIG_NSH_ARCHINIT
/* 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
/* Set SMPS mode */

View file

@ -485,16 +485,6 @@ static bool createMediaPlayer(void)
int main(int argc, char *argv[])
{
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_BOARD_LATE_INITIALIZE)
// Should we perform board-specific initialization? There are two ways
// that board initialization can occur: 1) automatically via
// board_late_initialize() during bootup if CONFIG_BOARD_LATE_INITIALIZE, or
// 2) here via a call to boardctl() if the interface is enabled
// (CONFIG_BOARDCTL=y).
boardctl(BOARDIOC_INIT, 0);
#endif
#ifdef CONFIG_NXWM_NXTERM
// Initialize the NSH library

View file

@ -42,17 +42,6 @@ config TWM4NX_REVMINOR
string "Twm4Nx minor version number"
default "0"
config TWM4NX_ARCHINIT
bool "Have architecture-specific initialization"
default n
select BOARDCTL
depends on !NSH_ARCHINIT
---help---
Set if your board provides architecture specific initialization
via the board-interface function boardctl(). The boardctl()
function will be called early in Twm4Nx initialization to allow
board logic to do such things as configure MMC/SD slots.
config TWM4NX_NETINIT
bool "Network initialization"
default y

View file

@ -98,23 +98,6 @@ int main(int argc, FAR char *argv[])
int ret;
#if defined(CONFIG_TWM4NX_ARCHINIT) && defined(CONFIG_BOARDCTL) && \
!defined(CONFIG_BOARD_LATE_INITIALIZE)
// Should we perform board-specific initialization? There are two ways
// that board initialization can occur: 1) automatically via
// board_late_initialize() during bootup if CONFIG_BOARD_LATE_INITIALIZE, or
// 2) here via a call to boardctl() if the interface is enabled
// (CONFIG_BOARDCTL=y). board_early_initialize() is also possibility,
// although less likely.
ret = boardctl(BOARDIOC_INIT, 0);
if (ret < 0)
{
twmerr("ERROR: boardctl(BOARDIOC_INIT) failed: %d\n", errno);
return EXIT_FAILURE;
}
#endif
#ifdef CONFIG_TWM4NX_NETINIT
/* Bring up the network */

View file

@ -9,7 +9,7 @@ config NSH_LIBRARY
bool "NSH Library"
default n
select NETUTILS_NETLIB if NET
select BOARDCTL if (!NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT) || NSH_ARCHINIT
select BOARDCTL if (!NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT)
select BOARDCTL_MKRD if !NSH_DISABLE_MKRD && !DISABLE_MOUNTPOINT
---help---
Build the NSH support library. This is used, for example, by
@ -1116,16 +1116,6 @@ config NSH_USBDEV_TRACEINTERRUPTS
endif # NSH_USBDEV_TRACE
endmenu # USB Device Trace Support
config NSH_ARCHINIT
bool "Have architecture-specific initialization"
default n
select BOARDCTL
---help---
Set if your board provides architecture specific initialization
via the board-interface function boardctl(). The boardctl()
function will be called early in NSH initialization to allow
board logic to do such things as configure MMC/SD slots.
menu "Networking Configuration"
depends on NET

View file

@ -807,13 +807,6 @@ int nsh_loginscript(FAR struct nsh_vtbl_s *vtbl);
* available:
*/
/* Architecture-specific initialization depends on boardctl(BOARDIOC_INIT) */
#if defined(CONFIG_NSH_ARCHINIT) && !defined(CONFIG_BOARDCTL)
# warning CONFIG_NSH_ARCHINIT is set, but CONFIG_BOARDCTL is not
# undef CONFIG_NSH_ARCHINIT
#endif
/* The mkrd command depends on boardctl(BOARDIOC_MKRD) */
#if !defined(CONFIG_BOARDCTL) || !defined(CONFIG_BOARDCTL_MKRD)

View file

@ -143,12 +143,6 @@ void nsh_initialize(void)
boardctl(BOARDIOC_APP_SYMTAB, (uintptr_t)&symdesc);
#endif
#ifdef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
#endif
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
pstate = nsh_newconsole(false);
@ -163,12 +157,6 @@ void nsh_initialize(void)
netinit_bringup();
#endif
#if defined(CONFIG_NSH_ARCHINIT) && defined(CONFIG_BOARDCTL_FINALINIT)
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
#endif
#if defined(CONFIG_ETC_ROMFS) && !defined(CONFIG_NSH_DISABLESCRIPT)
/* Execute the start-up script */

View file

@ -200,19 +200,12 @@ config ADBD_SOCKET_SERVICE
---help---
Enable "adb forward|reverse" feature.
config ADBD_BOARD_INIT
bool "Board initialization"
depends on BOARDCTL
default n
---help---
Setup board before running adb daemon.
config ADBD_USB_BOARDCTL
bool "USB Board Control"
depends on BOARDCTL
depends on ADBD_USB_SERVER
select BOARDCTL_USBDEVCTRL
default ADBD_BOARD_INIT
default y
---help---
Connect usbdev before running adb daemon.

View file

@ -32,8 +32,7 @@
#include <syslog.h>
#include <nuttx/streams.h>
#if defined(CONFIG_ADBD_BOARD_INIT) || defined (CONFIG_BOARDCTL_RESET) || \
defined(CONFIG_ADBD_USB_BOARDCTL)
#if defined (CONFIG_BOARDCTL_RESET) || defined(CONFIG_ADBD_USB_BOARDCTL)
# include <sys/boardctl.h>
#endif
@ -120,10 +119,6 @@ int main(int argc, FAR char **argv)
int ret;
#endif
#ifdef CONFIG_ADBD_BOARD_INIT
boardctl(BOARDIOC_INIT, 0);
#endif /* CONFIG_ADBD_BOARD_INIT */
#ifdef CONFIG_ADBD_USB_BOARDCTL
/* Setup USBADB device */

View file

@ -382,16 +382,10 @@ int main(int argc, FAR char *argv[])
pthread_t thread;
int ret;
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
# ifdef CONFIG_BOARDCTL_FINALINIT
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
# endif
#endif
#ifdef CONFIG_SYSTEM_ADCSCOPE_CDCACM

View file

@ -35,7 +35,7 @@
#include "ofloader.h"
/****************************************************************************
* Private Typess
* Private Types
****************************************************************************/
struct devinfo_s
@ -320,16 +320,10 @@ int main(int argc, FAR char *argv[])
size_t i;
mqd_t mq;
#if defined(CONFIG_BOARDCTL) && !defined(CONFIG_NSH_ARCHINIT)
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
# ifdef CONFIG_BOARDCTL_FINALINIT
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
# endif
#endif
memset(&mqattr, 0, sizeof(struct mq_attr));

View file

@ -412,16 +412,10 @@ int main(int argc, FAR char *argv[])
pthread_t thread;
int ret;
#ifndef CONFIG_NSH_ARCHINIT
/* Perform architecture-specific initialization (if configured) */
boardctl(BOARDIOC_INIT, 0);
# ifdef CONFIG_BOARDCTL_FINALINIT
#ifdef CONFIG_BOARDCTL_FINALINIT
/* Perform architecture-specific final-initialization (if configured) */
boardctl(BOARDIOC_FINALINIT, 0);
# endif
#endif
#ifdef CONFIG_SYSTEM_SENSORSCOPE_CDCACM