2

As I want to write an efficient program to use minimal RAM & Flash, I want to remove HAL library completely from my project & program only in registers.

I want to use cubeIDE for compiling & Debugging but I do not know how to remove HAL library from my project(It seems that HAL library created and attached to project by default when generating project).

Is there any practical way?

Best!

1 Answers1

2

There is an option in STM32CubeIDE project generation which allows you to create empty projects.

The empty project comes with the following:

  • main.c : Mostly empty
  • syscalls.c : I don't know what it is for but probably useless.
  • sysmem.c : Implements _sbrk() function, which is used by malloc() & new()
  • startup_stm32[xxxxxxxx].s : Startup file in assembly. You can leave it as it is
  • [xxxxxx]_FLASH.ld : Linker script file. Most of the time, this can be left unchanged.

But you need some additional libraries & files.

  • CMSIS Library : This includes some core functions common to all Cortex M devices. The core library is header only, and it's the only one you need to get started. There are some additional CMSIS libraries, like the DSP library which you may need depending on your project requirements. I suggest downloading it from its official repository.

  • Official STM32 headers from ST : This is actually called STM32Cube[xx] (STM32CubeF4 for example) and includes the Cube & HAL framework you want to get rid off. But we're interested in CMSIS compliant device headers. You can delete the rest. It also includes a version of CMSIS which lags behind the official one. Since you can download the latest CMSIS from its official repository, you don't need the one included in Cube package. You can download the relevant package from ST. For example, this one is for F4 series.

Once you have the needed packages, you need to configure STM32CubeIDE such that your project uses the newly obtained libraries. Basically, you need to add some additional include directories and symbol definitions. And there is an additional system_stm32[xxxxx].c file, which can be found in STM32Cube package and needs to be included in your project.

Here you can find a somewhat related answer.

Here is an example STM32CubeIDE blinky project I've created for the Blue Pill board (STM32F103C8). It may be somewhat outdated but it's probably still useful.

The method I've described probably isn't very practical. Some people suggest creating a normal Cube & HAL project and than pruning the unused parts.

Tagli
  • 2,412
  • 2
  • 11
  • 14