Skip to main content
TDao.19
Associate II
March 10, 2021
Solved

What's the best way to port CMSIS UART from F0 to G0

  • March 10, 2021
  • 8 replies
  • 4268 views

An existing project runs on STM32F091, it use CMSIS USART driver (ARM_DRIVER_USART Driver_USART1). Now I need to migrate this project to run on STM32G070. But in CubeMX for STM32G070, there aren't any USART driver under CMSIS driver, except a header file for customary implementation. So what is the best way to migrate UART functionality? Do I need to implement a similar CMSIS USART driver for G0 series? (CMSIS should be easier for migration, now it seems to cause more trouble.)

This topic has been closed for replies.
Best answer by Piranha

The HAL is broken and almost useless because of flawed API design. Sadly CMSIS drivers are also based on HAL. They are kind of more stable, because they are stuffed full with workarounds for the broken HAL, but I doubt the HAL "lock" and other race conditions are fixed. And even if it is, the API is still the dumb receive-stop-receive design. Therefore continuous stream reception is not possible.

Just make your own sane implementation. One can base it on or at least get inspired by this:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

It even has an example for G0.

8 replies

waclawek.jan
Super User
March 10, 2021

> CMSIS USART driver (ARM_DRIVER_USART Driver_USART1)

Where do you have it from?

JW

TDao.19
TDao.19Author
Associate II
March 11, 2021

Right, I enabled the driver in "manage run time environment" in keil, not CubeMX.

So, it was keil who implement the CMSIS USART driver for ST MCUs... Oh.. I feel like ordering a McChicken in KFC

Tesla DeLorean
Guru
March 11, 2021

w/Nacho Fries?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
March 11, 2021

> Oh.. I feel like ordering a McChicken in KFC

:D

Please select your post as Best so that the thread is marked as Solved.

JW

Andrew Neil
Super User
March 12, 2021
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
TDao.19
TDao.19Author
Associate II
March 15, 2021

This problem is still not solved. I learned that it is not ST who implements CMSIS UART driver, but it doesn't mean the problem is solved.

It would be solved if someone help point out 1) here's the CMSIS UART driver for STM32G0 series. or 2) The driver is not available, the best way is ....

waclawek.jan
Super User
March 15, 2021

Apparently, 2.

There's no best way. Options may include:

- rewrite the program from scratch to avoid using said driver

- port the driver yourself

- find somebody who will port it for you

- try to contact Keil directly and ask this question there

- try to contact ST directly (maybe through web support form) and ask this question there.

JW

TDao.19
TDao.19Author
Associate II
March 17, 2021

Thank you for laying out the options.

Isn't the forum the best chance of getting answers? In my pass experience, contact technical support is often not helpful, they often suggest to ask on the forum and say they have engineers monitor forum and answer tough questions. Anyway I will try my luck with technical support first.

Andrew Neil
Super User
March 16, 2021

Don't ST provide a suitable driver or HAL or ... ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
TDao.19
TDao.19Author
Associate II
March 17, 2021

Yeah, but I used CMSIS driver, not HAL driver. And I try to avoid falling into the rabbit hole of porting UART driver: reliability issue, debugging, and all that.

waclawek.jan
Super User
March 16, 2021

Okay so add:

- use a suitable driver or HAL or ... provided by ST

although IMHO it falls under the more general "rewrite the program from scratch".

JW

Piranha
PiranhaBest answer
Principal III
March 16, 2021

The HAL is broken and almost useless because of flawed API design. Sadly CMSIS drivers are also based on HAL. They are kind of more stable, because they are stuffed full with workarounds for the broken HAL, but I doubt the HAL "lock" and other race conditions are fixed. And even if it is, the API is still the dumb receive-stop-receive design. Therefore continuous stream reception is not possible.

Just make your own sane implementation. One can base it on or at least get inspired by this:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

It even has an example for G0.

TDao.19
TDao.19Author
Associate II
March 26, 2021

Contacted ST support, here's the response:

We recommend for you to use the HAL APIs included in our STM32Cube libraries to take benefit from the easy migration of firmware from one STM32 family to another. Although CMSIS is part of the STM32Cube library, the APIs used is for Core related operations with some of these functions have HAL macros implemented in STM32Cube library.

STM32Cube libraries have the same architecture and follow the same API naming conventions that use can easily port to other STM32 devices. The library also includes ready to run sample codes for user to use as reference. USART sample codes is of course include as well as preconfigured Keil projects.

We suggest you to start with the available sample codes and build from there.

Please download the related libraries in www.st.com/stm32cube. Look for STM32CubeF0 and STM32CubeG0.

Training and tutorial materials are in www.st.com/stm32education.