On 2024-07-09 10:06:53, Alan C. Assis wrote: > How can we improve things? > > How can we simplify this?
I am just copy pasting my message from other thread, as I did not see that one in time :) So my proposition is: I think I would be good if nuttx had something like /sbin/init that would do some very simple service management. Then you could just tick "Start NSH after boot up". Programs would probably be had to added via some compile-time header file that could look like that: | struct program | { | const char *name; | int priority; | int stack_size; | main_t entry_point; | int pid; | }; | | struct program programs[] = | { | #ifdef CONFIG_EXAMPLES_NSH | { "console", 50, 2048, nsh_consolemain }, | #endif | #ifdef CONFIG_SOME_DAEMON | { "some-custom-daemon", 50, 2048, daemon_function }, | #endif | { NULL, 0, 0, NULL } | }; And program in its simplest form would do: | #include <rc/rc.h> | int main(int argc, char *argv[]) { | for (int i = 0; programs[i].name != NULL; ++i) { | struct program *p = &programs[i]; | printf("starting: %s\n", p->name); | p->pid = task_create(p->name, p->priority, p->stack_size, | p->entry_point, NULL); | } | for (;;) sleep(UINT_MAX); | } I think such init could also handle all initialization code (so not only starting up daemons). It could be more clear than current board initialization routines which are a little bit confusing (for me at least). That would solve 2 problems. It would be very clear that NSH is not needed, and user would have an easy way to start it's own daemons/applications. -- .-----------------.-------------------.----------------------.-----------------. | Michal Lyszczek | Embedded C, Linux | Company Address | .-. opensource | | +48 727 564 419 | Software Engineer | Akacjowa 10a; 55-330 | oo| supporter | | https://bofc.pl `----.--------------: Brzezinka Sredzka PL | /`'\ & | | GPG FF1EBFE7E3A974B1 | Bits of Code | NIP: 813 349 58 78 |(\_;/) programer | `----------------------^--------------^----------------------^-----------------'
signature.asc
Description: PGP signature