Wonderful things happen when we read the documentation. For instance, we’ve all seen a Raspberry Pi work as an Ethernet adapter over USB, or a ESP32-S2 presenting as a storage device. Well, [parkerlreed] has made his Steam Deck work as a USB printer after reading the Linux kernel docs on the USB gadget configuration, and all it took was some C code and a BIOS setting change.
“Wouldn’t it be cool if our USB tablets exposed a fake printer interface and saved the received documents as PDF?” With a SteamDeck, you can do just that – thanks to the
g_printer kernel module. The C code is fairly straightforward, and even lets you configure some aspects of the printer device.
Of course, there’s gotta be a cherry on the cake, and [parkerlreed]’s shell script hides an addition that makes your PDF printing experience all that more realistic! Not to spoil it too much – you should watch the video of the script in action, showcasing both the ease of use and the added realism.
Jokes aside, the usefulness of this script is undeniable, and owners of USB-device-capable portable Linux devices will find this script a must-have. It’s seriously cool when someone dives into documentation and pulls out a clever solution to a “wouldn’t it be cool” idea – fundamentally, it is the same mindset that gave us the venerable RTL-SDR. What’s your favourite ‘dig into docs and figure out a clever feature’ hack?
We thank [Myself] for sharing this with us on the Hackaday Discord!
Continue reading “SteamDeck: Become Printer”
The Raspberry Pi Zero – and the not-perpetually-out-of-stock Raspberry Pi A+ – only have one USB port, but behind that port is a lot of functionality. This is an OTG USB port, and just like the USB port on your smartphone, this little plug can become any kind of USB device. Transforming the Pi into a USB gadget allows it to be a serial connection, MIDI device, audio source or sink, or a USB mass storage device.
[Francesco] was especially interested in the USB mass storage capability of the Raspberry Pi Zero and built a small project to show off its capabilities. He turned a Pi Zero into the controller for a digital picture frame, constantly displaying all the image files on a small screen.
The build started with [Andrew Mulholland]’s guide for Pi Zero OTG modes, with just a few modifications. When the Pi is plugged into a PC, it automatically becomes a 100 Megabyte USB storage device. You don’t need that much space on a digital picture frame, anyway.
While setting up a digital picture frame is easy enough, there’s still a tremendous amount of untapped potential in using the Pi Zero as a USB gadget. With enough buttons, switches, and sensors, the Pi can become a wearable MIDI device, or with the Pi camera module, an IP webcam. Neat stuff, and we can’t wait to see what the community comes up with next.
Just as the USB port on your phone can serve as a serial connection, mass storage device, and a network connection, the Pi Zero can do the same. We’ve seen a few people turn the Zero into a single USB gadget, but what about turning the Zero into a USB HID device, network connection, and serial port all at the same time? That’s what [Tobias] did, and his method is even easier than the old one.
The old method of turning the Pi Zero into a USB device required the user to modify and recompile the kernel. Obviously, this isn’t an ideal solution. [Tobias]’ implementation fixes this by putting everything into userland. Everything is configurable through a script and a few tweaks to how the Pi starts up.
The result is a Raspberry Pi Zero that will appear as any USB peripheral. [Tobias] goes through the usual examples: setting the Pi up as a serial device for hacking and code cracking in a terminal, as an Ethernet device to give the Pi Zero networking capabilities, as a keyboard to send keypresses to another computer, and as a mass storage device so that other computers can read a small portion of the Pi’s SD card.
There are plenty more USB gadgets the Pi can emulate, from printers to audio devices to MIDI adapters to webcams. If you can wrap your head around what a Pi Zero could do when configured as one of these devices, drop a note in the comments.
[gbaman] has figured out a simpler way to program the new Raspberry Pi Zero over USB without modifying the board. Why is this useful? One example which appealed to us was setting the Zero’s USB port up as a mass storage device. Imagine plugging in your Pi powered robot, dragging and dropping a Python script into the mass storage device that shows up, and pressing a button on the robot to run the new script. Pretty fancy for $5.00.
You can get the PI to emulate a whole range of devices from a USB MIDI controller to a simple USB serial interface. We’re excited to see what uses people come up with. Unfortunately the Pi Zero is still out of stock most everywhere as we wait for the next production run to finish. Though if you’ve got one, why not check out a few of our thoughts and experiences with the device!
[gbaman] based his work off the work done by [Dave-0] and others over at the Raspberry Pi forums. [LadyAda] also has a version of this hack, which we covered, that involves soldering a header to the pi and using a UART adapter.
[via Hacker News]
The Raspberry Pi Zero is limited, or so everyone says, and everyone is trying to cram a USB hub and WiFi adapter on this tiny, tiny board. One thing a lot of people haven’t realized is that the Raspberry Pi Zero comes with a USB OTG port, meaning it can function as a USB device rather than a USB host. This means the Raspi can become a serial device with just a USB cable, an Ethernet device, MIDI device, camera, or just about anything else you can plug into a USB port. Adafruit has your back with a tutorial for using the USB OTG port as a serial and Ethernet interface, and the possible applications are extremely interesting.
The only requirement for using the USB OTG port for device applications is an update to the kernel. This is easily installed by dumping a few files on an SD card and a employing bit of command line wizardry. The simplest example is setting up the Pi Zero as a USB serial device, allowing anyone to log into a serial console on the Pi with just a USB cable.
A slightly more interesting application is setting up the Pi as an Ethernet gadget. This effectively tunnels all the networking on the Pi Zero through a USB cable and a separate computer. The instructions are extremely OS-specific, but the end result is the same: you can
apt-get on a Pi Zero to your heart’s desire with a new kernel loaded onto the SD card and a USB cable.
This experimentation is just scratching the surface of what is possible with the OTG port on the Pi Zero. MIDI devices are easy, and with a ton of GPIOs, the Pi Zero itself could become a very interesting musical instrument. Want the Pi Zero to be a storage device? That’s easy too. The USB Gadget will end up being one of the most exciting uses for the Pi Zero, and we can’t wait to see what everyone will come up with next.