return to table of content

I turned my ThinkPad into a programmable USB device

aendruk
53 replies
2d1h

One thing I’ve always wondered is why it’s not common to be able to use a laptop as a generic keyboard and monitor for another computer. For doing maintenance on a headless machine it feels silly to go buy a keyboard and monitor when my laptop already is those.

ThrowawayTestr
13 replies
2d1h

The inability to simply connect one computer to another has always bothered me. Apparently there's a mode in USB 4 which will allow this.

ssl-3
5 replies
1d21h

There was a time when FireWire did that kind of thing -- not specifically with remote displays, but providing a high-bandwidth (for the time) wired network link between two PCs.

At home, in the Ye Olde 10/100 Ethernet days, sometimes I plugged my laptop into my desktop with 400Mbps FireWire to transfer big files.

No special cable required; any dumb FireWire cable with the right connectors on each end ("big" for the desktop, "little" for that particular laptop) worked just fine between any two FireWire devices.

LoganDark
4 replies
1d13h

You talking about Target Display Mode? Or did that never support FireWire?

ssl-3
3 replies
1d13h

I think Display Target Mode only worked with Thunderbolt, which was different.

I just used Firewire (er... maybe IEEE-1394, since it was in PC space) as a temporary and fast network connection for running (eg) IP stuff and file transfers with SMB, but it could have been used permanently.

At the time, plugging a Firewire cable in betwixt two Windows machines generated this network automatically, with RFC 3330 addresses for each end.

It just worked; each machine could be addressed by name nearly instantly after connection, and whatever file shares they had available could then be accessed with the same mechanisms that would be used on the normal Ethernet LAN.

I never did anything particularly complex with it.

ssl-3
1 replies
1d

TIL.

That's completely fantastic.

What was old is now new again.

LoganDark
0 replies
23h56m

One of the extremely rare cases where modern technology can actually do what was trivial decades ago.

bmicraft
0 replies
1d15h

Yeah but then you're limited to Ethernet speeds, which (if even present on a modern laptop) is often 1/20th the speed of its fastest USB port. I just want to image the SSD without disassembling the laptop, damnit

ThrowawayTestr
0 replies
1d7h

Sure, but then you have to set ip addresses and network shares, it's a pain.

rusk
1 replies
2d

RS232 null modem ftw!

dekhn
0 replies
1d1h

At some point in college (in the mid 90s) I had a Linux box and a Sun box (pre-solaris) and had them connected up using X11 over SLIP over RS232 with a null modem and gender changer. The sun workstation could be completely controlled through RS232- you could reset the machine, do stuff to the boot system, etc. IIRC the max baud I could use was 19200, or maybe 38400.

mixmastamyk
0 replies
1d17h

I just did this but had to buy a special tb4 cable. Just worked, though I had to look up the IP addresses.

RockRobotRock
0 replies
1d17h

Linus showed off a really impressive tech demo which accomplishes that: https://www.youtube.com/watch?v=GqCwLjhb4YY

I would link another source if I can, but there's almost nothing I could find about Thunderbolt Share.

leonheld
11 replies
2d1h

Everyone uses ssh to do that.

dingnuts
6 replies
2d1h

That's a completely different use-case. SSH doesn't let me control the GUI on the remote

And no, X11 forwarding is not what I mean either

jeffbee
3 replies
2d

So, you'll accept any solution, except the existing ones that work?

XDMCP solves this exact issue. You use one device which becomes virtually an attached terminal of another device which is actually headless and with no input devices of its own. We've had this for 30+ years.

exe34
1 replies
1d22h

XDMCP

muh wayland

pierat
0 replies
1d17h

I'm sure we'll see functionality like that in Wayland.... In a decade or 2.

pessimizer
0 replies
2d

No, we already use the solutions that actually work, and are speculating why there isn't one with the simple, obvious user experience. Why shouldn't we?

bee_rider
1 replies
2d

There is/was a tool called x2x, which somehow let you send your input (mouse/keyboard) to another machine (I think via X forwarding tricks, although I don’t know how it worked, so I could be wrong).

I tried it around a decade ago and at the time it felt a bit abandoned. I vaguely remember that it might not have worked with every window manager? Anyway, I assume it hasn’t got better supported since then. But it did feel magical.

ssl-3
0 replies
1d21h

x2x worked fine for input devices.

Later, things like x2vnc made the idea more cross-platform (X on the local unix-like box, VNC on some other platform), but only with two machines.

After that, Synergy became a thing, and supported many machines, but then they eventually went to a model that tended to require payment.

Later, Barrier forked from Synergy, and it allows much of the same functionality. It's still very free, and it still works, but it's kind of abandoned.

Today, there's Input Leap. It is (naturally) a fork of Barrier, and it is still sees regular development.

https://github.com/input-leap/input-leap

calamari4065
2 replies
1d22h

And what do you do when your ssh server stops working, or there's a hardware fault, a network fault, a failed OS upgrade?

filoleg
1 replies
1d21h

Idk about all machines ever, but I remember being able to access ssh over a serial port.

Though in that specific case for me, it was more of a necessity rather than just a quirky way of using ssh (due to the “machine” just being a dev board with a UART ESP32).

calamari4065
0 replies
1d20h

To access the serial port remotely you need to add hardware to bridge it to the network. Or you go up to the machine and plug in another computer with a keyboard and monitor to access it directly.

aendruk
0 replies
2d

…except for when they can’t. The relevant retort would be that I could instead be using hardware with a remote management interface like IPMI, and building a custom OS installation image with remote access preconfigured. But even then I’m not sure how you’d have me troubleshoot surprise network issues.

nfriedly
6 replies
1d23h

The GPD Pocket 3 has a KVM module that lets you do exactly this: it has HDMI & USB-C inputs and then it acts as a display, keyboard, and mouse for whatever machine it's connected to: https://gpd.hk/gpdpocket3

There's also the up-and-coming Minisforum V3 tablet that has a video input so that it can act as an external monitor, but I don't think it'll be able to share it's keyboard and mouse.

I agree with you, though, it really would be nice if this were a more common feature.

bodge5000
3 replies
1d20h

Not much of a hardware guy so don't know if this is at all plausible, but it'd be nice to see that as an extension port on the framework laptops.

That surely is the advantage of having modular ports. This is a fairly niche application so I can see why it's not a standard option, but for those who want it it could be a real game changer.

pbronez
2 replies
1d19h

That’s a neat concept. Are there any products that take a video input and USB A connection, combine into USB C and act as a KVM?

I can’t even think what that would be called, TBH. It’s hard to search for.

Zircom
1 replies
1d18h

Something like this maybe? Can use USB C or HDMI+USB A depending

https://www.amazon.com/Dopesplay-Wireless-Portable-Touchscre...

I've had some success searching "lapdock" as well, they're marketed towards using them with smartphones it looks like but can't see why you couldn't plug it into a server or computer as well.

bryanrasmussen
0 replies
1d10h

I had one of those - not that exact one, it was great but I forgot it on the train one day.

xeonmc
0 replies
1d19h

It would be even better if Framework laptops could do that since they’re all about parts reuse.

idiotsecant
0 replies
1d3h

Wow what a cool little piece of hardware! If it was just a bit smaller and had a radio for it, it would be an amazing phone

myself248
5 replies
2d

Seriously. A friend of mine built a cyberdeck specifically for this -- his mouse and keyboard can be switched to an external port and then cabled to another machine, and there are two HDMI ports on the side, one output and one input, with an internal switch to select either the deck's own machine, or the external input, as the source for the deck's monitor.

WillAdams
4 replies
2d

Has your friend done a write-up or parts list or build?

I think this would be a big hit on Hackaday or some similar site.

speed_spread
3 replies
1d21h

An OrangePi 5 Plus would be a good starting platform for this because of the HDMI input port.

RockRobotRock
1 replies
1d17h

what?? Can you run PiKVM on it?

speed_spread
0 replies
1d3h

I didn't know about PiKVM. I have no idea if it will run. Probably not as-is.

myself248
0 replies
1d19h

Oooo.

mrb
4 replies
1d13h

As someone who often deals with headless machines, the best solution I have found for using my laptop as a monitor is this: https://www.amazon.com/dp/B0BJ2YDV7Q It's basically a chip to capture the HDMI signal from a headless machine, and expose an emulated webcam via USB to your laptop. It's so tiny the electronic is basically built into the cable.

For the keyboard I haven't found a good solution other than buying a standard wireless keyboard (with integrated trackpad, for the rare cases where a mouse is needed).

rfoo
0 replies
1d9h

For the keyboard I use a CH340+CH9329 cable, the former is a USB to UART converter and the latter is a UART to USB-HID converter. Feels unnecessarily complicated but hey at least it's only $3. It's effectively a USB "keyboard" controlled by another host.

Then I use a ~30 line Python script to forward key press to it. I really hope someone make a better integrated solution (or me having time to do it), though.

btgeekboy
0 replies
1d11h

That's basically what I do as well. I combined a similar HDMI dongle with a Logitech K400 Plus wireless keyboard+trackpad combo. It's an absolutely terrible membrane keyboard for everyday use, but having the trackpad and keyboard in the same device, using the same single dongle that has a storage slot in the keyboard makes things really easy for light, occasional use.

bryanrasmussen
0 replies
1d10h

So if you have a broken monitor on your M1 with this can you use it on your other laptop? Because my broken M1 has a working keyboard.

RCitronsBroker
0 replies
1d11h

Thats genius

justsomehnguy
3 replies
1d18h

Costs, extremely low demand, no standard interconnect and interfaces, anything non-standard wouldn't work with dead OS, costs.

aaronblohowiak
2 replies
1d15h

Can’t it all be acccomplished in Software with usb-c?

justsomehnguy
1 replies
1d8h

You still need software support for it on the host device.

While you can imitate Keyboard and Mouse (and they would work through boot or without OS), Video is out of question for now.

And while there is still some value on it using on a healthy system, most of the time KVM device is needed when something is not working.

NB there is/was Intel ATM which provides (at least on paper and on rare, extremely rare posts on Internet) KVM-like experience and power control. Theoretically it can be used as the basis for single USB port KVM interface.

aaronblohowiak
0 replies
5h10m

Thanks!

guenthert
1 replies
1d10h

Oh me too, but that's now quite a few years ago. These days we have IPMI, no?

aendruk
0 replies
1d6h

You can deduce the answer by charitably interpreting that the situations in which I’m attaching a keyboard and monitor are those in which that’s a reasonable action.

boneitis
0 replies
1d12h

Thanks for posting this. It is pretty much solving a major pain point for me (as is TFA, seemingly on a brief skim), even if with some usability friction.

I have a Flipper Zero and have always fantasized about having some sort of VMware/VirtualBox-like application that operates in a capture mode to forward all inputs to another device (similarly as to the guest machine in the VM player) with a keyboard shortcut to release the HIDs back to the host.

In the Flipper Zero's case (or any SBC/SOC/microcontroller/whatever-term-is-appropriate), it would be so lovely to be able to operate in all four combinations of:

Host - BT - Flipper - BT - Second device

Host - USB - Flipper - BT - Second device

Host - BT - Flipper - USB - Second device

Host - USB/GPIO - Flipper - USB/GPIO - Second device

Unfortunately, I don't work so close to the hardware, so I've no idea where to even begin with this. A man can dream. Sigh.

molave
0 replies
1d22h

My laptop's monitor went bust and now serves as a glorified CPU.

