
Raspberry Pi 4 as a USB-C peripheral - hardillb
https://www.hardill.me.uk/wordpress/2019/11/02/pi4-usb-c-gadget/
======
rkagerer
You can also do a USB client on a $1.50 AVR chip:
[https://www.obdev.at/products/vusb/index.html](https://www.obdev.at/products/vusb/index.html)

Source: Compiled and connected a mouse/keyboard firmware running on an
ATtiny861a using internal RC oscillator.

~~~
IshKebab
Why would you do that though when there are a gazillion Cortex-M chips
available that support hardware USB? Fast USB and you don't have to use AVR.

Hell, Atmel even sells Cortex-M chips with High Speed USB-2 support
(reasonably hard to find; most are only Full Speed).

~~~
HeyLaughingBoy
Tool Familiarity?

I've been doing embedded systems large and small for decades but before this
year, never put anything with an ARM into production.

AVRs are still my go to for most things because I know them well and have all
the tooling ready to go.

------
kees99

      [R]ecent update to the Raspberry Pi 4 bootloader
      (...) enables data over the USB-C port
    

Am I reading this right that RPi4 has _five_ usable USB ports, i.e. unlike
earlier models, port on bottom left of the board can carry data along with
power? This is awesome!

~~~
fanf2
USB-C includes a USB-2 management channel in addition to the high-bandwidth
lanes. It is used for things like advanced power delivery negotiation. On the
Raspberry Pi 4, the USB-C port has no high-bandwidth lanes, and it only uses
passive power negotiation.

~~~
cesarb
> USB-C includes a USB-2 management channel in addition to the high-bandwidth
> lanes. It is used for things like advanced power delivery negotiation.

No, all the power delivery negotiation in USB-C, both the basic one using only
passive resistor values and the advanced one using the USB-PD protocol, is
through the configuration channel pins, which is a separate pair of pins
completely independent from the USB 2.0 pins in the middle. (The configuration
channel is implemented incorrectly on the Raspberry Pi 4, however; it shorts
together the pins, while they should be separate, so it fails with advanced
cables which use both pins; and when powered through a source other than the
USB-C connector, it incorrectly sources 5V to the USB-C port even when it
shouldn't.)

------
p1mrx
Yay, that feature was previously only available on the Pi Zero. Does anyone
know if this will work on older computers, using a USB A-to-C cable?

~~~
hardillb
Yep, should work fine with a USB-A to USB-C cable as well

------
mmastrac
Site is getting a bit slow - mirror here:
[http://archive.is/3bp5L](http://archive.is/3bp5L)

~~~
rwha
cloudflare (1.1.1.1) is resolving archive.is to 127.0.0.5 ??

~~~
detaro
Archive.is doesn't like that cloudflare doesn't give them information about
the subnet the query came from, so they give a bad reply to cloudflare.
([https://news.ycombinator.com/item?id=19828317](https://news.ycombinator.com/item?id=19828317))

------
NicoJuicy
Fyi: USB-c in the rpi 4 is not standards compliant.

A new revision is underway, a fix is just using dumb cables.

~~~
cesarb
Using dumb cables avoids one of the issues (configuration channel pins shorted
together), but not the other one (sourcing power even when the configuration
channel says it shouldn't source power).

That is, the workaround is both "use only dumb cables (which use only one of
the CC pins)" and "never connect to a USB-C device which might source power
while the rpi is being powered by something other than the USB-C".

~~~
xg15
> _" never connect to a USB-C device which might source power while the rpi is
> being powered by something other than the USB-C"_

Wouldn't this actually apply to a lot of use-cases of the project in the
linked blog?

The whole point is connecting the RPi as a peripheral of a laptop, i.e. a
power-sourcing host. if you do that, you'll also likely be tempted to use an
external power supply for the Pi as the USB's supply is limited. It's
important to note that this will lead to problems.

------
shinwn
Is there anything like this that can act as gadget devices for more than one
host? (So I can plug it in to 4 different PCs or the like)

------
lhoff
I fail to imagine a usw case for that. Could someone enlighten me?

~~~
mmastrac
... build a smart boot device that provides a bunch of different CD images for
BIOSes that don't do USB boot well

... build a safe password keeper that looks like a HID device

... do something interesting with USB-based gamepads to map those to keyboard
keys for playing old DOS games

... make a connected USB storage device that offers some sort of additional
sync services for the data stored on it (maybe over wifi?)

... make a network adapter that also acts as a firewall, or possibly links to
tor/vpn/etc

... Something something MIDI over USB

~~~
swiley
> ... build a smart boot device that provides a bunch of different CD images
> for BIOSes that don't do USB boot ...

There’s an Android app for that, it’s one of the biggest things I miss after
switching to the iPhone.

~~~
mmastrac
That's awesome. Do you recall the name?

~~~
nougatbyte
[https://play.google.com/store/apps/details?id=com.softwareba...](https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid&hl=en)

~~~
ce4
The last time i checked it needed gadget kernel driver support and root, a
showstopper for me...

Apart from that, great concept: load your 5+ cd images onto your 64+ gb
android and be done (win10, ubuntu, debian, grml, kali, bios update cd image,
etc) and forget about your usb drive collection...

~~~
swiley
I thought modern android required the gadget driver anyway? I’m pretty I was
able to use it without root but it was (supposedly) less reliable without it.

------
villgax
Literally converting it into a successful Mac accessory itself is a
kickstarter gold!

------
fattire
wonder if this would be a much better hw solution for TeslaUSB...

[https://github.com/cimryan/teslausb](https://github.com/cimryan/teslausb)

