aidantwoods / RPi0w-keyboard

Other
51 stars 9 forks source link

enableHid.sh not working #1

Open kontez opened 7 years ago

kontez commented 7 years ago

Hey, I followed your guide 1:1 and I have problems with the enableHid.sh, since at startup nothing happens I decided to run it manually and I get these errors:

pi@raspberrypi:~ $ sudo ./enableHid.sh
/home/pi/hid.sh: line 20: echo: write error: Device or resource busy
/home/pi/hid.sh: line 21: echo: write error: Device or resource busy
/home/pi/hid.sh: line 22: echo: write error: Device or resource busy
/home/pi/hid.sh: line 23: echo: write error: Device or resource busy 
ln: failed to create symbolic link ‘configs/c.1/hid.usb0’: File exists 
ls: write error: Device or resource busy

I also tried to power the pi and execute it via ssh over wifi since I thought the problem may be in the connected USB, but the errors are the same. Any known issues that may be causing this?

Thanks! :)


Edit from @aidantwoods: This appears to be a bug upstream, here are your options: https://github.com/aidantwoods/RPi0w-keyboard/issues/1#issuecomment-315045349

aidantwoods commented 7 years ago

Looks like the /dev/hidg0 device already exists by that error message, was ./enableHid.sh run at boot as-well?

aidantwoods commented 7 years ago

Just to clarify, enableHid.sh should only need to be run once per boot (and it looks like it's already been run), what happens when you try to send keystrokes with hid_gadget_test ?

kontez commented 7 years ago

Hey Aidan, thanks for the quick reply
Yes, enableHid.sh is executed at boot, in my rc.local I have

sudo /home/pi/enableHid.sh
sudo chmod -R 777 /dev/hidg0

as specified in your writeup.

The output of echo 'a' | /home/pi/hid_gadget_test /dev/hidg0 keyboard is: /dev/hidg0: No such file or directory

In /dev/ there is no hidgX device either:

pi@raspberrypi:~ $ ls /dev/ | grep hidg
pi@raspberrypi:~ $

The lines in the hid.sh where the command fails, are:

echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length
...

Thanks again!

aidantwoods commented 7 years ago

If you disable enableHid.sh running at boot and run it manually do you get any error messages? The one's you're currently getting all appear to be caused by the script being run twice (but something else must be failing initially if you don't see /dev/hidg0)

kontez commented 7 years ago

Sorry for the delay, I disabled enableHid.sh at boot and ran it manually after startup, the onyl error message I get is:

pi@raspberrypi:~ $ sudo /home/pi/enableHid.sh
ls: write error: Device or resource busy
pi@raspberrypi:~ $ ls /dev/ | grep hidg
pi@raspberrypi:~ $
aidantwoods commented 7 years ago

Hmm, looks like the last line of hid.sh isn't running properly for some reason in that case.

Tried Googling for "ls /sys/class/udc ls: write error: Device or resource busy" and a few results seem to be with RPis, no solution I can see immediately from a search though.

Have you got anything plugged into the OTG port on the Pi when you execute this?

Just to double check, your pi isn't running in some other OTG at the same time, e.g. emulating a network over USB ethernet?

Could you print out the contents of your /boot/config.txt and /etc/modules files?

kontez commented 7 years ago

I have nothing plugged in, only the USB cable from the Pi to the PC on the data usb port.
This is my /boot/config.txt:

pi@raspberrypi:~ $ cat /boot/config.txt
# For more options and information see
# http://rpf.io/configtxtreadme
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

dtoverlay=dwc2

And this is my /etc/modules:

pi@raspberrypi:~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
dwc2

The Pi should be the same model as yours as I bought the kit you linked on your blog! Thanks!

aidantwoods commented 7 years ago

Hmm... as far as I can tell those files are identical to mine

Do these commands match your output?

screen shot 2017-05-17 at 15 17 33

Also, perhaps try adding g_hid on a new line in /etc/modules (shouldn't really need it because of the modprobe in the hid.sh script).

aidantwoods commented 7 years ago

Could you confirm you're using raspbian jessie too? I'm using the lite (GUI-less version) (though I can't see why the other would have drivers absent).

And also that this matches up (I can't see why any of this would be missing, since it's meant to be bundled with the OS).

screen shot 2017-05-17 at 15 29 33
kontez commented 7 years ago

I downloaded the latest raspian jessie lite I could find when installing it, it's the 2017-04-10. The commands do not match your output:

pi@raspberrypi:~ $ uname -r
4.9.24+
pi@raspberrypi:~ $ lsmod | egrep -i 'libcomposite|hid'
libcomposite           49619  3 usb_f_ecm,g_ether,usb_f_rndis
udc_core               40356  5 usb_f_ecm,dwc2,u_ether,usb_f_rndis,libcomposite

the last one matches though

aidantwoods commented 7 years ago

Possibly something has been broken in the newer OS, unfortunate if that's the case. I'll try and investigate that.

In the meantime (if the problem is stemming from the newer kernel) you might be able to fix it by downgrading your kernel version to the 4.4.x branch (though I'd advise taking an image of the SD card prior, incase the Pi isn't bootable after doing that – that way you can revert the change by just re-imaging the SD card with your backup, instead of having to setup from scratch).

You should be able to install 4.4.50+ by running

sudo rpi-update 52241088c1da59a359110d39c1875cda56496764
kontez commented 7 years ago

I'll try it asap Thanks again!

kontez commented 7 years ago

the pi died after that haha are there any other ways I could roll back to an older kernel?

aidantwoods commented 7 years ago

Ha, yeah... not entirely surprised by that 😉

I guess you could always use an older OS – just out of question, where did you get this OS from?

Download page I'm looking at gives the current version release dated such that it's likely the version I picked up, and kernel version at 4.4

screen shot 2017-05-22 at 17 04 03

https://www.raspberrypi.org/downloads/raspbian/

kontez commented 7 years ago

I probably updated it during the setup, I can try with a fresh setup! Unfortunately I don't have a lot of time, so the replies are delayed sometimes, sorry for that. Thanks for your help!

Ax3l-91 commented 7 years ago

Hello all, any news @aidantwoods? I have the same issues :( Thanks a lot for your help

aidantwoods commented 7 years ago

Hi there @Ax3l-91

Are you also using the 4.9 kernel, or is the problem replicated on 4.4? (check with uname -r).

Ax3l-91 commented 7 years ago

Hello, Yes on 4.4.50+, I've tried everything, on 4.9as weel, I've ls: write error: Device or resource busy. I don't know know to do... I also view many topics on rc-local issues because it doesn't execute scripts, when I check his status I've that : sudo systemctl status rc-local.service

`rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; static) Drop-In: /etc/systemd/system/rc-local.service.d └─ttyoutput.conf Active: failed (Result: exit-code) since sam. 2017-06-10 16:46:11 CEST; 18s ago Process: 712 ExecStart=/etc/rc.local start (code=exited, status=2)

juin 10 16:46:11 raspberrypi sudo[714]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAN....sh juin 10 16:46:11 raspberrypi sudo[714]: pam_unix(sudo:session): session opened for user...=0) juin 10 16:46:11 raspberrypi sudo[719]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAN....sh juin 10 16:46:11 raspberrypi sudo[719]: pam_unix(sudo:session): session opened for user...=0) juin 10 16:46:11 raspberrypi sudo[719]: pam_unix(sudo:session): session closed for user root juin 10 16:46:11 raspberrypi sudo[714]: pam_unix(sudo:session): session closed for user root juin 10 16:46:11 raspberrypi systemd[1]: rc-local.service: control process exited, code...s=2 juin 10 16:46:11 raspberrypi systemd[1]: Failed to start /etc/rc.local Compatibility. juin 10 16:46:11 raspberrypi systemd[1]: Unit rc-local.service entered failed state.

Warning: Unit file changed on disk, 'systemctl daemon-reload' recommended. Hint: Some lines were ellipsized, use -l to show in full`

I don't know if it's related or not... I added sh on sudo /home/pi/hid.sh to recognize the command...

aidantwoods commented 7 years ago

Cheers for going through the steps on both kernel versions, looks like the version I used to set everything up was released on 2017-03-02 (so not the current latest). I'll try and set aside some time to see if I can reproduce this starting from a clean install of the latest raspbian.

Will report back on what I find. :)

aidantwoods commented 7 years ago

I was able to reproduce the script not working on the later kernel version. Looks very much like a bug to me.

I've put together an install script that should work right off the bat on a clean install of jessie (the specific version I'm working with is dated 2017-04-10), which has a working internet connection.

Make sure that if you used the OTG port as an initial communication channel to the Pi (as described here https://gist.github.com/gbaman/975e2db164b3ca2b51ae11e45e8fd40a) that you go into /boot/cmdline.txt and remove modules-load=dwc2,g_ether (after setting up another communication channel of course, i.e. broadcast or connect to a WiFi network).

After you've got all that sorted, the following should setup everything this will automatically download and install the kernel version 4.4.50+ if you are not already running it.

BACKUP IF NECESSARY BEFORE RUNNING THIS

Also, make sure rpi-update is installed (sudo apt-get install rpi-update) if you are not running the correct kernel version before running these.

gpg --recv-keys 9A6A8EFAA512BBB9
wget https://gist.githubusercontent.com/aidantwoods/87b720761fd88973b7740b4b425fd66a/raw/4e23f1d59ebe59796064d7be756c74ed36050c05/install-hid.sh.asc
gpg -o install-hid.sh -d install-hid.sh.asc && chmod +x install-hid.sh && ./install-hid.sh

After that

sudo reboot

And after reboot, check you are able to run sudo ./hid.sh and maybe do an ls /dev/hidg0 for good measure that the hid device was created. You should then be able to pick back up on the guide to set that to start at boot etc...

If you'd like to see my entire build process starting right after writing jessie to the pi, see this gist (where /Volumes/boot on my local machine is the mounted SD card's boot partition).

Here's the final screenshot where I ask the Pi to send the keystroke "a", and an "a" appears back in my terminal (Pi is plugged in to my machine).

screen shot 2017-06-17 at 23 43 23
aidantwoods commented 7 years ago

@Ax3l-91 you mentioned you were having issues on 4.4.50+, could you confirm that the OTG port is not in use at time of running the script to setup the Pi as a HID?

If so, could you prevent it running on boot and run the ./hid.sh script manually, and let me know any output you get?

aidantwoods commented 7 years ago

@kontez

the pi died after that haha

I tried upgrading to the latest kernel available, and then using rpi-update to drop back down to 4.4.50+ (using the same command I posted earlier). I managed to have to Pi boot fine after that, so not entirely sure what happened. Did you encounter any errors during the kernel installation process?

If you start from a fresh install of jessie then the kernel will be at the correct version anyway (I observed it updating if you do an apt-get update && apt-get upgrade though).

Ax3l-91 commented 7 years ago

Hello @aidantwoods, Thank you! All run right now, my OTG port should run at the same time...

Ax3l-91 commented 7 years ago

Hi again @aidantwoods,

I wanted to try your quack.php script but I have this error relative to this line: function translate(string $l) : array PHP Parse error: syntax error, unexpected ':', expecting '{' in /home/pi/quack.php on line 47

Thanks in advance for your help!

aidantwoods commented 7 years ago

Hi @Ax3l-91,

Looks like you're running an old version of PHP?

The colon denotes a return type declaration, which need ≥ PHP 7 (http://php.net/manual/en/migration70.new-features.php#migration70.new-features.return-type-declarations)

You can either remove the return type declarations (remove the colon and the type from the lines they are on), or update PHP to a recent version :)


If you wanted to update PHP, I think I just compiled from source on the Pi (think I recall 7 not being available on apt-get when I checked). But this script designed to configure it on Kali (another debian distribution) should work fine on the Pi (haven't tested it though so possible it doesn't grab all the needed dependencies).

https://gist.github.com/aidantwoods/bb26af07588c7fa6c68be237a1caf22c

You'd just need to cd php* and then run make, (make test if you like), and sudo make install after that.

(though for the quack.php script it'll run on a bare bones install of PHP without all the usual config options – so you could easily compile from source too).


I've copied that answer over to #2 so it's a little more searchable incase anyone else runs into the same issue, let me know over there if that answer helps/you need more info :)

julianwieg commented 7 years ago

Hi, same issue with "2017-06-21-raspbian-jessie-lite.zip" and yes I was clever enough to go into cmdline.txt and remove the modules-load=dwc2,g_ether string I used for headless setup after troubleshooting why the script fails at line #20 root@duckypi:/sys/kernel/config/usb_gadget/g1# echo 1 > functions/hid.usb0/protocol bash: echo: write error: Device or resource busy

So what is the solution or workaround now? Is to go to kernel 4.4.50+ and use the install script you mentioned above?

Bit confusing with all the replies going on :) Thanks

aidantwoods commented 7 years ago

Hi @julianwieg,

Workaround/fix is using the earlier kernel. If you've set everything else up already then you only need install 4.4.50+. If you happen to start again from scratch then the install script I mentioned will just run through all the setup steps that you've likely already done, as well as installing the known good kernel.

julianwieg commented 7 years ago

Worked but does anyone else have Windows initially say: USB device not recognised/not working error and then 4 5 seconds later the "not working" device in Device Manager disappears and a new HID device appears? That for all intense and purposes is not very stealthy :)

What I did to get it working:

  1. So I did a fresh install of Jessie with kernel 4.4.50+ from https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-03-03/
  2. Setup Wifi Hotspot aka AP per another website linked on your blog/website
  3. Followed your guide on your blog/website
  4. https://github.com/anbud/DroidDucky
  5. https://github.com/theresalu/rspiducky -> copy usleep.c into pi home dir. make usleep.c move usleep into the bin directory so its available to the scripts. also rename/copy the hidgadget test app to - to as the droidducky uses another naming convention so the droidducky script cannot call/use the hid_gadget app otherwise due to the wrong name.
aidantwoods commented 7 years ago

Great to hear that worked!

does anyone else have Windows initially say: USB device not recognised/not working error and then 4 5 seconds later the "not working" device in Device Manager disappears and a new HID device appears? That for all intense and purposes is not very stealthy :)

Shall we move this to a separate issue? As you mentioned, this one is already quite hard to follow 😉

aidantwoods commented 7 years ago

I'll leave this open, since I suspect it's a bug others will run into. For anyone arriving, the available options for a workaround/fix are:

  1. Use working kernel version, before this (probably a bug) was introduced: https://github.com/aidantwoods/RPi0w-keyboard/issues/1#issuecomment-309244795
  2. Report this as an issue upstream

I haven't reported upstream, but anyone who wishes to is welcome to do so :)

julianwieg commented 7 years ago

Absolutely... sorry that's a to early in the morning fail

On Thu 13. Jul 2017 at 12:44, Aidan Woods notifications@github.com wrote:

Great to hear that worked!

does anyone else have Windows initially say: USB device not recognised/not working error and then 4 5 seconds later the "not working" device in Device Manager disappears and a new HID device appears? That for all intense and purposes is not very stealthy :)

Shall we move this to a separate issue? As you mentioned, this one is already quite hard to follow 😉

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aidantwoods/RPi0w-keyboard/issues/1#issuecomment-315042407, or mute the thread https://github.com/notifications/unsubscribe-auth/AcPdqjM7jLeY69WL07Z-8JWuxc1ib0XFks5sNfUUgaJpZM4NSCLB .

karpana commented 7 years ago

I figured I would sound i on this as well... I'm running 2017-07-05-raspbian-jessie-lite on a Raspberry Pi Zero W and having the same issues...

uname -r 4.9.35+

The problem I'm running into, as desxcirbed above, is the /dev/hidg0 file/entry isn't being created, so the chmod command (in rc.local) fails and causes a non-zero exit.

karpana commented 7 years ago

disabling the startup stuff in rc.local, and trying to run this manually gives this

pi@raspberrypi:~ $ sudo ./enableHid.sh

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.090387] Internal error: Oops: 17 [#1] ARM

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.121635] Process ls (pid: 678, stack limit = 0xd8d22188)

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.123692] Stack: (0xd8d23d98 to 0xd8d24000)

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.125681] 3d80:                                                       00000001 d8e6a970

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.129574] 3da0: 00000000 bf3cdc80 d8d23dec d8d23db8 bf3cc7f0 bf0b6fcc da761880 da567d24

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.133541] 3dc0: d8d23e04 d8d23dd0 bf0b237c d8e6a970 da567ca8 d84285e0 da567d1c d8e6a970

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.137548] 3de0: d8d23e04 d8d23df0 bf0b20c0 bf3cc75c da567ca8 d842868c d8d23e3c d8d23e08

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.141638] 3e00: bf0b638c bf0b2050 da599d10 d8428654 c013ef88 da6daa00 bf07bea4 d84285e0

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.145888] 3e20: d84285e0 bf07be98 00000000 d8ecc000 d8d23e5c d8d23e40 bf079838 bf0b614c

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.150368] 3e40: 00000000 da6daa00 bf07bea4 da706b80 d8d23e84 d8d23e60 bf079d68 bf079808

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.155057] 3e60: 00000032 da706b80 da7ee3c0 d8428400 d8428590 0000000d d8d23eac d8d23e88

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.159976] 3e80: bf0b6d18 bf079c74 0000000d da7ee3c0 da7ee3d8 d8d23f80 d8d12460 b6f10000

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.164937] 3ea0: d8d23edc d8d23eb0 c01bb3b8 bf0b6c74 d8d23f80 d8d12460 d8d23f80 b6f10000

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.170120] 3ec0: d8d23f80 0000000d d8d22000 00000000 d8d23f4c d8d23ee0 c0144244 c01bb2f0

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.175523] 3ee0: b6f10000 d8d23fb0 01858df8 00000000 d8d23fac d8d23f00 c0009204 c05d4f30

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.180938] 3f00: 59826229 181ece00 00002949 d8d89894 00000003 00001000 00000000 c0145040

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.186419] 3f20: d8d22000 c0147778 d8d23f4c 0000000d d8d12460 b6f10000 d8d23f80 c000ffc4

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.191904] 3f40: d8d23f7c d8d23f50 c014507c c0144218 00000001 c01624c4 d8d12460 d8d12460

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.197310] 3f60: 0000000d b6f10000 c000ffc4 d8d22000 d8d23fa4 d8d23f80 c014618c c0144fd8

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.202792] 3f80: 00000000 00000000 0000000d b6f10000 b6e87b40 00000004 00000000 d8d23fa8

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.208273] 3fa0: c000fe40 c0146144 0000000d b6f10000 00000001 b6f10000 0000000d 00000000

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.213689] 3fc0: 0000000d b6f10000 b6e87b40 00000004 0000000d b6f10000 0000000d 00000000

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.219168] 3fe0: 00000000 bee311ec b6db5008 b6e0c89c 60000010 00000001 03481009 f002debf

Message from syslogd@raspberrypi at Aug  2 23:37:13 ...
 kernel:[   64.280621] Code: ebff044b e2506000 0a000013 e5952024 (e1d230d2)
/home/pi/hid.sh: line 29:   678 Segmentation fault      ls /sys/class/udc > UDC
aidantwoods commented 7 years ago

Hi @karpana,

Yes, as mentioned above something changed in the kernel since 4.4.50+ (which is the last known working version for this), meaning 4.9.35+ isn't really expected to work. Have you tried downgrading the kernel as described in https://github.com/aidantwoods/RPi0w-keyboard/issues/1#issuecomment-309244795?

On another note, please feel free to open a bug upstream (https://github.com/Hexxeh/rpi-firmware) 😉 (unfortunately I don't think there's anything I can do within the scope of this project to get it working on the latter kernel).

karpana commented 7 years ago

not yet... but I'll be doing so on my next attempt... I've tried about a dozen different ways of getting this pi to work like a keyboard... for a project I'll be working on... but if an older kernel will work... I'll give it a go... and then have to figure out how to NOT upgrade the kernel thereafter. ;-)

I'll definitely look at opening an upstream bug.

karpana commented 7 years ago

is there a way to downgrade the kernel without reimaging (I"m sorta new to using Rpi)

aidantwoods commented 7 years ago

In the linked comment make sure to take a look at the linked gist – contains a script to do most of the setup for you :)

I'll definitely look at opening an upstream bug.

Cheers, unfortunately I haven't really found the time to try and properly identify the cause


is there a way to downgrade the kernel without reimaging (I"m sorta new to using Rpi)

Yes, using rpi-update – always a risk of bricking the install (so you should backup data/take an image beforehand to be safe). If you're just wanting to avoid re-doing setup, hopefully the script should help though (also see the linked log for complete step by step from clean install).

aidantwoods commented 7 years ago

Looks like the latest Jessie now includes the broken kernel by default, which is unfortunate.

Last known one that will have a working kernel without needing to downgrade is here: https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-04-10/

I think you may have to avoid doing apt-get upgrade though, or the Pi will update the kernel if I recall :/

karpana commented 7 years ago

thank you. I"ll download the one you linked... reimage and move forward from there... I don't think anything I plan on doing for this project needs the latest kernel.

zontarian commented 6 years ago

Again I can confirm it works with the Raspbian lite of 2017-04-10 as above. I've tried frutlessly with Raspbian 4.9 for a few hours and then with your scripts(and your suggestion) it worked immediately. Thanks!

timothyleung1 commented 5 years ago

I followed the build that you provided but when I run echo "a" | sudo ./hid_gadget_test /dev/hidg0 keyboard, it just hangs.

^Croot@raspberrypi:/home/pi# uname -r
4.4.50+
pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# ls
config.txt
root@raspberrypi:/home/pi# rm  config.txt
root@raspberrypi:/home/pi# echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt
dtoverlay=dwc2
root@raspberrypi:/home/pi# echo "dwc2" | sudo tee -a /etc/modules
dwc2
root@raspberrypi:/home/pi# sudo echo "libcomposite" | sudo tee -a /etc/modules
libcomposite
root@raspberrypi:/home/pi# gpg
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: Go ahead and type your message ...
gpg: processing message failed: eof
root@raspberrypi:/home/pi# gpg --recv-keys 9A6A8EFAA512BBB9
gpg: requesting key A512BBB9 from hkp server keys.gnupg.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key A512BBB9: public key "Aidan Woods <aidantwoods@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
root@raspberrypi:/home/pi# wget https://gist.githubusercontent.com/aidantwoods/87b720761fd88973b7740b4b425fd66a/raw/4e23f1d59ebe59796064d7be756c74ed36050c05/install-hid.sh.asc
--2019-03-06 05:09:00--  https://gist.githubusercontent.com/aidantwoods/87b720761fd88973b7740b4b425fd66a/raw/4e23f1d59ebe59796064d7be756c74ed36050c05/install-hid.sh.asc
Resolving gist.githubusercontent.com (gist.githubusercontent.com)... 151.101.28.133
Connecting to gist.githubusercontent.com (gist.githubusercontent.com)|151.101.28.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1597 (1.6K) [text/plain]
Saving to: ‘install-hid.sh.asc’

install-hid.sh.asc        100%[====================================>]   1.56K  --.-KB/s   in 0s

2019-03-06 05:09:01 (4.62 MB/s) - ‘install-hid.sh.asc’ saved [1597/1597]

root@raspberrypi:/home/pi# gpg --edit-key aidan
gpg (GnuPG) 1.4.18; Copyright (C) 2014 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

pub  4096R/A512BBB9  created: 2016-11-20  expires: 2020-11-19  usage: SC
                     trust: unknown       validity: unknown
sub  4096R/3CEF3959  created: 2016-11-20  expires: 2020-11-19  usage: E
[ unknown] (1). Aidan Woods <aidantwoods@gmail.com>

gpg> trust
pub  4096R/A512BBB9  created: 2016-11-20  expires: 2020-11-19  usage: SC
                     trust: unknown       validity: unknown
sub  4096R/3CEF3959  created: 2016-11-20  expires: 2020-11-19  usage: E
[ unknown] (1). Aidan Woods <aidantwoods@gmail.com>

Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)

  1 = I don't know or won't say
  2 = I do NOT trust
  3 = I trust marginally
  4 = I trust fully
  5 = I trust ultimately
  m = back to the main menu

Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y

pub  4096R/A512BBB9  created: 2016-11-20  expires: 2020-11-19  usage: SC
                     trust: ultimate      validity: unknown
sub  4096R/3CEF3959  created: 2016-11-20  expires: 2020-11-19  usage: E
[ unknown] (1). Aidan Woods <aidantwoods@gmail.com>
Please note that the shown key validity is not necessarily correct
unless you restart the program.

gpg> q
root@raspberrypi:/home/pi# wget https://gist.githubusercontent.com/aidantwoods/87b720761fd88973b7740b4b425fd66a/raw/4e23f1d59ebe59796064d7be756c74ed36050c05/install-hid.sh.asc
--2019-03-06 05:09:28--  https://gist.githubusercontent.com/aidantwoods/87b720761fd88973b7740b4b425fd66a/raw/4e23f1d59ebe59796064d7be756c74ed36050c05/install-hid.sh.asc

Resolving gist.githubusercontent.com (gist.githubusercontent.com)... 151.101.28.133
Connecting to gist.githubusercontent.com (gist.githubusercontent.com)|151.101.28.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1597 (1.6K) [text/plain]
Saving to: ‘install-hid.sh.asc.1’

install-hid.sh.asc.1      100%[====================================>]   1.56K  --.-KB/s   in 0s

2019-03-06 05:09:29 (4.49 MB/s) - ‘install-hid.sh.asc.1’ saved [1597/1597]

root@raspberrypi:/home/pi#
root@raspberrypi:/home/pi# gpg -o install-hid.sh -d install-hid.sh.asc && chmod +x install-hid.sh && ./install-hid.sh
gpg: Signature made Sat 17 Jun 2017 21:38:31 UTC using RSA key ID A512BBB9
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2020-11-19
gpg: Good signature from "Aidan Woods <aidantwoods@gmail.com>"
gpg: Signature made Sat 17 Jun 2017 17:57:11 UTC using RSA key ID A512BBB9
gpg: Good signature from "Aidan Woods <aidantwoods@gmail.com>"
gpg: Signature made Sat 17 Jun 2017 17:57:14 UTC using RSA key ID A512BBB9
gpg: Good signature from "Aidan Woods <aidantwoods@gmail.com>"
root@raspberrypi:/home/pi# sudo reboot
packet_write_wait: Connection to 192.168.1.93 port 22: Broken pipe
[~]$ ssh pi@192.168.1.93
pi@192.168.1.93's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Mar  6 05:04:51 2019 from fla-sp-m1g8wl.home

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $ ls
hid_gadget_test    hid-gadget-test.c.asc  hid.sh.asc      install-hid.sh.asc
hid-gadget-test.c  hid.sh                 install-hid.sh  install-hid.sh.asc.1
pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# sudo ./hid.sh
root@raspberrypi:/home/pi# ls /dev/hidg0
/dev/hidg0
root@raspberrypi:/home/pi# echo "a" | sudo ./hid_gadget_test /dev/hidg0 keyboard
^Croot@raspberrypi:/home/pi# uname -r
4.4.50+
root@raspberrypi:/home/pi#
timothyleung1 commented 5 years ago

Any ideas on how to debug the issue?

timothyleung1 commented 5 years ago

dmesg output provided

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 4.4.50+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #970 Mon Feb 20 19:12:50 GMT 2017
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine model: Raspberry Pi Zero W Rev 1.1
[    0.000000] cma: Reserved 8 MiB at 0x1b400000
[    0.000000] Memory policy: Data cache writeback
[    0.000000] On node 0 totalpages: 114688
[    0.000000] free_area_init_node: node 0, pgdat c08844b4, node_mem_map db010000
[    0.000000]   Normal zone: 1008 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 114688 pages, LIFO batch:31
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113680
[    0.000000] Kernel command line: 8250.nr_uarts=0 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 dma.dmachans=0x7f35 bcm2708.boardrev=0x9000c1 bcm2708.serial=0x52fb5841 bcm2708.uart_clock=48000000 bcm2708.disk_led_gpio=47 smsc95xx.macaddr=B8:27:EB:FB:58:41 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=PARTUUID=fad27579-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 436516K/458752K available (6063K kernel code, 437K rwdata, 1844K rodata, 376K init, 726K bss, 14044K reserved, 8192K cma-reserved)
[    0.000000] Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xdc800000 - 0xff800000   ( 560 MB)
    lowmem  : 0xc0000000 - 0xdc000000   ( 448 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc07c1094   (7909 kB)
      .init : 0xc07c2000 - 0xc0820000   ( 376 kB)
      .data : 0xc0820000 - 0xc088d590   ( 438 kB)
       .bss : 0xc088d590 - 0xc0943150   ( 727 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000029] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000072] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000170] bcm2835: system timer (irq = 27)
