From ec61512cdf42db33df0134dbb175a56d026297fb Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Tue, 20 Apr 2021 12:34:12 -0700 Subject: [PATCH] NuttX inits null console --- boards/cuav/nora/src/bootloader_main.c | 3 +- boards/cuav/x7pro/src/bootloader_main.c | 3 +- .../cubeorange/src/bootloader_main.c | 3 +- boards/holybro/can-gps-v1/src/manifest.c | 2 +- .../holybro/durandal-v1/src/bootloader_main.c | 3 +- boards/modalai/fc-v2/src/bootloader_main.c | 1 - .../ctrl-zero-h7-oem/src/bootloader_main.c | 3 +- boards/mro/ctrl-zero-h7/src/bootloader_main.c | 3 +- boards/mro/pixracerpro/src/bootloader_main.c | 3 +- boards/px4/fmu-v6u/src/bootloader_main.c | 3 +- boards/px4/fmu-v6x/src/bootloader_main.c | 3 +- platforms/nuttx/src/px4/common/print_load.cpp | 5 +- platforms/nuttx/src/px4/common/px4_init.cpp | 49 +------------------ 13 files changed, 14 insertions(+), 70 deletions(-) diff --git a/boards/cuav/nora/src/bootloader_main.c b/boards/cuav/nora/src/bootloader_main.c index 0a481dcc19..bb6b4dc23a 100644 --- a/boards/cuav/nora/src/bootloader_main.c +++ b/boards/cuav/nora/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/cuav/x7pro/src/bootloader_main.c b/boards/cuav/x7pro/src/bootloader_main.c index 0a481dcc19..bb6b4dc23a 100644 --- a/boards/cuav/x7pro/src/bootloader_main.c +++ b/boards/cuav/x7pro/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/cubepilot/cubeorange/src/bootloader_main.c b/boards/cubepilot/cubeorange/src/bootloader_main.c index 0a481dcc19..bb6b4dc23a 100644 --- a/boards/cubepilot/cubeorange/src/bootloader_main.c +++ b/boards/cubepilot/cubeorange/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/holybro/can-gps-v1/src/manifest.c b/boards/holybro/can-gps-v1/src/manifest.c index bad12d0a73..1beb74589a 100644 --- a/boards/holybro/can-gps-v1/src/manifest.c +++ b/boards/holybro/can-gps-v1/src/manifest.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2018 PX4 Development Team. All rights reserved. + * Copyright (c) 2018, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/boards/holybro/durandal-v1/src/bootloader_main.c b/boards/holybro/durandal-v1/src/bootloader_main.c index 677e5dec2a..915b7f3d29 100644 --- a/boards/holybro/durandal-v1/src/bootloader_main.c +++ b/boards/holybro/durandal-v1/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * Copyright (c) 2019, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/modalai/fc-v2/src/bootloader_main.c b/boards/modalai/fc-v2/src/bootloader_main.c index 677e5dec2a..cb84261652 100644 --- a/boards/modalai/fc-v2/src/bootloader_main.c +++ b/boards/modalai/fc-v2/src/bootloader_main.c @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/mro/ctrl-zero-h7-oem/src/bootloader_main.c b/boards/mro/ctrl-zero-h7-oem/src/bootloader_main.c index 0a481dcc19..bb6b4dc23a 100644 --- a/boards/mro/ctrl-zero-h7-oem/src/bootloader_main.c +++ b/boards/mro/ctrl-zero-h7-oem/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/mro/ctrl-zero-h7/src/bootloader_main.c b/boards/mro/ctrl-zero-h7/src/bootloader_main.c index 0a481dcc19..bb6b4dc23a 100644 --- a/boards/mro/ctrl-zero-h7/src/bootloader_main.c +++ b/boards/mro/ctrl-zero-h7/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/mro/pixracerpro/src/bootloader_main.c b/boards/mro/pixracerpro/src/bootloader_main.c index 0a481dcc19..bb6b4dc23a 100644 --- a/boards/mro/pixracerpro/src/bootloader_main.c +++ b/boards/mro/pixracerpro/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/px4/fmu-v6u/src/bootloader_main.c b/boards/px4/fmu-v6u/src/bootloader_main.c index 677e5dec2a..915b7f3d29 100644 --- a/boards/px4/fmu-v6u/src/bootloader_main.c +++ b/boards/px4/fmu-v6u/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * Copyright (c) 2019, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/boards/px4/fmu-v6x/src/bootloader_main.c b/boards/px4/fmu-v6x/src/bootloader_main.c index 677e5dec2a..915b7f3d29 100644 --- a/boards/px4/fmu-v6x/src/bootloader_main.c +++ b/boards/px4/fmu-v6x/src/bootloader_main.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * Copyright (c) 2019, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -65,7 +65,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) void board_late_initialize(void) { - px4_platform_console_init(); sercon_main(0, NULL); } diff --git a/platforms/nuttx/src/px4/common/print_load.cpp b/platforms/nuttx/src/px4/common/print_load.cpp index ecfeb1fed0..70a17dfd0a 100644 --- a/platforms/nuttx/src/px4/common/print_load.cpp +++ b/platforms/nuttx/src/px4/common/print_load.cpp @@ -335,11 +335,10 @@ void print_load_buffer(char *buffer, int buffer_length, print_load_callback_f cb const float sched_load = 1.f - idle_load - task_load; - snprintf(buffer, buffer_length, "Processes: %d total, %d running, %d sleeping, max FDs: %d", + snprintf(buffer, buffer_length, "Processes: %d total, %d running, %d sleeping", system_load.total_count, print_state->running_count, - print_state->blocked_count, - CONFIG_NFILE_DESCRIPTORS); + print_state->blocked_count); cb(user); snprintf(buffer, buffer_length, "CPU usage: %.2f%% tasks, %.2f%% sched, %.2f%% idle", (double)(task_load * 100.f), diff --git a/platforms/nuttx/src/px4/common/px4_init.cpp b/platforms/nuttx/src/px4/common/px4_init.cpp index 563974a171..041eccafb9 100644 --- a/platforms/nuttx/src/px4/common/px4_init.cpp +++ b/platforms/nuttx/src/px4/common/px4_init.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2019 PX4 Development Team. All rights reserved. + * Copyright (c) 2019, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -44,56 +44,11 @@ #include -int px4_platform_console_init(void) -{ -#if !defined(CONFIG_DEV_CONSOLE) && defined(CONFIG_DEV_NULL) - - /* Support running nsh on a board with out a console - * Without this the assumption that the fd 0..2 are - * std{in..err} will be wrong. NSH will read/write to the - * fd it opens for the init script or nested scripts assigned - * to fd 0..2. - * - */ - - int fd = open("/dev/null", O_RDWR); - - if (fd == 0) { - /* Successfully opened /dev/null as stdin (fd == 0) */ - - (void)fs_dupfd2(0, 1); - (void)fs_dupfd2(0, 2); - (void)fs_fdopen(0, O_RDONLY, NULL, NULL); - (void)fs_fdopen(1, O_WROK | O_CREAT, NULL, NULL); - (void)fs_fdopen(2, O_WROK | O_CREAT, NULL, NULL); - - } else { - /* We failed to open /dev/null OR for some reason, we opened - * it and got some file descriptor other than 0. - */ - - if (fd > 0) { - (void)close(fd); - } - - return -ENFILE; - - } - -#endif - return OK; -} int px4_platform_init(void) { - int ret = px4_platform_console_init(); - - if (ret < 0) { - return ret; - } - - ret = px4_console_buffer_init(); + int ret = px4_console_buffer_init(); if (ret < 0) { return ret;