Linux · Embedded
-
Are blocking/non-blocking and sync/async the same thing? Wait queues, O_NONBLOCK, epoll and io_uring
The difference between blocking vs non-blocking and synchronous vs asynchronous I/O comes down to two separate questions: whether a call waits when I/O cannot proceed yet, and whether the call itself performs the I/O and returns the result or submits a request whose completion is collected later. Based on the Linux manual pages (`pipe(7)`, `read(2)`, `epoll(7)`, `io_uring(7)`), official Linux kernel documentation, and four C programs run in this post's environment (x86-64 Linux, gcc 14.2, liburing 2.9, strace 6.13), this post compares how each model behaves on a real pipe.
-
What is the difference between I2C, SMBus and I3C?
Understanding the difference between I2C, SMBus and I3C comes down to what electrical, timing, and command rules SMBus tightens on top of the baseline two-wire I2C bus, and how MIPI I3C redesigns addressing, interrupts, and line driving while remaining backward compatible with legacy I2C targets. Based on the SMBus Specification 3.3.1, the Linux kernel documentation, and the MIPI I3C specification resources, this post compares the three protocols and walks through a pure Python 3.13 computation of the SMBus PEC (CRC-8) byte.
-
What is the difference between open-drain and push-pull? Why pull-up and pull-down resistors are needed
The core difference between open-drain and push-pull GPIO outputs lies in whether the output stage actively drives the line to both high (1) and low (0) logic levels, or actively drives only one level and releases the line to a high-impedance (Hi-Z) state for the other. Based on the Linux kernel GPIO driver and consumer interface documentation along with an illustrative Python logic-level model, this post explains how both output stages work and why pull-up or pull-down resistors are required.
-
How does a user program call the kernel? The svc/syscall, ioctl and copy_from_user flow
User programs normally call glibc wrapper functions such as `write()` and `read()`—or the generic `syscall(2)` library function—which place the system call number and arguments into registers and execute the architecture's transition instruction (`svc #0` on arm64, `syscall` on x86-64). When plain byte-stream reads and writes are not enough, `ioctl()` manipulates underlying device parameters of special files using an open file descriptor, a 32-bit operation code (encoded with `_IO`, `_IOR`, `_IOW`, or `_IOWR`), and a memory pointer. Inside the kernel, VFS dispatches the call through `struct file_operations` callbacks (`read`, `write`, `unlocked_ioctl`, `compat_ioctl`), and kernel code copies user-space memory safely with `copy_from_user()` and `copy_to_user()` instead of dereferencing user pointers directly.
-
What is a stack overflow? Finding and preventing MCU stack overflows for embedded interviews
A stack overflow happens when the stack used by function calls, local variables, and interrupts exceeds its allocated size and overwrites adjacent memory. On an MCU without an MMU, this rarely triggers an immediate clean fault; instead, neighbouring data such as .bss or the heap is silently corrupted, leading to hard-to-trace malfunctions or resets. To find it, inspect per-function frame sizes at compile time with -fstack-usage and -Wstack-usage, and check peak usage at run time with stack painting or FreeRTOS overflow checking and high water mark APIs. To prevent it, move large buffers off the stack, eliminate recursion, and size stacks from measured usage plus a margin.
-
What is an ESP32 emulator? Running firmware on a PC or in the browser without a board
An ESP32 emulator imitates the CPU and selected peripherals in software so you can run compiled firmware on a PC or in a browser without a physical board. This post summarizes concepts, use cases, differences from real hardware, and tools such as the QEMU fork, esp32sim, and Wokwi based on official documentation and community discussions.
-
What are common MCTP/PLDM interview questions and model answers? 19 Qs on packets, EIDs, Instance IDs, sensors, firmware update and debugging
Most MCTP/PLDM questions fall into five groups: MCTP packets and addressing (EIDs and tags), PLDM common rules (TID and Instance ID), monitoring (sensors, thresholds, and events), firmware update (Type 5 sequence), and the layer-by-layer order for debugging a missing response. Citing the underlying specification numbers (DSP0236, DSP0240, DSP0248, DSP0267) makes each answer much stronger.
-
How are MCTP and PLDM handled on Linux? AF_MCTP sockets, mctp, mctpd, libpldm and pldmd
Based on the Linux kernel MCTP documentation and the CodeConstruct and OpenBMC repositories, this post explains AF_MCTP sockets and sockaddr_mctp, the mctp and mctpd tools, and libpldm and pldmd. It includes checking Errno 97 on a kernel without MCTP, building user-space tools, and encoding a PLDM Base GetPLDMTypes request into bytes.
-
What are MCTP and PLDM? Server device management and how MCTP packets, EIDs and bindings work
MCTP and PLDM are DMTF PMCI standards used inside a server board so that a BMC and on-board devices can exchange management messages. Based on DSP0236 MCTP Base Specification 1.4.0 and transport bindings, this post explains server device management structure, the MCTP transport header, EIDs, message tags, bindings, and the bus owner.
-
What are PLDM types? Base, monitoring (PDRs and sensors), firmware update and RDE
PLDM is a DMTF standard that uses the PLDM type field in its message header to group base discovery, platform monitoring (PDRs and sensors), firmware update, and RDE. Based on DSP0240 PLDM Base Specification 1.2.1 and companion type specifications, this post summarizes the common header and the roles of Types 0, 2, 5, and 6 plus the firmware update sequence.
-
What is a ring buffer (circular buffer)? Implementing a UART receive buffer in an embedded interview
A ring buffer (circular buffer) is a classic data structure in embedded interviews when discussing how to implement a UART receive buffer. This post explains head and tail movement, full vs empty detection, and ISR caveats using the Linux kernel docs and a C example verified with gcc 14.2.
-
What is endianness? Telling big-endian from little-endian in an embedded interview
Endianness is the order in which the bytes of a multi-byte value are placed in memory. Little-endian stores the LSB at the lowest address and big-endian stores the MSB there; use htonl to convert to network byte order (big-endian) before sending on the network.
-
.data vs .bss: where global variables live in memory, for embedded interviews
The .data vs .bss difference comes down to initial values. .data holds globals and statics with a non-zero initializer stored in the file (flash on embedded targets); .bss holds zero or uninitialized globals with only size recorded in the file and zero-filled at startup.
-
Buildroot vs Yocto: what's the difference when choosing an embedded Linux image build tool?
Buildroot is a simple tool that builds the root filesystem and image in one pass from menuconfig/defconfig. Yocto is a large framework that manages packages and distributions with layers, recipes and bitbake. For a small product or a fast start, pick Buildroot. For multiple products, long-term maintenance or package management, pick Yocto.
-
What is a watchdog timer? How it recovers a hung system, explained for embedded interviews
A hardware watchdog resets the system when software stops sending kicks in time. This post covers how it works, where to place kicks, the Linux /dev/watchdog API, and common interview questions, based on the kernel watchdog docs.
-
What Is SDR (Software-Defined Radio)? Steps to Receive 433 MHz Sensor Signals with an RTL-SDR
SDR demodulates and decodes IQ samples from the antenna, tuner, and ADC in PC software. This guide covers unloading the DVB-T driver, verifying the dongle with rtl_test, and decoding 433.92 MHz sensors with rtl_433 using captured terminal output and public sample files.
-
What Is Cross-Compiling? Building with ARM gcc and Running It in QEMU, Step by Step
Cross-compiling builds ARM aarch64 binaries on an x86_64 host. This guide walks through installing aarch64-linux-gnu-gcc on Debian, building hello.c, and running the ELF with qemu-aarch64 -L against the target sysroot, with captured terminal output.
-
What Is IoT Security? Blocking Authentication Bypass and Internet Exposure on Embedded Devices
Embedded IoT security is the practice of designing defenses for hardware that directly operates physical equipment and runs unattended in the field for long periods. It means unique initial passwords on each device, management interfaces kept off the public internet, and a split between read (sensor) and write (actuator) from the architecture stage. The OWASP IoT Top 10 also lists weak or default passwords, insecure network services, and insecure default settings among its main categories. Engineering defaults should therefore include a mandatory password change on first boot, isolation behind a VPN or firewall, one-way telemetry, and cryptographically signed firmware updates.
-
How to Install Yocto BitBake and Boot core-image-minimal in QEMU
On Yocto 6.0 "Wrynose" LTS (supported until 2030), start a BitBake build with the bitbake-setup tool and configuration fragments. Install the host packages and the en_US.UTF-8 locale, run bitbake-setup init --non-interactive, source init-build-env, enable the root-login fragment that ships disabled, and run bitbake core-image-minimal. Then boot the image with runqemu qemux86-64 nographic and log in as root.
-
BLE GATT from Scratch: Structure, bluetoothctl Practice, and a Reliable PASS Verdict
In BLE, a Peripheral advertises and a Central scans and connects. The rules for finding and connecting are GAP; the rules for exchanging data once connected are GATT, whose data is organized as a service → characteristic → descriptor tree identified by UUIDs. On Linux, BlueZ `bluetoothctl` reads a value with `connect` → `menu gatt` → `select-attribute` → `read`. When you automate the test, don't treat `ServicesResolved: yes` as a PASS; only pass when a value appears on the line after `Attempting to read …`.
-
How to Find Crash Causes with gdb in Embedded Linux: Core Dump and gdbserver in Practice
When an embedded Linux process crashes with a Segmentation fault (SIGSEGV), you can inspect the post-mortem state by opening the core dump in gdb alongside the matching symbol-bearing binary and running `bt` to find where it died, or debug it live by running `gdbserver` on the board and connecting from the host PC via `target remote board-ip:port`. Because gdbserver has no built-in security of its own, it must only ever be used on an isolated private network.
-
I2C vs SPI vs UART: How to Compare Them in an Embedded Interview
An interview comparison of I2C, SPI, and UART starts with wire count and whether the bus is synchronous or asynchronous. I2C is 2-wire synchronous, SPI is 4-wire synchronous, and UART is 2-wire asynchronous; then cover device selection, speed, and a typical use for each.
-
What Is DMA? How It Differs from CPU Copy and How to Answer in Embedded/Firmware Interviews
DMA lets a DMA controller move data between a peripheral and memory, so the CPU only handles setup and completion. In an interview, explain how that differs from a CPU copy and cover cache coherency as well.
-
Cross-compile sysroot missing headers: how to fill them
Separate include-path failure signals with --sysroot and PKG_CONFIG_SYSROOT_DIR, then copy headers, libs, and .pc files from a board/rootfs image into the sysroot. Grounded in GCC and pkg-config docs. No affiliate.
-
systemd path units: start a service when a file appears
Pair .path + .service with PathExists/PathChanged for oneshot activation. Short timer/OnCalendar contrast only. Grounded in man systemd.path and journal debug. No affiliate.
-
Device Tree Overlay Not Applying: Debug Order
Debug order when a DT overlay does not apply: dtc -@ / symbols, config.txt dtoverlay path, /proc/device-tree. Grounded in kernel and Raspberry Pi docs. No board anecdotes or prices.
-
When Should You Choose a ~3 TOPS NPU SoM for Embedded Vision on Debian?
Treat 3 TOPS as a vendor spec label. This is which camera workloads fit, what to check first in a Debian BSP, and what separates a SoM from an SBC.
-
How Does the Hexagon NPU Look Upstream in the Snapdragon X2 Linux Preview?
Who the Snapdragon X2 Linux preview is for on the kernel and distro side, how Hexagon is reached through upstream FastRPC, and which gaps remain before an OEM ships. Dates stay unconfirmed.
-
What Is /var For on Embedded Linux?
A board-level guide to /var on embedded Linux: what FHS says it is for, and how to split log, cache, lib, spool, run, and tmp between tmpfs and persistent storage when you have flash wear, a read-only root, and journald to deal with.
-
How to Debug When gpiochip Numbers Shift
Debug gpiochipN renumbering across boots/kernels: pin by label/name via /dev/gpiochip, libgpiod, /sys/bus/gpio. No invented board timings or affiliates.
-
Putting /var/log on tmpfs on embedded — when does it make sense?
fstab example for /var/log on tmpfs, what reboot does to logs, journald Storage=volatile. Grounded in fstab and journald.conf. No affiliates.
-
udev ACTION=add vs change — Why Rules Run Twice
udev ACTION add vs change, stop duplicate RUN, verify with udevadm monitor. Grounded in systemd udev ACTION keys. No affiliates.
-
cgroup v2 memory.max — How Do You Cap Process Memory?
Howto for cgroup v2 memory.max: where to write, OOM symptoms via memory.events, and how containers differ. Grounded in the kernel cgroup-v2 memory controller docs. No affiliates.
-
strace -e trace= — How Do You Filter Syscalls?
Howto for strace -e trace=: filter syntax, %file/%net for file and network only, performance cost and --seccomp-bpf. Grounded in strace(1). Separate from a full intro. No affiliates.
-
Embedded Serial Console Getty — How Do You Enable It?
Minimal howto to attach a login getty on a serial console: serial-getty@ unit and device, baud/TERM, what to check when the screen is blank. Grounded in systemd-getty-generator and kernel console=. No affiliates.
-
Yocto IMAGE_INSTALL vs RDEPENDS — Where Does the Package Go?
Put intentional image members in IMAGE_INSTALL; put hard runtime needs in RDEPENDS. Duplicating both breaks removal and audits. Grounded in the Yocto mega-manual.
-
overlayroot vs A/B Updates: What to Pick on Embedded Linux
Choice criteria for Ubuntu overlayroot (read-only lower root plus overlay) versus A/B slot OTA—failure modes, OTA fit, and development images—grounded in public docs. Not Device Tree Overlay debugging.
-
Device-Tree Alias·Label Debugging — What to Check and How to Align
Device Tree /aliases vs DTS labels vs nodes, plus debug tips. Grounded in the DT Spec and Linux OF APIs. No board measurements, pricing, or affiliates.
-
journald Vacuum: How to Shrink Disk Usage
Use journalctl --vacuum-size/--vacuum-time/--vacuum-files to trim archived journals, then cap growth with Storage and SystemMaxUse. Disk retention howto—not filter queries.
-
BitBake bbappend: Patch Recipes Without Overwriting
Use .bbappend instead of copying upstream .bb files. Path layout, FILESEXTRAPATHS, and BBFILE_PRIORITY only. Separate axis from yocto-systemd. Grounded in Yocto docs.
-
Minimizing a Buildroot defconfig — What to Drop, Deps, savedefconfig
How to shrink a Buildroot defconfig: what to turn off, dependency breakage, and reproducing with savedefconfig. Grounded in the Buildroot manual. No invented board footprints or affiliates.
-
Reading dmesg on Embedded Without an RCU Deep Dive
How to read embedded dmesg around log levels, timestamps, and repeating panic patterns. Grounded in dmesg(1) and printk docs. No invented board stories or affiliates.
-
systemd Socket Activation: Delay-Start a Service
Open the listening socket first; start the service on traffic. Accept= meaning; vs timer and path. Grounded in man systemd.socket. No affiliate.
-
How to Install a systemd Service in a Yocto Recipe
Use inherit systemd and SYSTEMD_SERVICE:${PN}, install units under ${D}${systemd_system_unitdir}, and enable image init with INIT_MANAGER = "systemd".
-
Docker BuildKit Cache Mounts: How to Speed Up Builds
Use RUN --mount=type=cache for npm/Go/apt package caches across builds. Split buckets with id, use sharing=locked for apt, and pair with external cache in CI.
-
BusyBox vs coreutils: What to Pick on Embedded
BusyBox multi-call vs GNU coreutils: size/compat, script breakage, selection criteria. Grounded in BusyBox/coreutils public docs. No invented board stories or prices. No affiliates.
-
mdev vs udev: What Fits a Small Embedded Rootfs
BusyBox mdev vs udev/systemd-udevd on a small embedded rootfs: when mdev fits, when udev is required, rule-migration caveats. Grounded in BusyBox mdev and udev public docs. No invented board stories or prices. No affiliates.
-
sysfs GPIO vs libgpiod: When to Use Which
sysfs `/sys/class/gpio` is an obsolete migration path; new work uses `/dev/gpiochipX` + libgpiod. Selection axis, benefits, and permissions only—no gpiomon-edge or libgpiod howto rehash.
-
udev Input Device Permissions: How to Pin dialout and plugdev
Put tty/hid rules in /etc/udev/rules.d, match ATTRS{idVendor/idProduct}, set GROUP=dialout and SYMLINK, then verify with udevadm info/test/trigger.
-
USB Serial udev Symlink: How to Pin `/dev/ttyUSB`
Pin a stable path with SYMLINK when ttyUSB enumeration order shifts. ATTR/ATTRS keys, GROUP/MODE, udevadm verify/test/trigger only. No general udev tour or invented board stories.
-
libgpiod Edge Events: How to Catch Them with gpiomon
Use gpiomon --edges for rising, falling, or both; pass --chip with offsets; add --debounce-period for chatter. Unlike polling, it waits on kernel edge events.
-
How to Use ftrace function_graph to See Kernel Call Paths
Set current_tracer to function_graph under tracefs, narrow the scope with set_ftrace_filter, then use tracing_on and trace or trace_pipe to read the call graph. Covers buffer, filters, and overhead only.
-
How to Use i2cdetect and i2cget to Find a Sensor Address
List adapters with i2cdetect -l on i2c-dev buses under /dev/i2c-*, scan slave addresses with i2cdetect, then read registers with i2cget. Covers permissions and the Device Tree boundary briefly.
-
AArch64 Cross-Compile with CMake: How to Use a Toolchain File
For cross-compiling to a target board like aarch64, point CMAKETOOLCHAINFILE at a file that sets the target system and compilers, set CMAKESYSROOT to the target root filesystem, an
-
Filtering Service Logs with journalctl
journalctl is the core tool for querying the systemd journal. Use -u and -b to narrow by unit and boot, then --since, --until, and -p to filter by time and severity.
-
libgpiod: Userspace GPIO Access on Linux
libgpiod provides the userspace C library, language bindings, and command-line tools for interacting with GPIO lines through Linux's GPIO character device.
-
Setting Up systemd Timers with OnCalendar for Periodic Jobs
To run a periodic job, create a .timer unit that shares its base name with a .service unit and set OnCalendar= in the [Timer] section. This post covers timer-service pairing, calendar expressions, and catching up missed runs with Persistent=true.
-
How Docker Containers Run: Namespaces and cgroups
A Docker container is not a virtual machine with its own kernel—it is a set of Linux processes isolated by namespaces and constrained by cgroups on the same host kernel. This article summarizes how docker run actually works based on official Docker documentation.
-
Loading and Running Docker Images with save, load, and run
When transferring images without a registry, use docker save and docker load to preserve every layer, history, and tag metadata. Once loaded locally, docker run follows the same execution path as a pulled image.
-
Docker Layer Cache, Volumes, and Bind Mounts in Practice
Docker reuses build cache from the top down, so frequently changing instructions belong at the bottom of the Dockerfile. Persistent data should live in volumes or bind mounts—not in the overlay writable layer that is destroyed when a container is removed.
-
Docker overlay2 Storage: How Image Layers Merge
Docker overlay2 uses OverlayFS to combine read-only image layers with a container-specific writable layer into a single mount point. This post explains how the storage driver stacks layers on disk and why container writes do not persist to the underlying image.
-
systemd Type= Explained: simple, exec, notify, and Key Service Keywords
The systemd Type= directive determines when the service manager considers start-up complete. This article covers all eight Type= values and essential service file keywords from the official man pages.
-
Profiling with Linux perf: Finding CPU Hotspots
Linux perf uses the kernel performance-counter framework to sample CPU activity and expose functions where samples accumulate as hotspots.