2019-09-09 04:13 AM
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
2019-09-11 01:33 AM
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?
2019-09-11 01:59 AM
> 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.
2019-09-11 10:40 AM
This depends on how you instructed the Cube ("IOC UI") to treat the library files: copy into our project directory or link to the "repository".
As After Forever wrote, try to enable or tweak flash related things in the "IOC UI" to convince it to copy or link the stmxxx_hal_flash.c.
Selection of HAL or LL for specific module is also in the "IOC UI", in advanced settings.
To use LL files, define USE_FULL_LL_DRIVER in the Eclipse project settings.
You can copy the library .c files to your project manually and refresh (F5) or add a "linked resource".
The include directory is same for HAL and LL drivers, it should be already set in your project,
-- pa
2019-09-12 07:31 AM
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.
2019-09-12 07:36 AM
> 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" (:
2019-09-12 08:06 AM
2024-01-28 07:20 AM
Hi, as you mentioned solution from @After Forever works :thumbs_up:, when in i set ENABLED on NVIC tab it adds the HAL files. Then I also disable the "Generate Enable in Init". This way it has practically no other effect that including the files.
I would advise not to copy the files your self because that would not get updated along the firmware package. There can be compatibility problems as result.
Hal drivers are great for initial inspiration, but do implement everything with LL API. So once I change all HAL to LL the flash files were removed by the code generator which is not obvious. I would prefer if there was an explicit checkbox in mx designer for that rather than this workaround. :slightly_frowning_face: