cancel
Showing results for 
Search instead for 
Did you mean: 

configuration vs. standarisation

Johanan1
Associate II
Posted on October 28, 2014 at 21:16

While the STM32F4 is a real beast, it is very clear that ST people put a lot of effort in the HAL library an the CubeMX software.

Unfortunately, it seems to me that this huge effort has not produce the expected result, I have not been able to use any of CubMX code ''out of the box'', and the initialization is rather complex, it took me a lot of time to get things to work (one option is that I am not talented enough. could be...)

While I am aware of the almost infinite options that the chip has, it is clear the the majority of users will use it in a rather ''standard'' way, and peripherals like UART, GPIO, ADC etc. are used in very similar ways, maybe in DMA or non-DMA mode.

So, playing a bit with an Arduino , just to learn why it has become so popular, one can not avoid wondering. To use a SD card in the Arduino ''ecosystem'' you start by

SD.begin();

 if this is successful the next thing you do is

file = SD.open(''index.html'');

Now, how much code should one write to get the STM32F4  to do the same thing?

I wonder why ST is not using the C++ options, which are available in all ARM IDEs and write a really easy to use library. (looking at the Arduino library can be a good start).

4 REPLIES 4
chen
Associate II
Posted on October 29, 2014 at 12:10

''I wonder why ST is not using the C++ options, which are available in all ARM IDEs and write a really easy to use library. (looking at the Arduino library can be a good start).''

Statements like that justify :

''one option is that I am not talented enough''

My opinion is that the Embedded software industry does not consider C++ as a good language to use because it uses too much code space (FLASH) and RAM.

Having work in both, yes C++ can generate more code and use more RAM than if written in C but in my opinion the clear separation between code and design make C++ much better to work with and in the long run will result in better maintained code (ie the temptation with C is to do code fixes rather than look at design issues when doing fixes).

Many people do not understand the HAL. HAL = Hardware Abstraction Layer.

The HAL API should try to obscure as much of the hardware implementation as possible but my experience is that is does not, so end up polluting the Application with knowledge of the underlying hardware.

''looking at the Arduino library can be a good start''

Hardly, Arduino being 8 bit have to do compromises that screw up all the good work of a structured design in my opinion!

What they do is make starting out in embedded easier for beginners.

''Now, how much code should one write to get the STM32F4  to do the same thing?''

Actually, the same. What you have not reaalised is the amount of code an Arduino shield and the driver provides!

Johanan1
Associate II
Posted on October 29, 2014 at 22:36

Well,  using C++ to the full is very memory hungry. I don't think this is the right place to open a discussion on the code generation of C++, and also the way it initiate class etc. 

Whoever, it can be useful to use the C++ abstractions and can be done with out making the code as big. (BTW Arduino does it for 8 bit chips with rather small flash..)

The STM32F4 has up to 2Mb flash, why not use it?

My opinion so far on the HAL library is not very good, the documentation is terse, and I spent a lot of time getting things to work, ( 7'' LCD 800x480, FMC to control SDRAM and external NOR flash , SPI, ADC, RTC, and now I am struggling with USB host and FatFS, next I will deal with SD card, and UARTs, which I hope will be simple) all this before I start writing my real application code. None of the above worked the first time, and took a lot of work, including digging in the chip data sheet and reference manual. My point is that the HAL library has to hide all these details, I am afraid it does not, even if it is called  Hardware Abstraction Layer...

And BTW, this library calls a lot of code when all you need is just something like

XXXX -> yy  =  zz;

All in the name of cross chip-platform compatibility.

chen
Associate II
Posted on October 30, 2014 at 10:56

I do not think comparing Arduino development to STM32 that you are comparing like for like.

''all this before I start writing my real application code.''

For Ardunio, you probably either started with the base board which already has mature device drivers written for it OR

a 'shield' which also has the device driver written for it.

With the STM32, the Cube tool which generates the drivers, is still in development. The old (now unsupported) Peripheral Libraries (which are the device drivers) were more mature and pretty much did work out of the box BUT did not provide any HAL abstraction at all.

''My opinion so far on the HAL library is not very good, the documentation is terse, and I spent a lot of time getting things to work''

Agreed, the cube generated HAL is still in development. The cube tool has to support multiple STM32 devices and families and hence can get confused and generated incompatible code. Still has lots of bugs.

You are complaining about the lack of working device drivers : well when it comes to the STM32Cube tool - you have my sympathies.

However, you do have the choice to use the old Peripheral libraries.

You would not complain about Arduino development if you built your own shield and had to write the driver for the shield yourself because that is what you are comparing : the time it takes to get device drivers working.

''My point is that the HAL library has to hide all these details, I am afraid it does not, even if it is called  Hardware Abstraction Layer...''

Agreed, the ST implementation of the HAL does not really hide the detail. They actively do not want to abstract the implementation detail because that would allow you to make the application generic and port it to another vendors device.

Johanan1
Associate II
Posted on October 30, 2014 at 11:16

Glad we agree on most.

Actually I am not really complaining.

By now I got most of my hardware working, and I assume I'll have the USB host file system also working in a few hours. Needless to say, I could not get all these devices working without the library (and some demo sources).

This was my title ''standardization vs configuration'', a library with standard pins assignment for peripherals, clock etc. could be written for those of us how are willing to use it, giving up the option to configure everything. So forget my comments about C++, if a set of standard wiring is used,  all can be done by  very simple function calls, which hide the details.

As I said, not complaining, just giving some constructive feedback.

One more note: I played with Arduino and it took me about 20 minutes to have a web server reading html pages from SD card.  I think it is really grate  for beginners.