Author Topic: Is ST Cube IDE a piece of buggy crap?  (Read 227458 times)

0 Members and 5 Guests are viewing this topic.

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #300 on: February 04, 2022, 02:11:25 pm »
Why? The OS doesn't matter because the very same compiler is built for several OSses producing the exact same binary.
If tested and 100% than it is not important.
But I recall severall issues in the past with spaces in filenames, makefile issues with relative paths even the runtime packages that differed with different versions of the same OS.
One of the reasons that realtime updates are blocked by the company, IT tests the new updates on all software packages before releasing.
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #301 on: February 04, 2022, 02:12:29 pm »
Broken file and path names:

Options:
1) Fix the broken file and path names
2) Force everybody to use same OS and tool versions that luckily "work".

Come on.

I mean, if the project is so out of control that no one can know what the file names are, where they are located, and how to rename a file, how can anyone understand the code inside of those files?
 
The following users thanked this post: dtodorov

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15444
  • Country: fr
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #302 on: February 04, 2022, 06:46:23 pm »
Indeed. =)
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #303 on: February 04, 2022, 07:47:11 pm »
Yep it's buggy crap. But it still saves design time as compared to writing everything from scratch or (god forbid) piece together your own toolchains.

Outside of super-high volume design, code generation tools are king when it comes to shortening software dev time, which is often a major NRE cost contributor.

And if code bloat is bad for performance in some cases, you can always register-bang that part and still use quick code generation for the rest.
I love the smell of FR4 in the morning!
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #304 on: February 05, 2022, 11:36:20 am »
Somehow this time-saving seems to waste a lot of time, evidenced by others struggling with it.

Somehow I have saved a lot of time by never trying to save time by using this crap.

This is a recurring pattern. Just saw it recently with nRF52. Tried for a week or two to use the SDK, to no avail. Gave up and implemented all peripheral code I needed in a few hours! The difference in productivity is at least an order of magnitude.

Don't buy the marketing. MCU peripherals are usually actually simple.

I mean, if it takes me 5 minutes to use UART bare metal, what is the saving potential. How quickly will I do it with Cube&HAL? 2 minutes? 30 seconds? 5 seconds? 50 nanoseconds?

My guess, based on actual reality, is, it takes at least 30 minutes; IF I have everything installed and set up and learned.
« Last Edit: February 05, 2022, 11:40:07 am by Siwastaja »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3251
  • Country: ca
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #305 on: February 05, 2022, 04:18:29 pm »
... if it takes me 5 minutes to use UART bare metal, what is the saving potential.

I noticed that when a piece of code is already written, most people attach substantial value to it. They feel that if they write their own code, they somehow waste the already existing code. Same way as a woodworker who already has a decent piece of wood may want to re-use it rather than buying a new piece of wood.

IMHO, code is different. It is intangible and easy to write. Moreover, writing new code is often easier than correcting the existing code. Hanging on to old pieces of code often creates more problems that it solves.

 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #306 on: February 05, 2022, 06:34:33 pm »
IMHO, code is different. It is intangible and easy to write. Moreover, writing new code is often easier than correcting the existing code. Hanging on to old pieces of code often creates more problems that it solves.

I strongly, almost violently agree. And IMHO, this is an indicator of programmers who are afraid of programming due to the lack of experience. Nothing wrong in that, except the end result is full-blown horror: the solution is to "reuse" whatever pieces of code, copy-pasting from Stack Overflow (the site), or using wrong kind of library code and code generation. People who fall into this trap, don't even understand their mistake; because they see how much time it takes to get all that code actually work, they assume that if they did not reuse that code, they would have needed to replicate the same code 1:1, which, as they don't understand the code, seems almost an impossible task. Thus, they think they "save time".

