I've got a PI zero and and soon as it boots up - I can ssh to it via WIFI. So I assume the ethernet gadget is setup.
I then plug in the USB cable (not power) to my PC's usb port - hoping to see a serial port - I don't see it on the PC's devices list.
Here's what I'm hoping to achieve - ssh via WIFI for development and the usb wired serial port for commuication between my zero and the pc server program I'm writing.
I know I edited the config files long time ago - but can't remember exactly what I did.
- HawaiianPi
- Posts: 7850
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: Getting WIFI and USB serial port to work on Pi0W
Not sure why you would assume that, since SSH over WiFi has nothing to do with Ethernet gadget mode. Most people use Ethernet gadget mode to SSH into a Pi Zero without a wireless connection.
That's confusing...

Are you trying to create a serial gadget, or an Ethernet gadget (they are not the same thing).
Not sure why you'd need both, but okay.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?
lots of pop-ups, and where is that annoying music coming from?
Re: Getting WIFI and USB serial port to work on Pi0W
Apologies for my lack of clarity and also ignorance on this matter...let me be clearer.
I'm writing a client program on the zero and the server program on the PC and having them communicate via the usb serial port...if I can.
I'd like the above and yet at the same time be able to develop the client program via ssh from the PC. I'm assuming that if I ssh over usb - then there won't be a serial port to be opened by my programs.
Right now, ssh is working via WIFI - that is I can connect with no usb cable connection.
That's fine by me...I can use it for development.
Now just need a serial port when I plug the usb cable in.
Normally when you connect the cable - you see the serial port in Windows Device Manager - I don't see it.
Hope I made it a little bit clearer.
I'm writing a client program on the zero and the server program on the PC and having them communicate via the usb serial port...if I can.
I'd like the above and yet at the same time be able to develop the client program via ssh from the PC. I'm assuming that if I ssh over usb - then there won't be a serial port to be opened by my programs.
Right now, ssh is working via WIFI - that is I can connect with no usb cable connection.
That's fine by me...I can use it for development.
Now just need a serial port when I plug the usb cable in.
Normally when you connect the cable - you see the serial port in Windows Device Manager - I don't see it.
Hope I made it a little bit clearer.
Re: Getting WIFI and USB serial port to work on Pi0W
OK, so by default the USB port on a zeroW works in host only mode so when connected to a PC's USB port no data/device is detected.
Here's ther quick and dirty way to get it to act as a USB serial device:
Editied for typos
Here's ther quick and dirty way to get it to act as a USB serial device:
- Add the following to /boot/config.txt:
Code: Select all
dtoverlay=dwc2
- Add the following to the end of /boot/cmdline.txt ensuring every thing remains on a single line:
Code: Select all
modules-load=g_serial
- Reboot
Editied for typos
Last edited by thagrol on Mon Jun 27, 2022 11:23 pm, edited 1 time in total.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Getting WIFI and USB serial port to work on Pi0W
Nope. Not unless your OS is non-standard or has been tweaked.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Getting WIFI and USB serial port to work on Pi0W
Should have replied in one post not in pieces. Oh well.
You can get that USB connection to act as both serial and network (ethernet) between Pi and USB host. See USB Ethernet Gadget A Beginner's Guide section 6.1.3. With a little modification, it may be possible to get two serial ports via the configfs method.
ssh doesn't work over serial.* You can log in over serial if you start a getty on that serial port** but if you do so you can't use that port to communicate between your programs at the same time.
*: It can if you run a PPP or SLIP connection over the serial ports but that's a whole other can of worms.
**: Ask your favourite web search engine.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Getting WIFI and USB serial port to work on Pi0W
I've got `dtoverlay=dwc2` at the end of my config.txt file.
This is the current cmdline.txt file - 1 line
`console=serial0,115200 console=tty1 root=PARTUUID=775f7f6a-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether silent quiet splash loglevel=0 logo.nologo`
So I just add SPACE g_serial to the end or after 'splash'???
Note there's already a g_ether in there.
UPDATE: I added g_serial between 'splash' and 'loglevel' and rebooted pi and I don't see the serial port on the PC.
Note still ssh connection is via WIFI.
Re: Getting WIFI and USB serial port to work on Pi0W
Nope. You can only run one g_* module at a time. Use g_cdc instead of g_ether. g_cdc provides both ethernet and serial USB devices.erjdriver wrote: ↑Mon Jun 27, 2022 10:48 pmI've got `dtoverlay=dwc2` at the end of my config.txt file.
This is the current cmdline.txt file - 1 line
`console=serial0,115200 console=tty1 root=PARTUUID=775f7f6a-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether silent quiet splash loglevel=0 logo.nologo`
So I just add SPACE g_serial to the end or after 'splash'???
Note there's already a g_ether in there.
This is explained in the guide I linked to.
I'm confused and curious: why are you asking about WiFI and serial if you're currently using g_ether? They are completely unrelated and both can provide a network connection with ssh to the PC.
My answer was based on your indication of WiFi with serial over USB not getting both a USB ethernet gadget and USB serial gadget working together.
Incidentally, if you already have the ethernet gadget working, why not use sockets for the data connection rather than serial? That way you only need g_ether and, just like any other network connection, can run multiple streams/applications/connections over it.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Getting WIFI and USB serial port to work on Pi0W
Ok I changed the modules-list to g_cdc and removed g_ether and g_serial
Now I see a new device CDC Composite Gadget on Windows - but looks like it's missing drivers - no serial port available.
Re why I'm using serial port instead of ethernet/tcp - 1. I already wrote the server code for serial i/o - but that's not a huge issue - mainly I'm thinking serial i/o will be faster than tcp/ip and more reliable than udp. My program sends text lines back and forth.
Since I already have WIFI working and don't need g_ether for wired SSH - can I just change from g_cdc to g_serial and get the serial port working - or will I still need a driver.
Once again my apologies for my lack of knowledge of the pi/linux etc.
Now I see a new device CDC Composite Gadget on Windows - but looks like it's missing drivers - no serial port available.
Re why I'm using serial port instead of ethernet/tcp - 1. I already wrote the server code for serial i/o - but that's not a huge issue - mainly I'm thinking serial i/o will be faster than tcp/ip and more reliable than udp. My program sends text lines back and forth.
Since I already have WIFI working and don't need g_ether for wired SSH - can I just change from g_cdc to g_serial and get the serial port working - or will I still need a driver.
Once again my apologies for my lack of knowledge of the pi/linux etc.
Re: Getting WIFI and USB serial port to work on Pi0W
Hmm. That merits further investigation. When I have the time.
A network connection is at least an order of magnitude (Mb/s rather than Kb/s faster than serial.Re why I'm using serial port instead of ethernet/tcp - 1. I already wrote the server code for serial i/o - but that's not a huge issue - mainly I'm thinking serial i/o will be faster than tcp/ip and more reliable than udp. My program sends text lines back and forth.
You shouldn't need a driver for g_serial (I didn't) but if you do, I'd expect the internet to provide.Since I already have WIFI working and don't need g_ether for wired SSH - can I just change from g_cdc to g_serial and get the serial port working - or will I still need a driver.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Getting WIFI and USB serial port to work on Pi0W
The g_serial port worked as advertised.
I had to install pyserial on the zero - but the same serial code that I wrote for the server - works for the client. Which is a plus!
I'll proceed as is with serial# - but will fall back on the tcp transport if it turns out to be too slow.
Thanks much for your help.
I had to install pyserial on the zero - but the same serial code that I wrote for the server - works for the client. Which is a plus!
I'll proceed as is with serial# - but will fall back on the tcp transport if it turns out to be too slow.
Thanks much for your help.