It’s Linux. On An ESP32

By today’s standards, the necessities for running a Linux-based operating system are surprisingly meagre in terms of RAM and processor power. Back in the day we ran earlier Linux versions on Intel 386 and 486 machines with tiny quantities of memory compared to the multi-gigabyte many-core powerhouses we do today.

So it stands to reason that many of the more powerful microcontrollers should also run Linux, but of course they are often unable because the lack a memory management unit. The original ESP32 is just such a candidate, plenty of power but unable to run Linux. Not so fast, because [Dror Gluska] has managed to boot a Linux kernel on Espressif’s dual-core chip. How on earth? By emulating a RISC-V processor on it and booting a RISC-V version of the kernel.

The emulator in question is [Fabrice Belard]’s TinyEMU, a piece of software that brings both RISC-V and x86 to limited-spec platforms, and the write-up describes the extensive optimization and tracing of ESP32 bottlenecks which was finally able to get a Linux kernel booting in 1 minute and 35 seconds. Of course it’s simply an exercise to prove it can be done and we won’t be seeing Linux-based ESP projects any time soon, but it’s still an impressive piece of work.

This isn’t the lowest-spec microcontroller we’ve seen run Linux, back in 2012 we saw it on emulated ARM running on an 8-bit AVR.

A purple PCB with an OLED display and various chips

A Neat Little Tool To Reset The Fuses On Your ATtiny

If you’re an experienced hacker, you’ve probably run into a problem at some point and thought “let’s make a tool to automate that”. A few hours later you’ve got your tool, but then realize that the amount of work you put into making the tool vastly exceeds what you would have needed to solve the original problem manually. That really doesn’t matter though: developing a fancy tool can be a rewarding experience that teaches you way more about the original problem than you would have learned otherwise. [sjm4306]’s ATtiny High Voltage Fuse Reset-er is a clever device that firmly falls into this category.

The problem it solves is familiar to anyone who’s ever worked with Atmel/Microchip’s ATtiny series of microcontrollers: set one of the configuration fuses incorrectly and you’re no longer able to reprogram your chip. Getting the ATtiny back to its original configuration requires a high-voltage programming step that involves pulling the reset pin to 12 V in what’s otherwise a 5 V system. You could simply grab a spare 12 V supply and hack together a level shifter with a few transistors, but where’s the fun in that?

[sjm4306]’s solution is built on a pretty purple PCB that contains an ATmega328, an OLED display, and sockets to accommodate various versions of the ATtiny series microcontrollers. To generate the required 12 V, one could simply use an off-the-shelf boost converter IC. But instead, he decided it would be interesting to make such a circuit out of discrete components and control it using the ATmega. After all, this chip already contains timers to generate PWM signals and an ADC to measure the converter’s output voltage, so all it took was to write some control logic in the form of a PID controller.

The end result, as you can see in the video embedded below, is a convenient little PCB that runs off a 5 V USB power supply and resets the fuses on your ATtiny at the push of a button. Sometimes, simple tools that do one thing well are all you need; however, if you’re looking for an all-in-one AVR programmer that also supports HV programming, check out this AVR Multi-Tool.

Continue reading “A Neat Little Tool To Reset The Fuses On Your ATtiny”

Strange Computer Languages: A Hacker’s Field Guide

Why do we build radios or clocks when you can buy them? Why do we make LEDs blink for no apparent purpose? Why do we try to squeeze one extra frame out of our video cards? We don’t know why, but we do. That might be the same attitude most people would have when learning about esolangs — esoteric programming languages — we don’t know why people create them or use them, but they do.

We aren’t talking about mainstream languages that annoy people like Lisp, Forth, or VBA. We aren’t talking about older languages that seem cryptic today like APL or Prolog. We are talking about languages that are made to be… well… strange.

INTERCAL

We have to start at the beginning. INTERCAL. This was started as a joke in 1972 and the acronym is purportedly for Compiler Language With No Pronounceable Acronym. There was no actual implementation, though, until around 1990. Now there are two: C-INTERCAL and CLC-INTERCAL.

Since INTERCAL is a parody, it makes some very odd choices. For example, bitwise operators like AND operate with two arguments, but one of the arguments is reversed. That is, the top bit of one operand matches the bottom bit of the second operand. In a nod to social convention, there is a modifier known as PLEASE that you should sometimes use when, for example, reading data as in “PLEASE READ IN.” If you don’t use it often enough, the compile will fail warning you that the program is insufficiently polite. However, if you use it too often, you’ll also get an error that your program is excessively polite.

Originally, the implementation used EBCDIC, so it uses some characters that don’t appear on conventional 7-bit ASCII systems. This forced some character substitutions and now, with Unicode, some versions will allow the old-style characters if you prefer them. The INTERCAL manual renames nearly all the special characters for further confusion. A single quote is a “spark” and the equal sign is a “half-mesh”. Only the ampersand remains unscathed.

Want to know more? Be careful what you wish for.

Continue reading “Strange Computer Languages: A Hacker’s Field Guide”

Remoticon 2021: Uri Shaked Reverses The ESP32 WiFi

You know how when you’re working on a project, other side quests pop up left and right? You can choose to handle them briefly and summarily, or you can dive into them as projects in their own right. Well, Uri Shaked is the author of Wokwi, an online Arduino simulator that allows you to test our your code on emulated hardware. (It’s very, very cool.) Back in the day, Arduino meant AVR, and he put in some awesome effort on reverse engineering that chip in order to emulate it successfully. But then “Arduino” means so much more than just AVR these days, so Uri had to tackle the STM32 ARM chips and even the recent RP2040.