The right thing to do? Start programming, write new code, if code is too long, delete it all and rewrite. You get better and start to find smaller and simpler solutions. This isn't as hard as it sounds, because the point of comparison is not the 1000-LoC solution of cobbled-together piece of crap, you will never have to replicate that when you work from scratch. You will see how miraculously you get the job done in much less.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 28113
  • Country: nl
    • NCT Developments
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #307 on: February 05, 2022, 06:45:19 pm »
@NorthGuy & Siwastaja:
The truth is somewhere in the middle. It takes quite a bit of effort to get all the quirks from a reasonable sized software project with all the usual ways things are intertwined. Even if the code itself isn't optimal.  On top of that it is easy to be fooled by pieces of code that look odd / weird but actually are written that way for a good reason. Rewriting larger chunks of code often is way more work than it seems at first sight. Remember the rule of thumb about the number of bugs per lines of code.

Then again, the structure of existing code may no longer line up well with the structure of new parts OR requirements of the software in which case a rewrite is something to consider. One of the projects I'm involved in is undergoing a complete rewrite because the existing code (partly inherited) no longer fits. That is likely going to take a big part of this year.

In most cases re-using existing, proven code is much more efficient than cooking up your own. Not seeing that as a benefit smells like the 'not invented here syndrom'. The sole reason libraries exist is to have people re-using existing code and not needing to re-invent the wheel everytime. Sure some libraries need time to learn but adding Lwip to your project is a whole lot quicker compared to coming up with your own IP stack with all the security related details that come with it. Spotting what pieces of existing code are useful and which not is a good skill to learn & have.
« Last Edit: February 05, 2022, 09:08:54 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15444
  • Country: fr
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #308 on: February 05, 2022, 06:47:17 pm »
Not "reinventing the wheel" is - usually - a reasonable approach in engineering in general, but software is definitely a different beast (and it has been debated for decades whether software development is really engineering... and sure, feel free to insert another coin! ;D )

With software, it... depends. For instance, sure it might not be reasonable to develop your own printf function if you're writing "desktop" software. Now if you're writing embedded software, that may be.

And those who think that software written by others is necessarily better than what they would themselves write, yes maybe that comes from a self-confidence issue. And while it could still seem reasonable if said piece of software has been maintained by a bunch of developers (not just one), has been used and tested for years, ... just have a look at disasters that happen on a regular basis (think about the Log4j drama :-DD ) to convince yourself that even in that case, it may be worth writing your own, small and dedicated piece of software rather than relying on a third-party bloated library or tool that may just end up blowing up in your face. :popcorn:
 

Online peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 4161
  • Country: gb
  • Doing electronics since the 1960s...
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #309 on: February 05, 2022, 06:47:23 pm »
Quote
Somehow this time-saving seems to waste a lot of time, evidenced by others struggling with it.

Well, it depends.

I have just helped someone set up Cube IDE on another machine, just using some instructions over instant messaging. He was compiling my project in about 30 mins, and that included recompiling a win32 command line executable which does some Cube post-build steps. This guy is a good programmer, although his expertise is in server side code which is mostly what he will be doing. But with Cube he can work on a particular module and single step through stuff, or just run USB VCP debugs. That's a huge amount of debug capability.

And the other day I properly broke my code. It crashed on start. It took me less than 5 mins to find it (it was some over-enthusiastic code clean-ups, resulting in overlapping mutex regions; always a great way to blow things up ;) ) by looking at the stack trace and some single stepping.

This is a vastly higher capability than I ever had in the old days. One day I might even learn the 99% of Cube which I have never used :) And I would dread having to set up a new project with it (somebody set this one up for me a couple of years ago) but I hope this basic hardware+software platform will last me past my actuarial life expectancy :)

It has stupid bugs, like often having to build the project _twice_ to get the Build Analyser to show up. That just shows ST have muppets looking after this project. But it's not a big deal.

And it is free, so you can have any number of people working on a project without paying out for some stupid floating license (I would never buy a tool with such copy protection; been there and always got burnt eventually). You could even give them a VMWARE VM and they just need to install the VMWARE player (well, there is the matter of the copy of win7-64 inside the VM ;) which is why you can't do this openly).

Quote
Hanging on to old pieces of code often creates more problems that it solves.

