Topics

#stm32 pinmux.c compile failure STM32F407 #stm32


nanjunneo@...
 

Hello guys,

for the board STM32F407 I want to add pin PA8 25 MHz clk output to Etherent Phy. So that I add the following sentence (1)
 
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1)          into the pinmux.c.
 
The rest of code in pinmux.c I copied from stm32f4_dico, except I configure OTG_HS_DM / OTG_HS_DP as virtual port.
 
The compiling fails at the last step:  `HAL_GPIO_Init' is not defined.
[129/134] Linking C executable zephyr/zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf
.....
.....
/home/neo/ARM-GCC-Toolchain/gcc-arm-none-eabi-8-2019-q3-update-linux/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: modules/stm32/stm32cube/lib..__modules__hal__stm32__stm32cube.a(stm32f4xx_hal_rcc.c.obj): in function `HAL_RCC_MCOConfig':
/home/neo/zephyr_2_0_99/zephyrproject/modules/hal/stm32/stm32cube/stm32f4xx/drivers/src/stm32f4xx_hal_rcc.c:769: undefined reference to `HAL_GPIO_Init'
/home/neo/ARM-GCC-Toolchain/gcc-arm-none-eabi-8-2019-q3-update-linux/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /home/neo/zephyr_2_0_99/zephyrproject/modules/hal/stm32/stm32cube/stm32f4xx/drivers/src/stm32f4xx_hal_rcc.c:793: undefined reference to `HAL_GPIO_Init'
collect2: error: ld returned 1 exit status
 
The pinmux.c is attaced here. the compile is successful without adding the sentence(1).
 
Do you have any idea? or how can I check it further?
Thank you!
------------------------------------------------------pinmux.c in board file-----------------------------------------------------------------
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <drivers/pinmux.h>
#include <sys/sys_io.h>

#include "stm32f4xx.h"
#include <pinmux/stm32/pinmux_stm32.h>

/* pin assignments for STM32F4DISCOVERY board */
static const struct pin_config pinconf[] = {
 
#ifdef CONFIG_UART_1
{STM32_PIN_PB6, STM32F4_PINMUX_FUNC_PB6_USART1_TX},
{STM32_PIN_PB7, STM32F4_PINMUX_FUNC_PB7_USART1_RX},
#endif /* CONFIG_UART_1 */
 
#ifdef CONFIG_UART_2
{STM32_PIN_PA2, STM32F4_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32F4_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
 
#ifdef CONFIG_PWM_STM32_2
{STM32_PIN_PA0, STM32F4_PINMUX_FUNC_PA0_PWM2_CH1},
#endif /* CONFIG_PWM_STM32_2 */
 
#ifdef CONFIG_USB_DC_STM32
    { STM32_PIN_PB14, STM32F4_PINMUX_FUNC_PB14_OTG_HS_DM },
    { STM32_PIN_PB15, STM32F4_PINMUX_FUNC_PB15_OTG_HS_DP },
#endif  /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
{
ARG_UNUSED(port);

HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); ----------------------------------------------------------------------(1)

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

return 0;
}

SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

Best regards,
Neo


Erwan Gouriou
 

Hi Neo

I'd advise you to have a look to STM32 clock control driver.
It provides MCO support. It might not provide exactly the requested configuration, but at least it would be a working point that you can custom to your own need.

Erwan


On Fri, 8 Nov 2019 at 18:28, <nanjunneo@...> wrote:
Hello guys,

for the board STM32F407 I want to add pin PA8 25 MHz clk output to Etherent Phy. So that I add the following sentence (1)
 
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1)          into the pinmux.c.
 
The rest of code in pinmux.c I copied from stm32f4_dico, except I configure OTG_HS_DM / OTG_HS_DP as virtual port.
 
The compiling fails at the last step:  `HAL_GPIO_Init' is not defined.
[129/134] Linking C executable zephyr/zephyr_prebuilt.elf
FAILED: zephyr/zephyr_prebuilt.elf
.....
.....
/home/neo/ARM-GCC-Toolchain/gcc-arm-none-eabi-8-2019-q3-update-linux/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: modules/stm32/stm32cube/lib..__modules__hal__stm32__stm32cube.a(stm32f4xx_hal_rcc.c.obj): in function `HAL_RCC_MCOConfig':
/home/neo/zephyr_2_0_99/zephyrproject/modules/hal/stm32/stm32cube/stm32f4xx/drivers/src/stm32f4xx_hal_rcc.c:769: undefined reference to `HAL_GPIO_Init'
/home/neo/ARM-GCC-Toolchain/gcc-arm-none-eabi-8-2019-q3-update-linux/gcc-arm-none-eabi-8-2019-q3-update/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: /home/neo/zephyr_2_0_99/zephyrproject/modules/hal/stm32/stm32cube/stm32f4xx/drivers/src/stm32f4xx_hal_rcc.c:793: undefined reference to `HAL_GPIO_Init'
collect2: error: ld returned 1 exit status
 
The pinmux.c is attaced here. the compile is successful without adding the sentence(1).
 
Do you have any idea? or how can I check it further?
Thank you!
------------------------------------------------------pinmux.c in board file-----------------------------------------------------------------
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <drivers/pinmux.h>
#include <sys/sys_io.h>

#include "stm32f4xx.h"
#include <pinmux/stm32/pinmux_stm32.h>

/* pin assignments for STM32F4DISCOVERY board */
static const struct pin_config pinconf[] = {
 
#ifdef CONFIG_UART_1
{STM32_PIN_PB6, STM32F4_PINMUX_FUNC_PB6_USART1_TX},
{STM32_PIN_PB7, STM32F4_PINMUX_FUNC_PB7_USART1_RX},
#endif /* CONFIG_UART_1 */
 
#ifdef CONFIG_UART_2
{STM32_PIN_PA2, STM32F4_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32F4_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
 
#ifdef CONFIG_PWM_STM32_2
{STM32_PIN_PA0, STM32F4_PINMUX_FUNC_PA0_PWM2_CH1},
#endif /* CONFIG_PWM_STM32_2 */
 
#ifdef CONFIG_USB_DC_STM32
    { STM32_PIN_PB14, STM32F4_PINMUX_FUNC_PB14_OTG_HS_DM },
    { STM32_PIN_PB15, STM32F4_PINMUX_FUNC_PB15_OTG_HS_DP },
#endif  /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
{
ARG_UNUSED(port);

HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); ----------------------------------------------------------------------(1)

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

return 0;
}

SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

Best regards,
Neo