Arduino runs on the ESP32, too, so Uri put on his reverse engineering hat (literally) and took aim at that chip as well. But the ESP32 is a ton more complicated than any of these other microcontrollers, being based not only on the slightly niche Xtensa chip, but also having onboard WiFi and its associated binary firmware. Reverse engineering the ESP32’s WiFi is the side-quest that Uri embarks on, totally crushes, and documents for us in this standout Remoticon 2021 talk. Continue reading “Remoticon 2021: Uri Shaked Reverses The ESP32 WiFi”

Mike Szczys at the 2018 Hackaday Superconference

Today Is My Last Day At Hackaday; Thanks For All The Hacks!

I have decided to make a career move and have accepted a position as Developer Relations Engineer at Golioth.io. I’m happy to announce that Elliot Williams will be the next Editor in Chief of Hackaday.

Right now I’m in my 13th year at Hackaday, having started in the summer of 2009. But like all of the Hackaday writing crew, I began as a loyal reader of the site. I remember hearing about Hackaday when Kevin Rose mentioned in on an episode of the old CNET TV program The Screensavers early in 2005. Having already been building robots and just starting on 8-bit AVR microcontrollers, Hackaday was exactly the source of new and interesting projects I was looking for.

Remember when all Hackaday photos looked like this? This one is actually the first time I had a project featured on the site!

An enormous amount has changed since then. When I started as a writer we had just stopped using black and white photos. A few articles later, we removed the CSS that forced all articles to be lowercase. When I became head editor in 2013 we stopped calling it Hack a Day in favor of Hackaday, and about a year later we overhauled the site, moving from green-on-black to yellow-on black and expanding the 470 pixel content width to 800. Progress.

What hasn’t changed is how we stay fresh. Hackaday has always trusted our writers to guide us by following their own interests. The people who write for Hackaday have far better things to do, but they use their writing as a creative outlet to focus on leveling up their skills, to discover new uses of available technology, and to share that energy with the greater Hackaday community. They live all over the world and work in many different fields. These experiences come together in there collective writings. I’m lucky to have this great group of writers, and so are you. When their time has ended, the hope is that a new group of readers will step up to the plate and make sure the good times never end.

Continue reading “Today Is My Last Day At Hackaday; Thanks For All The Hacks!”

Up Close And Personal With Some Busted Avionics

When he found this broken Narco DME 890 that was headed for the trash, [Yeo Kheng Meng] did what any self-respecting hardware hacker would do: he took it back to his workbench so he could crack it open. After all, it’s not often you get to look at a piece of tech built to the exacting standards required by even outdated avionics.

DME stands for “Distance Measuring Equipment”, and as you might expect from the name, it indicates how far the aircraft is from a given target. [Yeo Kheng Meng] actually goes pretty deep into the theory behind how it works in his write-up if you’re interested in the nuts and bolts of it all, but the short version is that the pilot selects the frequency of a known station on the ground, and the distance to the target is displayed on the screen.

Inside the device, [Yeo Kheng Meng] found several densely packed boards, each isolated to minimize interference. The main PCB plays host to the Mostek MK3870 microcontroller, an 8-bit chip that screams along at 4 MHz and offers a spacious 128 bytes of RAM. It doesn’t sound like much to the modern AVR wrangler, but for 1977, it was cutting edge stuff.

Digging further, [Yeo Kheng Meng] opens up the metal cans that hold the transmitter and receiver. Thanks to the excellent documentation available for the device, which contains extensive schematics and block diagrams, he was able to ascertain the function of many of the components. Even if you’re unlikely to ever go hands on with this type of technology, it’s fascinating to see the thought and attention to detail that goes into even seemingly mundane aspects of the hardware.

Hungry for more airworthy engineering? We’ve taken a close look at some hardware pulled from a civilian airliner, as well as some battle-hardened electronics that once graced the cockpit of an AH-64 Apache attack helicopter.

DIY Forth On Arduino

On a recent rainy afternoon, [Thanassis Tsiodras] decided to build his own Forth for the Arduino to relieve the boredom. One week of intense hacking later, he called it done and released his project as MiniForth on GitHub. [Thanassis] says he was inspired by our series of Forth articles from a few years back, and his goal was to build a Forth interpreter / compiler from scratch, put it into a Blue Pill microcontroller. That accomplished, he naturally decides to squeeze it into an Arduino Uno with only 2K of RAM.

Even if you are ambivalent about the Forth language, [Thanissis]’s project has some great ideas to check out. For example, he’s a big proponent of Makefile automation for repetitive tasks, and the project’s Makefile targets implements almost every task needed for development, building and testing his code.

Some development and testing tasks are easier to perform on the host computer. To that end, [Thanassis] tests his programs locally using the simavr simulator. The code is also portable, and he can compile it locally on the host and debug it using GDB along with Valgrind and AddressSanitizer to check for memory issues. He chose to write the program in C++ using only zero-cost abstractions, but found that compiling with the ArduinoSTL was too slow and used too much memory. No problem, [Thanassis] writes his own minimalist STL and implements several memory-saving hacks. As a final test, the Makefile can also execute a test suite of Forth commands, including a FizzBuzz algorithm, to check the resulting implementation.

Here’s a short video of MiniForth in action, blinking an LED on an UNO, and the video below the break shows each of the various Makefile tasks in operation. If you want to learn more, check out Elliot Williams’s Forth series which inspired [Thanassis] and this 2017 article discussing several different Forth implementations. Have you ever built your own compiler? Let us know in the comments below.

Continue reading “DIY Forth On Arduino”