You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/19 12:23:32 UTC

[GitHub] [incubator-nuttx] w8jcik opened a new issue #2567: Not possible to select SPI3 DMA RX1 on STM32 F2, F4, F7, H7

w8jcik opened a new issue #2567:
URL: https://github.com/apache/incubator-nuttx/issues/2567


   ### Short story
   
   - There is a check in SPI driver which checks if we defined SPI channels
   - `0` in this check means **not defined**, so in case of `0` driver doesn't enable DMA
   - SPI3 DMA RX1 is unlucky to be `0` 
   
   ### Long story
   
   `DMAMAP_SPI3_RX_1` is defined in [arch/arm/src/stm32/hardware/stm32_dma_v2.h#L406](https://github.com/apache/incubator-nuttx/blob/master/arch/arm/src/stm32/hardware/stm32_dma_v2.h#L406) and evaluates to `0`:
   
   ```
   #define STM32_DMA_MAP(d,s,c)       ((d) << 6 | (s) << 3 | (c))
   ```
   
   ```
   #define DMAMAP_SPI3_RX_1           STM32_DMA_MAP(DMA1,DMA_STREAM0,DMA_CHAN0)
   ```
   
   ```
   #define DMA1                      (0)
   ...
   #define DMA_STREAM0               (0)
   ...
   #define DMA_CHAN0                 (0)
   ```
   
   
   
   In `arch/arm/src/stm32/stm32_spi.c`
   
   This commit [cfc5b59](https://github.com/apache/incubator-nuttx/commit/cfc5b596364ddbe163009c69309ababe62309c98) from NuttX 7.27 added a check if DMA channels are defined, before enabling DMA for SPI.
   
   ```
   if (priv->rxch && priv->txch)
   ```
   
   Type of `rxch` is `uint8_t` and `0` is used to indicate no channel being assigned.
   
   It is fine, except if we are unlucky, and try to use SPI3 DMA1, Stream 0, Channel 0 `DMAMAP_SPI3_RX_1`, for example:
   
   `board.h`
   
   ```
   #define DMACHAN_SPI3_RX DMAMAP_SPI3_RX_1  /* DMA1, Stream 0, Channel 0 */
   #define DMACHAN_SPI3_TX DMAMAP_SPI3_TX_1  /* DMA1, Stream 5, Channel 0 */
   ```
   
   Not sure how to fix it nicely. Zero shouldn't be used to detect lack of channel if `0` is valid channel identifier.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] dagar commented on issue #2567: Not possible to select SPI3 DMA RX1 on STM32 F2, F4, F7, H7

Posted by GitBox <gi...@apache.org>.
dagar commented on issue #2567:
URL: https://github.com/apache/incubator-nuttx/issues/2567#issuecomment-748709412


   Nice find, would a quick define for invalid (UINT8_MAX) suffice?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] w8jcik closed issue #2567: Not possible to select SPI3 DMA RX1 on STM32 F2, F4, F7, H7

Posted by GitBox <gi...@apache.org>.
w8jcik closed issue #2567:
URL: https://github.com/apache/incubator-nuttx/issues/2567


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] davids5 commented on issue #2567: Not possible to select SPI3 DMA RX1 on STM32 F2, F4, F7, H7

Posted by GitBox <gi...@apache.org>.
davids5 commented on issue #2567:
URL: https://github.com/apache/incubator-nuttx/issues/2567#issuecomment-748473231


   @w8jcik - Good find and thank you for the clear explanation of the issue. I will check all the drivers and would up a solution.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org