BostonBatman
Posts: 8
Joined: Sun Jul 14, 2019 10:06 pm

Use GPIO as USB?

Mon Jan 20, 2020 5:43 pm

DexOS wrote:
Wed Jul 18, 2012 3:22 pm
You could use one of there's "Microchip 24FJ64GB002 microcontroller" to add a USB Host, i have used one of these to add usb support to my bare metal OS on the R-PI, in my case it uses Uart pins and was for uses with hid devices.

Here's a ready made example: http://www.hobbytronics.co.uk/usb-host-board

Note: The "24FJ64GB002" is a lot cheaper, than that board.
Super old post but a pretty basic question: You're suggesting adding a usb host chip... what is the upstream connection back to the pi and does the chip need to be flashed/programmed differently to use?

I've been playing with the idea of a usb hub chip, which would require no 'flashing' but would still be limited to the pi's onboard usb controller.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12589
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Use GPIO as USB?

Mon Jan 20, 2020 6:13 pm

Split off from necro.
next time please start a new posts, re-opening ancient post is discouraged.

Basically GPIO's cannot be used as (reprogrammed to be) USB ports.

hippy
Posts: 6729
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Use GPIO as USB?

Tue Jan 21, 2020 3:44 pm

BostonBatman wrote:
Mon Jan 20, 2020 5:43 pm
Super old post but a pretty basic question: You're suggesting adding a usb host chip... what is the upstream connection back to the pi and does the chip need to be flashed/programmed differently to use?
USB Host Modules usually use I2C, SPI or UART. It may be possibly to bit-bang signals and use any GPIO pins.

Whether a chip on a module needs to be reflashed depends on what you purchase, what it is intended to be used with, and what you want to do with it. Whether it can be reflashed, and how easily, depends on the module.

The old link is to a discontinued product, but it seems USB Host Modules are still available. There may be other suppliers of similar products -

http://www.hobbytronics.co.uk/usb-host

BostonBatman
Posts: 8
Joined: Sun Jul 14, 2019 10:06 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 4:50 pm

hippy wrote:
Tue Jan 21, 2020 3:44 pm
Whether a chip on a module needs to be reflashed depends on what you purchase, what it is intended to be used with, and what you want to do with it. Whether it can be reflashed, and how easily, depends on the module.
This is basically what I was asking: Whether all chips are pre-programmed or if you'd need to write and flash the program yourself. For something like adding a usb host to an ATMega328p or something, you'd need to write your own program and UART flash to the chip, right? Talking bare-bones custom PCB without the need for proprietary (albeit "free") software.

trejan
Posts: 1112
Joined: Tue Jul 02, 2019 2:28 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 4:57 pm

You can use a MAX3421E which is a SPI attached USB host controller if you really need to have USB over the GPIOs. It will appear as a USB controller in Linux but performance will be awful.

Why do you want to do this anyway?
BostonBatman wrote:
Tue Jan 21, 2020 4:50 pm
Whether all chips are pre-programmed or if you'd need to write and flash the program yourself.
The HobbyTronics chips are preprogrammed microcontrollers. They will have their own USB stack and internal drivers for the limited selection of USB devices they support. You'll need to talk to it using the UART or I2C with its own proprietary protocol. Linux will have no clue what this device is and it won't be linked into the usual USB subsystem.

BostonBatman
Posts: 8
Joined: Sun Jul 14, 2019 10:06 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 5:16 pm

I don't necessarily need it over SPI, it's more about the concept of adding the host to an IC or SoC so have a similar custom PCB similar to a Raspberry Pi. The Pi has everything embedded and hard-routed to the CPU, so I wanted to do my own version for a pretty specific use case (small screen, weather station peripherals, USB 3.1 for video streaming eventually)

I'm looking for an expandable station with multiple use cases that would be monstrously easier with USB 3.1, so I'm looking for the appropriate method to add a USB host to something that doesn't have it.

Also, just to quell any comments trying to solve for the single use case, no, I'm not interested in the ESP32 webcam variant of a "weather station". I've tried it, it's okay for what it does, but I've got bigger plans. I'm not OP, but it was a relevant thread so sorry for tagging along. The OTG route and usb hub IC route only goes as far as the host controller, but I'm looking to avoid the bottlenecks.

Thanks in advance!

trejan
Posts: 1112
Joined: Tue Jul 02, 2019 2:28 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 5:27 pm

BostonBatman wrote:
Tue Jan 21, 2020 5:16 pm
I don't necessarily need it over SPI, it's more about the concept of adding the host to an IC or SoC so have a similar custom PCB similar to a Raspberry Pi. The Pi has everything embedded and hard-routed to the CPU, so I wanted to do my own version for a pretty specific use case (small screen, weather station peripherals, USB 3.1 for video streaming eventually)

I'm looking for an expandable station with multiple use cases that would be monstrously easier with USB 3.1, so I'm looking for the appropriate method to add a USB host to something that doesn't have it.
So this isn't anything to do with the Raspberry Pi at all?

If you need USB 3.1 then you're going to have to get a SoC with USB 3 built into it or do it like the Pi 4 with a PCIe attached USB 3 controller. You're not going to find anything cheap & simple like the Maxim chip or the Hobbytronics module that'll be capable of this.

Finding a suitable SoM will greatly simplify design and manufacture of your device.

BostonBatman
Posts: 8
Joined: Sun Jul 14, 2019 10:06 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 5:34 pm

It is - It began as a search of a way to add a usb-c host controller to a pi zero w and has evolved from there. GPIO was the first logical step for interfacing, but are there other, faster channels to utilize the USB 3.1r2 upstream signal from the host controller chip to the pi?

I think that's the TL;DR question

trejan
Posts: 1112
Joined: Tue Jul 02, 2019 2:28 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 6:08 pm

BostonBatman wrote:
Tue Jan 21, 2020 5:34 pm
are there other, faster channels to utilize the USB 3.1r2 upstream signal from the host controller chip to the pi?
No. The fastest interface on every Pi except the Pi 4 is the built-in USB 2.0 interface. The Pi 4 added a PCIe 2.0 x1 interface but it is used for the onboard VLI USB 3.0 controller. Replacing the USB 3.0 controller wouldn't give you anything extra either as a PCIe 2.0 x1 interface is capable of running a single USB 3.0 port at maximum speed.

BostonBatman
Posts: 8
Joined: Sun Jul 14, 2019 10:06 pm

Re: Use GPIO as USB?

Tue Jan 21, 2020 6:29 pm

trejan wrote:
Tue Jan 21, 2020 6:08 pm
No. The fastest interface on every Pi except the Pi 4 is the built-in USB 2.0 interface.
And so you're saying that it's a limitation of the broadcom chip to be able to transfer data as USB 3 - compliant speeds, unless it's the pi4?

Return to “Interfacing (DSI, CSI, I2C, etc.)”