-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support USB OTG gadget serial with Zero 2 W #418
Comments
Ah, so we’d boot the kernel with I tried using kernel-console-on-ttyUSB for router7 a while ago:
As you can see, aside from the inconvenient setup, that console also lacks parts of the kernel log (possibly exactly the part that is relevant for debugging) and has reliability issues. I’m not a fan. That said, if we can make it work, I’m not opposed to having it. But I don’t know yet whether it’ll be doable. |
I think it'd be ttyGS0 for gadget serial but I think you're right about losing some of kernel messages. True for debugging gokrazy but less so for building appliances with gokrazy. Besides once you get to shell you can use dmesg to see the earlier messages. It does have the side effect of using the only USB port obviously, so it's not for everyone either. I think it's be still useful because on Zero you may not have working networking. |
Now that ee3d95c is submitted, I think we could take a more serious look at the OTG serial. Can you outline how to enable/use it? Would it just be a matter of turning on a kernel option? |
It needs dtb overlay dwc2 in config.txt and then the g_serial. Then /dev/ttyGS0 should be a serial port and it shows as a USB serial device on micro USB attached to the Zero/Zero 2 (data port, not charge port). I should set it up again to have the specifics to cite. |
I was curious about what the dwc2 overlay does, and according to https://raspberrypi.stackexchange.com/a/77061/132131, it switches from the But, it looks like the AFAICT, we already use the dwc2 driver via our device tree:
(The Raspberry Pi dtb uses So, perhaps we don’t need the overlay at all? Perhaps we just need to enable |
Sounds plausible. I'm fairly sure I had ttyGS0 working in alpine before (based on IRC logs I did). https://gitlab.alpinelinux.org/alpine/aports/-/commit/f7c1d7e3a6a02a71501dbb9f6c84161f5eba83ea is related to making it work. I think most likely these would be good for testing the gadget USB further. CONFIG_USB_DWC2=m Not sure if we need to configure dwc2 to switch from host to otg mode or something. (For gadget ethernet too; could be useful if we can have USB ethernet for fallback?) |
https://systemoverlord.com/2017/05/21/pi-zero-as-a-serial-gadget.html This works in Raspbian.
When loaded, this shows up in System Information on Mac connected to the USB port: Loading g_ether didn't work for me.
|
Thanks for the pointers. When adding
(we already have …I get:
Not sure why that is, or if USB gadget mode is supposed to work with the upstream Linux kernel at all. The Raspberry Pi kernel has a different device tree (see https://github.com/raspberrypi/linux/pull/1086/files), but copying the |
Here's some thoughts, could turn out false leads. The DTB may still have dr_mode as host instead of peripheral. Not sure if this could explain the error, I think not based on Googling. I see legacy/ in the path. I think there's two g_serial in Linux but I have no clue if they are part of same or incompatible? Finally perhaps there's some other problem that could explain not finding symbols. Missing some dependency in config? Not copying all module objects in? Depmod? Oh and finally, the gadget serial would not work if you have a device connected (port is host mode). To have it work you need another computer as host on the micro USB. This can only work on Zero and Zero 2. I don't think this should cause the error that you got but also it can never actually work if you use the port as host. |
Thanks for the thoughts! Answers inline:
We set
I can only find one, the one with legacy/ in the path.
Right, I did test with the Pi Zero 2 W connected (and powered) only via the USB data port from another computer. I also booted it up in that configuration, just to be sure. |
Does the lsmod from Raspbian help identify the dependencies?
|
Dependencies as a graph: https://go.dev/play/p/r_VGByiQ9Jw graph TD
aes_generic --> aes_arm
af_alg --> algif_hash
af_alg --> algif_skcipher
btbcm --> hci_uart
bluetooth --> hci_uart
bluetooth --> bnep
bluetooth --> btbcm
bluetooth --> rfcomm
ecdh_generic --> bluetooth
ecc --> ecdh_generic
libaes --> bluetooth
libaes --> aes_arm
libaes --> aes_generic
garp --> 8021q
stp --> garp
llc --> garp
llc --> stp
brcmutil --> brcmfmac
cec --> vc4
libsha256 --> sha256_generic
drm_kms_helper --> vc4
cfg80211 --> brcmfmac
snd_soc_core --> vc4
snd_soc_core --> snd_soc_hdmi_codec
snd_compress --> snd_soc_core
snd_pcm_dmaengine --> snd_soc_core
syscopyarea --> drm_kms_helper
rfkill --> bluetooth
rfkill --> cfg80211
sysfillrect --> drm_kms_helper
sysimgblt --> drm_kms_helper
fb_sys_fops --> drm_kms_helper
v4l2_mem2mem --> bcm2835_codec
bcm2835_mmal_vchiq --> bcm2835_isp
bcm2835_mmal_vchiq --> bcm2835_codec
bcm2835_mmal_vchiq --> bcm2835_v4l2
videobuf2_vmalloc --> bcm2835_v4l2
videobuf2_dma_contig --> bcm2835_isp
videobuf2_dma_contig --> bcm2835_codec
videobuf2_memops --> videobuf2_dma_contig
videobuf2_memops --> videobuf2_vmalloc
videobuf2_v4l2 --> bcm2835_isp
videobuf2_v4l2 --> bcm2835_codec
videobuf2_v4l2 --> bcm2835_v4l2
videobuf2_v4l2 --> v4l2_mem2mem
videobuf2_common --> bcm2835_isp
videobuf2_common --> bcm2835_codec
videobuf2_common --> bcm2835_v4l2
videobuf2_common --> v4l2_mem2mem
videobuf2_common --> videobuf2_v4l2
snd_pcm --> snd_compress
snd_pcm --> snd_pcm_dmaengine
snd_pcm --> snd_soc_hdmi_codec
snd_pcm --> snd_bcm2835
snd_pcm --> snd_soc_core
snd_timer --> snd_pcm
snd --> snd_compress
snd --> snd_soc_hdmi_codec
snd --> snd_timer
snd --> snd_bcm2835
snd --> snd_soc_core
snd --> snd_pcm
videodev --> bcm2835_isp
videodev --> bcm2835_codec
videodev --> videobuf2_common
videodev --> bcm2835_v4l2
videodev --> v4l2_mem2mem
videodev --> videobuf2_v4l2
mc --> bcm2835_isp
mc --> bcm2835_codec
mc --> videobuf2_common
mc --> videodev
mc --> v4l2_mem2mem
mc --> videobuf2_v4l2
vc_sm_cma --> bcm2835_isp
vc_sm_cma --> bcm2835_mmal_vchiq
uio --> uio_pdrv_genirq
usb_f_rndis --> g_ether
u_ether --> g_ether
u_ether --> usb_f_rndis
u_serial --> usb_f_acm
libcomposite --> g_serial
libcomposite --> usb_f_acm
libcomposite --> g_ether
libcomposite --> usb_f_rndis
udc_core --> usb_f_acm
udc_core --> u_serial
udc_core --> dwc2
udc_core --> u_ether
udc_core --> usb_f_rndis
udc_core --> libcomposite
roles --> dwc2
drm --> vc4
drm --> drm_kms_helper
drm_panel_orientation_quirks --> drm
backlight --> drm
x_tables --> ip_tables
|
That output just confirms that g_serial only has libcomposite as a dependency |
It'd be really cool to have USB OTG serial console work with Raspberry Zero 2 W. It should be possible to use the DWC2 g_serial to provide a serial console over USB OTG, without having to use UART for it. This would be great because it doesn't require a serial/TTL adapter and leaves the UART usable for Bluetooth.
The text was updated successfully, but these errors were encountered: