RP2040 Boot Loader Is A Worm

[Hunter Adams] has written a secondary bootloader for the RP2040 that uses an IR link and can be extended to behave like a polite worm virus. This allows the easy updating of a large cluster of co-located RP2040-based controllers. This could be handy in applications like swarm robotics or virtual cattle fencing. The project he demonstrates in the two videos ( below the break ) uses a pair of IR transmitters/receivers. But he purposely wrote the boot loader to be independent of the serial link, which could be infrared, radio, audio, or just wires.

Not only did [Hunter] make a boot loader, but he documented the entire boot process of the RP2040 chip. Whether or not you need a secondary bootloader, this is an excellent resource for understanding how the RP2040 responds to power cycling and resets. The boot loader code is available at his GitHub repository.

You may recall that [Hunter] is the lecturer of Cornell University’s Designing with Microcontroller classes, whom we’ve mentioned before. We’ve also covered some of his students’ projects as well, like these air drums and this CoreXY pen plotter.

Continue reading “RP2040 Boot Loader Is A Worm”

Blinkenlights To Bootloader: A Guide To STM32 Development

While things like the Arduino platform certainly opened up the gates of microcontroller programming to a much wider audience, it can also be limiting in some ways. The Arduino IDE, for example, abstracts away plenty of the underlying machinations of the hardware, and the vast amount of libraries can contribute to this effect as well. It’s not a problem if you just need a project to get up and running, in fact, that’s one of its greatest strengths. But for understanding the underlying hardware we’d recommend taking a look at something like this video series on the STM32 platform.

The series comes to us from [Francis Stokes] of Low Byte Productions who has produced eighteen videos for working with the STM32 Cortex-M4 microcontroller. The videos start by getting a developer environment up and blinking LEDs, and then move on to using peripherals for more complex tasks. The project then moves on to more advanced topics and divides into two parts, the development of an application and also a bootloader. The bootloader begins relatively simply, and then goes on to get more and more features built into it. It eventually can validate and update firmware, and includes cryptographic signing (although [Francis] notes that you probably shouldn’t use this feature for production).

One of the primary goals for [Francis], apart from the actual coding and development, was to liven up a subject matter that is often seen as dry, which we think was accomplished quite well. A number of future videos are planned as well. But, if you’re not convinced that the STM32 platform is the correct choice for you, we did publish a feature a while back outlining a few other choices that might provide some other options to consider.

Continue reading “Blinkenlights To Bootloader: A Guide To STM32 Development”

Using An Old Smartphone In Place Of A Raspberry Pi

The Raspberry Pi was a fairly revolutionary computing device when it came on the scene around a decade ago. Enough processing power to run a full Linux desktop and plenty of GPIO meant almost certain success. In the past year, though, they’ve run into some issues with their chip supplier and it’s been difficult to find new Pis, which has led to some looking for alternatives to these handy devices. [David] was hoping to build a music streaming server and built it on an old smartphone instead of the ubiquitous single-board computer.

Most smartphones are single-board computers though, and at least the Android devices are fully capable of running Linux just like the Pi. The only problem tends to be getting around the carrier or manufacturer restrictions like a locked bootloader or lack of root access. For [David]’s first try getting this to work, he tried to install Navidrome on a Samsung phone but had difficulties with the lack of memory and had to build the software somewhere else and then load it on the phone. It did work, but the stock operating system kept killing the process for consuming too much memory.

Without root access, [David] decided to try LineageOS, a version of Android which, among other benefits, is typically much more configurable than the stock version of Android that is shipped with smartphones. This allowed him to disable or uninstall anything not needed for his music server to free up enough memory. After some issues with transcoding the actual music files he planned on streaming, his music server was successfully up and running on a phone that would have otherwise been relegated to the junk drawer. The specific steps he took to get this working can be found on his GitHub page as well.

[David] also mentioned looking at PostmarketOS for this job which is certainly a viable option for some, but the Linux distribution for phones is only supported on a few devices. Another viable alternative for a project like this if no Raspberry Pis are available might be any of a number of Pine64 devices that might also be sitting around gathering dust, like the versatile Linux-based Pinephone.

Getting The Most From Fading ThinkPads

The ThinkPad line of laptops has been widely prized not only by businesses but also by those who appreciate a high standard of hardware quality and repairability. But some think the cracks are starting to form in their reputation, as it seems that new ThinkPads are sacrificing quality for aesthetics and cost. As a result a huge modding scene has popped up around models that are a few years old like [Cal] found out when working on this X230.

At first he only made some cosmetic improvements to the laptop like replacing the worn palm rest, but quickly found himself in a rabbit hole with other upgrades like swapping out the keyboard and battery. The new keyboard is a 7-row X220 keyboard, which required modification of the connector and flashing the embedded controller with a hacked image to change the keyboard map without needing to make changes at the OS level. From there, he decided to replace the lackluster screen with a 1920×1080 matte IPS panel using an adapter board from Nitrocaster, and finished off his upgrades with a customized Coreboot BIOS for improved performance and security.

