Home > On-Demand Archives > Theatre Talks >
Developing Reusable Firmware for MCUs
Jacob Beningo - Watch Now - EOC 2020 - Duration: 51:38
Once upon a time, firmware developers wrote code that was tightly coupled, spaghetti code that was fit for a single purpose and nothing else. That has changed! The ability to reuse embedded software has the potential to decrease time to market, decrease costs and prevent teams from reinventing the wheel.
In this session, we will explore how to develop reusable firmware for microcontroller-based systems. We will explore reusable and portable firmware best practices, software architecture, how to create abstractions and walk through an example.
Glad to hear it!
Why do you always have void returns for HAL functions shown on slides?
Is it deliberate ? Then how do you recommend to handle errors?
Yes it is deliberate. What I release publicly doesn't fully match what I release to my clients or use in my development efforts. Typically each set of peripheral HAL's would return an error type for that peripheral or there could be a generic error type that is used.
As usual Great webinar, I`ll certainly use some of these practices in my work. Does the code you have shown is available in your site? If so, please provide the link. Thanks.
I don’t have them published on my site but they are in my book on reusable firmware.
What's your opinion on Rust and C++ for embedded systems? You mentioned you've been trying C++ lately - would you recommend it? Also, have you tried Mbed OS?
Thanks for the comment.
Rust is very interesting but as of this moment, there are no international standards that one can develop compilers to, or for following best practices. I think it would be good to experiment with, but probably wouldn’t build any significant system with it.
C++ is great for embedded systems. You just have to make sure you use language features that work well with real-time systems. There is a good book called Real-time C++ that is a good reference along with articles that Dan Saks wrote.
Great, thank you!
Hello,
I don't find the right words to say "Thank you" for every thing.
Best regards.
K.M
You’re welcome! We hope that you enjoyed the conference!
What could be a proper path in the following case?
There is a codebase for a product using a microcontroller A (16 bits, Arch X) which is not very reusable (15 % reusability) and the plan is to update it to a new microcontroller B (32 bits, Arch Y) and the manufacturer provides a kind of HAL/drivers suite. Will it be better to refactor/restructure the code or to start from scratch targeting mainly the new platform?
Thank you Jacob for your presentation and book, they have been very useful.
P.D. a small typo in the slide for best practices, "effecting" should be "affecting"
In my experience, its generally more efficient to "start from scratch". Basically architect how you want system B to look. Leverage the systems HAL/drivers suite the best you can, hopefully using your own abstraction layer so that your application is not dependent on it.
Then from code base A, reuse or leverage any functional algorithms and refactor/restructure them into the new system. Just be careful that if things are too tightly coupled, you just use it as a functional example and start from scratch.
Let me know if that covers it.
(Thanks for the typo point-out, I always accidentally do that with those two!)
Thanks Jacob, you covered my question. It's good to have your point of view because this is a scenario where there will be some up-front cost to make the code reusable, as you said. And sometimes management won't agree to that. Thanks again.
Yes. When discussing these types of issues with management you have to put everything in terms of return-on-investment. It costs more up front like a month now but it will save us 3 months and X dollars in six months.
The video keeps hanging.
I'm sorry to hear that you are having issues. It may be related to your own internet connection. The video plays directly from Vimeo. In the player settings, try to decrease your video quality and see if that helps!
In the slide about "Creating Abstraction Layers", what is the rationale for using mixed function-naming convention (camelCase and underscore)?
Good question. So for me, I like to organize my HAL functions as PERIPHERAL_Functionality. I find it easier to read if I use an underscore to separate the peripheral or module function with what the function does. You could just as easily to SpiInit, SpiTransfer but for me that is harder to scan and read than Spi_Transfer.
I hope that helps!
Will the slides be made available to attendees after the presentation?
Just posted them. Thanks!
Thanks for the nice presentation! About halfway through your book and I'm definitely taking lessons home with me.
Great question! I just uploaded them. Thanks for catching that they were missing!
I'm glad to hear that you enjoyed it!
Thank you very much Jacob! I have your book, I am learning a lot from it, and I started to build my modules of HAL.