Composite USB Gadgets on the Raspberry Pi Zero isticktoit.net 1 / :36. g_{hid,ether,serial,*}

Similar documents
Kernel USB Gadget Configfs Interface. Matt Porter Linaro

USB System Design in Sitara Devices Using Linux. [Part 6]: Use USB in Device Mode Bin Liu (EP, Processors)

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

This tutorial will guide you how to setup and run your own minecraft server on a Linux CentOS 6 in no time.

INd_rasN SOME SHELL SCRIPTING PROGRAMS. 1. Write a shell script to check whether the name passed as first argument is the name of a file or directory.

I think this is messy. I don't do it that way, but to keep things dead simple, the default way is presented here.

PiCloud. Building owncloud on a Raspberry PI

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Development Environment Embedded Linux Primer Ch 1&2

Linux Essentials Objectives Topics:

The Broadband Ham Net community has had a need for a stand alone time server for their meshes. This document will attempt to fill in this need.

Embedded Linux. A Tour inside ARM's Kernel

Linux Systems Administration Getting Started with Linux

Interfacing with Raspberry Pi 3 Model B Updated: 9/19/17

The TinyHPC Cluster. Mukarram Ahmad. Abstract

Davide Cavaliere 18 th February 2017

Let us ping! First we will learn the Hello World of a networked machine.

Enabling CDC-ETHER Connection for Skywire CAT1

Providing Traditional Computational Facility through TV SetTop Box (PROTRACTS)

Quick Start Guide for BeagleBone. Table of Contents. by Brian Fraser Last update: Sept 24, 2017

Configuring Linux pppd for a Skywire Global LTE CAT-M1 NL-SW-LTE-QBG96

Kernel Graphics Development on Remote Machines , Joonas Lahtinen Intel Corporation

Raspberry Pi Class Ed 299. Mike Davis Truman College 5/26/2015

LING 408/508: Computational Techniques for Linguists. Lecture 5

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

How to install Microsoft Windows XP SP3 on Debian GNU / Linux Squeeze

Lab Working with Linux Command Line

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Adafruit's Raspberry Pi Lesson 6. Using SSH

dnsmasq configuration

1. $ who 2. $ date 3. $ echo $? 4. $ echo $$ 5. $ ps 6. $ echo $PATH 7. $ echo $HOME 8. $ echo \thola 9. $ echo "\thola" 10. $ echo e "\thola" 11.

USB 3.0 Dual Port Gigabit. Ethernet Cable

RearPi Documentation. Download Google Play. Donate

User-friendly Cross-platform Industry 4.0 Web Viewer Smartphone-App Free Hotline

Itron Riva Dev Software Development Getting Started Guide

Recap From Last Time:

= Session-(1.4) Preparing the Workstation for the Lab / OS Installation = Session-(1.4) Preparing the Workstation for the Lab / OS Installation

BGGN 213 Working with UNIX Barry Grant

RNG-406Uv2. USB 3.0 to Gigabit Ethernet Cable

Configuring Linux pppd for a Skywire 4G LTE CAT3 Verizon

3 Connection, Shell Serial Connection over Console Port SSH Connection Internet Connection... 5

Install and Configure Ubuntu on a VirtualBox Virtual Machine

#Uncomment the second line to enable any form of FTP write command. #write_enable=yes

If you had a freshly generated image from an LCI instructor, make sure to set the hostnames again:

You will need to know the IP address or the hostname of the pi (as discussed above) to continue and login to your pi via putty over Ethernet.

HOW-TO-GUIDE: demonstrating Fabric Attach using OpenVSwitch

Introduction: What is Unix?

Using RANCID. Contents. 1 Introduction Goals Notes Install rancid Add alias Configure rancid...

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to the shell Part II

Introduction to Linux

RTNET for the SPB and LiRE. Patrick Hohmann

Exercise 1: Basic Tools

My guide for setting up a raspberry pi zero w as a wifi rerouter and access point

Install and Configure wxwidgets on Ubuntu

Creating a low end server for SOHO.

Defensie Exercises preparing for the exam.

Raspberry Pi (RPi) Setup Documentation Instrumentation Development Lab Department of Physics and Astronomy University of Hawaii at Manoa

USB Type-C Dual Port Gigabit. Ethernet Cable

Understand USB (in Linux)

Spring 2017 Gabriel Kuri

IoT with Intel Galileo Gerardo Carmona. makerobots.tk

Installation of the OS

D, E I, J, K. Generalized Regular Expression Parser (GREP), 110 Generic 105 key (Intl) PC, 29 git command, 242

Introduction to remote command line Linux. Research Computing Team University of Birmingham

SAMA5D3x-CM Instruction to program images with PEEDI

Linux PPPd for LTE CAT M1 Verizon Skywire on Raspberry Pi 3

USER MANUAL: 4G. The PiIoT is a WAN communications board which provides a 2G / 3G / 4G

USB Type-C Gigabit Ethernet. Adapter

Assignment 1: Build Environment

This guide assumes that you are setting up a masternode for the first time. You will need:

Git & Github Fundamental by Rajesh Kumar.

Adding a Real Time Clock to Raspberry Pi

Link Gateway ISO Installation Manual

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to Linux

Embedded System Design

Cross-compilation with Buildroot

Automatic Creation of a Virtual Network with VBoxManage [1]

ECE 471 Embedded Systems Lecture 10

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Setting up a Chaincoin Masternode

Introduction To. Barry Grant

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Precursor Steps & Storage Node

MacGyver IT: w/raspberry Pi 3 Kevin Capwell META Pat Zielke Viroqua

USER MANUAL: Raspberry Pi 2

Raspberry Pi Tutorial Connect to WiFi or Create An Encrypted DHCP... Network as Fallback. Lasse Christiansen Development. 1 of 11 3/9/2013 9:04 AM

Basic Linux Command Line Interface Guide

CSCM98 Lab Class #5 Getting familiar with the command line

Connect the GSM-DSA to a router where the network is configured to x with a mask

Docker task in HPC Pack

IBM AIX Basic Operations V5.

Configure router. 26. Start AirPort Utility (located in the Utilities folder). The AirPort Utility window show a component diagram:

Raspberry Pi NTP Clock Setup Guide

Shifter Configuration Guide 1.0

Introduction of Linux

Power over Ethernet (PoE) Adaptor

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Transcription:

1 / 8 23.4.2017 17:36 g_{hid,ether,serial,*}

2 / 8 23.4.2017 17:36 $ sudo BRANCH=next rpi-update $ echo "dtoverlay=dwc2" sudo tee -a /boot/config.txt $ echo "dwc2" sudo tee -a /etc/modules libcomposite $ sudo echo "libcomposite" sudo tee -a /etc/modules /sys/

3 / 8 23.4.2017 17:36 isticktoit_usb /usr/bin/ $ sudo touch /usr/bin/isticktoit_usb #create the file $ sudo chmod +x /usr/bin/isticktoit_usb #make it executable $ sudo nano /usr/bin/isticktoit_usb #edit the file rc.local /etc/rc.local $ sudo nano /etc/rc.local GNU nano 1.2.3 File: /etc/rc.local... /usr/bin/isticktoit_usb # libcomposite configuration exit #!/bin/bash cd /sys/kernel/config/usb_gadget/ mkdir -p isticktoit cd isticktoit echo 0x1d6b > idvendor # Linux Foundation echo 0x0104 > idproduct # Multifunction Composite Gadget echo 0x0100 > bcddevice # v1.0.0 echo 0x0200 > bcdusb # USB2 mkdir -p strings/0x409 echo "fedcba9876543210" > strings/0x409/serialnumber echo "Tobias Girstmair" > strings/0x409/manufacturer echo "isticktoit.net USB Device" > strings/0x409/product mkdir -p configs/c.1/strings/0x409 echo "Config 1: ECM network" > configs/c.1/strings/0x409 /configuration echo 250 > configs/c.1/maxpower

4 / 8 23.4.2017 17:36 # see gadget configurations below # End functions ls /sys/class/udc > UDC mkdir -p functions/acm.usb0 ln -s functions/acm.usb0 configs/c.1/ # End functions $ sudo systemctl enable getty@ttygs0.service install screen screen sudo apt-get $ sudo screen /dev/ttyacm0 115200 $ dmesg grep "USB ACM device" $ sudo nano /usr/bin/isticktoit_usb

5 / 8 23.4.2017 17:36 mkdir -p functions/ecm.usb0 # first byte of address must be even HOST="48:6f:73:74:50:43" # "HostPC" SELF="42:61:64:55:53:42" # "BadUSB" echo $HOST > functions/ecm.usb0/host_addr echo $SELF > functions/ecm.usb0/dev_addr ln -s functions/ecm.usb0 configs/c.1/ # End functions ls /sys/class/udc > UDC #put this at the very end of the file: ifconfig usb0 10.0.0.1 netmask 255.255.255.252 up route add -net default gw 10.0.0.2 $ dmesg grep cdc_ether [13890.668557] cdc_ether 1-1:1.2 eth0: register 'cdc_ether' at usb-0000:00:14.0-1, CDC Ethernet Device, 48:6f:73:74:50:43 [13890.674117] usbcore: registered new interface driver cdc_ether [13890.687619] cdc_ether 1-1:1.2 enp0s20u1i2: renamed from eth0 $ sudo ifconfig enp0s20u1i2 10.0.0.2 netmask 255.255.255.252 up $ ssh 10.0.0.1 -l pi $ sudo nano /usr/bin/isticktoit_usb

6 / 8 23.4.2017 17:36 mkdir -p functions/hid.usb0 echo 1 > functions/hid.0/protocol echo 1 > functions/hid.0/subclass echo 8 > functions/hid.0/report_length echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0 \\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02 \\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08 \\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03 \\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00 \\x29\\x65\\x81\\x00\\xc0 > functions/hid.0/report_desc ln -s functions/hid.usb0 configs/c.1/ # End functions $ sudo su # echo -ne "\0\0\x4\0\0\0\0\0" > /dev/hidg0 #press the A-button # echo -ne "\0\0\0\0\0\0\0\0" > /dev/hidg0 #release all keys $ cd PATH_TO_HARDPASS_REPO $ make #compile the program $ echo -n "hello world!" sudo./scan /dev/hidg0 1 2 count=1024

7 / 8 23.4.2017 17:36 $ dd if=/dev/zero of=~/usbdisk.img bs=1024 count=1024 $ mkdosfs ~/usbdisk.img sudo nano /usr/bin/isticktoit_usb FILE=/home/pi/usbdisk.img mkdir -p ${FILE/img/d} # mount -o loop,ro,offset=1048576 -t ext4 $FILE ${FILE/img/d} # FOR OLD WAY OF MAKING THE IMAGE mount -o loop,ro, -t vfat $FILE ${FILE/img/d} # FOR IMAGE CREATED WITH DD mkdir -p functions/mass_storage.usb0 echo 1 > functions/mass_storage.usb0/stall echo 0 > functions/mass_storage.usb0/lun.0/cdrom echo 0 > functions/mass_storage.usb0/lun.0/ro echo 0 > functions/mass_storage.usb0/lun.0/nofua echo $FILE > functions/mass_storage.usb0/lun.0/file ln -s functions/mass_storage.usb0 configs/c.1/ # End functions$

8 / 8 23.4.2017 17:36 Article Revisions 1.000: Initial article 1.001: Added 'Hi, Hackaday' 1.010: Fixed configuration script ('') (thanks, Hans) 1.011: Fixed and simplified a few things (thanks, Tom) 1.100: Fixed the 'press A-button' example (missing `-ne`) (thanks, Jim)