From d91e03cb8149cc031af7f64438e61be6f3a059dc Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 27 Feb 2018 16:56:58 +0100 Subject: [PATCH 1/7] FMUv5: Swap debug and PX4 IO serial ports to avoid DMA channel resource overlap This is necessary to be able to use DMA on the IO link. We free one channel by disabling DMA entirely on the debug console. --- .../nuttx/nuttx-configs/px4fmu-v5/nsh/defconfig | 6 +++--- src/drivers/boards/px4fmu-v5/board_config.h | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/platforms/nuttx/nuttx-configs/px4fmu-v5/nsh/defconfig b/platforms/nuttx/nuttx-configs/px4fmu-v5/nsh/defconfig index 381f80208209..af94144b573f 100644 --- a/platforms/nuttx/nuttx-configs/px4fmu-v5/nsh/defconfig +++ b/platforms/nuttx/nuttx-configs/px4fmu-v5/nsh/defconfig @@ -174,7 +174,7 @@ CONFIG_UART4_RXDMA=y # CONFIG_USART6_RS485 is not set CONFIG_USART6_RXDMA=y # CONFIG_UART7_RS485 is not set -CONFIG_UART7_RXDMA=y +# CONFIG_UART7_RXDMA is not set # CONFIG_UART8_RS485 is not set CONFIG_UART8_RXDMA=y CONFIG_SERIAL_DISABLE_REORDERING=y @@ -835,8 +835,8 @@ CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y # CONFIG_USART3_SERIAL_CONSOLE is not set # CONFIG_UART4_SERIAL_CONSOLE is not set # CONFIG_USART6_SERIAL_CONSOLE is not set -# CONFIG_UART7_SERIAL_CONSOLE is not set -CONFIG_UART8_SERIAL_CONSOLE=y +CONFIG_UART7_SERIAL_CONSOLE=y +# CONFIG_UART8_SERIAL_CONSOLE is not set # CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_NO_SERIAL_CONSOLE is not set diff --git a/src/drivers/boards/px4fmu-v5/board_config.h b/src/drivers/boards/px4fmu-v5/board_config.h index eb229c3e3996..b5b8d5b653f5 100644 --- a/src/drivers/boards/px4fmu-v5/board_config.h +++ b/src/drivers/boards/px4fmu-v5/board_config.h @@ -56,15 +56,15 @@ /* PX4IO connection configuration */ #define BOARD_USES_PX4IO_VERSION 2 -#define PX4IO_SERIAL_DEVICE "/dev/ttyS5" -#define PX4IO_SERIAL_TX_GPIO GPIO_UART7_TX -#define PX4IO_SERIAL_RX_GPIO GPIO_UART7_RX -#define PX4IO_SERIAL_BASE STM32_UART7_BASE /* hardwired on the board */ +#define PX4IO_SERIAL_DEVICE "/dev/ttyS6" +#define PX4IO_SERIAL_TX_GPIO GPIO_UART8_TX +#define PX4IO_SERIAL_RX_GPIO GPIO_UART8_RX +#define PX4IO_SERIAL_BASE STM32_UART8_BASE /* hardwired on the board */ #define PX4IO_SERIAL_VECTOR STM32_IRQ_UART7 -#define PX4IO_SERIAL_TX_DMAMAP DMAMAP_UART7_TX -#define PX4IO_SERIAL_RX_DMAMAP DMAMAP_UART7_RX +#define PX4IO_SERIAL_TX_DMAMAP DMAMAP_UART8_TX +#define PX4IO_SERIAL_RX_DMAMAP DMAMAP_UART8_RX #define PX4IO_SERIAL_RCC_REG STM32_RCC_APB1ENR -#define PX4IO_SERIAL_RCC_EN RCC_APB1ENR_UART7EN +#define PX4IO_SERIAL_RCC_EN RCC_APB1ENR_UART8EN #define PX4IO_SERIAL_CLOCK STM32_PCLK1_FREQUENCY #define PX4IO_SERIAL_BITRATE 1500000 /* 1.5Mbps -> max rate for IO */ From 7677065d6d1e5b3d8bdb6362b2fb2929d3df4cde Mon Sep 17 00:00:00 2001 From: DanielePettenuzzo Date: Fri, 2 Mar 2018 17:45:41 +0100 Subject: [PATCH 2/7] fmu-v5 board_config.h > change PX4IO_SERIAL_VECTOR for px4io communication on uart 8 --- src/drivers/boards/px4fmu-v5/board_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/boards/px4fmu-v5/board_config.h b/src/drivers/boards/px4fmu-v5/board_config.h index b5b8d5b653f5..60245e230413 100644 --- a/src/drivers/boards/px4fmu-v5/board_config.h +++ b/src/drivers/boards/px4fmu-v5/board_config.h @@ -60,7 +60,7 @@ #define PX4IO_SERIAL_TX_GPIO GPIO_UART8_TX #define PX4IO_SERIAL_RX_GPIO GPIO_UART8_RX #define PX4IO_SERIAL_BASE STM32_UART8_BASE /* hardwired on the board */ -#define PX4IO_SERIAL_VECTOR STM32_IRQ_UART7 +#define PX4IO_SERIAL_VECTOR STM32_IRQ_UART8 #define PX4IO_SERIAL_TX_DMAMAP DMAMAP_UART8_TX #define PX4IO_SERIAL_RX_DMAMAP DMAMAP_UART8_RX #define PX4IO_SERIAL_RCC_REG STM32_RCC_APB1ENR From 117c8acb73f0a079943f9242416955ee2aa78979 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 5 Mar 2018 09:44:40 +0100 Subject: [PATCH 3/7] PX4IO Firmware: Only decode DSM if no other input method matched This ensures that the DSM decoder does not accidentally decode noise on the bus as DSM is not well-protected against CRC errors. --- src/modules/px4iofirmware/controls.c | 38 +++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/modules/px4iofirmware/controls.c b/src/modules/px4iofirmware/controls.c index f65ffefe1c05..9d10f1c8ba53 100644 --- a/src/modules/px4iofirmware/controls.c +++ b/src/modules/px4iofirmware/controls.c @@ -230,24 +230,6 @@ controls_tick() rssi = 0; } - perf_begin(c_gather_dsm); - bool dsm_updated, st24_updated, sumd_updated; - (void)dsm_port_input(&rssi, &dsm_updated, &st24_updated, &sumd_updated); - - if (dsm_updated) { - PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_DSM); - } - - if (st24_updated) { - PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_ST24); - } - - if (sumd_updated) { - PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_SUMD); - } - - perf_end(c_gather_dsm); - perf_begin(c_gather_sbus); bool sbus_failsafe, sbus_frame_drop; @@ -300,6 +282,26 @@ controls_tick() perf_end(c_gather_ppm); + if (!((r_status_flags & PX4IO_P_STATUS_FLAGS_RC_SBUS) || (r_status_flags & PX4IO_P_STATUS_FLAGS_RC_PPM))) { + perf_begin(c_gather_dsm); + bool dsm_updated, st24_updated, sumd_updated; + (void)dsm_port_input(&rssi, &dsm_updated, &st24_updated, &sumd_updated); + + if (dsm_updated) { + PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_DSM); + } + + if (st24_updated) { + PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_ST24); + } + + if (sumd_updated) { + PX4_ATOMIC_MODIFY_OR(r_status_flags, PX4IO_P_STATUS_FLAGS_RC_SUMD); + } + + perf_end(c_gather_dsm); + } + /* limit number of channels to allowable data size */ if (r_raw_rc_count > PX4IO_RC_INPUT_CHANNELS) { r_raw_rc_count = PX4IO_RC_INPUT_CHANNELS; From 73390b3d59c1e01d1297c8a818ac80d6e2eb205f Mon Sep 17 00:00:00 2001 From: DanielePettenuzzo Date: Mon, 5 Mar 2018 17:28:59 +0100 Subject: [PATCH 4/7] PX4IO Firmware: bug fix in variable initialization --- src/modules/px4iofirmware/controls.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/px4iofirmware/controls.c b/src/modules/px4iofirmware/controls.c index 9d10f1c8ba53..690477f16bb6 100644 --- a/src/modules/px4iofirmware/controls.c +++ b/src/modules/px4iofirmware/controls.c @@ -282,9 +282,11 @@ controls_tick() perf_end(c_gather_ppm); + bool dsm_updated = false, st24_updated = false, sumd_updated = false; + if (!((r_status_flags & PX4IO_P_STATUS_FLAGS_RC_SBUS) || (r_status_flags & PX4IO_P_STATUS_FLAGS_RC_PPM))) { perf_begin(c_gather_dsm); - bool dsm_updated, st24_updated, sumd_updated; + (void)dsm_port_input(&rssi, &dsm_updated, &st24_updated, &sumd_updated); if (dsm_updated) { From 69949b3afbb21265669102f0d2fa36ea98071418 Mon Sep 17 00:00:00 2001 From: DanielePettenuzzo Date: Mon, 5 Mar 2018 17:29:52 +0100 Subject: [PATCH 5/7] rcS: initialize TELEM4 on ttyS3 on FMUv5 --- ROMFS/px4fmu_common/init.d/rcS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index a17536f184a8..58f058985b6c 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -552,6 +552,12 @@ then mavlink start -r 20000 -b 921600 -d /dev/ttyS0 fi + # Use ttyS3 (TELEM4) for MAVLink on FMUv5 in addition to ttyS1 (TELEM1) and ttyS2 (TELEM2) + if ver hwcmp PX4FMU_V5 + then + mavlink start -r 2000 -b 57600 -d /dev/ttyS3 + fi + if ver hwcmp AEROFC_V1 then set MAVLINK_F "-r 1200 -d /dev/ttyS3" From 2e2378c507514c75cdc9b614f299d2d9df4559f1 Mon Sep 17 00:00:00 2001 From: Daniele Pettenuzzo Date: Tue, 6 Mar 2018 21:16:37 +0100 Subject: [PATCH 6/7] fmuv5 board config: disabled USART6 due to conflict on SBUS --- src/drivers/boards/px4fmu-v5/board_config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/drivers/boards/px4fmu-v5/board_config.h b/src/drivers/boards/px4fmu-v5/board_config.h index 60245e230413..a5c6c87db7a6 100644 --- a/src/drivers/boards/px4fmu-v5/board_config.h +++ b/src/drivers/boards/px4fmu-v5/board_config.h @@ -517,7 +517,6 @@ #define GPIO_PPM_IN /* PI5 T8C1 */ GPIO_TIM8_CH1IN_2 #define RC_UXART_BASE STM32_USART6_BASE /* NOT FMUv5 test HW ONLY*/ -#define RC_SERIAL_PORT "/dev/ttyS4" /* NOT FMUv5 test HW ONLY*/ #define GPS_DEFAULT_UART_PORT "/dev/ttyS0" /* UART1 on FMUv5 */ From 1b68977128b48200becfa08d87a526d2b6e0c259 Mon Sep 17 00:00:00 2001 From: DanielePettenuzzo Date: Mon, 26 Mar 2018 13:21:50 +0200 Subject: [PATCH 7/7] fmuv5 board_config: added TIM5_CH4 spare pin & 3 Input Cap channels --- src/drivers/boards/px4fmu-v5/board_config.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/drivers/boards/px4fmu-v5/board_config.h b/src/drivers/boards/px4fmu-v5/board_config.h index a5c6c87db7a6..0c5ba9e00d43 100644 --- a/src/drivers/boards/px4fmu-v5/board_config.h +++ b/src/drivers/boards/px4fmu-v5/board_config.h @@ -360,10 +360,14 @@ */ #define GPIO_TIM2_CH1_IN /* PA5 T22C1 FMU_CAP1 */ GPIO_TIM2_CH1IN_3 #define GPIO_TIM2_CH2_IN /* PB3 T22C2 FMU_CAP2 */ GPIO_TIM2_CH2IN_2 -#define GPIO_TIM2_CH4_IN /* PB1 T22C4 FMU_CAP3 */ GPIO_TIM2_CH4IN_2 +#define GPIO_TIM2_CH4_IN /* PB11 T22C4 FMU_CAP3 */ GPIO_TIM2_CH4IN_2 #define DIRECT_PWM_CAPTURE_CHANNELS 3 +/* TIM5_CH4 SPARE PIN */ +#define GPIO_TIM5_CH4IN /* PI0 T5C4 TIM5_SPARE_4 */ GPIO_TIM5_CH4IN_2 +#define GPIO_TIM5_CH4OUT /* PI0 T5C4 TIM5_SPARE_4 */ GPIO_TIM5_CH4OUT_2 + /* PWM * * 8 PWM outputs are configured. @@ -520,6 +524,19 @@ #define GPS_DEFAULT_UART_PORT "/dev/ttyS0" /* UART1 on FMUv5 */ +/* Input Capture Channels. */ +#define INPUT_CAP1_TIMER 2 +#define INPUT_CAP1_CHANNEL /* T4C1 */ 1 +#define GPIO_INPUT_CAP1 /* PA5 */ GPIO_TIM2_CH1_IN + +#define INPUT_CAP2_TIMER 2 +#define INPUT_CAP2_CHANNEL /* T4C2 */ 2 +#define GPIO_INPUT_CAP2 /* PB3 */ GPIO_TIM2_CH2_IN + +#define INPUT_CAP3_TIMER 2 +#define INPUT_CAP3_CHANNEL /* T4C4 */ 4 +#define GPIO_INPUT_CAP3 /* PB11 */ GPIO_TIM2_CH4_IN + /* PWM input driver. Use FMU AUX5 pins attached to timer4 channel 2 */ #define PWMIN_TIMER 4 #define PWMIN_TIMER_CHANNEL /* T4C2 */ 2