diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index f3761200a1..e305713377 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -97,6 +97,12 @@ then fi fi +# This is a FMUv2+ thing +if ver hwcmp PX4FMU_V1 +then + set MIXER_AUX none +fi + if [ $MIXER_AUX != none ] then # diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index e5d527dd71..718a5e8212 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -110,11 +110,6 @@ else fi fi -# Check for flow sensor -if px4flow start & -then -fi - if ll40ls start then fi diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index dfa270b048..ff873adac0 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -705,16 +705,22 @@ then # End of autostart fi +# There is no further script processing, so we can free some RAM +# XXX potentially unset all script variables. +unset TUNE_ERR + # Boot is complete, inform MAVLink app(s) that the system is now fully up and running mavlink boot_complete +if ver hwcmp PX4FMU_V2 +then + # Check for flow sensor - as it is a background task, launch it last + px4flow start & +fi + if [ $EXIT_ON_END == yes ] then echo "Exit from nsh" exit fi unset EXIT_ON_END - -# There is no further processing, so we can free some RAM -# XXX potentially unset all script variables. -unset TUNE_ERR diff --git a/mavlink/include/mavlink/v1.0 b/mavlink/include/mavlink/v1.0 index 645a0e1b1e..d23a551e10 160000 --- a/mavlink/include/mavlink/v1.0 +++ b/mavlink/include/mavlink/v1.0 @@ -1 +1 @@ -Subproject commit 645a0e1b1eb09efeeaa14cc18d2474628a31ab53 +Subproject commit d23a551e108d92c7a49a66d162cb9d542bbe6be1 diff --git a/nuttx-configs/aerocore/nsh/defconfig b/nuttx-configs/aerocore/nsh/defconfig index e314bf1d82..655dd1406e 100644 --- a/nuttx-configs/aerocore/nsh/defconfig +++ b/nuttx-configs/aerocore/nsh/defconfig @@ -268,6 +268,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=256 # CONFIG_USART1_RS485 is not set CONFIG_USART1_RXDMA=y # CONFIG_USART2_RS485 is not set diff --git a/nuttx-configs/px4-stm32f4discovery/nsh/defconfig b/nuttx-configs/px4-stm32f4discovery/nsh/defconfig index 03092256e9..7be5399629 100644 --- a/nuttx-configs/px4-stm32f4discovery/nsh/defconfig +++ b/nuttx-configs/px4-stm32f4discovery/nsh/defconfig @@ -263,6 +263,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=256 # CONFIG_USART2_RS485 is not set CONFIG_USART2_RXDMA=y # CONFIG_USART6_RS485 is not set diff --git a/nuttx-configs/px4fmu-v1/nsh/defconfig b/nuttx-configs/px4fmu-v1/nsh/defconfig index 2c9a21f212..874615d3b2 100644 --- a/nuttx-configs/px4fmu-v1/nsh/defconfig +++ b/nuttx-configs/px4fmu-v1/nsh/defconfig @@ -260,6 +260,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=64 # CONFIG_USART1_RS485 is not set # CONFIG_USART1_RXDMA is not set # CONFIG_USART2_RS485 is not set diff --git a/nuttx-configs/px4fmu-v2/nsh/defconfig b/nuttx-configs/px4fmu-v2/nsh/defconfig index ef9c673785..e828e42be0 100644 --- a/nuttx-configs/px4fmu-v2/nsh/defconfig +++ b/nuttx-configs/px4fmu-v2/nsh/defconfig @@ -294,6 +294,8 @@ CONFIG_STM32_USART=y # # U[S]ART Configuration # +# Hot fix for lost data +CONFIG_STM32_RXDMA_BUFFER_SIZE_OVERRIDE=256 # CONFIG_USART1_RS485 is not set CONFIG_USART1_RXDMA=y # CONFIG_USART2_RS485 is not set diff --git a/src/drivers/px4flow/module.mk b/src/drivers/px4flow/module.mk index ecd3e804a1..8d6964d103 100644 --- a/src/drivers/px4flow/module.mk +++ b/src/drivers/px4flow/module.mk @@ -41,4 +41,6 @@ SRCS = px4flow.cpp MAXOPTIMIZATION = -Os +MODULE_STACKSIZE = 1200 + EXTRACXXFLAGS = -Wno-attributes diff --git a/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp b/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp index a1c56aa1f8..53c81b64cd 100644 --- a/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp +++ b/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp @@ -205,7 +205,7 @@ int AttitudeEstimatorQ::start() { _control_task = task_spawn_cmd("attitude_estimator_q", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, - 2500, + 2000, (main_t)&AttitudeEstimatorQ::task_main_trampoline, nullptr); diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 57e175ed19..a01b33087f 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -275,7 +275,7 @@ int commander_main(int argc, char *argv[]) if (!strcmp(argv[1], "start")) { if (thread_running) { - warnx("commander already running"); + warnx("already running"); /* this is not an error */ exit(0); } @@ -288,11 +288,18 @@ int commander_main(int argc, char *argv[]) commander_thread_main, (argv) ? (char * const *)&argv[2] : (char * const *)NULL); - while (!thread_running) { - usleep(200); + unsigned constexpr max_wait_us = 1000000; + unsigned constexpr max_wait_steps = 2000; + + unsigned i; + for (i = 0; i < max_wait_steps; i++) { + usleep(max_wait_us / max_wait_steps); + if (thread_running) { + break; + } } - exit(0); + exit(!(i < max_wait_steps)); } if (!strcmp(argv[1], "stop")) { diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 1e0b3ddb3e..f2dcd33d79 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1789,6 +1789,12 @@ Mavlink::start(int argc, char *argv[]) // before returning to the shell int ic = Mavlink::instance_count(); + if (ic == MAVLINK_COMM_NUM_BUFFERS) { + warnx("Maximum MAVLink instance count of %d reached.", + (int)MAVLINK_COMM_NUM_BUFFERS); + return 1; + } + // Instantiate thread char buf[24]; sprintf(buf, "mavlink_if%d", ic); diff --git a/src/modules/mavlink/module.mk b/src/modules/mavlink/module.mk index e82b8bd935..509fd9e495 100644 --- a/src/modules/mavlink/module.mk +++ b/src/modules/mavlink/module.mk @@ -53,6 +53,6 @@ MAXOPTIMIZATION = -Os MODULE_STACKSIZE = 1200 -EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed +EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 -EXTRACFLAGS = -Wno-packed +EXTRACFLAGS = -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index bedd854af6..71ac96350a 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -344,7 +344,20 @@ int sdlog2_main(int argc, char *argv[]) 3000, sdlog2_thread_main, (char * const *)argv); - exit(0); + + /* wait for the task to launch */ + unsigned const max_wait_us = 1000000; + unsigned const max_wait_steps = 2000; + + unsigned i; + for (i = 0; i < max_wait_steps; i++) { + usleep(max_wait_us / max_wait_steps); + if (thread_running) { + break; + } + } + + exit(!(i < max_wait_steps)); } if (!strcmp(argv[1], "stop")) { @@ -1228,8 +1241,6 @@ int sdlog2_thread_main(int argc, char *argv[]) /* close stdout */ close(1); - thread_running = true; - /* initialize thread synchronization */ pthread_mutex_init(&logbuffer_mutex, NULL); pthread_cond_init(&logbuffer_cond, NULL); @@ -1263,6 +1274,9 @@ int sdlog2_thread_main(int argc, char *argv[]) sdlog2_start_log(); } + /* running, report */ + thread_running = true; + while (!main_thread_should_exit) { usleep(sleep_delay); diff --git a/src/modules/systemlib/cpuload.c b/src/modules/systemlib/cpuload.c index b41896abd9..ffbeb608b5 100644 --- a/src/modules/systemlib/cpuload.c +++ b/src/modules/systemlib/cpuload.c @@ -78,8 +78,6 @@ void cpuload_initialize_once() system_load.tasks[i].valid = false; } - uint64_t now = hrt_absolute_time(); - int static_tasks_count = 2; // there are at least 2 threads that should be initialized statically - "idle" and "init" #ifdef CONFIG_PAGING @@ -94,7 +92,6 @@ void cpuload_initialize_once() // perform static initialization of "system" threads for (system_load.total_count = 0; system_load.total_count < static_tasks_count; system_load.total_count++) { - system_load.tasks[system_load.total_count].start_time = now; system_load.tasks[system_load.total_count].total_runtime = 0; system_load.tasks[system_load.total_count].curr_start_time = 0; system_load.tasks[system_load.total_count].tcb = sched_gettcb( @@ -111,7 +108,6 @@ void sched_note_start(FAR struct tcb_s *tcb) for (i = 1; i < CONFIG_MAX_TASKS; i++) { if (!system_load.tasks[i].valid) { /* slot is available */ - system_load.tasks[i].start_time = hrt_absolute_time(); system_load.tasks[i].total_runtime = 0; system_load.tasks[i].curr_start_time = 0; system_load.tasks[i].tcb = tcb; diff --git a/src/modules/systemlib/cpuload.h b/src/modules/systemlib/cpuload.h index 16d132fdb8..adc60671ec 100644 --- a/src/modules/systemlib/cpuload.h +++ b/src/modules/systemlib/cpuload.h @@ -42,7 +42,6 @@ __BEGIN_DECLS struct system_load_taskinfo_s { uint64_t total_runtime; ///< Runtime since start (start_time - total_runtime)/(start_time - current_time) = load uint64_t curr_start_time; ///< Start time of the current scheduling slot - uint64_t start_time; ///< FIRST start time of task FAR struct tcb_s *tcb; ///< bool valid; ///< Task is currently active / valid };