7 ms·
Software defined USB port (Raspberry Pi pico RP2040)
- akravel 5y agoNote: signaling rates of 1.5 Mbit/s (LS Low Speed) and 12 Mbit/s (FS Full Speed) only.
- tkanarsky 5y agoThat's freaking awesome. For those unaware, the RP2040 microcontroller has several Programmable IO (PIO) cores, which are essentially standalone state machines that read/write directly from memory to the GPIO pins. Unlike bitbanging the pins with the CPU, you can implement much more timing-sensitive protocols while reducing CPU usage at the same time. There's demos of people implementing VGA out, digital audio, all sorts of interesting protocols.
- TillE 5y agoI love the PIOs, it's such a great idea. I've only used one to emulate a 4021 shift register being clocked at 100 kHz, which is light work compared to what they're capable of, but still something an Arduino struggles to keep up with.
- nomel 5y agoI used them (PRU in Beaglebone) to implement e-fuse burning with JTAG (the chips stops working if you take a little too long) and MDIO (the interface for controlling a network PHY). My interesting battle story around this is that I first implemented the MDIO as bit banging in the kernel. This used quite a bit of CPU, which I wanted to use for other things. I switched it over to the PRU and CPU usage dropped to 1%. Great! But the data rate was much slower, with huge latency spikes. It turned out that the CPU usage was so low that the CPU governor thought the system was idle, so was throttling the CPU to just a few hundred MHz. I had to change the governor to keep the CPU clock to 100%, then everything was about 10x faster.
- Teknoman117 5y agoThe PRUs in the beaglebone are way more flexible to be honest. Most of my effort with the Pico PIOs is squeezing everything to fit inside the 32 instruction limit.
- synack 5y agoIf you're short on PIO memory, the OUT EXEC instruction will execute an instruction directly from the FIFO. Feed the FIFO with a DMA channel and it'll keep up with the system clock. From the RP2040 datasheet section 3.4.5.2: > OUT EXEC allows instructions to be included inline in the FIFO datastream. The OUT itself executes on one cycle, and the instruction from the OSR is executed on the next cycle. There are no restrictions on the types of instructions which can be executed by this mechanism. Delay cycles on the initial OUT are ignored, but the executee may insert delay cycles as normal.
- dexterhaslem 5y agois this open source? im using an am355x and would be interested in looking if so
- nomel 5y agoNo, sorry. I also don't have documentation that I can give. When I left the company, the Beaglebone community was pretty well into a C compiler, which is probably complete by now. There was also some coprocessor library being developed, to provide a nice interface to the host. It was all asm and kernel modules back then. I'm sure things are much easier now.
- fps-hero 5y agoIt is very humbling to know I’m not the only person to have had to implement bit banged MDIO recently. If your PHY’s data sheet says clause 45 register access only and you don’t have GPIO access as the bus master, run away. Unfortunately I was tasked with emulating a clause 45 PHY on a clause 22 bus. Without creative use of the microcontroller peripherals, it is next to impossible to achieve implemented a 2.5Mhz slave. I had to use an edge interrupt to jump in to a while loop state machine, whose state was determined by a timer counter driven by the MDIO bus, with all GPIO acessd via hard coded bit banded GPIO. Fun times, but this is definitely an FPGA job.
- msla 5y agoHow does this compare with, say, channel I/O from mainframe designs? https://en.wikipedia.org/wiki/Channel_I/O https://en.wikipedia.org/wiki/Channel_I/O
- pxx 5y agoI think we've just reinvented the concept with a harder to search name. "Programmable I/O (PIO)" is sure similar to "programmed I/O (PIO)"
- akavel 5y agoNoob question: can it be said that the microcontroller contains a very simple FPGA? Or are there some crucial differences between the two technologies?
- a2800276 5y agoThe pio subsystem is like a special purpose coprocessor for IO. You write small assembly programs defining the behavior. You could compare this to a GPU (special purpose coprocessor for vector calculation) or a very complicated IO peripheral you are configuring. An FPGA allows you to build up actual hardware gates and wire them together. For pio you configure existing hardware. There are some similarities in the domain you're using them, though. FPGA are often used for timing critical IO as well.
- rusk 5y agoWould I be right in saying this is something similar to BPF?
- trasz 5y agoMore like Amiga’s Copper.
- bayindirh 5y agoOh, like BeagleBone Black's realtime co-processors. Neat.
- fps-hero 5y agoMuch more limited capability wise, but much tighter guarantees about latency. More like a 80Mhz AVR 8bit than an ARM coprocessor. The real shame of modern microcontrollers is the decoupling of peripherals and GPIO from the main processor. It prevents these sorts of hacks as all access has to be through the memory bus, effectively capping bitbanging at sub 10MHz speeds.
- 5y ago
- mmastrac 5y agoThis is a pretty big deal, considering that the RP2040's USB hardware is purportedly buggy in a few places (IIRC you cannot plug it into a hub with a device that reports or is polled often, like a USB/Serial device). See RP2040-E5 (USB errata) here: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.p... EDIT: apparently this has a workaround now!
- 1MachineElf 5y agoOne of my favorite innovations from sekigon-gonnoc is his BLE Micro Pro, which brings a Pro Micro compatible nrf52840-based board that brings wireless BLE capability to QMK keyboards. Newer projects like ZMK have taken over that space, but this was very cool a few years ago when few other solutions were availabe. https://github.com/sekigon-gonnoc/BLE-Micro-Pro https://github.com/sekigon-gonnoc/BLE-Micro-Pro
- dheera 5y agoDamn. I wonder if I can emulate a USB host on the other end and put a USB device such as a Yubikey "in the cloud" so that multiple devices can use it as a U2F device.
- tgv 5y agoSounds possible, but wouldn't that defeat the purpose of the yubikey, or at least undermine it?
- dheera 5y agoYes, but the problem is many websites have horribly shitty implementations of 2FA notably AWS, PayPal, Kraken, Gusto among others. All of these websites only permit registering one key instead of multiple. You're supposed to allow multiple keys so that if one key gets lost or stolen, you can login with another one and deactivate the lost key, among other reasons. I also generally leave a key in each of my frequently-used devices and don't like to move keys around or travel with keys, especially on the streets of San Francisco. I have a computer at work, a computer at home, and don't want to commute with a laptop considering 3 friends have been mugged in just the past week. So for these I'd rather circumvent the 2FA by putting the key in the cloud until they hire some better engineers who can implement multi-key 2FA.
- magixx 5y agoYou might be able to use something like VirtualHere or USBIP for sharing a remote USB device over network
- vukgr 5y agoA bit off topic but does anyone know if there's anything like a standalone PIO? They seem genuinely fun to use even without the pico attached.
- mastax 5y agoSort-of related things: - GreenPAK - Programmable Array Logic (PAL)
- sgtnoodle 5y agoIsn't a standalone PIO literally just a microcontroller? You may have fun playing around with a Parallax Propeller MCU. Rather than have a bunch of peripherals, the Propeller has 8 CPU cores. The idea is that you implement whatever peripherals you want by dedicating cores to the purpose and bit-banging it. It's a similar idea to a PIO, but rather than having a main core and a bunch of tiny cores, you just have a bunch of equally capable cores.
- oxplot 5y agoNice — RP2040 is cheap, capable (2 cores running at 120Mhz+, PIO, etc) and most importantly available. It can't be overstated just how the global chip shortage affects even hobbyists or those making small runs of some breakout board. My own product [1] has been out of stock for a long time now, because its main chip (AND the aux. one) has been unavailable for year and still has many weeks lead time. Seeing this, I learnt that if it can be done in software, it should be. RP2040 is perfect for this and I've started writing a minimal USB-PD stack in Micropython to run on one of the cores and so far so good! [1]: https://fpx.oxplot.com https://fpx.oxplot.com
- Teknoman117 5y agoI've spent a few hundred bucks over the last couple of month snapping up components I want for projects whenever I notice them in stock. FPGAs, gate drivers, etc. Anything and everything seems to be randomly affected. Been doing a lot of retro computing projects because the eBay parts are still there for the most part.
- Findecanor 5y agoThat's cool. There is also USB HID host firmware in TMK Keyboard Firmware [1] for 8-bit AVR, but those µC are quite small and the USB part in the firmware is quite limited. * 1: TMK: https://github.com/tmk/tmk_keyboard/tree/master/converter/usb_usb https://github.com/tmk/tmk_keyboard/tree/master/converter/us...
- trasz 5y agoSomewhat related: https://github.com/obdev/v-usb https://github.com/obdev/v-usb
- rraghur 5y agoSo.... Would this work to make a qmk usb usb converter device? I mean something like Solder a type A port to the pi2040, hook up a usb kbd there and then connect rpi2040 to the pc?