From fe7d3b221a6ef7d7e6f418561df412ad2e456b09 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Wed, 28 Aug 2024 15:25:54 +0300 Subject: [PATCH 1/3] pwm_esc: Use PX4_STACK_ADJUSTED() for stack size The module occasionally runs out of stack otherwise --- src/drivers/pwm_esc/pwm_esc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/pwm_esc/pwm_esc.cpp b/src/drivers/pwm_esc/pwm_esc.cpp index 9e9a6b4f2002..28e85cee0fa4 100644 --- a/src/drivers/pwm_esc/pwm_esc.cpp +++ b/src/drivers/pwm_esc/pwm_esc.cpp @@ -282,7 +282,7 @@ PWMESC::init(bool hitl_mode) _task = px4_task_spawn_cmd("pwm_esc", SCHED_DEFAULT, SCHED_PRIORITY_ACTUATOR_OUTPUTS, - 3048, + PX4_STACK_ADJUSTED(3048), (px4_main_t)&PWMESC::task_main_trampoline, nullptr); From 802d555625344161177f77e686cb413aba304073 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Mon, 2 Sep 2024 12:42:34 +0300 Subject: [PATCH 2/3] board_ioctl.c: Fix return values, check incoming parameter - Return value should be negated errno ok OK (not PX4_OK) - Check that the incoming argument is valid (not NULL) --- platforms/nuttx/src/px4/common/board_ioctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platforms/nuttx/src/px4/common/board_ioctl.c b/platforms/nuttx/src/px4/common/board_ioctl.c index d510b743488a..3753042a2e16 100644 --- a/platforms/nuttx/src/px4/common/board_ioctl.c +++ b/platforms/nuttx/src/px4/common/board_ioctl.c @@ -131,7 +131,7 @@ static int launch_kernel_builtin(int argc, char **argv) return builtin->main(argc, argv); } - return ENOENT; + return -ENOENT; } /************************************************************************************ @@ -144,7 +144,11 @@ static int launch_kernel_builtin(int argc, char **argv) static int platform_ioctl(unsigned int cmd, unsigned long arg) { - int ret = PX4_OK; + int ret = OK; + + if (arg == 0) { + return -EINVAL; + } switch (cmd) { case PLATFORMIOCLAUNCH: { From 828d95af1f2c60393f2e2691300c296e9bf2f763 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Mon, 2 Sep 2024 12:43:23 +0300 Subject: [PATCH 3/3] hrt_ioctl.c: Cast NULL (which is defined as (void *)0) to integer The value is returned as integer, some compilers are not happy we assign a pointer to void. --- platforms/nuttx/src/px4/common/hrt_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/nuttx/src/px4/common/hrt_ioctl.c b/platforms/nuttx/src/px4/common/hrt_ioctl.c index 4cba925a47a0..4c0a7d6aab26 100644 --- a/platforms/nuttx/src/px4/common/hrt_ioctl.c +++ b/platforms/nuttx/src/px4/common/hrt_ioctl.c @@ -354,7 +354,7 @@ hrt_ioctl(unsigned int cmd, unsigned long arg) #ifdef PX4_USERSPACE_HRT *(uintptr_t *)arg = hrt_absolute_time_usr_base(); #else - *(uintptr_t *)arg = NULL; + *(uintptr_t *)arg = (uintptr_t)NULL; #endif } break;