davids5 opened a new pull request, #8992: URL: https://github.com/apache/nuttx/pull/8992
## Summary See discussion the discussion https://github.com/apache/nuttx/issues/1570 The `tools/stm32_pinmap_tool.py` can be used to migrate an arch pinmap as follows. 1. Run conversion tool `tools/stm32_pinmap_tool.py --pinmap arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap.h --addall --suffix _0 --legacy > arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap-new.h` 2. diff and verify `arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap.h` ` arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap-new.h` are as expected. 3. delete `arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap.h` 4. rename `arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap-new.h` to `arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap.h` 5. edit `arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap_legacy.h` (that was created by the --legacy option) a. add _legacy to the title block, b. add _LEGACY to the #ifdef, #define and endif comment of the inclusion guard. 6. Edit the top level 1arch/arm/src/stm32x/stm32x_pinmap.h1 file and add a CONFIG_STM32xx_USE_LEGACY_PINMAP section. That includes the legacy pinmap files. For example ``` #if defined(CONFIG_STM32H7_USE_LEGACY_PINMAP) # pragma message "CONFIG_STM32H7_USE_LEGACY_PINMAP will be deprecated migrate board.h see tools/stm32_pinmap_tool.py" # if defined(CONFIG_STM32H7_STM32H7X3XX) # include "hardware/stm32h7x3xx_pinmap_legacy.h" # elif defined(CONFIG_STM32H7_STM32H7B3XX) # include "hardware/stm32h7x3xx_pinmap_legacy.h" # elif defined(CONFIG_STM32H7_STM32H7X7XX) # include "hardware/stm32h7x3xx_pinmap_legacy.h" # else # error "Unsupported STM32 H7 Pin map" # endif #else # if defined(CONFIG_STM32H7_STM32H7X3XX) # include "hardware/stm32h7x3xx_pinmap.h" # elif defined(CONFIG_STM32H7_STM32H7B3XX) # include "hardware/stm32h7x3xx_pinmap.h" # elif defined(CONFIG_STM32H7_STM32H7X7XX) # include "hardware/stm32h7x3xx_pinmap.h" # else # error "Unsupported STM32 H7 Pin map" # endif #endif ``` 8. Add a STM32Hx_USE_LEGACY_PINMAP to the Kconfig defaulted to y For example ``` config STM32H7_USE_LEGACY_PINMAP bool "Use the legacy pinmap with GPIO_SPEED_xxx included." default y ---help--- In the past, pinmap files included GPIO_SPEED_xxxMhz. These speed settings should have come from the board.h as it describes the wiring of the SoC to the board. The speed is really slew rate control and therefore is related to the layout and can only be properly set in board.h. STM32H7_USE_LEGACY_PINMAP is provided, to allow lazy migration to using pinmaps without speeds. The work required to do this can be aided by running tools/stm32_pinmap_tool.py. The tools will take a board.h file and a legacy pinmap and outut the required changes that one needs to make to a board.h file. Eventually, STM32H7_USE_LEGACY_PINMAP will be deprecated and the legacy pinmaps removed from NuttX. Any new boards added should set STM32H7_USE_LEGACY_PINMAP=n and fully define the pins in board.h ``` ## Impact All boards board.h should be migrated using tools/stm32_pinmap_tool.py `tools/stm32_pinmap_tool.py --pinmap arch/arm/src/stm32h7/hardware/stm32h7x3xx_pinmap.h --addall --suffix _0 --report <path to board>/include/board.h it will output 2 sections that should be used to update the board.h. ``` board.h defines that need to have speeds added. N.B. The legacy version of the pin defines included speed settings. These are in reality, slew rates. The correct speed setting for a given pin is very dependent on the layout of the circuit board and load presented to the SoC on that pin. Pin that had an explicit GPIO_SPEED_xxxMHz that were removed are listed below with the original speed. The speeds listed below are provided to insure the changes do not break system, using the old defined. However, it is highly recommended that the speed setting be verified for overshoot and undershoot on real hardware and adjusted appropriately. #define GPIO_USART1_RX (GPIO_USART1_RX_3 | GPIO_SPEED_100MHz) /* PB7 */ #define GPIO_USART1_TX (GPIO_USART1_TX_3 | GPIO_SPEED_100MHz) /* PB6 */ #define GPIO_USART2_RX (GPIO_USART2_RX_1 | GPIO_SPEED_100MHz) /* PA3 */ #define GPIO_USART2_TX (GPIO_USART2_TX_2 | GPIO_SPEED_100MHz) /* PD5 */ #define GPIO_USART3_RX (GPIO_USART3_RX_3 | GPIO_SPEED_100MHz) /* PD9 */ #define GPIO_USART3_TX (GPIO_USART3_TX_3 | GPIO_SPEED_100MHz) /* PD8 */ #define GPIO_UART4_RX (GPIO_UART4_RX_6 | GPIO_SPEED_100MHz) /* PH14 */ #define GPIO_UART4_TX (GPIO_UART4_TX_6 | GPIO_SPEED_100MHz) /* PH13 */ #define GPIO_UART5_RX (GPIO_UART5_RX_3 | GPIO_SPEED_100MHz) /* PD2 */ #define GPIO_UART5_TX (GPIO_UART5_TX_3 | GPIO_SPEED_100MHz) /* PC12 */ #define GPIO_USART6_RX (GPIO_USART6_RX_1 | GPIO_SPEED_100MHz) /* PC7 */ #define GPIO_USART6_TX (GPIO_USART6_TX_1 | GPIO_SPEED_100MHz) /* PC6 */ #define GPIO_UART7_RX (GPIO_UART7_RX_4 | GPIO_SPEED_100MHz) /* PF6 */ #define GPIO_UART7_TX (GPIO_UART7_TX_3 | GPIO_SPEED_100MHz) /* PE8 */ #define GPIO_UART8_RX (GPIO_UART8_RX_1 | GPIO_SPEED_100MHz) /* PE0 */ #define GPIO_UART8_TX (GPIO_UART8_TX_1 | GPIO_SPEED_100MHz) /* PE1 */ #define GPIO_CAN1_RX (GPIO_CAN1_RX_3 | GPIO_SPEED_50MHz) /* PD0 */ #define GPIO_CAN1_TX (GPIO_CAN1_TX_3 | GPIO_SPEED_50MHz) /* PD1 */ #define GPIO_CAN2_RX (GPIO_CAN2_RX_1 | GPIO_SPEED_50MHz) /* PB12 */ #define GPIO_CAN2_TX (GPIO_CAN2_TX_1 | GPIO_SPEED_50MHz) /* PB13 */ #define GPIO_SPI1_MISO (GPIO_SPI1_MISO_3 | GPIO_SPEED_50MHz) /* PG9 */ #define GPIO_SPI1_MOSI (GPIO_SPI1_MOSI_2 | GPIO_SPEED_50MHz) /* PB5 */ #define GPIO_SPI2_MISO (GPIO_SPI2_MISO_3 | GPIO_SPEED_50MHz) /* PI2 */ #define GPIO_SPI2_MOSI (GPIO_SPI2_MOSI_4 | GPIO_SPEED_50MHz) /* PI3 */ #define GPIO_SPI3_MISO (GPIO_SPI3_MISO_2 | GPIO_SPEED_50MHz) /* PC11 */ #define GPIO_SPI3_MOSI (GPIO_SPI3_MOSI_3 | GPIO_SPEED_50MHz) /* PB2 */ #define GPIO_SPI5_MISO (GPIO_SPI5_MISO_2 | GPIO_SPEED_50MHz) /* PH7 */ #define GPIO_SPI5_MOSI (GPIO_SPI5_MOSI_1 | GPIO_SPEED_50MHz) /* PF11 */ #define GPIO_SPI6_MISO (GPIO_SPI6_MISO_2 | GPIO_SPEED_50MHz) /* PA6 */ #define GPIO_SPI6_MOSI (GPIO_SPI6_MOSI_1 | GPIO_SPEED_50MHz) /* PG14 */ #define GPIO_I2C1_SCL (GPIO_I2C1_SCL_2 | GPIO_SPEED_50MHz) /* PB8 */ #define GPIO_I2C1_SDA (GPIO_I2C1_SDA_2 | GPIO_SPEED_50MHz) /* PB9 */ #define GPIO_I2C2_SCL (GPIO_I2C2_SCL_2 | GPIO_SPEED_50MHz) /* PF1 */ #define GPIO_I2C2_SDA (GPIO_I2C2_SDA_2 | GPIO_SPEED_50MHz) /* PF0 */ #define GPIO_I2C3_SCL (GPIO_I2C3_SCL_1 | GPIO_SPEED_50MHz) /* PA8 */ #define GPIO_I2C3_SDA (GPIO_I2C3_SDA_2 | GPIO_SPEED_50MHz) /* PH8 */ #define GPIO_I2C4_SCL (GPIO_I2C4_SCL_2 | GPIO_SPEED_50MHz) /* PF14 */ #define GPIO_I2C4_SDA (GPIO_I2C4_SDA_2 | GPIO_SPEED_50MHz) /* PF15 */ #define GPIO_SDMMC2_CMD (GPIO_SDMMC2_CMD_1 | GPIO_SPEED_50MHz) /* PD7 */ #define GPIO_SDMMC2_D2 (GPIO_SDMMC2_D2_1 | GPIO_SPEED_50MHz) /* PG11 */ #define GPIO_ETH_RMII_TX_EN (GPIO_ETH_RMII_TX_EN_1 | GPIO_SPEED_100MHz) /* PB11 */ #define GPIO_ETH_RMII_TXD0 (GPIO_ETH_RMII_TXD0_2 | GPIO_SPEED_100MHz) /* PG13 */ #define GPIO_ETH_RMII_TXD1 (GPIO_ETH_RMII_TXD1_2 | GPIO_SPEED_100MHz) /* PG12 */ board.h defines that will need to be added: N.B. The legacy version of the pin defines did not have a suffix on all pins and therefore all pins could not be modified. All new pinmap’s pins have a suffix and the speed removed. If the pin had only one choice previously the pin name now contains a _0 suffix. Pin that had an explicit GPIO_SPEED_xxxMHz that were removed are listed below with the original speed. Pins that did not have an explicit GPIO_SPEED_xxxMHz specified are listed with the pin name containing the new suffix. #define GPIO_USART1_CK GPIO_USART1_CK_0 /* PA8 */ #define GPIO_USART1_CTS_NSS GPIO_USART1_CTS_NSS_0 /* PA11 */ #define GPIO_USART1_RTS GPIO_USART1_RTS_0 /* PA12 */ #define GPIO_UART5_CTS GPIO_UART5_CTS_0 /* PC9 */ #define GPIO_UART5_RTS GPIO_UART5_RTS_0 /* PC8 */ #define GPIO_UART8_CTS GPIO_UART8_CTS_0 /* PD14 */ #define GPIO_UART8_RTS GPIO_UART8_RTS_0 /* PD15 */ #define GPIO_I2C1_SMBA (GPIO_I2C1_SMBA_0 | GPIO_SPEED_50MHz) /* PB5 */ #define GPIO_SDMMC2_D0 (GPIO_SDMMC2_D0_0 | GPIO_SPEED_50MHz) /* PB14 */ #define GPIO_SDMMC2_D1 (GPIO_SDMMC2_D1_0 | GPIO_SPEED_50MHz) /* PB15 */ #define GPIO_SDMMC2_D3 (GPIO_SDMMC2_D3_0 | GPIO_SPEED_50MHz) /* PB4 */ #define GPIO_SDMMC2_D4 (GPIO_SDMMC2_D4_0 | GPIO_SPEED_50MHz) /* PB8 */ #define GPIO_SDMMC2_D5 (GPIO_SDMMC2_D5_0 | GPIO_SPEED_50MHz) /* PB9 */ #define GPIO_SDMMC2_D6 (GPIO_SDMMC2_D6_0 | GPIO_SPEED_50MHz) /* PC6 */ #define GPIO_SDMMC2_D7 (GPIO_SDMMC2_D7_0 | GPIO_SPEED_50MHz) /* PC7 */ #define GPIO_ETH_MDC (GPIO_ETH_MDC_0 | GPIO_SPEED_100MHz) /* PC1 */ #define GPIO_ETH_MDIO (GPIO_ETH_MDIO_0 | GPIO_SPEED_100MHz) /* PA2 */ #define GPIO_ETH_MII_RX_CLK (GPIO_ETH_MII_RX_CLK_0 | GPIO_SPEED_100MHz) /* PA1 */ #define GPIO_ETH_MII_RX_DV (GPIO_ETH_MII_RX_DV_0 | GPIO_SPEED_100MHz) /* PA7 */ #define GPIO_ETH_MII_RXD0 (GPIO_ETH_MII_RXD0_0 | GPIO_SPEED_100MHz) /* PC4 */ #define GPIO_ETH_MII_RXD1 (GPIO_ETH_MII_RXD1_0 | GPIO_SPEED_100MHz) /* PC5 */ #define GPIO_ETH_MII_TX_CLK (GPIO_ETH_MII_TX_CLK_0 | GPIO_SPEED_100MHz) /* PC3 */ #define GPIO_ETH_MII_TXD2 (GPIO_ETH_MII_TXD2_0 | GPIO_SPEED_100MHz) /* PC2 */ #define GPIO_ETH_RMII_CRS_DV (GPIO_ETH_RMII_CRS_DV_0 | GPIO_SPEED_100MHz) /* PA7 */ #define GPIO_ETH_RMII_REF_CLK (GPIO_ETH_RMII_REF_CLK_0 | GPIO_SPEED_100MHz) /* PA1 */ #define GPIO_ETH_RMII_RXD0 (GPIO_ETH_RMII_RXD0_0 | GPIO_SPEED_100MHz) /* PC4 */ #define GPIO_ETH_RMII_RXD1 (GPIO_ETH_RMII_RXD1_0 | GPIO_SPEED_100MHz) /* PC5 */ ``` ## Testing -- 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. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org