RSSAmplifier

Blog

Marcus Folkesson

Recent content on Marcus Folkesson

marcusfolkesson.seRSS feed ↗183 posts

Latest posts

Electricity price on an e-Paper display

Electricity price on an e-Paper display I've written before about how much the electricity price varies here in Sweden during the day [1]. It's usually cheapest at night and most expensive in the morning and evening, but "usually" is doing a lot of work in that sentence - some days it's the exact opposite, and every now and then a price spike will make an hour or two absurdly expensive.

Making coffee difficult

Making coffee difficult Let's start this post with a video I found on Instagram [1]:
I found this video incredibly fun as it reminds me of my own discussions about coffee.
Me & Coffee A bit of my history I have been drinking coffee since even before I started elementary school. That's how it is growing up in a farming community; coffee and buns at 1PM for everyone. Then back to work for…

memtrack and memview - tracking down memory leaks with LD_PRELOAD

memtrack and memview - tracking down memory leaks with LD_PRELOAD This time I want to share a neat application I wrote to track down memory leaks in long-running, multithreaded applications without having to recompile or relink them. It consists of two parts: memtrack, an LD_PRELOAD library that logs every allocation and free, and memview, a curses-based viewer that lets you browse the log and…

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]…

Rooting a VMC2040 security camera part 7: Conclusion and summary

Rooting a VMC2040 security camera part 7: Conclusion and summary Brief In this part we are going to give some thoughts about the security of the camera and what to do to prevent this kind of attack.
The other parts of the series are:
Part1: Basic examination Part2: Extract the firmware Part3: Analyse the boot sequence Part4: Deeper analysis Part5: What didn't work Part6: What did work…

Rooting a VMC2040 security camera part 6: What did work

Rooting a VMC2040 security camera part 6: What did work Brief In this part I will show how I finally got root access to the camera.
The other parts of the series are:
Part1: Basic examination Part2: Extract the firmware Part3: Analyse the boot sequence Part4: Deeper analysis Part5: What didn't work Part6: What did work Part7: Conclusion and summary What about those symlinks in /config?…

Rooting a VMC2040 security camera part 5: What didn't work

Rooting a VMC2040 security camera part 5: What didn't work Brief In this part I will write down the things I tried that didn't work.
The other parts of the series are:
Part1: Basic examination Part2: Extract the firmware Part3: Analyse the boot sequence Part4: Deeper analysis Part5: What didn't work Part6: What did work Part7: Conclusion and summary U-Boot Environment The first thing I…

Rooting a VMC2040 security camera part 4: Deeper analysis

Rooting a VMC2040 security camera part 4: Deeper analysis Brief This part will focus on gathering as much information as possible about the system. As I in this stage don't know what I'm looking for, I will just try to document everything I find interesting.
The other parts of the series are:
Part1: Basic examination Part2: Extract the firmware Part3: Analyse the boot sequence Part4:…

Rooting a VMC2040 security camera part 3: Analyze the boot sequence

Rooting a VMC2040 security camera part 3: Analyze the boot sequence Brief In this part we will go through the init script to see what (and how!) services are started during the boot.
The other parts of the series are:
Part1: Basic examination Part2: Extract the firmware Part3: Analyse the boot sequence Part4: Deeper analysis Part5: What didn't work Part6: What did work Part7: Conclusion…

Rooting a VMC2040 security camera part 2: Extract the firmware

Rooting a VMC2040 security camera part 2: Extract the firmware Brief As there were no exposed vulnerabilities via UART (no TX, only RX) or network (no open ports that could be exploited), I decided to extract the firmware from the SPINAND flash.
This part of the series is about the process of extracting the firmware and analyzing it.
The other parts of the series are:
Part1: Basic…

Rooting a VMC2040 security camera part 1: Basic examination

Rooting a VMC2040 security camera part 1: Basic examination Brief My friend had a Arlo VMC2040 security camera [1] on his shelf. He bought it a while ago, but never really used it as it required a subscription to work properly. The only feature that he wanted was to get the video stream out from the camera without any cloud involvement, but that was unfortunately not possible.
Here in Sweden…

TIL - DNS queries with multiple interfaces

TIL - DNS queries with multiple interfaces TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post
I must admin that I'm not one of those network gurus that knows everything about every protocol out there and how they work. But I have a pretty good understanding how things works, or at least that's what I tell…

Tracing function calls in C with -finstrument-functions

Tracing Function Calls in C with -finstrument-functions Some time ago, I wrote a blog post about mutex guards in the Linux kernel [1]. It uses a cool feature in GCC which allows you to cleanup resources when they go out of scope. I have a few of such GCC features that I use every now and then, which often show itself handy in the most unexpected way. -finstrument-functions is one of those.

Reverse engineer a serial key validator