Depends on how much regression testing you need to do. In anything "real time", bugs can hide almost for ever. Once I get a platform solid, I stick with it practically for ever, and this is a big part of why almost nobody has ever found a bug in any product I released since about 1980. As the owner of my little business, this is a big motivation :) For me, bugs = huge hassle, especially if I have to open up code done years ago. If I was employed, bugs = wonderful employment opportunities :)

I once had a discussion with an electronics engineer regarding ROHS, and all the sh*it to do with having to scrap whole product families because a certain part could not be obtained lead-free. He thought ROHS was a fantastic new opportunity for designers, ensuring they would have jobs for many years. As the owner of my firm, I simply cannot get my head around such a way of thinking.

Quote
this is an indicator of programmers who are afraid of programming due to the lack of experience

That's true, but expertise is a finite thing. Especially if someone has a "life" outside electronics and software. It's like the debate between coding for IOS or Android. To code for Android you need more skill and above all more experience, because you need to know which parts of the API are common across the many varied devices. Many people don't bother and do IOS only. Not surprising; the vast majority of app writers are "kids". I get approx 5 emails per day offering to do an "app" for a site I run :)

« Last Edit: February 05, 2022, 06:51:25 pm by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #310 on: February 05, 2022, 08:05:15 pm »
@NorthGuy & Siwastaja
Are you hardware engineers by chance ?
The concensus of SW engineers is that re-using proven and tested code modules is far superior than rewriting from scratch. Some software code like network stacks take many manmonths development and many more writing testsuites that test all possible sunny and rainy day usecases.
Even if the software is not that great but open source or supported you have a forum or other means for support, to improve the code, or file bugs for the backlog to be solved in the future.

 
The following users thanked this post: nctnico, Bassman59, dkonigs

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #311 on: February 06, 2022, 08:02:01 am »
@NorthGuy & Siwastaja
Are you hardware engineers by chance ?
The concensus of SW engineers is that re-using proven and tested code modules is far superior than rewriting from scratch. Some software code like network stacks....

I do more software than hardware, but in my case, software means mostly firmware, I suck at doing large desktop application projects for example, maybe exactly because I try to apply MCU-proven workflows too eagerly, and they don't scale to everything. (Exactly the same pattern as software engineers struggling with MCU projects, just in the opposite way!)

Consensus doesn't matter, reality wins over consensus. Consensus depends pretty much on in what circles you work with. Besides, the track record of current software practices is not that beautiful (for example, in public healthcare, software systems that cost billions and then fail to work and cost human lives as a result, to be replaced after just a few years. This is all well documented. Digitalization is all great as a concept, but one could claim the software development practices are in crisis. Popularity of some practice does not prove anything beyond the popularity itself.)

Good microcontroller firmware developers are scarce. I know only a few, and they totally agree with my points. Trying to apply software-industry standard SW engineering practices, which struggle to work even there, to MCU development is a proven path to failure. The applications are just so fundamentally different. Microcontroller projects fundamentally depend on the hardware, but are also simple enough to be developed in teams of 1-3 people. The limited resources are needed in the fullest. Hardware engineers depend on the features listed on the datasheets. The software engineer needs to know how to implement that; best MCU engineers are those who can do both hardware and firmware, so that neither is a secondary trait.

No one suggested rewriting networking stacks just because of NIH. You are fighting against made up strawman. Reuse modules that are complex to implement, but easy to abstract, with well tested and proven solutions. TCP/IP stack - if you need the full stack with all the features - is the most classic example. If you want to DMA ADC readings, FIR filter that in real time, feed back into control loop, trig overcurrent limit, and communicate that over SPI to another microcontroller, this is all easier and safer and more maintainable to write yourself than using Cube autogeneration.

Comparing autogenerated, unreadable, non-modifiable, bloated crap from some trend tool of a year to well tested open source networking stacks - just no. They are not the same thing.

