A Hacker’s Introduction To DIY Light Guide Plates

Last year, I found myself compelled to make a scaled-down replica of the iconic test chamber signs from the video game Portal. If you’ve played the game, you’ll remember these signs as the illuminated monoliths that postmarked the start of every test chamber. In hyperstylized video game fashion, they were also extremely thin.

Stay tuned for cake at the end of this article.

True to the original, my replica would need to be both slimmed down and backlit with a uniform, natural white glow. As fate would have it, the crux of this project was finding a way to do just that: to diffuse light coming in from the edges so that it would emit evenly from the front.

What I thought would be quick project ended up being a dive down the rabbit hole that yielded some satisfying results. Today, I’d like to share my findings and introduce you to light guide plates, one of the key building blocks inside of much of today’s backlit screen technology. I’ll dig into the some of the working principles, introduce you to my homebrew approach, and leave you with some inspirational source code to go forth and build your own. Continue reading “A Hacker’s Introduction To DIY Light Guide Plates”

Laptop Motherboard? Let’s Boot And Tinker

Last time, I’ve shared my experience on why you might want to consider a laptop motherboard for a project of yours, and noted some things you might want to keep in mind if buying one for a project. Now, let’s go through the practical considerations!

Making It Boot

Usually, when you plug some RAM and a charger into a board, then press the power button, your board should boot up and eventually show the BIOS on the screen. However, there will be some caveats – it’s very firmware-dependent. Let me walk you through some confusing situations you might encounter.

If the board was unpowered for a while, first boot might take longer – or it might power on immediately after a charger has been plugged in, and then, possibly, power off. A bit of erratic behaviour is okay, since boards might need to do memory training, or recover after having lost some CMOS settings. Speaking of those, some boards will not boot without a CMOS battery attached, and some will go through the usual ‘settings lost’ sequence. Sometimes, the battery will be on a daughterboard, other times, especially with new boards, there will be no CR2032 in sight and the board will rely on the main battery to provide CMOS settings saving functions – in such case, if you don’t use the battery, expect the first boot to take longer, at least. Overall, however, pressing the power switch will cause the board to boot. Continue reading “Laptop Motherboard? Let’s Boot And Tinker”

Laptop Motherboard? No, X86 Single-Board Computer!

Sometimes a Raspberry Pi will not cut it – especially nowadays, when the prices are high and the in-stock amounts are low. But if you look in your closet, you might find a decently-specced laptop with a broken screen or faulty hinges. Or perhaps someone you know is looking to get rid of a decent laptop with a shattered case. Electronics recycling or eBay, chances are you can score a laptop with at least some life left in it.

Let’s hack! I’d like to show you how a used laptop motherboard could be the heart of your project, and walk you through some specifics you will want to know.

And what a great deal it could be for your next project! Laptop motherboards can help bring a wide variety of your Linux- and Windows-powered projects to life, in a way that even NUCs and specialized SBCs often can’t do. They’re way cheaper, way more diverse, and basically omnipresent. The CPU can pack a punch, and as a rule PCIe, USB3, and SATA ports are easily accessible with no nonsense like USB-throttled Ethernet ports.

Continue reading “Laptop Motherboard? No, X86 Single-Board Computer!”

All About USB-C: Replying Low-Level PD

Last time, we configured the FUSB302 to receive USB PD messages, and successfully received a “capability advertisement” message from a USB-C PSU. Now we crack the PD specification open, parse the message, and then craft a reply that makes the PSU give us the highest voltage available.

How did the buffer contents look, again?

>>> b
b'\xe0\xa1a,\x91\x01\x08,\xd1\x02\x00\x13\xc1\x03\x00\xdc\xb0\x04\x00\xa5@\x06\x00<!\xdc\xc0H\xc6\xe7\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

The zeroes at the end might look non-significant, and they indeed are not with 99.99% certainty – that said, don’t just discard the entire tail end; one of the bytes in the beginning encodes the length of the message. We’ll read those bytes first, and then read only exactly as much as we need, making sure we aren’t reading two messages and interpreting it as one, and that we’re not discarding zeroes that are part of the message.

Today, we will write code that parses messages right after reading them from the FIFO buffer – however, keep this message handy for reference, still; and if you don’t have the hardware, you can use it to try your hand at decoding nevertheless. If you wanna jump in, you can find today’s full code here!

Continue reading “All About USB-C: Replying Low-Level PD”

All About USB-C: Talking Low-Level PD

In this USB-C series, we’ve covered quite a bit of USB-C – things that are well known, things that should be  better known, and a couple things that just appeared online for the first time. We’ve covered almost everything in some depth except USB Power Delivery. I’ve described the process a bit in the “Power” article, but that was mostly about how to use PD by simply buying the right solution. However, that’s not enough for a hacker. Let’s see if we can make our own PD trigger board. Continue reading “All About USB-C: Talking Low-Level PD”

All About USB-C: Resistors And Emarkers

If you’ve been following along our USB-C saga, you know that the CC wire in the USB-C cables is used for communications and polarity detection. However, what’s not as widely known is that there are two protocols used in USB-C for communications – an analog one and a digital one. Today, let’s look at the analog signalling used in USB-C – in part, learn more about the fabled 5.1 kΩ resistors and how they work. We’ll also learn about emarkers and the mysterious entity that is VCONN!

USB-C power supply expects to sense a certain value pulldown on the CC line before it provides 5 V on VBUS, and any higher voltages have to be negotiated digitally. The PSU, be it your laptop’s port or a charger, can detect the pulldown (known as Rd) because it keeps a pullup (known as Rp) on the CC line – it then checks if a voltage divider has formed on CC, and whether the resulting voltage is within acceptable range.

If you plug a device that doesn’t make a pulldown accessible through the CC wire in the cable, your device will never get power from a USB-C port, and would only work with a USB-A to USB-C cable. Even the smarter devices that can talk the digital part of USB-C are expected to have pulldowns, it’s just that those pulldowns are internal to the USB-C communication IC used. A USB-C port that wants to receive power needs to have a pulldown.

This part is well-known by now, but we’ve seen lack-of-resistor failures in cheap devices aplenty, and the colloquial advice is “add 5.1 kΩ resistors”. You might be afraid to think it’s so simple, but you’d be surprised. Continue reading “All About USB-C: Resistors And Emarkers”

All About USB-C: Cable Types

USB-C cables and connectors: these are controversial topics, and rightfully so – I don’t want to pull any punches. I will also show you that things don’t have to be that bad for you, as long as you’re willing to apply a few tricks and adjust your expectations.

Wild West of Wiring

You might have a bunch of USB-C cables, and they all might look exactly the same, but you’ve likely experienced that they’re not the same internally, and often there’s not a label in sight. Yes, it’s pretty bad, and one could argue it’s getting worse.

I’d like to clarify that I’m only talking about USB C male – USB C male cables here. While cables like USB-A to USB-C are popular, they are quite simple; you get USB 2.0 or USB 3.0 data and 2 A of current at most, and the USB-C plug is usually hardwired as “host, will supply five volts”, which is defined by a pullup resistor. Also, while cables like “Type-C to DisplayPort” might look like cables at a glance, they are adapters with a meaningful amount of active circuitry in them.

Purely following the specification, there used to be six types of USB-C to USB-C cables out there. Then, it became eight. Now, I’m afraid, there’s twelve of them, purely following the spec, and there’s way more when counting all the out-of-spec cables. Good news is – for most of the time, majority of these cables will be suitable for simple tasks like charging and data transfer, and situations where you need a very specific cable are going to be rare enough. Still, let’s go through it, and you’ll see that they’re easier to tell apart than it might look. Continue reading “All About USB-C: Cable Types”