zzz999
6 replies
1d17h

You can do that with cheap ESP boards worth about $3

JoBrad
3 replies
1d17h

Yes, but now you can do it with a laptop!

zzz999
2 replies
1d12h

Sure could, but it is almost the most inefficient way... I guess it works for experimentation

zokier
1 replies
1d12h

Sure, dinky ESP works if you want to just do trivial gadgets. But for stuff like facedancer embedded solutions start to become actually quite limiting

zzz999
0 replies
17h18m

Most people are surprised what an ESP can do when you show them

extraduder_ire
1 replies
1d16h

Do you mean by wiring up the GPIO, or via their USB port? Any esp 8266/32 I have used has only had a cheap serial adapter on the USB port.

zzz999
0 replies
1d15h

You can get USB otg on esp... Like the s2... I did a rubber ducky using those

steelbrain
6 replies
2d

This is really interesting. I've been researching some viable options like this. I have a beefy Network Attached Storage (NAS) server that I actively look for excuses to make use of. I have connected with some 40g and 10g interconnects for it across the house. I also have a PS5 & XBox that use USB hard-drives for additional storage.

I looked into whether I could expose my NAS storage to PS5 & XBox. Turns out that it's possible! It's possible by mounting the NAS shares over iSCSI or NFS, and then emulating a USB storage device using the g_mass_storage module that exposes said storage to USB hosts.

Besides time and cost, one major blocker for me right now is the bandwidth that such a system would provide. It's just not that big of an upgrade. Raspberry Pi very famously supports USB-OTG (similar/same as xDCI), but it only does so with USB 2.0 speeds, and so do all the other SBCs in that class that I found, except for one, RockPi4. RockPi has a Gigabit ethernet port, so if you max out ethernet, you can provide stable HDD speeds to both the PS5 & Xbox.

It would be really interesting to explore a solution where you have the ability to plug in a custom PCIe network card (or an express card) that lets you go beyond 1gbe because then you can really saturate the USB 3.0 interface.

moondev
1 replies
1d18h

I have a similar homelab setup and have been playing with USB over IP via https://www.virtualhere.com

It does require a client to talk to the server but seems to work pretty well. My thought is to setup a "thin USB client" on my desk that I can attach USB devices to which then are attached or switched to whatever metal or VM host I want in my lab.

steelbrain
0 replies
1d9h

This is really interesting. Thanks for sharing!

Unfortunately the consoles don't allow installation of such a USB over IP client so I can't use this, but for other usecases where the clients are running general purpose OS, this could be great!

chatmasta
1 replies
1d20h

Raspberry Pi 5 has a gigabit ethernet port, as do a number of other SBCs, like the NanoPi variants from FriendlyElec for example. In fact the NanoPi R6S has two 2.5G ethernet ports in addition to a 1 gigabit port.

steelbrain
0 replies
1d9h

Raspberry Pi 5 still has a USB 2.0 OTG port. So the bottleneck is USB in that case

CTDOCodebases
1 replies
1d17h

How are you physically connecting the PS5 to the NAS?

I’m guessing NAS->SBC->PS5. Or are you connecting the NAS to the PS5 directly with a USB cable?

Also how does content play on the PS5? I know the internal NVMe has support a certain speed. Does this not apply to external drives?

steelbrain
0 replies
1d9h

You guessed it, it's NAS -(Ethernet)-> SBC -(USB)-> PS5. This is partially because they are on different floors and partially because the NAS server doesn't have any OTG ports.

Also how does content play on the PS5?

As far as the PS5 is concerned, it just has a USB hard drive plugged into it. It doesn't know how it works under the hood.

controversial97
5 replies
1d23h

This reminds me of a thing from a few years ago, my vague memory is that it was by Travis Goodspeed.

A smart TV would accept a firmware update from a file on a standard USB stick.

The TV reads the file start to finish to check the digital signature then reads it again to update.