Reuse is tool among other tools, it should not be a religion. When in doubt, write code. Code can always be rewritten, and competition drives development. If existing code by others do better job - it shall win, then. Just don't do the mistake I have done a few times, promise a too large piece of software to be handled, struggle at making existing code work, start from scratch, but with too little resources and time. This is a game which is hard to win.
« Last Edit: February 06, 2022, 08:28:09 am by Siwastaja »
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #312 on: February 06, 2022, 08:54:25 am »
Code generation tools just make life easier, but their main strength is that they appeal to project managers. Writing low level from scratch will take 2 weeks, using a code gen tool, 2 days + 1 day of bugs cleanup. Convincing them that 10 work days is better than 3 is gonna be hard.

Actually, network stack and USB implementations have some horrendous bugs, but it's still much faster than brewing your own solution, code reuse or not.

I love the smell of FR4 in the morning!
 

Offline JOEBOBSICLE

  • Regular Contributor
  • *
  • Posts: 63
  • Country: gb
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #313 on: February 06, 2022, 08:58:36 am »
@NorthGuy & Siwastaja
Are you hardware engineers by chance ?
The concensus of SW engineers is that re-using proven and tested code modules is far superior than rewriting from scratch. Some software code like network stacks....

I do more software than hardware, but in my case, software means mostly firmware, I suck at doing large desktop application projects for example, maybe exactly because I try to apply MCU-proven workflows too eagerly, and they don't scale to everything. (Exactly the same pattern as software engineers struggling with MCU projects, just in the opposite way!)

Consensus doesn't matter, reality wins over consensus. Consensus depends pretty much on in what circles you work with. Besides, the track record of current software practices is not that beautiful (for example, in public healthcare, software systems that cost billions and then fail to work and cost human lives as a result, to be replaced after just a few years. This is all well documented. Digitalization is all great as a concept, but one could claim the software development practices are in crisis. Popularity of some practice does not prove anything beyond the popularity itself.)

Good microcontroller firmware developers are scarce. I know only a few, and they totally agree with my points. Trying to apply software-industry standard SW engineering practices, which struggle to work even there, to MCU development is a proven path to failure. The applications are just so fundamentally different. Microcontroller projects fundamentally depend on the hardware, but are also simple enough to be developed in teams of 1-3 people. The limited resources are needed in the fullest. Hardware engineers depend on the features listed on the datasheets. The software engineer needs to know how to implement that; best MCU engineers are those who can do both hardware and firmware, so that neither is a secondary trait.

No one suggested rewriting networking stacks just because of NIH. You are fighting against made up strawman. Reuse modules that are complex to implement, but easy to abstract, with well tested and proven solutions. TCP/IP stack - if you need the full stack with all the features - is the most classic example. If you want to DMA ADC readings, FIR filter that in real time, feed back into control loop, trig overcurrent limit, and communicate that over SPI to another microcontroller, this is all easier and safer and more maintainable to write yourself than using Cube autogeneration.

Comparing autogenerated, unreadable, non-modifiable, bloated crap from some trend tool of a year to well tested open source networking stacks - just no. They are not the same thing.

Reuse is tool among other tools, it should not be a religion. When in doubt, write code. Code can always be rewritten, and competition drives development. If existing code by others do better job - it shall win, then. Just don't do the mistake I have done a few times, promise a too large piece of software to be handled, struggle at making existing code work, start from scratch, but with too little resources and time. This is a game which is hard to win.
I've done all of that using cube Mx and never had any problems, I just use the provided callbacks from interrupts. I've done 20kHz current loops for bldc motors. I compile with opt 3 on and use LTO and never worry about bloat

I don't have time to write peripheral drivers, especially things like ethernet so it's a big win being able to use the st libs. For other chips like the samd range I've done it all myself but it's a bit of a timesink.
 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #314 on: February 06, 2022, 09:08:11 am »
Siwastaja
Ok lets focus on microcontroller dev only.
Those are limited projects and limited amount of code.
Still take Cube, if there is a bug it is likely to be found and fixed if ten thousand or even tenfold look at it and use it then you writing your own code.
Even if it is not fixed it will be discussed on the forum and you will know about it.

The only reason for rewriting it yourself is if you already done it so the investment has been done in the past, or the architecture and implementation do not suit you, or you don't understand it.
All perfectly fine reasons but it should not be the first step.
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #315 on: February 06, 2022, 09:44:58 am »
rewriting it yourself

