Menu

#108 SPL instead of HAL

Version 1.x
closed
None
5
2015-03-21
2015-01-28
Lukasz
No

Hi there,
I was wondering is there a simple way of replacing the HAL library added to the created stm32 project example with the standard peripheral library? Most of the example I can find in the internet are using SPL. Would then startup routines colapse?

Discussion

1 2 > >> (Page 1 of 2)
  • Liviu Ionescu (ilg)

    as mid/long term, HAL is the future.

    I know that now there are a lot of examples for SPL, but they'll slowly be migrated to HAL.

    in the future GNU ARM Eclipse versions, when components will be used to create projects, I see no problem to add a SPL component, but for now you need to manually edit the projects.

     
  • Lukasz

    Lukasz - 2015-01-28

    I am trying to install spl into the project instead of hall, but I have loads of symbols that cannot be resolved. I am using STM32F4Discovery board. I have downloaded the spl library from here http://www.st.com/web/en/catalog/tools/PF257901 . Do you know maybe either I am forgetting about something?

    Ps: Wherever I go people have different opinions, when I tried to get help on HAL they said on ST forums that noone is using that there and there are only SPL examples :/

     
  • Liviu Ionescu (ilg)

    the only place where empty projects generated by the plug-in use HAL is in the inits, you have to comment out the inits, change the include paths and it should work.

     
  • Liviu Ionescu (ilg)

    btw, if you plan to start a new project, I strongly suggest to go for HAL.

     
  • Lukasz

    Lukasz - 2015-01-28

    Im confused, because half of the people say to use hal and the other says not to do that. My problem is that im new to STM32 and most of the examples in the internet are using SPL.

     
  • Lukasz

    Lukasz - 2015-01-28

    Are there maybe any older versions of gnu arm eclipse plugin that created example projects basing on SPL? I am not abble to echange the HAL for SPL in the project- it doesnt want to compile, its reffering to defines that shouldnt be take under consideration when stm32f407 mcu is used and defined.

     
  • Liviu Ionescu (ilg)

    im new to STM32 and most of the examples in the internet are using SPL.

    if you feel more comfortable with SPL, than use SPL.

    just be aware that on long term HAL might have more support from ST and at a certain point you'll have to migrate your apps from SPL to HAL.

     
  • Lukasz

    Lukasz - 2015-01-28

    All books about STM32 that are available to me and the examples in the internet are in SPL, I am not abble to move in HAL. Later on I dont mind changing to HAL, but for now I just need to configure a project in SPL, which I cant because of the problems I described.

     
  • Liviu Ionescu (ilg)

    older versions of gnu arm eclipse plugin that created example projects basing on SPL

    I don't think so, and even if they are, I doubt they are still functional.

    but I guess the F1 template is still using SPL, you can create a project with it and take a look at the settings.

    I am not abble to echange the HAL for SPL

    you probably need some more time to get used to Eclipse settings. SPL is just a kind of library, the system init calls only a very limited number of functions (SysInit and some clock function).

     
  • Lukasz

    Lukasz - 2015-01-28

    I am trying to- but there is something I dont get about the SPL. I Cannot compile the code, because it claims that there are unknown symbols, ie:

    Description Resource Path Location Type
    'FMC_Bank1' undeclared (first use in this function) stm32f4xx_fmc.c /MotorCtrl_SPL/system/src/STM32F4xx_SPL line 144 C/C++ Problem

    But theres no symbol because this would be declared only if I had other type of STM32 MCU, its not available in STM32F407VG. Why is it trying to compile it?

     
  • Lukasz

    Lukasz - 2015-01-28

    I found out that the problem is that compiller doesnt see that I have declared the STM32F40_41xxx symbol, and the definitions are in preprocessor ifdef:

    if defined (STM32F40_41xxx)

    define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE)

    define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE)

    define FSMC_Bank2 ((FSMC_Bank2_TypeDef *) FSMC_Bank2_R_BASE)

    define FSMC_Bank3 ((FSMC_Bank3_TypeDef *) FSMC_Bank3_R_BASE)

    define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE)

    endif / STM32F40_41xxx /

    I have declared the symbol both in code and in eclipse prefference. Do you know maybe what could be the case?

     

    Last edit: Lukasz 2015-01-28
  • Lukasz

    Lukasz - 2015-01-28

    I have attached my project, could you please only take a look and tell me either you are abble to compile it?

     
  • Liviu Ionescu (ilg)

    if your processor is 407, why do you also define another symbol? remove it from all languages and all configurations. also remove the HAL symbol.

    exclude the peripherals you do not use from the build, since some (like fmc) are not supported by 407.

    I don't know how you generated the original project, but it looks like it does not apply to 407.

    I suggest you recreate a new 407 project, with the correct settings, then replace the HAL with SPL and update the symbols and include reference.

     

    Last edit: Liviu Ionescu (ilg) 2015-01-29
  • Lukasz

    Lukasz - 2015-01-29

    I recreated the project from scratch, but its the same. I cant remove the files that compiller says there are no refferences to, because there are, and it doesnt see it, for example:

    Description Resource    Path    Location    Type
    'FMC_Bank1' undeclared (first use in this function) stm32f4xx_fmc.c /MotorControlSPL/system/src/spl line 144    C/C++ Problem
    

    declaration in stm32f4xx.h:

    #if defined (STM32F427_437xx) || defined (STM32F429_439xx)
    /*!< FMC Bankx registers base address */
    #define FMC_Bank1_R_BASE      (FMC_R_BASE + 0x0000)
    #define FMC_Bank1E_R_BASE     (FMC_R_BASE + 0x0104)
    #define FMC_Bank2_R_BASE      (FMC_R_BASE + 0x0060)
    #define FMC_Bank3_R_BASE      (FMC_R_BASE + 0x0080)
    #define FMC_Bank4_R_BASE      (FMC_R_BASE + 0x00A0)
    #define FMC_Bank5_6_R_BASE    (FMC_R_BASE + 0x0140)
    #endif /* STM32F427_437xx ||  STM32F429_439xx */
    

    I didnt have any new mcus defined, spl requires STM32F427_437xx symbol for stm32f407vg and USE_STDPERIPH_DRIVER for enabling spl, I dont have any other. Also removed the HAL symbol.
    Its like compiller doesnt care about the #if defined statement...

    Configuration was for the right mcu:
    project

    I have attached the new project.

     
  • Liviu Ionescu (ilg)

    the 407 family does not have a FMC, do not attempt to compile the fmc.c file with these settings, because it'll fail. exclude fmc.c from build (right click, Resource Configuration -> Exclude from build).

    then in initialize_hardware.c

    • remove the references to stm32f4xx_hal.h and hal_cortexm.h
    • remove the configure_system_clock() function
    • in __initialize_hardware(void) remove the references to HAL_init... and configure_system_clock
     
  • Lukasz

    Lukasz - 2015-01-29

    I cannot find the exclude from build option, searched pretty much everywhere in the project options.

     
  • Liviu Ionescu (ilg)

    right click on file

     
  • Lukasz

    Lukasz - 2015-01-29

    It works now, thank you a lot.

     
  • Liviu Ionescu (ilg)

    please be aware that having both symbols (STM32F407xx and STM32F40_41xx) defined at the same time might have side effects on other sources.

    future CMSIS headers will probably follow the new HAL requirements, while STL will most probably not be updated and will use the old definitions, so you're stuck with two definitions, which will require extra care.

     
  • Lukasz

    Lukasz - 2015-01-29

    Yesterday I was trying to figure out a way to work this HAL out. I downloaded STM32CUbe for F4. It seems that one can by using graphical interface generate HAL based C code. If that will work out ill go for HAL- Basing on what you are saying, my SPL code would be obsolete soon.

     
  • Liviu Ionescu (ilg)

    STM32CUbe for F4 ... generate HAL based C code.

    I have no experience with Cube, but be aware that programs generated by these tools might have simplistic startups, poor library support and you need to take them 'as-is' otherwise you'll run into other problems.

    my SPL code would be obsolete soon.

    that's obvious.

     
  • Lukasz

    Lukasz - 2015-01-29

    Well in that case, do you know maybe any good refference for HAL in STM32? The documentation for the lib is very poor and there are no full examples of the code.

     
  • Liviu Ionescu (ilg)

    nope.

    the best reference to HAL are the source files themselves.

     
  • Lukasz

    Lukasz - 2015-01-29

    Okay, thanks for help.

     
  • Lukasz

    Lukasz - 2015-02-04

    Hey again,
    I have this problem now that I will have to maintain 2 projects- one for STM32F103RB and one for STM32F407VB. The first one is generated using SPL in the plugin and the second one in HAL. Now I dont know anymore either to use SPL or HAL... But could you please tell me either there are any plans for adding HAL for STM32F1xx projects or a smooth way of choosing SPL or HAL for all?

     
1 2 > >> (Page 1 of 2)