Reverse engineer a serial key validator A bit of nostalgia As many kids in my generation, I grew up with video games and the big question was always "Who is gonna be the host for the LAN party this weekend?". Same question. Every. Single. Weekend.
This was in late 90s, and we were about 10-12 years old, so we did not have a lot of money. We were lucky to have network equipment (mostly cables,…

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".

Naming your serial ports with udev

Naming your serial ports with udev Brief UART is still a very common way to communicate with embedded systems, in fact, I would say that it is the most common way. When looking around in my lab, I can see that I have four different development boards/projects connected via UART to my computer. Two of them even use more than one port.
My point is that when you have many serial ports connected…

Remotely controlled USB hub

Remotely controlled USB hub This is no fancy project, but I thought it might be useful for someone out there. There is probably better ways to do this, but this is what I came up with.
My situation For those who haven't read my previous post [1], I have recently bought two (yes, TWO!) Rigol DP832 power supplies to power my lab equipment. (I really love them and will never use a…

GNSS spoofing using SDR

GNSS spoofing using SDR First of all, sending false GNSS signals on the air is illegal in most countries. You must have a controlled RF environment (Faraday cage or such) to perform GNSS spoofing experiments. A box covered with aluminum foil with copper tape in all joints works quite well, but be sure everything (holes for cables, joints etc) are properly shielded.
The best is to not transmit…

Using AI to write me a tool

Using AI to write me a tool Brief This is my first attempt at using claude-sonnet-4.5 to help me write code using Github copilot.
I recently bought a Rigol DP832 programmable power supply [1] , which is actually a very nice piece of hardware for the price. The sad truth is that the main reason for buying it was that my old PSU is quite noisy, and I thought that a newer one would be quieter.

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,…

I2C Bus Recovery

I2C Bus Recovery Brief I was working on a project where we had a problem with an I2C bus that was sporadically hanging during communication with a certain device. I2C works with open-drain lines, which means that devices can only pull the lines low, and a pull-up resistor is used to pull the line high. If a device misbehaves and holds one of the lines low, the bus will be stuck, and no further…

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…

Repair of my Fluke 179 multimeter

Repair of my Fluke 179 multimeter My belowed Fluke 179 multimeter suddenly stopped working. There was no display, no beeps, nothing. I have had this multimeter for many (12+) years, and it has been a reliable companion in my projects.
Fluke has a lifetime warrenty, but that only applies to the original owner, and I bought it second hand.
Troubleshooting Here is what I did to troubleshoot…

Running mtest with U-Boot

Running mtest with U-Boot Memory is, of course, a very important part of any embedded system. They come in different speeds, types, sizes, requirements and technologies. All with different requirements on both software configuration and hardware design.
With that said, it is easy to get something wrong, and memory issues are not the easiest thing to debug as the symptoms can be very different…

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…

An attempt to learn blindfolded chess

An attempt to learn blindfolded chess This is one of my more unusual projects, but I still think it is worth sharing.
First of all, I do not consider myself as a skilled chess player. I would not say that I'm bad, but I have a lot more to learn. My ELO at Lichess is about 1400. I have played chess since I was a kid, but I have never been serious about it.

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…

Repair of Sennheiser Momentum True Wireless earbuds

Repair of Sennheiser Momentum True Wireless earbuds I have a pair of Sennheiser Momentum True Wireless (MTW3) earbuds that had been lost for a while. Once I found them, they had been laying around for a while and the battery was completely drained. I tried to charge them, but they did not charge at all. They are completely dead.
Here they are.
What I could see, there was no obvious way to…

Don't forget the Jira tag in your git message

Don't forget the Jira tag in your git message I keep forgetting to add the Jira tag in my git messages. This is a problem as we use Jira for our project management and the Jira tag is used to link the commit to the issue. It is simply hard to get into my workflow for some reason.
Some time ago, I wrote about pre-commit [1], a framework for managing and maintaining pre-commit hooks for git.

Control of my geothermal heat pump

Control of my geothermal heat pump The electicity price in Sweden varies a lot during the day. It's usually cheapest during the night and most expensive during the day, but not always.
One day a week ago, it was not much wind in Germany and therefore we exported electricity there which resulted in very high prices here in Sweden. 1 kWh cost over 10 SEK (almost 1 USD per kWh) for a few hours,…

UBI volumes in Yocto

UBI volumes in Yocto These days, managed NAND flash memories such as eMMC or SD-cards has become more common in the embedded Linux systems as they abstract (or hide..) the complicated raw NAND memory under the hood. Even if raw NAND memories are more complicated to handle, they are still used in many new products out there.
When working with raw NAND flashes, UBI [1] with UBIFS on top of that…

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…

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…

TIL - suid_dumpable

TIL - suid_dumpable TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post
Ever notice that you can't get a coredump from a process running with extra privileges like capabilites or setuid?
This is related to a previous post [1] about some restrictions that is applied to such processes. I suggest to read…

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…

Restoring a power hammer

Restoring a power hammer I have bought myself a power hammer - something that I have wanted for a long time. It is a Abno nr1, a swedish made 25kg spring hammer. It has been unused for many years and is in need of a little restoration.
The last Abno hammers were manufactured in the sixties, so it is at least 60 years old. I've seen 60 year olds in worse condition than this, although there are…

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…

Writing a UART driver for Linux

Writing a UART driver for Linux Today we are going to write a UART driver for Linux!
UART (Universal asynchronous receiver-transmitter) is one of the most common device-to-device communication protocols that almost every SoC or microcontroller has hardware support for. Most SoC has several UART ports, but sometimes that is not enough as in this case.
Background I'm working in a project…

Include code from a file with Hugo

Include code from a file with Hugo First of all, all credit goes to Marcus Olsson [1] who pretty much wrote this Hugo Shortcode [2] which I only have made some small changes to.
I also refer to his post [3] for a good explanation on how it works.
Background I prepare for some bigger posts with a lot of code examples where I only want to show fragments of a whole file.

TIL - make pacman-pkg

TIL - make pacman-pkg TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post&#xA;v6.11 of the upstream kernel makes it really easy to do kernel devlopment on Arch Linux with the new make pacman-pkg target [1]:&#xA;commit c8578539debaedfbb4671e1954be8ebbd1307c6f Author: Thomas Weißschuh <linux weissschuh.net> Date:…

&#34;You are the primary manager for this project&#34;

"You are the primary manager for this project" Yes I'm. But also:&#xA;THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF…

Restrictions that comes with capabilities

Restrictions that comes with capabilities I debugged an interesting problem this weekend related to which impact capabilities could have on a running process in a Linux system.&#xA;I already knew that there are some security restrictions for applications that setuid/setgid or have capabilities set. One example is that LD_LIBRARY_PATH is silently ignored for an application with capabilities. You…

TIL - strace and capabilites

TIL - strace and capabilities TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post&#xA;strace [1] is a terrific tool to trace system calls and signals for a specific command.&#xA;The fact that programs using the setuid bit do not have the effective user ID priviliges when being traced was something I already…

TIL - interactive shell script

TIL - interactive shell script TIL, Today I Learned, is more of a "I just figured this out: here are my notes, you may find them useful too" rather than a full blog post&#xA;Tody I saw this line in a script:&#xA;1INTERACTIVE='' && [[ -t 0 ]] && INTERACTIVE='-it' that later on started a container:&#xA;1docker run --rm ${INTERACTIVE} -v '${PWD}':/home/br-user \ 2 --user '$(id -u)':'$(id -g)' \ 3…

Board bring-up part 4: Wrap it up

Board bring-up part 4: Wrap it up I'm currently working with a board bring up for a custom hardware based on a OMAPL138 from Texas Instruments. It is fun to work with "real" bring-ups. Most of my customers use System On Modules (SoM:s) these days. You get a lot for free with those modules but a lot of the fun is stripped away.&#xA;This post is not intended to be guide, it is more of a…

Board bring-up part 3: Other peripherals

Board bring-up part 3: Other peripherals I'm currently working with a board bring up for a custom hardware based on a OMAPL138 from Texas Instruments. It is fun to work with "real" bring-ups. Most of my customers use System On Modules (SoM:s) these days. You get a lot for free with those modules but a lot of the fun is stripped away.&#xA;This post is not intended to be guide, it is more of a…

Board bring-up part 2: NAND flash

Board bring-up part 2: NAND flash I'm currently working with a board bring up for a custom hardware based on a OMAPL138 from Texas Instruments. It is fun to work with "real" bring-ups. Most of my customers use System On Modules (SoM:s) these days. You get a lot for free with those modules but a lot of the fun is stripped away.&#xA;This post is not intended to be guide, it is more of a…

Board bring-up part 1: Memory hassle

Board bring-up part 1: Memory hassle I'm currently working with a board bring up for a custom hardware based on a OMAPL138 from Texas Instruments. It is fun to work with "real" bring-ups. Most of my customers use System On Modules (SoM:s) these days. You get a lot for free with those modules but a lot of the fun is stripped away.&#xA;This post is not intended to be guide, it is more of a…

Forge a kitchen knife

Forge a kitchen knife Another attempt to forge a knife. The metal I use for this project is part of a feather harrow that I collected from my father farm.&#xA;I cut out a ~8x4cm long piece from the springs of the feather harrow:&#xA;Bosse (the dog) never leaves me, so I got him a sack to snuggle down on at the outside of the garage.&#xA;I used the gas forge for the entire project.

--build, --host and --target explained

--build, --host and --target explained Too often I see abuse of the --host, --build and --target options during (cross-)compilation of code using autotools. The feeling is more that people try different values until it seems to produce what they want without knowing what they are actually doing.&#xA;But who can blame them. What these parameters do is not obvious and very few people compile their…