Follow Us
Categories
Archives
- February 2024
- January 2024
- August 2023
- December 2022
- November 2022
- October 2022
- February 2022
- October 2021
- September 2021
- August 2021
- July 2021
- June 2021
- May 2021
- January 2021
- November 2020
- October 2020
- August 2020
- April 2020
- February 2020
- January 2020
- October 2019
- September 2019
- July 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- October 2018
- September 2018
- August 2018
- July 2018
- April 2018
- February 2018
- January 2018
- December 2017
- November 2017
- October 2017
- September 2017
- August 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- April 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- November 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- February 2013
- January 2013
- November 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- December 2011
- November 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
Author Archives: Niall Cooling
Navigating Memory in C++: A Guide to Using std::uintptr_t for Address Handling
In the modern landscape of embedded software development, efficiency and safety are paramount. As applications become more complex and demands on performance and security increase, developers turn to every tool in their arsenal to meet these challenges. Enter std::uintptr_t, a data type that, while not new, is sadly overlooked in most embedded codebases. This guide aims to introduce std::uintptr_t, showcasing its benefits and demonstrating how to use it effectively in your projects.
This article is written using C++ examples, but it […]
Embedded Expertise: Beyond Fixed-Size Integers; Exploring Fast and Least Types
The Challenge of Fixed-Size Integers Before C99
In embedded programming, before adopting the C99 standard (ISO/IEC 9899:1999), a significant challenge was ensuring the consistent sizing of key data objects. This complexity stemmed from the C standard’s (ISO/IEC 9899) non-committal stance on the size of an int. We knew:
A short is a minimum of 16-bits.
A long is a minimum of 32-bits.
An int is somewhere between a short and a long.
This flexibility boosted C’s portability, making it a favourite for various architectures, including […]
Posted in ARM, C/C++ Programming, Cortex, Toolchain
Tagged performance, stdint, uint32_t
Leave a comment
Disassembling a Cortex-M raw binary file with Ghidra
BlackHat Europe 2022
During the first week of December, I had the pleasure of attending a training course at BlackHat Europe 2022 titled Assessing and Exploiting Control Systems and IIoT run by Justin Searle.
Part of the course involved Assessing and Exploiting Embedded Firmware by reading on-chip Flash using OpenOCD. Unfortunately, we ran out of time to finish the last labs during the training (we ran 9 am-6 pm each day). So I decided to follow along with the very comprehensive notes […]
Using final in C++ to improve performance
Dynamic polymorphism (virtual functions) is central to Object-Oriented Programming (OOP). Used well, it provides hooks into an existing codebase where new functionality and behaviour can (relatively) easily be integrated into a proven, tested codebase.
Subtype inheritance can bring significant benefits, including easier integration, reduced regression test time and improved maintenance.
However, using virtual functions in C++ brings a runtime performance overhead. This overhead may appear inconsequential for individual calls, but in a non-trivial real-time embedded application, these overheads may build up and […]
Posted in C/C++ Programming, Design Issues
Tagged C++, design patterns, final, interface, Modern C++, Polymorphism
12 Comments
Understanding Arm Cortex-M Intel-Hex (ihex) files
Creating a flash image
The primary purpose of the ihex file in the embedded space is to create a file that is used to program/reprogram a target system. There are various file formats around, with the Intel Hex (ihex) format being among the most widely used.
The output of the linker stage of a build process is typically to generate a .elf file (Executable and Linkable Format). Many debuggers and programmers can work directly with the ELF file format. However, in many […]
Working with Strings in Embedded C++
In this post, by Embedded I’m generally referring to deeply embedded/bare-metal systems as opposed to Linux-based embedded systems.
Embedded systems and strings
Historically, the need for and thus the use of strings in embedded systems was fairly limited. However, this has changed with the advent of cheaper, full graphic displays and the growth of the ‘Internet of Things’ (IoT).
Many embedded systems sport full-colour graphics displays, supported by embedded-specific graphics libraries, including:
free open-source – e.g. LVGL
vendor-specific – e.g. TouchGFX from STMicroelectronics
fully specialised graphics […]
Posted in C/C++ Programming
Tagged #NTBS, #sso, #string, #string_view, C++11, C++17, pmr
11 Comments
TDD in C with Ceedling and WSL2 – performance issues
Ceedling is still probably the best Test-Driven Development (TDD) environment for C programmers out there. But, as with many Free Open-Source Software ( FOSS ), tools getting it to work natively on a Windows environment involves the odd hoop-jumping exercise; either involving messing around with the likes of Cygwin or Mingw; or using a full Virtual Machine (VM) environment such as VirtualBox or VMware.
However, with the introduction of Windows-Subsystem-for-Linux (WSL) and the much-improved update to WSL2, running Linux centric FOSS […]
Posted in Build-systems, C/C++ Programming, Linux, Testing
Tagged C Declarations, C++, ceedling, TDD, Testing, WSL2
3 Comments
C++20 modules with GCC11
Introduction
One of the headline changes of the C++20 standard is the inclusion of modules. Modules promise to significantly change the structure of C++ codebases and possibly signal headers’ ultimate demise (but probably not in my lifetime). It also opens the door to potentially have a unified build system and package manager, similar to Rust’s Cargo package manager; though I imaging standardising a unified build system would be one bloody battle.
Pre-C++20 builds
If you want to start a heated debate on any […]
Modern Embedded C++ – Deprecation of volatile
Compiling the following, straightforward code:
volatile int x;
int main() {
x += 10;
}
https://godbolt.org/z/jq83vdvj5
Using g++ with the directive -std=c++17 builds without any warnings or errors. However, change the directive to -std=c++20, and the result is:
source>: In function ‘int main()’:
<source>:5:5: warning: compound assignment with ‘volatile’-qualified left operand is deprecated [-Wvolatile]
5 | x += 10;
| ~~^~~~~
Compiler returned: 0
The new C++ standard, C++20, has deprecated volatile! So, what […]
GitHub Codespaces and online development
In our previous posting, we discussed using VSCode’s Dev Container extension to allow running workspaces directly within a Docker container.
In December 2020, I was granted early access to a new feature developed by GitHub called Codespaces. Codespaces offers an online VSCode development environment, enabling you to develop entirely in the cloud.
The great news is that Codespaces uses the same core process, and file structure, as Dev Containers; meaning once we have our .devcontainer folder setup (if you are unfamiliar with […]
Posted in Agile, C/C++ Programming, General, Industry Analysis, Testing
Tagged Codespaces, docker, GitHub, GoogleTest, Meson, VSCode
Leave a comment