Picowoose: The Raspberry Pi Pico-W meets Mongoose
This example application describes the way to adapt the George Robotics CYW43 driver, present in the Pico-SDK, to work with Cesanta's Mongoose. We are then able to use Mongoose internal TCP/IP stack (with TLS 1.3), instead of lwIP (and MbedTLS).
Small or fast?
Developers of software for desktop computers take code optimization for granted. Embedded developers typically need to pay much more attention to the details
Memory Mapped I/O in C
Interacting with memory mapped device registers is at the base of all embedded development. Let's explore what tools the C language - standard of the industry - provide the developer with to face this task.
Some Embedded System Software Design Resources
I recently received a message from an embedded systems engineer in England asking about a good resource for embedded system software design and easing debugging difficulties.
That's challenging because embedded systems cover such a wide range. There are many possible run-time environments and architectures.
Thus there's no single resource that covers all ground. However, the resources below provide a lot of good material. In aggregate, they make up a good set from which to pull various...
When a Mongoose met a MicroPython, part II
In the first part of this blog, we introduced this little framework to integrate MicroPython and Cesanta's Mongoose; where Mongoose runs when called by MicroPython and is able to run Python functions as callbacks for the events you decide in your event handler. Now we add MQTT to the equation, so we can subscribe to topics and publish messages right from MicroPython.
ANCS and HID: Controlling Your iPhone From Zephyr
In this blog post, we see how certain BLE services can be used to control an iPhone from a Nordic nRF52840 using The Zephyr Project. Specifically, we see how to control certain multimedia functionality using the HID service. Finally, we learn how to use the ANCS client library provided by Nordic in The Zephyr Project to accept or decline an incoming call.
Finite State Machines (FSM) in Embedded Systems (Part 4) - Let 'em talk
No state machine is an island. State machines do not exist in a vacuum, they need to "talk" to their environment and each other to share information and provide synchronization to perform the system functions. In this conclusive article, you will find what kind of problems and which critical areas you need to pay attention to when designing a concurrent system. Although the focus is on state machines, the consideration applies to every system that involves more than one execution thread.
Getting Started With CUDA C on an Nvidia Jetson: A Meaningful Algorithm
In this blog post, I demonstrate a use case and corresponding GPU implementation where meaningful performance gains are realized and observed. Specifically, I implement a "blurring" algorithm on a large 1000x1000 pixel image. I show that the GPU-based implementation is 1000x faster than the CPU-based implementation.
Finite State Machines (FSM) in Embedded Systems (Part 3) - Unuglify C++ FSM with DSL
Domain Specific Languages (DSL) are an effective way to avoid boilerplate or repetitive code. Using DSLs lets the programmer focus on the problem domain, rather than the mechanisms used to solve it. Here I show how to design and implement a DSL using the C++ preprocessor, using the FSM library, and the examples I presented in my previous articles.
C++ Assertion? Well Yes, But Actually No.
Assertions are a double-edged sword - on one side you enforce program correctness catching bugs close to their origin, on the other your application is subject to run-time error, like any interpreted language. This article explores what C++ can offer to get the advantages of assertions, without risking the crashes by moving contract checking at compile time.
Cracking the (embedded) Coding Interview
You never forget the day you land your first job.
The thrill of receiving that call from your recruiter to tell you that you bagged your dream role! The relief when you finally see the offer letter you’ve been working towards for years. The pride in your parents' voices when you call home and say “Hey look Ma, I’ve made it!”
But before that, there’s the grueling screening process to get through. Tech interviews often last up to three months and companies can have five...
Small or fast?
Developers of software for desktop computers take code optimization for granted. Embedded developers typically need to pay much more attention to the details
Creating a Hardware Abstraction Layer (HAL) in C
In my last post, C to C++: Using Abstract Interfaces to Create Hardware Abstraction Layers (HAL), I discussed how vital hardware abstraction layers are and how to use a C++ abstract interface to create them. You may be thinking, that’s great for C++, but I work in C! How do I create a HAL that can easily swap in and out different drivers? In today’s post, I will walk through exactly how to do that while using the I2C bus as an example.
Modern C++ in Embedded Development: (Don't Fear) The ++
While C is still the language of choice for embedded development, the adoption of C++ has grown steadily. Yet, reservations about dynamic memory allocation and fears of unnecessary code bloat have kept many in the C camp. This discourse aims to explore the intricacies of employing C++ in embedded systems, negotiating the issues of dynamic memory allocation, and exploiting the benefits of C++ offerings like std::array and constexpr. Moreover, it ventures into the details of the zero-overhead principle and the nuanced distinctions between C and C++. The takeaway? Armed with the right knowledge and a careful approach, C++ can indeed serve as a powerful, safer, and more efficient tool for embedded development.
Memory Mapped I/O in C
Interacting with memory mapped device registers is at the base of all embedded development. Let's explore what tools the C language - standard of the industry - provide the developer with to face this task.
Finite State Machines (FSM) in Embedded Systems (Part 2) - Simple C++ State Machine Engine
When implementing state machines in your project it is an advantage to rely on a tried and tested state machine engine. This component is reused for every kind of application and helps the developer focus on the domain part of the software. In this article, the design process that turns a custom C++ code into a finite-state machine engine is fully described with motivations and tradeoffs for each iteration.
Visual Studio Code Extensions for Embedded Software Development
Visual Studio Code has become one of the most popular IDEs in the world. To date, software developers have downloaded it more than 40 million times! I suspect you’ve at least heard of it, if not already attempting to use it. Visual Studio Code allows developers to easily customize their development environment which can help them accelerate development, minimize bugs, and make developing software overall much better.
One challenge with Visual Studio Code is that embedded software...
Some Embedded System Software Design Resources
I recently received a message from an embedded systems engineer in England asking about a good resource for embedded system software design and easing debugging difficulties.
That's challenging because embedded systems cover such a wide range. There are many possible run-time environments and architectures.
Thus there's no single resource that covers all ground. However, the resources below provide a lot of good material. In aggregate, they make up a good set from which to pull various...
C to C++: 3 Reasons to Migrate
I’ve recently written several blogs that have set the stage with a simple premise: The C programming language no longer provides embedded software developers the tools they need to develop embedded software throughout the full software stack. Now, don’t get me wrong, C is a powerhouse, with over 80% of developers still using it; however, as embedded systems have reached unprecedented levels of complexity, C might not be the right tool for the job.
In this post, I’m kicking...
Finite State Machines (FSM) in Embedded Systems (Part 4) - Let 'em talk
No state machine is an island. State machines do not exist in a vacuum, they need to "talk" to their environment and each other to share information and provide synchronization to perform the system functions. In this conclusive article, you will find what kind of problems and which critical areas you need to pay attention to when designing a concurrent system. Although the focus is on state machines, the consideration applies to every system that involves more than one execution thread.
Visual Studio Code Extensions for Embedded Software Development
Visual Studio Code has become one of the most popular IDEs in the world. To date, software developers have downloaded it more than 40 million times! I suspect you’ve at least heard of it, if not already attempting to use it. Visual Studio Code allows developers to easily customize their development environment which can help them accelerate development, minimize bugs, and make developing software overall much better.
One challenge with Visual Studio Code is that embedded software...
Cracking the (embedded) Coding Interview
You never forget the day you land your first job.
The thrill of receiving that call from your recruiter to tell you that you bagged your dream role! The relief when you finally see the offer letter you’ve been working towards for years. The pride in your parents' voices when you call home and say “Hey look Ma, I’ve made it!”
But before that, there’s the grueling screening process to get through. Tech interviews often last up to three months and companies can have five...
Modern C++ in Embedded Development: (Don't Fear) The ++
While C is still the language of choice for embedded development, the adoption of C++ has grown steadily. Yet, reservations about dynamic memory allocation and fears of unnecessary code bloat have kept many in the C camp. This discourse aims to explore the intricacies of employing C++ in embedded systems, negotiating the issues of dynamic memory allocation, and exploiting the benefits of C++ offerings like std::array and constexpr. Moreover, it ventures into the details of the zero-overhead principle and the nuanced distinctions between C and C++. The takeaway? Armed with the right knowledge and a careful approach, C++ can indeed serve as a powerful, safer, and more efficient tool for embedded development.
C to C++: Bridging the Gap from C Structures to Classes
In our last post, C to C++: Proven Techniques for Embedded Systems Transformation, we started to discuss the different ways that C++ can be used to write embedded software. You saw that there is no reason to be overwhelmed by trying to adopt complex topics like metaprogramming out of the gate. An important concept to understand is that you can make the transition gradually into C++ while still receiving the many benefits that C++ has to offer.
One of the first...
Creating a Hardware Abstraction Layer (HAL) in C
In my last post, C to C++: Using Abstract Interfaces to Create Hardware Abstraction Layers (HAL), I discussed how vital hardware abstraction layers are and how to use a C++ abstract interface to create them. You may be thinking, that’s great for C++, but I work in C! How do I create a HAL that can easily swap in and out different drivers? In today’s post, I will walk through exactly how to do that while using the I2C bus as an example.
Scorchers, Part 3: Bare-Metal Concurrency With Double-Buffering and the Revolving Fireplace
This is a short article about one technique for communicating between asynchronous processes on bare-metal embedded systems.
Q: Why did the multithreaded chicken cross the road?
A: to To other side. get the
There are many reasons why concurrency is
C to C++: 3 Reasons to Migrate
I’ve recently written several blogs that have set the stage with a simple premise: The C programming language no longer provides embedded software developers the tools they need to develop embedded software throughout the full software stack. Now, don’t get me wrong, C is a powerhouse, with over 80% of developers still using it; however, as embedded systems have reached unprecedented levels of complexity, C might not be the right tool for the job.
In this post, I’m kicking...
Review: Hands-On RTOS with Microcontrollers
Full disclosure: I was given a free copy of this book for evaluation.
Hands-On RTOS with Microcontrollers: Building real-time embedded systems using FreeRTOS, STM32 MCUs, and SEGGER debug tools by Brian Amos is an outstanding book. It lives up to its name, extremely hands-on and practical, taking you from knowing nothing about RTOS's (Real-Time Operating Systems) up to building real multithreaded embedded system applications running on real hardware.
It uses the ST Micro
C to C++: 5 Tips for Refactoring C Code into C++
The article titled "Simple Tips to Refactor C Code into C++: Improve Embedded Development" provides essential guidance for embedded developers transitioning from C to C++. The series covers fundamental details necessary for a seamless transition and emphasizes utilizing C++ as a better C rather than diving into complex language features. The article introduces five practical tips for refactoring C code into C++. Replace #define with constexpr and const: Discouraging the use of #define macros, the article advocates for safer alternatives like constexpr and const to improve type safety, debugging, namespaces, and compile-time computation. Use Namespaces: Demonstrating the benefits of organizing code into separate logical groupings through namespaces, the article explains how namespaces help avoid naming conflicts and improve code readability. Replace C-style Pointers with Smart Pointers and References: Emphasizing the significance of avoiding raw pointers, the article suggests replacing them with C++ smart pointers (unique_ptr, shared_ptr, weak_ptr) and using references
Creating a GPIO HAL and Driver in C
Creating a GPIO Hardware Abstraction Layer (HAL) in C allows for flexible microcontroller interfacing, overcoming the challenge of variability across silicon vendors. This method involves reviewing datasheets, identifying features, designing interfaces, and iterative development, as detailed in the "Reusable Firmware" process. A simplified approach prioritizes essential functions like initialization and read/write operations, showcased through a minimal interface example. The post also highlights the use of AI to expedite HAL generation. A detailed GPIO HAL version is provided, featuring extended capabilities and facilitating driver connection through direct assignments or wrappers. The significance of a configuration table for adaptable peripheral setup is emphasized. Ultimately, the blog illustrates the ease and scalability of developing a GPIO HAL and driver in C, promoting hardware-independent and extensible code for various interfaces, such as SPI, I2C, PWM, and timers, underscoring the abstraction benefits.