From 95f1477e401abcf9f282b079fcb5e096b9dfa2af Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 9 Mar 2021 10:59:07 +0100 Subject: [PATCH 1/4] CUAV X7Pro: Remove unused peripheral --- boards/cuav/x7pro/default.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/cuav/x7pro/default.cmake b/boards/cuav/x7pro/default.cmake index 8bd747f92c56..0133527b4315 100644 --- a/boards/cuav/x7pro/default.cmake +++ b/boards/cuav/x7pro/default.cmake @@ -37,7 +37,7 @@ px4_add_board( imu/invensense/icm20649 imu/invensense/icm20689 irlock - lights/blinkm + #lights/blinkm lights/rgbled lights/rgbled_ncp5623c lights/rgbled_pwm From 8401e0d9d2e6ad5d56f27e1bc5b62c6a898d9972 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 9 Mar 2021 11:03:24 +0100 Subject: [PATCH 2/4] MAVLink shell: Do not print before creation The statement could end up in the pipe during creation, leading to a hard fault. Fixes #17063 --- src/modules/mavlink/mavlink_shell.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/modules/mavlink/mavlink_shell.cpp b/src/modules/mavlink/mavlink_shell.cpp index afad6a0779c6..874320afd135 100644 --- a/src/modules/mavlink/mavlink_shell.cpp +++ b/src/modules/mavlink/mavlink_shell.cpp @@ -74,9 +74,6 @@ int MavlinkShell::start() return -1; #endif /* __PX4_NUTTX */ - - PX4_INFO("Starting mavlink shell"); - int p1[2], p2[2]; /* Create the shell task and redirect its stdin & stdout. If we used pthread, we would redirect From 42b59b284d91a27434e0e55055c686c91b346790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 10 Mar 2021 11:25:06 +0100 Subject: [PATCH 3/4] Revert "MAVLink shell: Do not print before creation" This reverts commit 8401e0d9d2e6ad5d56f27e1bc5b62c6a898d9972. --- src/modules/mavlink/mavlink_shell.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/mavlink/mavlink_shell.cpp b/src/modules/mavlink/mavlink_shell.cpp index 874320afd135..afad6a0779c6 100644 --- a/src/modules/mavlink/mavlink_shell.cpp +++ b/src/modules/mavlink/mavlink_shell.cpp @@ -74,6 +74,9 @@ int MavlinkShell::start() return -1; #endif /* __PX4_NUTTX */ + + PX4_INFO("Starting mavlink shell"); + int p1[2], p2[2]; /* Create the shell task and redirect its stdin & stdout. If we used pthread, we would redirect From a99627617b0dea345fa13e0dcdca02e6bb516209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 10 Mar 2021 11:44:24 +0100 Subject: [PATCH 4/4] mavlink shell: lock scheduling to ensure nothing gets written to the pipe Locking duration on F4: 0.3ms --- src/modules/mavlink/mavlink_shell.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/mavlink/mavlink_shell.cpp b/src/modules/mavlink/mavlink_shell.cpp index afad6a0779c6..6203e0f28ef5 100644 --- a/src/modules/mavlink/mavlink_shell.cpp +++ b/src/modules/mavlink/mavlink_shell.cpp @@ -84,8 +84,6 @@ int MavlinkShell::start() * keeps (duplicates) the first 3 fd's when creating a new task, all others are not inherited. * This means we need to temporarily change the first 3 fd's of the current task (or at least * the first 2 if stdout=stderr). - * And we hope :-) that during the temporary phase, no other thread from the same task writes to - * stdout (as it would end up in the pipe). */ if (pipe(p1) != 0) { @@ -105,6 +103,16 @@ int MavlinkShell::start() _shell_fds[0] = p2[0]; _shell_fds[1] = p1[1]; + /* + * Ensure that during the temporary phase no other thread from the same task writes to + * stdout (as it would end up in the pipe). + */ +#ifdef __PX4_NUTTX + sched_lock(); +#endif /* __PX4_NUTTX */ + fflush(stdout); + fflush(stderr); + int fd_backups[2]; //we don't touch stderr, we will redirect it to stdout in the startup of the shell task for (int i = 0; i < 2; ++i) { @@ -140,6 +148,10 @@ int MavlinkShell::start() close(fd_backups[i]); } +#ifdef __PX4_NUTTX + sched_unlock(); +#endif /* __PX4_NUTTX */ + //close unused pipe fd's close(_shell_fds[0]); close(_shell_fds[1]);