{"action":"created","issue":{"url":"https://api.github.com/repos/raspberrypi/linux/issues/1239","labels_url":"https://api.github.com/repos/raspberrypi/linux/issues/1239/labels{/name}","comments_url":"https://api.github.com/repos/raspberrypi/linux/issues/1239/comments","events_url":"https://api.github.com/repos/raspberrypi/linux/issues/1239/events","html_url":"https://github.com/raspberrypi/linux/pull/1239","id":123942030,"number":1239,"title":"rpi-4.4.y: Add USB gadget support to Pi Zero","user":{"login":"notro","id":530887,"avatar_url":"https://avatars.githubusercontent.com/u/530887?v=3","gravatar_id":"","url":"https://api.github.com/users/notro","html_url":"https://github.com/notro","followers_url":"https://api.github.com/users/notro/followers","following_url":"https://api.github.com/users/notro/following{/other_user}","gists_url":"https://api.github.com/users/notro/gists{/gist_id}","starred_url":"https://api.github.com/users/notro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/notro/subscriptions","organizations_url":"https://api.github.com/users/notro/orgs","repos_url":"https://api.github.com/users/notro/repos","events_url":"https://api.github.com/users/notro/events{/privacy}","received_events_url":"https://api.github.com/users/notro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-12-26T17:54:49Z","updated_at":"2015-12-29T18:17:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/raspberrypi/linux/pulls/1239","html_url":"https://github.com/raspberrypi/linux/pull/1239","diff_url":"https://github.com/raspberrypi/linux/pull/1239.diff","patch_url":"https://github.com/raspberrypi/linux/pull/1239.patch"},"body":"Build the dwc2 usb driver as a module to be able to use the USB On-the-Go functionality (supports both host and device/peripheral mode).\r\nAdd a specific Device Tree file for Pi Zero with dwc2 enabled in otg mode. Also fix the inverted ACT led.\r\n\r\nThis requires a change in the bootloader to give the Zero a dtb of it's own. Currently it uses this:\r\n```\r\n~$ sudo vcdbg log msg\r\n001289.085: Loading 'bcm2708-rpi-b-plus.dtb' from SD card\r\n```\r\n\r\nThis PR can be tested by setting the dtb manually in /boot/config.txt:\r\n```\r\ndevice_tree=bcm2708-rpi-zero.dtb\r\n```\r\n\r\n**Testing**\r\n\r\nThis will give a serial console on a connected computer:\r\n```\r\nsudo modprobe g_serial\r\nsudo systemctl start getty@ttyGS0.service\r\n```\r\n\r\nOn my Windows 8 computer, the USB serial port shows up as: ELMO GMAS (COM5)\r\n\r\nHotswapping to a keyboard works.\r\n\r\n\r\n**Controller fifo**\r\n\r\nThe fifo assignment isn't optimal. This PR uses only 1024 of the 4080 available dynamic fifo entries:\r\n```\r\n[    8.779556] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM\r\n```\r\n\r\nCurrently assigned in Device Tree:\r\n```\r\n&usb {\r\n\tg-np-tx-fifo-size = <32>;\r\n\tg-rx-fifo-size = <256>;\r\n\tg-tx-fifo-size = <256 128 128 64 64 64 32>;\r\n};\r\n```\r\nI don't know how to best distribute the remaining entries.\r\n\r\n\r\n**Issue**\r\n\r\nWhen I disconnect the keyboard, I get a warning:\r\n```\r\n[   93.639089] g_serial gadget: Gadget Serial v2.4\r\n[   93.639120] g_serial gadget: g_serial ready\r\n[   93.642186] dwc2 20980000.usb: bound driver g_serial\r\n<connect computer>\r\n[  101.877358] dwc2 20980000.usb: new device is high-speed\r\n[  101.893135] dwc2 20980000.usb: new address 5\r\n[  101.908600] g_serial gadget: high-speed config #2: CDC ACM config\r\n<disconnect computer and connect keyboard>\r\n[  158.138483] usb 1-1: new low-speed USB device number 2 using dwc2\r\n[  158.355959] usb 1-1: New USB device found, idVendor=046d, idProduct=c313\r\n[  158.356001] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0\r\n[  158.356019] usb 1-1: Product: USB Multimedia Keyboard\r\n[  158.356036] usb 1-1: Manufacturer: LITEON Technology\r\n[  158.378340] input: LITEON Technology USB Multimedia Keyboard as /devices/platform/soc/20980000.usb/usb1/1-1/1-1:1.0/0003:046D:C313.0001/input/input0\r\n[  158.441305] hid-generic 0003:046D:C313.0001: input,hidraw0: USB HID v1.10 Keyboard [LITEON Technology USB Multimedia Keyboard] on usb-20980000.usb-1/input0\r\n[  158.454182] input: LITEON Technology USB Multimedia Keyboard as /devices/platform/soc/20980000.usb/usb1/1-1/1-1:1.1/0003:046D:C313.0002/input/input1\r\n[  158.509498] hid-generic 0003:046D:C313.0002: input,hidraw1: USB HID v1.10 Device [LITEON Technology USB Multimedia Keyboard] on usb-20980000.usb-1/input1\r\n<disconnect keyboard>\r\n[  186.039220] usb 1-1: USB disconnect, device number 2\r\n[  186.219073] ------------[ cut here ]------------\r\n[  186.219241] WARNING: CPU: 0 PID: 67 at drivers/usb/dwc2/gadget.c:176 dwc2_hsotg_init_fifo+0x18c/0x1ac [dwc2]()\r\n[  186.219258] Modules linked in: evdev usb_f_acm u_serial g_serial libcomposite cfg80211 rfkill dwc2 udc_core bcm2835_gpiomem bcm2835_wdt uio_pdrv_genirq uio i2c_dev snd_bcm2835 snd_pcm snd_timer snd fuse\r\n[  186.219359] CPU: 0 PID: 67 Comm: kworker/u2:2 Not tainted 4.4.0-rc6+ #2\r\n[  186.219371] Hardware name: BCM2708\r\n[  186.219435] Workqueue: dwc2 dwc2_conn_id_status_change [dwc2]\r\n[  186.219508] [<c0016ccc>] (unwind_backtrace) from [<c0013b3c>] (show_stack+0x20/0x24)\r\n[  186.219548] [<c0013b3c>] (show_stack) from [<c032682c>] (dump_stack+0x20/0x28)\r\n[  186.219584] [<c032682c>] (dump_stack) from [<c00222c8>] (warn_slowpath_common+0x8c/0xc4)\r\n[  186.219613] [<c00222c8>] (warn_slowpath_common) from [<c00223bc>] (warn_slowpath_null+0x2c/0x34)\r\n[  186.219697] [<c00223bc>] (warn_slowpath_null) from [<bf0ae6ac>] (dwc2_hsotg_init_fifo+0x18c/0x1ac [dwc2])\r\n[  186.219831] [<bf0ae6ac>] (dwc2_hsotg_init_fifo [dwc2]) from [<bf0b04e4>] (dwc2_hsotg_core_init_disconnected+0x60/0x35c [dwc2])\r\n[  186.219937] [<bf0b04e4>] (dwc2_hsotg_core_init_disconnected [dwc2]) from [<bf0a6824>] (dwc2_conn_id_status_change+0xe8/0x21c [dwc2])\r\n[  186.220001] [<bf0a6824>] (dwc2_conn_id_status_change [dwc2]) from [<c0039c70>] (process_one_work+0x13c/0x490)\r\n[  186.220029] [<c0039c70>] (process_one_work) from [<c003a13c>] (worker_thread+0x178/0x538)\r\n[  186.220064] [<c003a13c>] (worker_thread) from [<c003fee8>] (kthread+0xe0/0xfc)\r\n[  186.220097] [<c003fee8>] (kthread) from [<c000f788>] (ret_from_fork+0x14/0x2c)\r\n[  186.220114] ---[ end trace 900ecfdec3d84a77 ]---\r\n<connect computer>\r\n[  189.792998] dwc2 20980000.usb: new device is high-speed\r\n[  189.808759] dwc2 20980000.usb: new address 13\r\n[  189.831151] g_serial gadget: high-speed config #2: CDC ACM config\r\n\r\n```\r\n\r\n**Failed on 4.1**\r\n\r\nI also tried to do this PR on rpi-4.1.y but it didn't work and I didn't try to find out why. Got this error:\r\n```\r\n[    7.463269] dwc2 20980000.usb: no platform data or transceiver defined\r\n```\r\n\r\nThis PR is based on work done by several people in #1212\r\n"},"comment":{"url":"https://api.github.com/repos/raspberrypi/linux/issues/comments/167847196","html_url":"https://github.com/raspberrypi/linux/pull/1239#issuecomment-167847196","issue_url":"https://api.github.com/repos/raspberrypi/linux/issues/1239","id":167847196,"user":{"login":"gbaman","id":833193,"avatar_url":"https://avatars.githubusercontent.com/u/833193?v=3","gravatar_id":"","url":"https://api.github.com/users/gbaman","html_url":"https://github.com/gbaman","followers_url":"https://api.github.com/users/gbaman/followers","following_url":"https://api.github.com/users/gbaman/following{/other_user}","gists_url":"https://api.github.com/users/gbaman/gists{/gist_id}","starred_url":"https://api.github.com/users/gbaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbaman/subscriptions","organizations_url":"https://api.github.com/users/gbaman/orgs","repos_url":"https://api.github.com/users/gbaman/repos","events_url":"https://api.github.com/users/gbaman/events{/privacy}","received_events_url":"https://api.github.com/users/gbaman/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T18:17:55Z","updated_at":"2015-12-29T18:17:55Z","body":"Using a similar adapter to @mobluse, just gave it a go with my A+. Unfortunately not having any luck getting it to appear on attached computer. Have tried this pull request and also tried using a kernel with dwc2 set to Gadget only mode. Both without any luck on fresh Raspbian images."}}