Just like the title says, I want to use both the GPIO UART and the USB Gadget at the same time.
Background: I've been working on modding up one of the Adafruit IoT printer projects, which uses the pi zero's GPIO based UART to perform its communications to the printer. Following all the steps, one thing that is called out is:
Under “Interfacing Options,” select “Serial.” Turn OFF the login shell over serial, and ENABLE the hardware serial port. NO and YES, respectively. This is vital!1
So I started back over the systemd configuration and attempted to update my /boot/cmdline.txt
to include a console=serial1,115200
(instead of serial0
), assuming (poorly) that since the g_serial
mod is loaded later in the process that I'd be able to still get a login shell on ttyGS0
(assuming that I followed the rest of the standard systemd service creation you can find all over the internet).
After experimentation, setting the console=ttyGS0
, console=ttyAMA0
, and console=serial1
resulted in nothing useful and no login prompt over USB serial. As expected, setting console=serial0
resulted in the printer vomiting piles of Linux kernel bootup debug out over the serial port - so clearly the [email protected]
is functioning correctly. Checking the debug logs:
Oct 30 01:39:18 iot kernel: [ 4.883816] hub 1-0:1.0: USB hub found
Oct 30 01:39:18 iot kernel: [ 4.886928] hub 1-0:1.0: 1 port detected
Oct 30 01:39:18 iot kernel: [ 5.085302] g_serial gadget: Gadget Serial v2.4
Oct 30 01:39:18 iot kernel: [ 5.087951] g_serial gadget: g_serial ready
Shows that it's getting loaded fine, but clearly, it's not finding / using the associated serial port as show by lsmod
which of course means that no systemd service will find it:
root@iot:~# lsmod
Module Size Used by
brcmfmac 273230 0
brcmutil 9114 1 brcmfmac
snd_bcm2835 23253 0
snd_pcm 89686 1 snd_bcm2835
snd_timer 22428 1 snd_pcm
cfg80211 542242 1 brcmfmac
snd 60154 3 snd_timer,snd_bcm2835,snd_pcm
rfkill 21476 4 cfg80211
i2c_bcm2835 6465 1
uio_pdrv_genirq 3718 0
uio 9901 1 uio_pdrv_genirq
fixed 3033 0
i2c_dev 6674 2
g_cdc 3862 0
u_ether 12901 1 g_cdc
usb_f_acm 5895 1
u_serial 10956 3 usb_f_acm
g_serial 3753 0 # ---- whomp, whomp :(
libcomposite 48212 3 g_serial,usb_f_acm,g_cdc
dwc2 128996 0
udc_core 38862 5 usb_f_acm,u_serial,dwc2,u_ether,libcomposite
ip_tables 12427 0
x_tables 22130 1 ip_tables
ipv6 397673 20
Has anyone else been able to get BOTH the GPIO UART and the USB Serial Gadget working at the same time?
NOTE: I'm aware I can always use SSH to log into the system but that approach isn't going to function long term for this project. Thanks though! :)
g_serial
works fine when you disable the hardware UART? Otherwise your question boils down to "how do I useg_serial
as a login console"?g_serial
as a login console