See? This is the source of your confusion. Rewriting STM32HAL, or an RTOS, or Cube, would be pure madness. If this is the strawman you are discussing with, I understand how stupid this all sounds to you.

But if they are not needed at all, and the alternative solution is orders of magnitude simpler, then it's not about rewriting anything.

The key is that you believe writing new code is the same, or similar, to rewriting existing code. It is not. It completely depends.

But I can't make you understand this. You will, by yourself, or you will not.

In my microcontroller projects, most of the code goes into the actual application "logic" or data structures, something you need to write anyway. Not having to conform to any particular interface decided by others, but use tailored interfaces for the job, makes this program logic only easier; for example, if you can avoid creating buffers in the first place, then you don't need to manage buffers.

But looking at Cube projects, I understand how it all feels so overwhelming. I don't have that on my shoulders, at all, and thank <deity> I don't have to replicate any of that.
« Last Edit: February 06, 2022, 09:52:25 am by Siwastaja »
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #316 on: February 06, 2022, 09:58:35 am »
I've done 20kHz current loops for bldc motors

And I have done 500kHz loops. This was running in a few days.

But I know what the EEVBlog forum suggestion is:

It can't be done, so don't do it, hire an FPGA specialist.
 

Offline JOEBOBSICLE

  • Regular Contributor
  • *
  • Posts: 63
  • Country: gb
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #317 on: February 06, 2022, 11:12:27 am »
I've done 20kHz current loops for bldc motors

And I have done 500kHz loops. This was running in a few days.

But I know what the EEVBlog forum suggestion is:

It can't be done, so don't do it, hire an FPGA specialist.

I'm sure it's possible to do that, the main bottleneck I had was the constant context switching between the other tasks. I profiled the current loop and it was only a couple of microseconds of calculations.

Again that can be solved by offloading the other tasks to another core like with those dual core ST parts.
 

Online Kjelt

  • Super Contributor
  • ***
  • Posts: 6576
  • Country: nl
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #318 on: February 06, 2022, 11:32:13 am »
See? This is the source of your confusion. Rewriting STM32HAL, or an RTOS, or Cube, would be pure madness.
If this is the strawman you are discussing with, I understand how stupid this all sounds to you.
I think we agree.
My whole point is if someone new wants to start with STM32 has a Nucleo board and wants to do something simple, Cube is at most one to two days and he has a blinky.
Letting him read datasheets , family reference manuals and Arm documentation to sort out which clocks to enable, output/input config, which deviders to program, which peripherals to enable how etc. etc. will take weeks and frustration.
There is where Cube shines IMO. That the underlying code is made so abstract that it needs more than three layers is also frustrating to me but understandable if you see how many different micro's and boards they have to support.
Still it could have been better, totaal agree there but it is much better than ten years ago.

Quote
In my microcontroller projects, most of the code goes into the actual application "logic" or data structures, something you need to write anyway.
Agree this is where the effort should be put in.

Quote
Not having to conform to any particular interface decided by others, but use tailored interfaces for the job, makes this program logic only easier; for example, if you can avoid creating buffers in the first place, then you don't need to manage buffers.
Depends, if you are up and running and have issues with some of the underlying code using too many buffers causing too large delays, yes but you can than also modify and tailor the underlying code.
I did this for example with the UART. Six years ago (maybe now it is better) you needed to say how many bytes you were expecting. Well the protocol did not have fixed byte packets so I had to interpret the packets as they came along.
So then just take in one byte at a time into your own protocol handler and figure it out there. Which does not mean you can not use the existing code.

Quote
But looking at Cube projects, I understand how it all feels so overwhelming.
Me too but the same goes for Libopencm3 or any other toolchain.
The most frustrating is if something changes in the years and older projects do not compile because of an interface change.
So I understand some people doing this kind of work for years develop their own toolchain and codebase and those people have enough experience to decide to do this.
I just would not recommend it on a forum to others, esp. knowing that 80% does not have that experience.
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #319 on: February 06, 2022, 11:56:19 am »
Oh boy I do hope that Somebody Else^tm would do a really good tutorial series on simple bare-metal development. Not for me, but for the beginners, like I once was, too. For the common good.

Because there really is no fundamental reason why it should take any longer than on the vendor's Libraries And Tools Of The Year.

I would do it but I don't have time, and I'm not really a tutorial writing kind of person.

I think ataradov's code examples are among the best examples on the 'net. If someone put that in motivational tutorial format, that would do the trick.

I mean, explain basic concepts like linker scripts and how the CPU works, without going too deep too early.

Fact is, when I started with ARM, specifically STM32, I never went the "cube way" (at that time, Cube didn't exist, but its precursors were equally horrible), I wrote "from scratch" from day one. The only tutorial I found was written by a Swedish Ubuntu fanboy and while that did really help me out, his linker scripts were broken and caused me a completely disproportionate amount of pain. I mean, there was only ONE big issue, the misaligned (by 4, not 8) stack pointer initialization value, and it caused colossal pain and wasted time, while everything else was a breeze.

The first LED blinker (unaffected by the misaligned stack pointer) was running in less than half an hour! I had some vendor toolchain downloading during that time, and got the LED blinker finished before the download finished. Only after I tried to call memcpy or do arithmetic on int64_t types, I was doomed. Think about it, this shows the importance of having correct references and examples.

If you cope by adding complexity, then risks for incorrectness add up, too. This is again compensated by strong marketing, trying to force large enough user base for the toolchain, so that bugs and issues are found and corrected, or social knowledge base on the Internet starts to build.

But, I'd prefer to see small and short examples that are of high quality and correct, not long examples of poor code quality like is typical in SDKs, or complicated tools that create totally unreadable code with a point&click interface, which can be only modified through that same pointy-clicky.
« Last Edit: February 06, 2022, 11:58:46 am by Siwastaja »
 

Online peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 4161
  • Country: gb
  • Doing electronics since the 1960s...
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #320 on: February 06, 2022, 03:00:24 pm »
Traditionally, one started with a CPU/uC by reading the RM description of the registers, and configuring them one by one.

Usually I would use a table and just parse that.

You can't do that with STM32, because things have to be in a specific order to work. Lots of gotchas like the PLL config, and having to wait here and there. That is why all code I have seen does it directly, line by line, and in a pretty random order. The MX generated code is weird, doing some of it twice, interspersed with other stuff (which I think is wrong, because I cleaned that up and it still works.

Link scripts are horrible and almost nobody understands them. I never found good explanations.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Online Siwastaja

  • Super Contributor
  • ***
  • Posts: 8907
  • Country: fi
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #321 on: February 06, 2022, 03:12:03 pm »
Usually the ordering of things is pretty obvious. For example, you have to enable a DMA channel before you can start the peripheral that generates the DMA requests.

Also, if you want to run a piece of code at full expected clock speed, you need to enable the related clock/PLL before that code. But I think this is particularly easy, because you can start without understanding the clock tree and clocks, the chip just boots with the internal RC oscillator and Just Works. This is neat! Compare to programming "fuses" in some 8-bitters.

This is all fundamentally quite simple, with the few catches made much worse than they actually are by poor quality of documentation, and lack of high-quality simple examples.

Agree on linker scripts being confusing. The core issue is that you rarely work with them, and quite late in your "career" (hobby or professional) you start working with them. This, again, can be mitigated with good examples and documentation. Especially for a beginner, all you need is to have a linker script and startup code, you don't need to write them from scratch. They can be modified later when you have special needs.

The first STM32 LED blinker I made, just had the linker script and startup code directly fetched from the Swedish Ubuntu Guy's website, and less than 10LoC main() that turns on the GPIO clock and then writes to BSRR with some while(--i) delays inbetween. I flashed it with the UART bootloader available in STM32, no need to buy a programmer. The LED started blinking immediately. I indeed finished this faster than some larger toolset downloaded. Oh, and IIRC, I didn't have any devboard. Just soldered the chip on some random piece of PCB. Or maybe I etched a PCB for it, I used to do it a lot, even for small projects, I don't remember anymore.

(Back then, the argument was "why would you etch your own PCBs when you can get one professionally made for just $100!" Times have changed.)
« Last Edit: February 06, 2022, 03:22:59 pm by Siwastaja »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3251
  • Country: ca
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #322 on: February 06, 2022, 04:01:49 pm »
... it should not be the first step.

The whole idea is that this is the only step, which saves you time which you would otherwise spent on other steps, also will decrease bloat in your code. I'll try to explain by example:

I did this for example with the UART.

Ok, Let's take UART as an example. Let's say I have to receive something by UART in my code. Here's how I would do it.

1. Thinking

I first think how I receive the characters from UART. I can create an ISR for UART, or I can poll in the main loop, or I can poll from within a timer ISR (shared with other processes), or I can use DMA. This depends on the UART speed, the overall structure of the program, the structure of the information etc.

Then I think of where and when I am going to parse and process the data. I may do parsing immediate. Or I may delayed until I have more time, in which case I need a buffer.

Then I think of buffering, which must meet few criterea:

- the buffer must be big enough to store all the data I receive until the parser is able to process it
- the buffer must be able to continue receiving characters while the parser processes it
- if the information comes in chuncks (e.g. packets or lines), the buffer must be big enough to fit full chuncks (although this might be impossible)

I may decide that I don't need any buffers at all (e.g. hardware FIFO with UART module is sufficient), or I may use a circular buffer, or I may need a ping-pong buffers (i.e. one buffer gets processed while the other is filled in), or I may decide on a linked list of packets. Whatever I can see fit.

Then I think how parser is going to read data from the buffer, and make sure that it will be easy to write the parser.

Once I thought this through, I can start writing code, but I don't write anything until all the parts of the system are thought through.

How long does the thinking take? In simple case less than a minute. But it may take couple hours if the case is unusual or difficult. I may consult the UART module datasheet, DMA datasheet etc.

2. Coding

I usually write in pieces - I write the smallest piece than I can, then I test and verify that it works, then I add the next piece.

UART is very simple, so I would probably make an exception and wrote receiving and buffering all at once. Most likely, I have already written something similar, so I find it, paste it, and edit it - this saves lots of typing. Instead of the parser, I create a small routine which outputs the data with printf or similar. This way I can see what will be received by the parser.

Once written I compile to eliminate all typos and make sure there's no compiler warning.

Coding will take about 10 minutes. But it totally depends on how much you need to type and whether or not you need intermediary testing.

3. Testing

I would create use cases trying to break my receiving mechanism by varying speed, content, limits. For example, if the receiving involves parsing the input into the lines, I would test various line delimiters, empty lines, enormously long lines etc.

Testing usually takes the longest. It is only few minutes with a simple circular buffer, but if something is not working it will need fixing. Or if buffers are more complex, it may take hours to fully test and fix all the bugs.

I don't feel that if someone would give me a code I could incorporate it into my process in any way. I would still need to do some coding interfacing the foreign code. I would have to eliminate thinking and succumb to whatever is offered by the foreign code. The data for the parser would arrive in the format dictated by the foreign code, and with timing dictated by the foreign code. This would create problems later, when I need to write parser. Overall, instead of doing my own design as I please, I would have to adjust everything to meet the requirements of the foreign code. What for?
 

Online peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 4161
  • Country: gb
  • Doing electronics since the 1960s...
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #323 on: February 06, 2022, 08:35:51 pm »
Now do some code for transmitting data.

The interrupt may be generated only when the TX becomes empty. So you have to put a byte into it "manually" to get things started.

It gets a bit more involved.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3251
  • Country: ca
Re: Is ST Cube IDE a piece of buggy crap?
« Reply #324 on: February 06, 2022, 10:31:30 pm »
Now do some code for transmitting data.

Transmitting UART is usually a bit easier than receiving because you typically can transmit at your own pace. But no matter what I do, I always employ the same process - design, write, test.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf