Can't find library for UART while compiling STM32 G0

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
Asensio12
Posts: 6
Joined: Thu Jan 13, 2022 3:33 pm

Can't find library for UART while compiling STM32 G0

Post by Asensio12 » Thu Feb 03, 2022 12:25 am

Hi,
I am working on porting the MicroPython to the STM32G0B1 Nucleo64 board (now that we finally have a 512 KB flash ROM).

After several days, I have gotten stuck in the UART/USART module

Code: Select all

...
CC uart.c
arm-none-eabi-gcc -I. -I../.. -Ibuild-NUCLEO_G0B1RE -I../../lib/cmsis/inc -I../../lib/stm32lib/CMSIS/STM32G0xx/Include/ -I../../lib/stm32lib/STM32G0xx_HAL_Driver/Inc -Iusbdev/core/inc -Iusbdev/class/inc -Ilwip_inc -Wall -Wpointer-arith -Werror -Wdouble-promotion -Wfloat-conversion -std=gnu99 -nostdlib -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -DMICROPY_VFS_FAT=1  -DSTM32G0B1xx -DUSE_FULL_LL_DRIVER -mthumb -msoft-float -mtune=cortex-m0plus -mcpu=cortex-m0plus -Os -DNDEBUG -Iboards/NUCLEO_G0B1RE -DSTM32_HAL_H='<stm32g0xx_hal.h>' -DMBOOT_VTOR=0x08000000 -DMICROPY_HW_VTOR=0x08000000 -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_FLOAT -fsingle-precision-constant -fdata-sections -ffunction-sections -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool -DMICROPY_MODULE_FROZEN_MPY -DMICROPY_MODULE_FROZEN_STR -DMICROPY_ROM_TEXT_COMPRESSION=1 -c -MD -o build-NUCLEO_G0B1RE/uart.o uart.c
uart.c: In function 'uart_get_baudrate':
uart.c:895:16: error: implicit declaration of function 'LL_LPUART_GetBaudRate' [-Werror=implicit-function-declaration]
  895 |         return LL_LPUART_GetBaudRate(self->uartx, uart_get_source_freq(self)
      |                ^~~~~~~~~~~~~~~~~~~~~
uart.c:902:12: error: implicit declaration of function 'LL_USART_GetBaudRate'; did you mean 'HAL_USART_GetState'? [-Werror=implicit-function-declaration]
  902 |     return LL_USART_GetBaudRate(self->uartx, uart_get_source_freq(self),
      |            ^~~~~~~~~~~~~~~~~~~~
      |            HAL_USART_GetState
uart.c:906:9: error: 'LL_USART_OVERSAMPLING_16' undeclared (first use in this function); did you mean 'UART_OVERSAMPLING_16'?
  906 |         LL_USART_OVERSAMPLING_16);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
      |         UART_OVERSAMPLING_16
...
I have reviewed everything I can think of and both function and the constant are present in the HAL driver for STM32 G0 (at stm32g0xx_ll_usart.h).
I'm not sure I understand how these libraries are normally imported nor why it is failing for STM32 G0.

How can I get help?

Asensio12
Posts: 6
Joined: Thu Jan 13, 2022 3:33 pm

Re: Can't find library for UART while compiling STM32 G0

Post by Asensio12 » Fri Feb 04, 2022 3:36 am

I found the issue.
I was copying the stm32g0xx_hal_conf_base.h too closely from the template provided by ST.

The LL UART headers are normally imported through stm32##_hal_conf_base.h.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Can't find library for UART while compiling STM32 G0

Post by dhylands » Fri Feb 04, 2022 6:19 pm

Your board directory should have an stm32g0xx_hal_conf.h file with a line like this one:
https://github.com/micropython/micropyt ... _conf.h#L8

Then there should be an stm32g0xx_hal_conf_base.h (which you'll need to create because it doesn't exist yet) which has the #include of the ll_lpuart file.

Here's the G4 one:
https://github.com/micropython/micropyt ... base.h#L72

Post Reply