Home > On-Demand Archives > Theatre Talks >

Developing Reusable Firmware for MCUs

Jacob Beningo - Watch Now - 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. 

M↓ MARKDOWN HELP
italicssurround text with
*asterisks*
boldsurround text with
**two asterisks**
hyperlink
[hyperlink](https://example.com)
or just a bare URL
code
surround text with
`backticks`
strikethroughsurround text with
~~two tilde characters~~
quote
prefix with
>

Doini
Score: 0 | 4 years ago | 1 reply

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.

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

Glad to hear it!

msaur
Score: 0 | 4 years ago | 1 reply

Why do you always have void returns for HAL functions shown on slides?
Is it deliberate ? Then how do you recommend to handle errors?

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

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.

MSARUL
Score: 0 | 4 years ago | 1 reply

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.

Jacob_BeningoSpeaker
Score: 1 | 4 years ago | no reply

I don’t have them published on my site but they are in my book on reusable firmware.

MSARUL
Score: 0 | 4 years ago | no reply
This post has been deleted by the author
diegolt
Score: 0 | 4 years ago | 1 reply

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?

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | 1 reply

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.

diegolt
Score: 0 | 4 years ago | no reply

Great, thank you!

Khaled
Score: 0 | 4 years ago | 1 reply

Hello,
I don't find the right words to say "Thank you" for every thing.
Best regards.
K.M

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

You’re welcome! We hope that you enjoyed the conference!

gustavovelascoh
Score: 0 | 4 years ago | 1 reply

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"

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | 1 reply

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!)

gustavovelascoh
Score: 0 | 4 years ago | 1 reply

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.

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

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.

radiorun
Score: -1 | 4 years ago | 1 reply

The video keeps hanging.

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

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!

gustavovelascoh
Score: 1 | 4 years ago | 1 reply

In the slide about "Creating Abstraction Layers", what is the rationale for using mixed function-naming convention (camelCase and underscore)?

Jacob_BeningoSpeaker
Score: 1 | 4 years ago | no reply

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!

LeeT
Score: 3 | 4 years ago | 1 reply

Will the slides be made available to attendees after the presentation?

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

Just posted them. Thanks!

HR
Score: 2 | 4 years ago | 2 replies

Thanks for the nice presentation! About halfway through your book and I'm definitely taking lessons home with me.

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

Great question! I just uploaded them. Thanks for catching that they were missing!

Jacob_BeningoSpeaker
Score: 0 | 4 years ago | no reply

I'm glad to hear that you enjoyed it!

OUR SPONSORS