mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-24 23:18:23 +00:00
system/nxinit: fix event-board timing
Move the boot event orchestration into a preset config buffer so the "init" and (optional) "netinit"/"finalinit" events are triggered as a serialized chain rather than queued back-to-back in main(). This fixes the timing between preset event initialization and board initialization. Adapted for the community tree: BOARDIOC_INIT has been removed upstream (replaced by CONFIG_BOARD_LATE_INITIALIZE), so no board_init/board_finalinit builtins are added and no boardctl(BOARDIOC_INIT)/boardctl(BOARDIOC_FINALINIT) calls are reintroduced; board device init is now performed by the kernel before init starts. netinit is not a boardctl call, so it is kept in the serialized event chain like the original: add a "netinit" builtin that calls netinit_bringup(), driven by "on init -> trigger netinit -> on netinit", instead of calling netinit_bringup() directly in main(). finalinit remains a pure event for user-defined services to hook. Assisted-by: GitHubCopilot:claude-opus-4.8 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
6d178011d5
commit
0923948d80
3 changed files with 41 additions and 14 deletions
|
|
@ -33,6 +33,8 @@
|
|||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <netutils/netinit.h>
|
||||
|
||||
#include "builtin.h"
|
||||
#include "init.h"
|
||||
#include "property.h"
|
||||
|
|
@ -81,6 +83,10 @@ static int cmd_boot(FAR struct action_manager_s *am,
|
|||
static int cmd_start_cpu(FAR struct action_manager_s *am,
|
||||
int argc, FAR char **argv);
|
||||
#endif
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
static int cmd_netinit(FAR struct action_manager_s *am,
|
||||
int argc, FAR char **argv);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
|
|
@ -93,6 +99,9 @@ static const struct cmd_map_s g_builtin[] =
|
|||
#endif
|
||||
#ifdef CONFIG_BOARDCTL_START_CPU
|
||||
{"start_cpu", 1, 3, cmd_start_cpu},
|
||||
#endif
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
{"netinit", 1, 1, cmd_netinit},
|
||||
#endif
|
||||
{"class_start", 2, 2, cmd_class_start},
|
||||
{"class_stop", 2, 2, cmd_class_stop},
|
||||
|
|
@ -152,6 +161,15 @@ static int cmd_start_cpu(FAR struct action_manager_s *am,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
static int cmd_netinit(FAR struct action_manager_s *am,
|
||||
int argc, FAR char **argv)
|
||||
{
|
||||
UNUSED(am);
|
||||
return netinit_bringup();
|
||||
}
|
||||
#endif
|
||||
|
||||
static int cmd_class_start(FAR struct action_manager_s *am,
|
||||
int argc, FAR char **argv)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,11 +29,8 @@
|
|||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/boardctl.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <netutils/netinit.h>
|
||||
|
||||
#include "action.h"
|
||||
#include "builtin.h"
|
||||
#include "init.h"
|
||||
|
|
@ -190,17 +187,6 @@ int main(int argc, FAR char *argv[])
|
|||
|
||||
init_action_add_event(&am, "boot");
|
||||
|
||||
init_action_add_event(&am, "init");
|
||||
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
netinit_bringup();
|
||||
init_action_add_event(&am, "netinit");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYSTEM_NXINIT_FINALINIT
|
||||
init_action_add_event(&am, "finalinit");
|
||||
#endif
|
||||
|
||||
for (; ; )
|
||||
{
|
||||
int t1 = init_service_refresh(&sm);
|
||||
|
|
|
|||
|
|
@ -331,11 +331,34 @@ out:
|
|||
|
||||
int init_parse_configs(FAR const struct parser_s *parser)
|
||||
{
|
||||
static const char preset[] =
|
||||
"on boot\n"
|
||||
" trigger init\n"
|
||||
#if defined(CONFIG_NETUTILS_NETINIT) || defined(CONFIG_SYSTEM_NXINIT_FINALINIT)
|
||||
"on init\n"
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
" trigger netinit\n"
|
||||
#endif
|
||||
#ifdef CONFIG_SYSTEM_NXINIT_FINALINIT
|
||||
" trigger finalinit\n"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_NETUTILS_NETINIT
|
||||
"on netinit\n"
|
||||
" netinit\n"
|
||||
#endif
|
||||
;
|
||||
FAR const char *path = CONFIG_SYSTEM_NXINIT_RC_FILE_PATH;
|
||||
FAR const char *ext;
|
||||
char file[PATH_MAX];
|
||||
int ret;
|
||||
|
||||
ret = init_parse_config_buffer(parser, preset, sizeof(preset));
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = init_parse_config_file(parser, path);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue