cancel
Showing results for 
Search instead for 
Did you mean: 

Use ST's HAL, or write own libraries?

liqingxin0092
Visitor

I am a novice, would like to ask if anyone will write a set of library files only for a single model of microcontroller because of the bloated official library files, is this common? For example, I was looking at the stm32h7 series recently, and the idea came to me because the layers of hal library nesting were very annoying.

1 ACCEPTED SOLUTION

Accepted Solutions
Javier1
Principal

>>would like to ask if anyone will write a set of library files only for a single model of microcontroller
Is that a job proposal? because it looks like a lot of work to me.

HAL is fine if youre a novice, annoyed is the natural state of mind 
check https://mongoose.ws/documentation/tutorials/stm32/all-make-freertos-builtin/ if youre not happy, lot of those RTOS have their own tailored "HAL"

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero

View solution in original post

8 REPLIES 8
Javier1
Principal

>>would like to ask if anyone will write a set of library files only for a single model of microcontroller
Is that a job proposal? because it looks like a lot of work to me.

HAL is fine if youre a novice, annoyed is the natural state of mind 
check https://mongoose.ws/documentation/tutorials/stm32/all-make-freertos-builtin/ if youre not happy, lot of those RTOS have their own tailored "HAL"

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero

Just to see if anyone would do this, people around me often say the hal library is bloated, but they all seem to be using it.

I use them, carefully.

ST HAL came a long way quality wise , a lot of people still have PTSD from the old days.

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero

Welcome to the forum.

Please review the posting guidelines: How to write your question to maximize your chances to find a solution

I've edited your title to better indicate what the thread is asking - "Novice question" isn't very informative!

 


@liqingxin0092 wrote:

I am a novice, would like to ask if anyone will write a set of library files only for a single model of microcontroller because of the bloated official library files, is this common? 


The pragmatic approach is to start by using HAL.

If that meets your needs (in terms of code size, performance, etc) - then you win.

If it doesn't meet your needs - then is the time to optimise whatever parts of it cause you difficulties.

As the famous saying goes,

Premature optimisation is a root of all kinds of evils.

 

I got it

I beg to differ, Andrew. That saying is just a saying, there's no more truth in it just because it sounds good.

Here's my view:

You may go the path of clicking in the code in any configurator, again provided as convenience/lock by mcu manufacturers, and then trying to build upon that. You may use various "peripheral libraries" and "hardware abstraction layers" out there. And you may also use frameworks such as Arduino, which isolates you from the "nasty details of hardware".

All these methods provide a relatively easy and painless way to accomplish certain groups of tasks. However, they inevitably implement only a limited fraction of the mcu capabilities and cater for a given group of applications, covering whatever their creators deemed to be the "usual cases". As soon as anything out-of-ordinary is to be achieved, these tools tend to become more of an obstacle than help, and usually time/effort for learning the "nasty details" spared at the start are spent usually in a more painful way, to learn not only the underlying details, but also to learn the various couplings between those details and the libraries/frameworks used.

In other words, once you start with Cube/HAL, you probably won't be able to get rid of it, ever; and unless you stick to the "usual" applications for which Cube/HAL caters, you'll regret that decision one day. Hereby, you've been warned.

One thing is true, though: ST refuses to provide normal register-based examples, which makes this path initially unnecessarily harder.

OTOH, I don't see any merit in writing a concurrent "library", if you are a normal user. Just use whatever you need, and then later recycle what you've already written, as appropriate.

JW

 


@waclawek.jan wrote:

I beg to differ, Andrew.


Indeed, we differ.

 


@waclawek.jan wrote:

OTOH, I don't see any merit in writing a concurrent "library", if you are a normal user. Just use whatever you need, and then later recycle what you've already written, as appropriate.


Absolutely agree on that!

Writing your own library requires that you define what will be your "usual cases" - a novice is unlikely to be well-equipped or sufficiently experienced to do this.

 

PS:


@waclawek.jan wrote:

ST refuses to provide normal register-based examples, which makes this path initially unnecessarily harder.


There are register-based examples and "code snippets" still to be found for some older families, like F0, F4 ...

Is LL available for H7 ?

It tends to be less "layered" ...