[    0.000475] Console: colour dummy device 80x30
[    0.001421] console [tty1] enabled
[    0.001475] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
[    0.060343] pid_max: default: 32768 minimum: 301
[    0.060741] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.060812] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.061842] Disabling cpuset control group subsystem
[    0.061943] Initializing cgroup subsys io
[    0.062008] Initializing cgroup subsys memory
[    0.062095] Initializing cgroup subsys devices
[    0.062157] Initializing cgroup subsys freezer
[    0.062215] Initializing cgroup subsys net_cls
[    0.062332] CPU: Testing write buffer coherency: ok
[    0.062447] ftrace: allocating 20652 entries in 61 pages
[    0.173518] Setting up static identity map for 0x81c0 - 0x81f8
[    0.175457] devtmpfs: initialized
[    0.184965] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    0.185574] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.187464] pinctrl core: initialized pinctrl subsystem
[    0.188460] NET: Registered protocol family 16
[    0.194111] DMA: preallocated 4096 KiB pool for atomic coherent allocations
[    0.202816] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.202905] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.203182] Serial: AMBA PL011 UART driver
[    0.203460] uart-pl011 20201000.uart: could not find pctldev for node /soc/gpio@7e200000/uart0_pins, deferring probe
[    0.203831] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    0.248586] bcm2835-dma 20007000.dma: DMA legacy API manager at f2007000, dmachans=0x1
[    0.249541] SCSI subsystem initialized
[    0.249938] usbcore: registered new interface driver usbfs
[    0.250115] usbcore: registered new interface driver hub
[    0.250357] usbcore: registered new device driver usb
[    0.253419] raspberrypi-firmware soc:firmware: Attached to firmware from 2017-04-05 11:49
[    0.281226] clocksource: Switched to clocksource timer
[    0.332979] FS-Cache: Loaded
[    0.333481] CacheFiles: Loaded
[    0.353459] NET: Registered protocol family 2
[    0.354881] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.355038] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.355169] TCP: Hash tables configured (established 4096 bind 4096)
[    0.355301] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.355370] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.355752] NET: Registered protocol family 1
[    0.356424] RPC: Registered named UNIX socket transport module.
[    0.356501] RPC: Registered udp transport module.
[    0.356539] RPC: Registered tcp transport module.
[    0.356574] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.357896] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[    0.359423] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.376505] VFS: Disk quotas dquot_6.6.0
[    0.376975] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.379740] FS-Cache: Netfs 'nfs' registered for caching
[    0.381202] NFS: Registering the id_resolver key type
[    0.381439] Key type id_resolver registered
[    0.381486] Key type id_legacy registered
[    0.386013] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.386543] io scheduler noop registered
[    0.386632] io scheduler deadline registered (default)
[    0.387099] io scheduler cfq registered
[    0.389916] BCM2708FB: allocated DMA memory 5b800000
[    0.390047] BCM2708FB: allocated DMA channel 0 @ f2007000
[    0.398176] Console: switching to colour frame buffer device 82x26
[    0.408128] bcm2835-rng 20104000.rng: hwrng registered
[    0.411063] vc-cma: Videocore CMA driver
[    0.413879] vc-cma: vc_cma_base      = 0x00000000
[    0.416595] vc-cma: vc_cma_size      = 0x00000000 (0 MiB)
[    0.419147] vc-cma: vc_cma_initial   = 0x00000000 (0 MiB)
[    0.422047] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    0.452556] brd: module loaded
[    0.467444] loop: module loaded
[    0.471048] vchiq: vchiq_init_state: slot_zero = 0xdb880000, is_master = 0
[    0.476046] Loading iSCSI transport class v2.0-870.
[    0.480231] usbcore: registered new interface driver smsc95xx
[    0.483430] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    0.486467] dwc_otg: FIQ enabled
[    0.486496] dwc_otg: NAK holdoff enabled
[    0.486507] dwc_otg: FIQ split-transaction FSM enabled
[    0.486571] Module dwc_common_port init
[    0.487203] usbcore: registered new interface driver usb-storage
[    0.490316] mousedev: PS/2 mouse device common for all mice
[    0.494182] bcm2835-cpufreq: min=700000 max=1000000
[    0.497202] sdhci: Secure Digital Host Controller Interface driver
[    0.499835] sdhci: Copyright(c) Pierre Ossman
[    0.502933] sdhost: log_buf @ db810000 (5b810000)
[    0.561312] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    0.566825] mmc-bcm2835 20300000.mmc: mmc_debug:0 mmc_debug2:0
[    0.569465] mmc-bcm2835 20300000.mmc: DMA channel allocated
[    0.631487] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.634840] ledtrig-cpu: registered to indicate activity on CPUs
[    0.637736] hidraw: raw HID events driver (C) Jiri Kosina
[    0.640870] usbcore: registered new interface driver usbhid
[    0.643742] usbhid: USB HID core driver
[    0.647987] Initializing XFRM netlink socket
[    0.650760] NET: Registered protocol family 17
[    0.653717] Key type dns_resolver registered
[    0.658364] registered taskstats version 1
[    0.661973] vc-sm: Videocore shared memory driver
[    0.664704] [vc_sm_connected_init]: start
[    0.669838] [vc_sm_connected_init]: end - returning 0
[    0.675168] 20201000.uart: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    0.681331] of_cfs_init
[    0.683940] of_cfs_init: OK
[    0.689002] mmc0: host does not support reading read-only switch, assuming write-enable
[    0.694195] Waiting for root device PARTUUID=fad27579-02...
[    0.702851] mmc0: new high speed SDHC card at address aaaa
[    0.706516] mmcblk0: mmc0:aaaa SC16G 14.8 GiB
[    0.712330]  mmcblk0: p1 p2
[    0.734665] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[    0.738974] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    0.743190] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    0.748617] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[    0.821576] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    0.826561] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    0.841645] devtmpfs: mounted
[    0.845597] Freeing unused kernel memory: 376K (c07c2000 - c0820000)
[    0.877905] mmc1: new high speed SDIO card at address 0001
[    1.142029] random: systemd: uninitialized urandom read (16 bytes read, 15 bits of entropy available)
[    1.154075] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)
[    1.160599] systemd[1]: Detected architecture 'arm'.
[    1.298616] NET: Registered protocol family 10
[    1.303469] systemd[1]: Inserted module 'ipv6'
[    1.311899] systemd[1]: Set hostname to <raspberrypi>.
[    1.315286] random: systemd: uninitialized urandom read (16 bytes read, 16 bits of entropy available)
[    1.321448] systemd[1]: Initializing machine ID from random generator.
[    1.325318] systemd[1]: Installed transient /etc/machine-id file.
[    1.547201] random: systemd-sysv-ge: uninitialized urandom read (16 bytes read, 17 bits of entropy available)
[    1.670686] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    1.679320] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    1.688509] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    1.726937] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    1.735679] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    1.743020] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    1.811944] random: systemd: uninitialized urandom read (16 bytes read, 19 bits of entropy available)
[    2.042611] systemd[1]: Cannot add dependency job for unit regenerate_ssh_host_keys.service, ignoring: Unit regenerate_ssh_host_keys.service failed to load: No such file or directory.
[    2.055262] systemd[1]: Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory.
[    2.072859] systemd[1]: Starting Forward Password Requests to Wall Directory Watch.
[    2.081773] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[    2.089831] systemd[1]: Starting Remote File Systems (Pre).
[    2.098955] systemd[1]: Reached target Remote File Systems (Pre).
[    2.103232] systemd[1]: Starting Encrypted Volumes.
[    2.111667] systemd[1]: Reached target Encrypted Volumes.
[    2.115797] systemd[1]: Starting Arbitrary Executable File Formats File System Automount Point.
[    2.128530] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point.
[    2.136079] systemd[1]: Starting Swap.
[    2.143914] systemd[1]: Reached target Swap.
[    2.147538] systemd[1]: Expecting device dev-disk-by\x2dpartuuid-fad27579\x2d01.device...
[    2.158272] systemd[1]: Starting Root Slice.
[    2.165907] systemd[1]: Created slice Root Slice.
[    2.169308] systemd[1]: Starting User and Session Slice.
[    2.176860] systemd[1]: Created slice User and Session Slice.
[    2.180227] systemd[1]: Starting /dev/initctl Compatibility Named Pipe.
[    2.187826] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe.
[    2.191478] systemd[1]: Starting Delayed Shutdown Socket.
[    2.198958] systemd[1]: Listening on Delayed Shutdown Socket.
[    2.202418] systemd[1]: Starting Journal Socket (/dev/log).
[    2.209668] systemd[1]: Listening on Journal Socket (/dev/log).
[    2.213152] systemd[1]: Starting udev Control Socket.
[    2.220409] systemd[1]: Listening on udev Control Socket.
[    2.223850] systemd[1]: Starting udev Kernel Socket.
[    2.230789] systemd[1]: Listening on udev Kernel Socket.
[    2.234074] systemd[1]: Starting Journal Socket.
[    2.240973] systemd[1]: Listening on Journal Socket.
[    2.244404] systemd[1]: Starting System Slice.
[    2.251479] systemd[1]: Created slice System Slice.
[    2.254695] systemd[1]: Starting File System Check on Root Device...
[    2.266569] systemd[1]: Starting system-systemd\x2dfsck.slice.
[    2.282967] systemd[1]: Created slice system-systemd\x2dfsck.slice.
[    2.288140] systemd[1]: Starting system-getty.slice.
[    2.307272] systemd[1]: Created slice system-getty.slice.
[    2.310569] systemd[1]: Starting Increase datagram queue length...
[    2.330769] systemd[1]: Starting Restore / save the current clock...
[    2.368520] systemd[1]: Mounting POSIX Message Queue File System...
[    2.401717] systemd[1]: Mounted Huge Pages File System.
[    2.423713] systemd[1]: Mounting Debug File System...
[    2.473419] systemd[1]: Starting Create list of required static device nodes for the current kernel...
[    2.658159] systemd[1]: Started Set Up Additional Binary Formats.
[    2.689867] systemd[1]: Starting udev Coldplug all Devices...
[    2.741999] systemd[1]: Starting Load Kernel Modules...
[    2.778841] systemd[1]: Starting Slices.
[    2.831806] systemd[1]: Reached target Slices.
[    2.861670] systemd[1]: Mounted Debug File System.
[    2.891400] systemd[1]: Mounted POSIX Message Queue File System.
[    2.908336] systemd[1]: Started File System Check on Root Device.
[    2.936089] systemd[1]: Started Increase datagram queue length.
[    2.945832] systemd[1]: Started Restore / save the current clock.
[    2.957960] systemd[1]: Started Create list of required static device nodes for the current kernel.
[    2.989881] systemd[1]: Time has been changed
[    3.170205] systemd[1]: Started udev Coldplug all Devices.
[    3.221424] dwc2 20980000.usb: EPs: 8, dedicated fifos, 4080 entries in SPRAM
[    3.316811] systemd[1]: Starting Create Static Device Nodes in /dev...
[    3.330677] systemd[1]: Starting Syslog Socket.
[    3.347720] systemd[1]: Listening on Syslog Socket.
[    3.353730] systemd[1]: Starting Journal Service...
[    3.392602] systemd[1]: Started Journal Service.
[    3.649948] systemd-udevd[108]: starting version 215
[    3.803190] dwc2 20980000.usb: DWC OTG Controller
[    3.811387] dwc2 20980000.usb: new USB bus registered, assigned bus number 1
[    3.814389] dwc2 20980000.usb: irq 33, io mem 0x00000000
[    3.834748] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    3.837638] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    3.840302] usb usb1: Product: DWC OTG Controller
[    3.843010] usb usb1: Manufacturer: Linux 4.4.50+ dwc2_hsotg
[    3.845673] usb usb1: SerialNumber: 20980000.usb
[    3.904863] hub 1-0:1.0: USB hub found
[    3.916299] hub 1-0:1.0: 1 port detected
[    5.014600] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer
[    5.151553] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    6.143345] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    6.749591] usbcore: registered new interface driver brcmfmac
[    6.926970] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: May 27 2016 00:13:38 version 7.45.41.26 (r640327) FWID 01-df77e4a7
[    6.984512] brcmfmac: brcmf_cfg80211_reg_notifier: not a ISO3166 code
[    7.757655] systemd-journald[106]: Received request to flush runtime journal from PID 1
[    8.978980] brcmfmac: brcmf_cfg80211_reg_notifier: not a ISO3166 code
[    8.979018] cfg80211: World regulatory domain updated:
[    8.979029] cfg80211:  DFS Master region: unset
[    8.979038] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[    8.979052] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[    8.979065] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz, 92000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[    8.979076] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A)
[    8.979088] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A)
[    8.979100] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s)
[    8.979111] cfg80211:   (5490000 KHz - 5730000 KHz @ 160000 KHz), (N/A, 2000 mBm), (0 s)
[    8.979121] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 2000 mBm), (N/A)
[    8.979131] cfg80211:   (57240000 KHz - 63720000 KHz @ 2160000 KHz), (N/A, 0 mBm), (N/A)
[    9.823988] brcmfmac: brcmf_add_if: ERROR: netdev:wlan0 already exists
[    9.824016] brcmfmac: brcmf_add_if: ignore IF event
[    9.830737] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[    9.830786] brcmfmac: power management disabled
[   10.631078] uart-pl011 20201000.uart: no DMA platform data
[   11.353036] Adding 102396k swap on /var/swap.  Priority:-1 extents:5 across:200700k SSFS
[   11.599341] cfg80211: Regulatory domain changed to country: AU
[   11.599371] cfg80211:  DFS Master region: ETSI
[   11.599381] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[   11.599397] cfg80211:   (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A)
[   11.599411] cfg80211:   (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 1700 mBm), (N/A)
[   11.599424] cfg80211:   (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2400 mBm), (0 s)
[   11.599435] cfg80211:   (5490000 KHz - 5710000 KHz @ 160000 KHz), (N/A, 2400 mBm), (0 s)
[   11.599445] cfg80211:   (5735000 KHz - 5835000 KHz @ 80000 KHz), (N/A, 3000 mBm), (N/A)
[   12.265427] random: nonblocking pool is initialized
[   12.331929] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   15.062043] Bluetooth: Core ver 2.21
[   15.062205] NET: Registered protocol family 31
[   15.062219] Bluetooth: HCI device and connection manager initialized
[   15.062247] Bluetooth: HCI socket layer initialized
[   15.062269] Bluetooth: L2CAP socket layer initialized
[   15.062318] Bluetooth: SCO socket layer initialized
[   15.072189] Bluetooth: HCI UART driver ver 2.3
[   15.072217] Bluetooth: HCI UART protocol H4 registered
[   15.072228] Bluetooth: HCI UART protocol Three-wire (H5) registered
[   15.072384] Bluetooth: HCI UART protocol BCM registered
[   15.377258] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   15.377288] Bluetooth: BNEP filters: protocol multicast
[   15.377320] Bluetooth: BNEP socket layer initialized
[   56.121518] dwc2 20980000.usb: dwc2_hsotg_enqueue_setup: failed queue (-11)
[   56.124563] dwc2 20980000.usb: bound driver configfs-gadget
alexslade commented 5 years ago

I don't suppose if anyone's revisited this recently? Is the latest kernel (4.19?) with Buster still having these issues?

MrBramme commented 5 years ago

I am just trying it out myself, not having success at the moment (but to be honest, I've used another tutorial). Kernel 4.19 from the Buster Lite image of 2019-06-20. So far, I'm experiencing the same issues as found in this issue.

MrBramme commented 5 years ago

As an update, I've just had my first success. I did switch to using the Jessie image mentioned earlier in this conversation. What was key to make it work on my end was removing the "g_ether" that I placed in "/boot/cmdline.txt" in order to get in in the first place. once that was removed, everything slowly came to life (of course, I also configured the script to be an ethernet device). But again, using the OLD Raspbian image. Haven't tried on buster just yet

I followed, like many others, this tutorial: http://www.isticktoit.net/?p=1383

update I've just reproduced my steps on Buster and ... it works! so the only flaw I could find was the fact that I had 'modules-load=dwc2,g_ether' in my boot/cmdline.txt file, while it should only be 'modules-load=dwc2' Once I removed the g_ether, it all started working! Great success! For anyone still interested, this is on a raspberry pi zero (without the W :) ), using Raspbian Buster Lite, version June 2019, Release date 2019-06-20, Kernel version 4.19, SHA-256: 9009409a9f969b117602d85d992d90563f181a904bc3812bdd880fc493185234

combatopera commented 5 years ago

the ls write error seems to be due to the one-liner, splitting it worked for me:

name="$(ls /sys/class/udc)"
echo "$name" >UDC