diff --git a/system/nxinit/builtin.c b/system/nxinit/builtin.c index 8ebeb4c02..f0097d90c 100644 --- a/system/nxinit/builtin.c +++ b/system/nxinit/builtin.c @@ -33,6 +33,8 @@ #include #include +#include + #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) { diff --git a/system/nxinit/init.c b/system/nxinit/init.c index e4b62f3d6..2c2bcb166 100644 --- a/system/nxinit/init.c +++ b/system/nxinit/init.c @@ -29,11 +29,8 @@ #include #include #include -#include #include -#include - #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); diff --git a/system/nxinit/parser.c b/system/nxinit/parser.c index 49193487f..ced92a2d8 100644 --- a/system/nxinit/parser.c +++ b/system/nxinit/parser.c @@ -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) {