Marcus Folkesson

Embedded Linux Artist

How to track down a file descriptor leak?

How to track down a file descriptor leak? I was troubleshooting an application that crashed with "Too many open files" error. The cause is clear - the application is leaking file descriptors. But how do I find out where the leak is happening? Number of open file descriptors The default limitation of open file descriptors is set to 1024 on most Linux systems. It is set as a resource limit [1] and can be set from the terminal using the ulimit command: cover

Shrink disk images

Shrink disk images Brief I wanted to shrink a raw disk image file I had that contained multiple partitions. Nothing unusual at all. I thought there should be multiple tools out there to do this (and I'm sure there are), but the first couple of Google results were just showing some old GUI tools - which I refuse to use. Instead of searching further, I decided to "just do it". cover

Using socat to bridge interfaces

Using socat to bridge interfaces Brief Whenever it comes to connecting two interfaces together on Linux, socat is my go-to tool. It is a flexible tool that basically create links between anything to anything. socat establishes two bidirectional byte streams and transfers data between them. These byte streams could be constructed from a very large set of different types of sinks and sources, which makes it very powerful. When I say anything, I really mean anything. cover

What to expect

What to expect When working in Linux, you’ve probably come across commands that require interactive input — things like typing a password or confirming the same prompt over and over again. This can be frustrating when you want to automate tasks or just need to e.g. type the same range of commands every time your embedded Linux system boots up. This is what expect [1] is used for. So, what is expect? cover

Determine wakeup cause (ACPI)

Determine wakeup cause (ACPI) I had a problem with my laptop to enter suspend mode, when I ran systemctl suspend it would just wake up immediately. Let's find out what causes this. Advanced Configuration and Power Interface (ACPI) First a few words about ACPI. The embedded Linux systems I used to work with usually do not support ACPI, even if support for ACPI starts to show up on some ARM64 and Risc-V boards. cover

Lets talk about ECC and NAND flashes

Lets talk about ECC and NAND flashes Raw NAND flashes are not that common these days. At least not in those projects I have been working with for the last ~8 years. They seem to have been replaced by eMMC for many applications, but there are still some use cases where raw NAND flashes are preferred. In this blog post, we will talk a little about Error Correcting Code (ECC) and NAND flashes as that is such a critical part of the NAND flash technology. cover

Remoteproc, rpmsg and SYSBIOS

Remoteproc, rpmsg and SYSBIOS I'm currently working with a couple of SoCs (OMAPL-138, DRA7xx) from Texas Instruments where both has an C6xx DSP core along with the ARM core. This is no unusual configuration, many modern SoCs today have heterogeneous remote processor devices in asymmetric multiprocessing (AMP) configurations like these two. In this case, the DSP-cores where supposed to run SYS/BIOS with the TI IPC MessageQ stack to communicate with the ARM core. cover

Detect time jumps in Linux

Detect time jumps in Linux Recently I had a case where the application created multiple timers for different events. After the timers were created, the NTP client updates the system time resulting in that all timers being off and needing to be adjusted. Adjusting the timers is one thing, but how do we detect the time jump? It's not the first time I'm in a situation where I have to deal with such time jumps, I guess it's quite a common case, so why not write a few words about it? cover

Protected FIFOs and regular files

Protected FIFOs and regular files Since version 4.19 [1], Linux has the default behaviour to prevent opening of regular files and FIFOs that is not owned by the user in world writable sticky directories. Example on such directory is /tmp/ which usually has the sticky bit set. This may sound obvious, but what is not so obvious is that this restriction also applies to the root user. You can therefore end up in a situation where e. cover

Writing a clocksource driver for Linux

Writing a clocksource driver for Linux Today we are going to write a clocksource [1] driver for Linux! A clocksource in a Linux system is one of several parts of the kernel timekeeping abstractions. The clocksource is the timeline of the Linux system and is the one you go to whenever you issue the command date. To do this, the clocksource should provide a monotonic, atomic counter that is as accurate as possible. cover