imrisaac
Posts: 2
Joined: Thu Mar 09, 2017 4:18 am

Headless programming while hosting USB device

Thu Mar 09, 2017 4:25 am

Currently have a pi zero set setup up for headless operation using the hardware uart and not USB.

I would like to have a USB device attached to the USB port as well as having access to the terminal via the uart port. Currently a soon as a USB device is attached to the USB port on the pi I loose the connection on the uart port likely due to the pi switching from slave to host.

Is there a way to accomplish this?

User avatar
topguy
Posts: 6983
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Headless programming while hosting USB device

Thu Mar 09, 2017 11:49 am

I can see no reason for the behavior you describe.
You are using the Linux console that is enabled by standard on the GPIO UART pins ? Or some other configuration ?
Have you loaded any of the USB Gadget kernelmodules so that the device is in "gadget" mode ? If not then the USB should be in "master" mode as always.

What kind of USB device are you connecting ? And what happens if the usb-device is already connected when you boot the Zero ?

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Headless programming while hosting USB device

Thu Mar 09, 2017 12:32 pm

(Edit: I was mistaken so I've corrected this post.)

The GPIO UART is now a different one due to one being needed for Bluetooth, but that causes problems because the baud rate changes with the processor clock. The processor clock slows down if the Pi is getting hot and maybe if it isn't heavily loaded.

There are two solutions: either lock the CPU frequency or disable Bluetooth and swap the UARTs back.

See: viewtopic.php?f=63&t=151454#p993901

DirkS
Posts: 10583
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Headless programming while hosting USB device

Thu Mar 09, 2017 3:12 pm

rurwin wrote:There are two solutions: either lock the CPU frequency or disable Bluetooth and swap the UARTs back.
3: or just swap the UARTS (using overlay pi3-miniuart-bt). Don't know how that affects BT, though.

User avatar
topguy
Posts: 6983
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Headless programming while hosting USB device

Fri Mar 10, 2017 11:37 am

OP have specified that he is using a Pi Zero, is this BT UART stuff even relevant ?

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Headless programming while hosting USB device

Fri Mar 10, 2017 1:28 pm

I don't know.

Does the Pi Zero use the swapped UARTs even though there's no Bluetooth? I hope not, but it might.

Or the OP might have ment that he had a Pi Zero W.

User avatar
thagrol
Posts: 4209
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Headless programming while hosting USB device

Fri Mar 10, 2017 8:37 pm

What USB device are you connecting? Could it be that your psu isn't up to the job and a the extra current draw is causing a brown out on the pi?
Arguing with strangers on the internet since 1993.

All advice given is based on my experience. it worked for me, it may not work for you.
All GPIO pin numbers are BCM numbers.

imrisaac
Posts: 2
Joined: Thu Mar 09, 2017 4:18 am

Re: Headless programming while hosting USB device

Fri Mar 10, 2017 9:01 pm

Got it working. It seems the usb hub i was using to connect the usb device was faulty. Swapping it has solved the problem.

Return to “General discussion”