A device that is pretending to be a USB storage device can send a manufacturer firmware file the first time then send your unofficial firmware after.

TeMPOraL
2 replies
1d20h

No surprise, those are near-impossible to avoid. I mean, a simple:

  if(check(resource)) {
    use(resource);
  }
is already vulnerable, unless you somehow make the entire piece of code run atomically.

crtasm
0 replies
1d20h

For a firmware update: read it into memory or copy it to storage you control first.

X-Cubed
0 replies
1d19h

One approach is to copy the data to a location that you control first (eg: RAM) and perform both the check and the use of that data from the trusted location. That can be difficult though on embedded devices with constrained resources.

hypercube33
0 replies
1d20h

Correct me if I'm wrong but I think that's how Gameboy carts show custom logos bypassing the Nintendo copyright check thing - one logo to pass the internal check and another for display.

urbandw311er
2 replies
1d19h

Why did they cripple this capability by hiding it in an undocumented and disabled BIOS setting?

crote
1 replies
1d18h

It's an extremely obscure feature for which the device lacks the hardware to do it properly (no VBUS switching), which is almost certainly untested. If I were designing a mass-market product, I would disable it too.

They got the BIOS from a 3rd party vendor, disabling it by default and hiding the setting was probably the easiest way to prevent anyone from accidentally trying to use it.

zokier
0 replies
1d12h

Its under "advanced" tab in BIOS. How many people accidentally stumble there? And how many of those people will have problems with it? And of the tiny number of people who end up enabling it and have problems, how many will then complain to Lenovo? That seems like really marginal case! Especially when it needs also things to happen from OS side too, so just flipping the flag in BIOS in itself shouldn't do much. How much trouble would it have been to add warning "this is not supported, use at own risk"?

actionfromafar
2 replies
2d

Being able to emulate a USB block device is really neat! Talk about easy way to copy files to another computer. :)

yonatan8070
1 replies
1d7h

A quick (and less intrusive) way to copy files quickly is by setting 2 machines to manual IP addresses and connecting them directly with an Ethernet cable, then using SMB to copy files from one to the other

If not using SMB, and python installation can serve a directory over HTTP using `python -m http.server`

planede
0 replies
1d6h

Or just netcat. Throw in tar if you copy a directory.

Topgamer7
2 replies
2d

However, dealing with a Raspberry Pi is a hassle: plugging in the wires, booting the board, accessing the shell, etc

Probably just could have configured USB OTG, so its powered by the device you plug in, enable shell, then scripted this. Then you can configure mounts over ssh, commands over ssh, probably even mount the device.

That being said, I encourage people to try to understand their devices, read the kernel, etc. Its something I strive to continually improve. Lets fix our own shit :D.

lima
1 replies
2d

The whole point of the exercise is playing with USB OTG, and the Pi has only one OTG port, so you need another way to connect to it

(been there, done that)

k8svet
0 replies
1d23h

The "Zero" variants of boards tend to allow power over the OTG port, so you can do some interesting things. (Of course, annoying if your powering-device resets power to it). Particularly, if I didn't suck at DTS/u-boot stuff, you could make a PiKVM for <$75. (You can get $10 1080p/60fps HDMI capture cards, you use the OTG port for kb/mouse).

Still, even if you had to external power it, those little boards have pins for power in. It would still be cheap/fairly elegant. And or a USB-C Hub should power it, and give you a place to put more non-host usb devices like a usb-eth dongle.

I would like to make one with some of the (Raspberry|Orange) Pi 3, but again, I've lost too much of my life to dts/u-boot stuff. BSP/mainline woes. It's just easier to be a software-only, cloud-machines-only guy and live minimally.

This article was exciting because I'd love to imagine cheap old laptops being salvagable as little KVM instances, but it seems like OTG/xDCI is just not a priority.

evanjrowley
1 replies
2d2h

I'm grateful for this extremely detailed article. Great quality here.

