Marcus Folkesson

Embedded Linux Artist

Mutex guards in the Linux kernel

Mutex guards in the Linux kernel I found an interresting thread [1] while searching my inbox for something completely unrelated. Peter Zijistra has written a few cleanup functions that where introduced in v6.4 with this commit: commit 54da6a0924311c7cf5015533991e44fb8eb12773 Author: Peter Zijlstra <peterz@infradead.org> Date: Fri May 26 12:23:48 2023 +0200 locking: Introduce __cleanup() based infrastructure Use __attribute__((__cleanup__(func))) to build: - simple auto-release pointers using __free() - 'classes' with constructor and destructor semantics for scope-based resource management.

Use b4 for kernel contributions

Use b4 for kernel contributions There is a little tool called b4 [1] that has been part of my workflow with the Linux kernel for a while. It's developed to be a tool used to simplify the work of the maintainers, but my main use of the tool has been to fetch patch series from the mailing list and apply them to my local git repository during reviews. I recently noticed that it got a lot of handy features (experimental though) for the contributors as well, which I now want to test! cover

Linux wireless regulatory domains

Linux wireless regulatory domains I had a case where I had an embedded system that should act as a WiFi Access Point on the 5GHz band. The HW was capable and the system managed to act as a client to 5GHz networks, so everything looked good. However, the system could not create an access point on some frequencies. How is it that? It's all about regulatory domains! Regulatory domains Radio regulations is something that applies to all devices that make transmissions in the radio spectrum. cover

Add support for MCP39XX in Linux kernel

Add support for MCP39XX in Linux kernel I've maintained the MCP3911 driver in the Linux kernel for some time and continuously add support for new features [1] upon requests from people and companies. Microchip has several IC:s in this series of ADC:s that works similar to MCP3911. Actually, all other IC:s are register compatible but MCP3911. The IC:s I've extended support for is MCP3910, MCP3912, MCP3913, MCP3914, MCP3918 and MCP3919. cover

Contiguous Memory Allocator

Contiguous Memory Allocator Introduction I do find memory management as one of the most fascinating subsystem in the Linux kernel, and I take every chance I see to talk about it. This post is inspired by a project I'm currently working on; an embedded Linux platform with a camera connected to the CSI-2 bus. Before we dig into which problems we could trip over, lets talk briefly about how the kernel handles memory. cover

Audio and Embedded Linux

Audio and Embedded Linux Brief Last time I used wrote kernel drivers for the ASoC (ALSA System on Chip) subsystem, the functionality was split up into these parts: Platform class driver that defines the SoC audio interface for the actual CPU itself. This includes both the DAI (Digital Audio Interface) and any potential audio muxes (e.g. i.MX6 has its AUDMUX). CODEC class driver that controls the actual CODEC. Machine drivers that is the magic glue between the SoC and the CODEC which connect the both interfaces. cover

Debug kernel with KGDB

Debug kernel with KGDB What is KGDB? KGDB intend to be used as a source code level debugger on a running Linux kernel. It works with GDB and allows the user to inspect memory, variables, setup breakpoints, step lines and instructions. Pretty much the same that all application developers are used to, but for the kernel itself. Almost every embedded Linux system does have a serial port available, and that is all that you need to connect GDB to your kernel. cover

What is libcamera and why should you use it?

What is libcamera and why should you use it Read out a picture from camera Once in a time, video devices was not that complex. To use a camera back then, your application software could iterated through /dev/video* devices and pick the camera that you want and then immediately start using it. You could query which pixel formats, frame rates, resolutions and all other properties that are supported by the camera. cover

HID report descriptors and Linux

HID report descriptors and Linux HID Devices USB HID (Human Interface Device) device class is the type of computer peripherals that human interacts with, such as keyboards, mice, game controllers and touchscreens. The protocol is probably one of the most simple protocols in the USB specification. Even if HID was originally written for USB in mind, it works with several other transport layers. Your mouse and keyboard do probably use HID over USB, the touchscreen in your smartphone could use HID over I2C. cover

Industrial I/O and triggers

Industrial I/O and triggers I've maintained a couple of IIO-drivers (MCP3911 [4] and LTC1660 [5]) for some time now and it's time to give at least the MCP3911 a face-lift. This time the face lift includes support for: Buffers Triggers Make the driver interrupt driven Add support for setting Oversampling Ratio Add support for setting PGA (Pre Gain Amplifier) Also clean it up a bit by only using device managed resources. cover