Skip to main content
BenMack99
Associate III
September 9, 2019
Question

STM32CubeIDE - How To Include Flash Library Code?

  • September 9, 2019
  • 3 replies
  • 5331 views

Hi

Forgive me for being dumb, but how do I include ST flash library code (functions to configure and program flash) in an STM32CubeIDE project?

I expected to find it in the ioc device configuration tool, along with system core drivers (DMA/GPIO/IWDG etc.) but cannot find it. Also not in the drivers folder.

In AC6 I simply included stm32f0xx_flash.h from the StdPeriph_Driver folder, and in CoIDE from the stm32_lib folder.

To get started I have copied across stm32f0xx_flash.c/h from an old AC6 project to my project src/inc folders, but I'm guessing there is a proper way?

This is for an STM32F030F4 target device.

Many thanks

This topic has been closed for replies.

3 replies

BenMack99
BenMack99Author
Associate III
September 11, 2019

I've added more topics, in the hope someone from the wider community can help.

We've also noticed there is a flash HAL driver file, but cannot find how to include it using the IOC UI (and anyway we prefer LL drivers for devices with little flash)

Any thoughts?

After Forever
Senior III
September 11, 2019

> In AC6 I simply included stm32f0xx_flash.h from the StdPeriph_Driver folder, and in CoIDE from the stm32_lib folder.

StdPeriph is deprecated, STM32CubeIDE's code generator doesn't support it, you have to use either the default HAL driver (stm32f0xx_hal_flash.c) or CMSIS level code (unfortunately the LL driver currently lacks flash support).

If stm32f0xx_hal_flash.c isn't included in your generated project's code tree then try to enable the "Flash global interrupt" in the NVIC settings, it might force Cube to include the flash module, but I don't have that problem in the latest version of CubeMX.

BenMack99
BenMack99Author
Associate III
September 12, 2019

Thanks both, much appreciated.

I think there was something screwy with my project - I tried starting with a new project, and it included the stm32f0xx_hal_flash.c/h files automatically, no need to nudge it with NVIC flash settings.

Pavel I use "copy into our project directory", and it put them in /Drivers/STM32F0xx_HAL_Driver/

AfterForever thanks for confirming the LL drivers don't exist. Shame, but the HAL driver doesn't look too bloated (I have had trouble with other HAL stuff so tend to avoid it). When you say "CMSIS level code" do you just mean I write my own drivers similar to the HAL ones, setting register flags directly etc?

So my problem is solved, and I'll stick with the HAL drivers for now. Many thanks

Pavel good tip re USE_FULL_LL_DRIVER, will have a go with that.

After Forever
Senior III
September 12, 2019

> When you say "CMSIS level code" do you just mean I write my own drivers similar to the HAL ones, setting register flags directly etc?

Yes (if you wanted to avoid HAL), otherwise it's OK to use HAL's module - as you said it "doesn't look too bloated" (:

BenMack99
BenMack99Author
Associate III
September 12, 2019
Got it, thanks