While Coreboot doesn’t remove all of the binary blobs that a bootloader like libreboot does, the latter is not compatible with more modern machines like this X230. Still, you’ll get many benefits from using Coreboot instead of the stock bootloader. For running Linux on a daily driver laptop, we appreciate all of these updates and expect that [Cal] will get plenty of years of use out of his machine. We’ve definitely seen an active modding scene for ThinkPads that were (at the time) seven years old and still going strong, so we’d expect nothing less for this one.

Low-Power Challenge: Making An Analog Clock Into A Calendar With A 50-Year Life

You have to be pretty ambitious to modify a clock to run for 50 years on a single battery. You also should probably be pretty young if you think you’re going to verify your power estimates, at least in person. According to [Josh EJ], this modified quartz analog clock, which ticks off the date rather than the time, is one of those “The March of Time” projects that’s intended to terrify incentivize you by showing how much of the year is left.

Making a regular clock movement slow down so that what normally takes an hour takes a month without making any mechanical changes requires some clever hacks. [Josh] decided to use an Arduino to send digital pulses to the quartz movement to advance the minute hand, rather than let it run free. Two pulses a day would be perfect for making a 30-day month fit into a 60-minute hour, but that only works for four months out of the year. [Josh]’s solution was to mark the first 28 even-numbered minutes, cram 29, 30, and 31 into the last four minutes of the hour, and sort the details out in code.

As for the low-power mods, there’s some cool wizardry involved with that, like flashing the Arduino Pro Mini with a new bootloader that reduces the clock speed to 1 MHz. This allows the microcontroller and RTC module to run from the clock movement’s 1.5 V AA battery. [Josh] estimates a current draw of about 6 μA per day, which works out to about 50 years from a single cell. That’s to be taken with a huge grain of salt, of course, but we expect the battery will last a long, long time.

[Josh] built this clock as part of the Low-Power Challenge contest, which wrapped up this week. We’re looking forward to the results of the contest — good luck to all the entrants!

Trojans Can Lurk Inside AVR Bootloaders

If there’s one thing we’ve learned over the years, it’s that if it’s got a silicon chip inside, it could be carrying a virus. Research by one group focused on hiding a trojan inside an AVR Arduino bootloader, proving even our little hobbyist microcontrollers aren’t safe.

The specific aim of the research was to hide a trojan inside the bootloader of an AVR chip itself. This would allow the trojan to remain present on something like a 3D printer even if the main firmware itself was reinstalled. The trojan would still be able to have an effect on the printer’s performance from its dastardly hiding place, but would be more difficult to notice and remove.

The target of the work was the ATmega328P, commonly used in 3D printers, in particular those using the Marlin firmware. For the full technical details, you can dive in and read the research paper for yourself. In basic terms, though, the modified bootloader was able to use the chip’s IVSEL register to allow bootloader execution after boot via interrupt. When an interrupt is called, execution passes to the trojan-infected bootloader’s special code, before then returning to the program’s own interrupt to avoid raising suspicion. The trojan can also execute after the program’s interrupt code too, increasing the flexibility of the attack. Continue reading “Trojans Can Lurk Inside AVR Bootloaders”

The TinyPICO board and the rocker switch soldered together showing a complete device, shown being held in the air by a crocodile clip

Simple Hardware Switch For OS Dualbooting, Thanks To RP2040

Dualbooting your computer can be a chore, the more switching between OSes you have to do – which is why virtualization or having separate computers are the go-to for many. Failing that, we have no choice but to smooth over our dualbooting experience with various workarounds and helpers. [William Somsky] shares one such helper tool with us – an elegant device made with a RP2040-sporting TinyPICO board and a three-way rocker switch, directing GRUB to boot into either Windows or Linux automatically, or leave us with the usual boot menu. This way, you can just flip the switch, hit “reboot” and walk away, coming back to your PC booted into OS of your choice, instead of timing your presence just so that you can catch the boot menu on time.

All you need to do is to solder a rocker switch to your RP2040 board of choice, then flash the RP2040 with code that detects the state of the switch, and creates a mass storage device hosting a file setting a Grub variable to either one of the 0, 1 or 2. [William] describes his journey, fighting mysterious caching problems, but tells us he got it working in the end. Sadly, [William] hasn’t shared the RP2040-side code with us, but he has at least put the Grub’s custom.cfg file in the ‘Files’ section of the Hackaday.io project.

Readily accessible microcontrollers with mass storage functions sure help make such hacks simple – earlier, we’ve seen dualboot switching like this done by modifying assembly code of the MBR. Dualbooting is a hacker’s rite of passage, and certain OSes of late can make it harder than other ones. Even if you don’t want to dualboot your PC, however, you sure can dualboot an Arduino!