From 99f694598ec6835f91d83f61a28d5646580527e2 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Tue, 28 Feb 2017 16:21:49 -1000 Subject: [PATCH] Updated NuttX submodule to upstream 7.19+ ==upstream The has the upstream irq dispatch changes and PX4 contrib fixes There is now a large static (4*NR_IRQ) NR_IRQ is > 77 on most SoS that is uses to save and pass args to an interrupt service. The problem this introduces is running out of ram on the STM32F100 devices. So we will carry a set patches to at COMPILE time use the oldstyle dispatch. --- NuttX | 2 +- nuttx-patches/no_irq_args.patch | 59 +++++ nuttx-patches/stm32_serial_no_irq_args.patch | 222 +++++++++++++++++++ 3 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 nuttx-patches/no_irq_args.patch create mode 100644 nuttx-patches/stm32_serial_no_irq_args.patch diff --git a/NuttX b/NuttX index 7b5eadd86d..d5435b6506 160000 --- a/NuttX +++ b/NuttX @@ -1 +1 @@ -Subproject commit 7b5eadd86d0adf7af65391b9e4dcd384dc5a1b62 +Subproject commit d5435b65060b11f375fc5ed9f5d62f1b260e990e diff --git a/nuttx-patches/no_irq_args.patch b/nuttx-patches/no_irq_args.patch new file mode 100644 index 0000000000..c7ea4b4bc0 --- /dev/null +++ b/nuttx-patches/no_irq_args.patch @@ -0,0 +1,59 @@ +diff --git NuttX/nuttx/sched/irq/irq.h NuttX/nuttx/sched/irq/irq.h +index 59bd5ea..fcf996f 100644 +--- NuttX/nuttx/sched/irq/irq.h ++++ NuttX/nuttx/sched/irq/irq.h +@@ -63,7 +63,9 @@ + struct irq + { + xcpt_t handler; /* Address of the interrupt handler */ ++#if !defined(CONFIG_NOIRQARGS) + FAR void *arg; /* The argument provided to the interrupt handler. */ ++#endif + }; + + /**************************************************************************** +diff --git NuttX/nuttx/sched/irq/irq_attach.c NuttX/nuttx/sched/irq/irq_attach.c +index ae147e2..50c621b 100644 +--- NuttX/nuttx/sched/irq/irq_attach.c ++++ NuttX/nuttx/sched/irq/irq_attach.c +@@ -97,7 +97,11 @@ int irq_attach(int irq, xcpt_t isr, FAR void * arg) + /* Save the new ISR in the table. */ + + g_irqvector[irq].handler = isr; ++#if defined(CONFIG_NOIRQARGS) ++ ASSERT(arg == NULL); ++#else + g_irqvector[irq].arg = arg; ++#endif + leave_critical_section(flags); + ret = OK; + } +diff --git NuttX/nuttx/sched/irq/irq_dispatch.c NuttX/nuttx/sched/irq/irq_dispatch.c +index 576e757..941eeb8 100644 +--- NuttX/nuttx/sched/irq/irq_dispatch.c ++++ NuttX/nuttx/sched/irq/irq_dispatch.c +@@ -75,7 +75,11 @@ void irq_dispatch(int irq, FAR void *context) + else + { + vector = g_irqvector[irq].handler; ++#if defined(CONFIG_NOIRQARGS) ++ arg = NULL; ++#else + arg = g_irqvector[irq].arg; ++#endif + } + #else + vector = irq_unexpected_isr; +diff --git NuttX/nuttx/sched/irq/irq_initialize.c NuttX/nuttx/sched/irq/irq_initialize.c +index e03d27a..3350fb0 100644 +--- NuttX/nuttx/sched/irq/irq_initialize.c ++++ NuttX/nuttx/sched/irq/irq_initialize.c +@@ -70,6 +70,8 @@ void irq_initialize(void) + for (i = 0; i < NR_IRQS; i++) + { + g_irqvector[i].handler = irq_unexpected_isr; ++#if !defined(CONFIG_NOIRQARGS) + g_irqvector[i].arg = NULL; ++#endif + } + } diff --git a/nuttx-patches/stm32_serial_no_irq_args.patch b/nuttx-patches/stm32_serial_no_irq_args.patch new file mode 100644 index 0000000000..5120fd1821 --- /dev/null +++ b/nuttx-patches/stm32_serial_no_irq_args.patch @@ -0,0 +1,222 @@ +diff --git NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c +index a6a2d07..ea8ba61 100644 +--- NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c ++++ NuttX/nuttx/arch/arm/src/stm32/stm32_serial.c +@@ -315,6 +315,9 @@ struct up_dev_s + const unsigned int rxdma_channel; /* DMA channel assigned */ + #endif + ++#if defined(CONFIG_NOIRQARGS) ++ int (*const vector)(int irq, void *context, void *arg); /* Interrupt handler */ ++#endif + /* RX DMA state */ + + #ifdef SERIAL_HAVE_DMA +@@ -371,6 +374,32 @@ static int up_pm_prepare(struct pm_callback_s *cb, int domain, + enum pm_state_e pmstate); + #endif + ++#if defined(CONFIG_NOIRQARGS) ++# ifdef CONFIG_STM32_USART1_SERIALDRIVER ++static int up_interrupt_usart1(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_USART2_SERIALDRIVER ++static int up_interrupt_usart2(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_USART3_SERIALDRIVER ++static int up_interrupt_usart3(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_UART4_SERIALDRIVER ++static int up_interrupt_uart4(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_UART5_SERIALDRIVER ++static int up_interrupt_uart5(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_USART6_SERIALDRIVER ++static int up_interrupt_usart6(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_UART7_SERIALDRIVER ++static int up_interrupt_uart7(int irq, void *context, void *arg); ++# endif ++# ifdef CONFIG_STM32_UART8_SERIALDRIVER ++static int up_interrupt_uart8(int irq, void *context, void *arg); ++# endif ++#endif + /**************************************************************************** + * Private Data + ****************************************************************************/ +@@ -536,7 +565,9 @@ static struct up_dev_s g_usart1priv = + .rxdma_channel = DMAMAP_USART1_RX, + .rxfifo = g_usart1rxfifo, + #endif +- ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_usart1, ++#endif + #ifdef CONFIG_USART1_RS485 + .rs485_dir_gpio = GPIO_USART1_RS485_DIR, + # if (CONFIG_USART1_RS485_DIR_POLARITY == 0) +@@ -597,6 +628,9 @@ static struct up_dev_s g_usart2priv = + .rxdma_channel = DMAMAP_USART2_RX, + .rxfifo = g_usart2rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_usart2, ++#endif + + #ifdef CONFIG_USART2_RS485 + .rs485_dir_gpio = GPIO_USART2_RS485_DIR, +@@ -658,6 +692,9 @@ static struct up_dev_s g_usart3priv = + .rxdma_channel = DMAMAP_USART3_RX, + .rxfifo = g_usart3rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_usart3, ++#endif + + #ifdef CONFIG_USART3_RS485 + .rs485_dir_gpio = GPIO_USART3_RS485_DIR, +@@ -723,6 +760,9 @@ static struct up_dev_s g_uart4priv = + .rxdma_channel = DMAMAP_UART4_RX, + .rxfifo = g_uart4rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_uart4, ++#endif + + #ifdef CONFIG_UART4_RS485 + .rs485_dir_gpio = GPIO_UART4_RS485_DIR, +@@ -788,6 +828,9 @@ static struct up_dev_s g_uart5priv = + .rxdma_channel = DMAMAP_UART5_RX, + .rxfifo = g_uart5rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_uart5, ++#endif + + #ifdef CONFIG_UART5_RS485 + .rs485_dir_gpio = GPIO_UART5_RS485_DIR, +@@ -849,6 +892,9 @@ static struct up_dev_s g_usart6priv = + .rxdma_channel = DMAMAP_USART6_RX, + .rxfifo = g_usart6rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_uart6, ++#endif + + #ifdef CONFIG_USART6_RS485 + .rs485_dir_gpio = GPIO_USART6_RS485_DIR, +@@ -910,6 +956,9 @@ static struct up_dev_s g_uart7priv = + .rxdma_channel = DMAMAP_UART7_RX, + .rxfifo = g_uart7rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_uart7, ++#endif + + #ifdef CONFIG_UART7_RS485 + .rs485_dir_gpio = GPIO_UART7_RS485_DIR, +@@ -971,6 +1020,9 @@ static struct up_dev_s g_uart8priv = + .rxdma_channel = DMAMAP_UART8_RX, + .rxfifo = g_uart8rxfifo, + #endif ++#if defined(CONFIG_NOIRQARGS) ++ .vector = up_interrupt_uart8, ++#endif + + #ifdef CONFIG_UART8_RS485 + .rs485_dir_gpio = GPIO_UART8_RS485_DIR, +@@ -1709,7 +1761,11 @@ static int up_attach(struct uart_dev_s *dev) + + /* Attach and enable the IRQ */ + ++#if defined(CONFIG_NOIRQARGS) ++ ret = irq_attach(priv->irq, priv->vector, NULL); ++#else + ret = irq_attach(priv->irq, up_interrupt, priv); ++#endif + if (ret == OK) + { + /* Enable the interrupt (RX and TX interrupts are still disabled +@@ -1740,7 +1796,7 @@ static void up_detach(struct uart_dev_s *dev) + } + + /**************************************************************************** +- * Name: up_interrupt ++ * Name: up_interrupt_common + * + * Description: + * This is the USART interrupt handler. It will be invoked when an +@@ -2480,6 +2536,72 @@ static bool up_txready(struct uart_dev_s *dev) + return ((up_serialin(priv, STM32_USART_SR_OFFSET) & USART_SR_TXE) != 0); + } + ++#if defined(CONFIG_NOIRQARGS) ++/**************************************************************************** ++ * Name: up_interrupt_u[s]art[n] ++ * ++ * Description: ++ * Interrupt handlers for U[S]ART[n] where n=1,..,6. ++ * ++ ****************************************************************************/ ++ ++# ifdef CONFIG_STM32_USART1_SERIALDRIVER ++static int up_interrupt_usart1(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_usart1priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_USART2_SERIALDRIVER ++static int up_interrupt_usart2(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_usart2priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_USART3_SERIALDRIVER ++static int up_interrupt_usart3(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_usart3priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_UART4_SERIALDRIVER ++static int up_interrupt_uart4(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_uart4priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_UART5_SERIALDRIVER ++static int up_interrupt_uart5(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_uart5priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_USART6_SERIALDRIVER ++static int up_interrupt_usart6(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_usart6priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_UART7_SERIALDRIVER ++static int up_interrupt_uart7(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_uart7priv); ++} ++# endif ++ ++# ifdef CONFIG_STM32_UART8_SERIALDRIVER ++static int up_interrupt_uart8(int irq, void *context, void *arg) ++{ ++ return up_interrupt(irq, context, &g_uart8priv); ++} ++# endif ++#endif ++ + /**************************************************************************** + * Name: up_dma_rxcallback + *