2024-04-22 04:30 AM
Hello everyone,
I am currently taking my first steps with the STM32VScode extension. Previously I worked exclusively with the STM32cubeIDE.
I created a Cmake project via STM32cubeMX, which I then imported via the STM32 VScode extension. Everything worked fine. The build process afterwards was successful and I was able to run the program on my Nucleo-C31C6 board.
Now I want to access the flash memory. But as soon as I insert the function HAL_FLASH_Unlock() into my code, the following error occurs during the build process: main.c:109: undefined reference to `HAL_FLASH_Unlock'.
How do I have to include the HAL drivers correctly so that I can use the function?
maxl95
2024-04-22 04:43 AM
So do you have a definition for HAL_FLASH_Unlock anywhere in your project?
@maxl95 wrote:How do I have to include the HAL drivers correctly so that I can use the function?
As with any C code:
2024-04-22 05:01 AM
Hi Andrew, thanks for your quick replay,
I have also successfully used other functions (e.g. LL_USART) where the problem did not occur.
2024-04-22 05:50 AM
@maxl95 wrote:
- The source file is in the defaul directory --> ./Drivers/STM32C0xx_HAL_Driver/Src
And is that file actually getting built?
2024-04-22 06:27 AM
I can't find the source file in the output of cmake, so I think not
2024-04-25 01:41 AM
Hello @maxl95
Actually Flash drivers are by default integrated to your project
If you are adding HAL_FLASH_Unlock() to a custom file you can include main.h or stm32c0xx_hal_conf.h to get flash functions available in your custom file