The fact that this has been achieved gives me hope that a networkless Synergy / Mouse Without Borders setup might be possible using just a modified USB cable. That's great for people like me who need to operate multiple computers simultaneously.

taskforcegemini
0 replies
2d1h

there is kvm switches (or just usb km without the video), but your suggestion sounds intriguing

urbandw311er
0 replies
1d19h

Wow - this guy REALLY wanted to use his xDCI capability and was not going to stop until he had done so!

tamimio
0 replies
2d1h

I quickly skimmed through it but great detailed article, and love the excessive use of emojis, not the typical boring wall of texts!

stragies
0 replies
1d21h

I have a Celeron N3350/Pentium N4200/Atom E3900 based system, that exposes an xDCI switch in the bios, and upon enabling it, I do get some other options, and upon bootup into linux a PCI device "USB controller: Intel Corporation Device 5aaa (rev 0b)"

But the UDC device node is not showing up. So it seems I have to dig a bit further using inspiration from the OP

seba_dos1
0 replies
14h31m

I'm somewhat irrationally irked by the use of the word "emulated". It does not "emulate" a USB device, it becomes one! This mechanism is exactly what all your gadgets with Linux on-board use to be USB devices.

rubatuga
0 replies
2d1h

Woah it's the stuff of dreams.

mrmuagi
0 replies
23h17m

I'm actually trying to do this on a Raspberry Pi right now to emulate a HDI. There are a lot of existing libraries that do this. I needed to do this because the native SendMessage/PostMessage ways to send keystrokes to a Windows process break down when you need to send modifier keys -- I needed to send ":" but I could only send ";". I tried endlessly to send the "shift" modifier key to no avail.

I actually considered directly writing to memory to "trick" the program to think certain keys are pressed (but this doesn't work for emulating actual typing input), or hook into functions with a dll injection and interleave fake input somehow.

luxuryballs
0 replies
1d19h

So does this mean I could essentially copy and paste between two machines by just feeding standard USB keyboard input into one of them?

lights0123
0 replies
1d21h

I was recently pleasantly surprised by a Linux utility that can list all UEFI variables stored in Hii and change them: https://github.com/linuxboot/uefisettings/

Obviously can't bypass security settings like this laptop has, but it's useful for a few settings in my case.

lathiat
0 replies
1d17h

I was looking into similar recently just wanting to do 10Gbps between two USB-C machines over USB with just a USB-C cable. Unfortunately most Ryzen boards still don't have Thunderbolt (which supports this natively and easily). And "dual role" USB controllers were quite uncommon (or as this article details, possible but not supported) until USB 3.2/4.0 - and even then it seems a bit hit and miss. It's totally crazy to me it's not easier to network two machines with a USB-C cable (without Thunderbolt).

I also love the part about the lock bit being cleared after a suspend, that seems to be such a common issue.. super common way to get SATA devices out of the state preventing secure erase for example.

imhoguy
0 replies
1d23h

Pity I can't do that with my AMD Ryzen ThinkPad.

icodefuture
0 replies
2d1h

Great article, thanks for sharing.

freedomben
0 replies
2d1h

This reminds me so much of the early internet hacker culture that it's actually triggering nostalgia. What a great write-up! When ESR talked about becoming a hacker (hacker in the Hacker News sense), this is the type of person he was talking about.

The combination of curiosity, dedication, and technical ability is exceedingly rare, and majorly impressive. Thanks so much for sharing!

explodingwaffle
0 replies
1d17h

Great article. You would hope this feature was more readily exposed on USB-C laptops where it makes a bit more sense… oh well.

erik
0 replies
2d

This goes to an impressive level of depth.

The ability to use a PC as a USB device opens up lots of fun possibilities. It's a little bit tragic that the required xDCI option is there in the hardware on this device, but it's not exposed and requires firmware hacking to access.

The hardware is capable, but the vendor has just turned it off and locked away the controls.