Error building port for STM32WB55

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
r.finkers
Posts: 8
Joined: Wed Dec 18, 2019 8:00 am

Error building port for STM32WB55

Post by r.finkers » Tue Sep 15, 2020 12:03 pm

Hello,

I'm getting errors when building for STM32WB55VGQ6.

The errors i get:

Code: Select all

CC led.c
In file included from ../../lib/stm32lib/STM32WBxx_HAL_Driver/Inc/stm32wbxx_hal_def.h:31:0,
                 from ../../lib/stm32lib/STM32WBxx_HAL_Driver/Inc/stm32wbxx_hal_dma.h:29,
                 from ./boards/stm32wbxx_hal_conf_base.h:30,
                 from boards/AEPYM/stm32wbxx_hal_conf.h:17,
                 from ../../lib/stm32lib/STM32WBxx_HAL_Driver/Inc/stm32wbxx_hal.h:30,
                 from ./mpconfigboard_common.h:30,
                 from ./mpconfigport.h:32,
                 from ../../py/mpconfig.h:62,
                 from ../../py/mpstate.h:31,
                 from ../../py/runtime.h:29,
                 from led.c:29:
led.c: In function 'led_pwm_init':
../../lib/stm32lib/STM32WBxx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h:2665:27: error: implicit declaration of function '__HAL_RCC_TIM3_CLK_ENABLE' [-Werror=implicit-function-declaration]
 #define __TIM3_CLK_ENABLE __HAL_RCC_TIM3_CLK_ENABLE
                           ^
led.c:145:13: note: in expansion of macro '__TIM3_CLK_ENABLE'
             __TIM3_CLK_ENABLE();
             ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
The microcontroller has no TIM3 so I don't understand why it is trying to import it.
When I remove the PWM from the LEDs in mpconfigboard.h the build is succesfull.
Maybe I'm declaring it wrong in the mpconfig?
This is the LED part of my mpconfigboard.h:

Code: Select all

// LEDs
#define MICROPY_HW_LED1             (pin_A1) // red TIM2_CH2
#define MICROPY_HW_LED2             (pin_A15) // green TIM2_CH1
#define MICROPY_HW_LED3             (pin_B11) // blue TIM2_CH4
#define MICROPY_HW_LED1_PWM         { TIM2, 2, TIM_CHANNEL_2, GPIO_AF1_TIM2 }
#define MICROPY_HW_LED2_PWM         { TIM2, 2, TIM_CHANNEL_1, GPIO_AF2_TIM2 }
#define MICROPY_HW_LED3_PWM         { TIM2, 2, TIM_CHANNEL_4, GPIO_AF1_TIM2 }
#define MICROPY_HW_LED_ON(pin)      (mp_hal_pin_high(pin))
#define MICROPY_HW_LED_OFF(pin)     (mp_hal_pin_low(pin))
does anyone know a solution?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Error building port for STM32WB55

Post by jimmo » Tue Sep 15, 2020 1:09 pm

r.finkers wrote:
Tue Sep 15, 2020 12:03 pm
This is the LED part of my mpconfigboard.h:
Can you share more information about your build -- is the AEPYM board definition public? How does it differ from the NUCLEO_WB55 or USBDONGLE_WB55 definitions in the main repo.

Are you able to build BOARD=NUCLEO_WB55 ?

r.finkers
Posts: 8
Joined: Wed Dec 18, 2019 8:00 am

Re: Error building port for STM32WB55

Post by r.finkers » Wed Sep 16, 2020 6:13 am

The board is custom made. There is a RGB led connected to Timer 2 CH1,2 and 4.
A non PWM build does succeed.

I've already tried to build the NUCLEO_WB55 and the USBDONGLE_WB55 and they succeed, but they don't have PWM leds.

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

Re: Error building port for STM32WB55

Post by mattyt » Wed Sep 16, 2020 6:25 am

Quick check: Have you set:

Code: Select all

MCU_SERIES = wb
CMSIS_MCU = STM32WB55xx
in mpconfigboard.mk? Those will determine how parts of the STM32 HAL will be configured, including the number of timers etc...

r.finkers
Posts: 8
Joined: Wed Dec 18, 2019 8:00 am

Re: Error building port for STM32WB55

Post by r.finkers » Wed Sep 16, 2020 6:45 am

Yes I have.

My mpconfigboard.mk:

Code: Select all

MCU_SERIES = wb
CMSIS_MCU = STM32WB55xx
AF_FILE = boards/stm32wb55_af.csv
LD_FILES = boards/stm32wb55xg.ld boards/common_basic.ld
STARTUP_FILE = lib/stm32lib/CMSIS/STM32WBxx/Source/Templates/gcc/startup_stm32wb55xx_cm4.o

# MicroPython settings
MICROPY_PY_BLUETOOTH = 1
MICROPY_BLUETOOTH_NIMBLE = 1
MICROPY_VFS_LFS2 = 1
And my stm32wbxx_hal_conf.h:

Code: Select all

/* This file is part of the MicroPython project, http://micropython.org/
 * The MIT License (MIT)
 * Copyright (c) 2019 Damien P. George
 */
#ifndef MICROPY_INCLUDED_STM32WBXX_HAL_CONF_H
#define MICROPY_INCLUDED_STM32WBXX_HAL_CONF_H

// Oscillator values in Hz
#define HSE_VALUE (32000000)
#define LSE_VALUE (32768)
#define EXTERNAL_SAI1_CLOCK_VALUE (48000)

// Oscillator timeouts in ms
#define HSE_STARTUP_TIMEOUT (100)
#define LSE_STARTUP_TIMEOUT (5000)

#include "boards/stm32wbxx_hal_conf_base.h"

#endif // MICROPY_INCLUDED_STM32WBXX_HAL_CONF_H

r.finkers
Posts: 8
Joined: Wed Dec 18, 2019 8:00 am

Re: Error building port for STM32WB55

Post by r.finkers » Wed Sep 16, 2020 8:21 am

I've added a if defined in the micropython/ports/stm32/led.c file. That was the solution for me. Now it builds successful. :D

Code: Select all

        case 2:
            __TIM2_CLK_ENABLE();
            break;
        #if defined(TIM3)
        case 3:
            __TIM3_CLK_ENABLE();
            break;
       #endif
        default:
            assert(0);

Post Reply