S7 working properly

This commit is contained in:
Bjoern Kerler 2022-08-31 10:59:54 +02:00
parent 8c65412192
commit f881b2e0a6
No known key found for this signature in database
GPG key ID: 52E823BB96A55380
4 changed files with 846 additions and 156 deletions

662
Drivers/50-android.rules Executable file
View file

@ -0,0 +1,662 @@
--------------------------------------------------------------------------------
# These rules refer: https://developer.android.com/studio/run/device.html
# and include many suggestions from Arch Linux, GitHub and other Communities.
# Latest version can be found at: https://github.com/M0Rf30/android-udev-rules
# Skip this section below if this device is not connected by USB
SUBSYSTEM!="usb", GOTO="android_usb_rules_end"
LABEL="android_universal_rule"
ENV{ID_USB_INTERFACES}!="*:ff420?:*", GOTO="android_usb_rules_begin"
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:ff420?:*", MODE="0660", GROUP="adbusers", SYMLINK+="android/$env{ID_SERIAL_SHORT}"
LABEL="android_usb_rules_begin"
# Devices listed here in android_usb_rules_{begin...end} are connected by USB
# Acer
ATTR{idVendor}!="0502", GOTO="not_Acer"
ENV{adb_user}="yes"
# Iconia Tab A1-830
ATTR{idProduct}=="3604", ENV{adb_adbfast}="yes"
# Iconia Tab A500
ATTR{idProduct}=="3325", ENV{adb_adbfast}="yes"
# Liquid (3202=normal,3203=debug)
ATTR{idProduct}=="3203", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Acer"
# Actions Semiconductor Co., Ltd
ATTR{idVendor}=="10d6", ENV{adb_user}="yes"
# Denver TAD 70111
ATTR{idProduct}=="0c02", SYMLINK+="android_adb"
# ADVANCE
ATTR{idVendor}=="0a5c", ENV{adb_user}="yes"
# S5
ATTR{idProduct}=="e681", SYMLINK+="android_adb"
# Amazon Lab126
ATTR{idVendor}=="1949", ENV{adb_user}="yes"
# Amazon Kindle Fire
ATTR{idProduct}=="0006", ENV{adb_adbfast}="yes"
# Archos
ATTR{idVendor}!="0e79", GOTO="not_Archos"
ENV{adb_user}="yes"
# 43
ATTR{idProduct}=="1417", ENV{adb_adbfast}="yes"
# 101
ATTR{idProduct}=="1411", ENV{adb_adbfast}="yes"
# 101 xs
ATTR{idProduct}=="1549", ENV{adb_adbfast}="yes"
GOTO="android_usb_rule_match"
LABEL="not_Archos"
# ASUSTeK
ATTR{idVendor}!="0b05", GOTO="not_Asus"
# False positive - accessory
ATTR{idProduct}=="1???", GOTO="android_usb_rules_end"
ENV{adb_user}="yes"
# Zenphone 2 (ZE500CL) (7770=adb 7773=mtp,adb 7777=ptp,adb 7775=rndis,adb,mass_storage 5F03=mtp,adb,pclink,mass_storage 5F07=ptp,adb,pclink 5F05=rndis,adb,pclink,mass_storage
ATTR{idProduct}=="7770", SYMLINK+="android_adb"
ATTR{idProduct}=="7773", SYMLINK+="android_adb"
ATTR{idProduct}=="7777", SYMLINK+="android_adb"
ATTR{idProduct}=="7775", SYMLINK+="android_adb"
ATTR{idProduct}=="5F03", SYMLINK+="android_adb"
ATTR{idProduct}=="5F07", SYMLINK+="android_adb"
ATTR{idProduct}=="5F05", SYMLINK+="android_adb"
# Zenphone 4 (581f=mtp,adb 583f=rndis,adb)
ATTR{idProduct}=="581f", SYMLINK+="android_adb"
ATTR{idProduct}=="583f", SYMLINK+="android_adb"
# Zenphone 5 (4c90=normal,4c91=debug,4daf=Fastboot)
ATTR{idProduct}=="4c91", SYMLINK+="android_adb"
ATTR{idProduct}=="4daf", SYMLINK+="android_fastboot"
# Tegra APX
ATTR{idProduct}=="7030"
GOTO="android_usb_rule_match"
LABEL="not_Asus"
# Azpen Onda
ATTR{idVendor}=="1f3a", ENV{adb_user}="yes"
# BQ
ATTR{idVendor}!="2a47", GOTO="not_BQ"
ENV{adb_user}="yes"
# Aquaris 4.5
ATTR{idProduct}=="0c02", ENV{adb_adbfast}="yes"
ATTR{idProduct}=="2008", ENV{adb_adbfast}="yes"
GOTO="android_usb_rule_match"
LABEL="not_BQ"
# Dell
ATTR{idVendor}=="413c", ENV{adb_user}="yes"
# Essential
ATTR{idVendor}!="2e17", GOTO="not_Essential"
ENV{adb_user}="yes"
# Essential PH-1
ATTR{idProduct}=="c009", SYMLINK+="android_adb"
ATTR{idProduct}=="c030", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Essential"
# Fairphone 2
ATTR{idVendor}=="2ae5", ENV{adb_user}="yes"
# Foxconn
ATTR{idVendor}=="0489", ENV{adb_user}="yes"
# Commtiva Z71, Geeksphone One
ATTR{idVendor}=="0489", ATTR{idProduct}=="c001", SYMLINK+="android_adb"
# Fujitsu/Fujitsu Toshiba
ATTR{idVendor}=="04c5", ENV{adb_user}="yes"
# Fuzhou Rockchip Electronics
ATTR{idVendor}=="2207", ENV{adb_user}="yes"
# Mediacom Smartpad 715i
ATTR{idVendor}=="2207", ATTR{idProduct}=="0000", SYMLINK+="android_adb"
# Ubislate 7Ci
ATTR{idVendor}=="2207", ATTR{idProduct}=="0010", SYMLINK+="android_adb"
# Garmin-Asus
ATTR{idVendor}=="091e", ENV{adb_user}="yes"
# Google
ATTR{idVendor}!="18d1", GOTO="not_Google"
ENV{adb_user}="yes"
# Nexus, Pixel, Pixel XL, Pixel 2, Pixel 2XL (4ee2=mtp,adb 4ee4=rndis,adb 4ee6=ptp,adb 4ee7=adb 4ee9=midi,adb 2d01=accessory,adb 2d03=audio_source,adb 2d05=accessory,audio_source,adb)
# See https://android.googlesource.com/device/google/wahoo/+/master/init.hardware.usb.rc
ATTR{idProduct}=="4ee2", SYMLINK+="android_adb"
ATTR{idProduct}=="4ee4", SYMLINK+="android_adb"
ATTR{idProduct}=="4ee6", SYMLINK+="android_adb"
ATTR{idProduct}=="4ee7", SYMLINK+="android_adb"
ATTR{idProduct}=="4ee9", SYMLINK+="android_adb"
ATTR{idProduct}=="2d01", SYMLINK+="android_adb"
ATTR{idProduct}=="2d03", SYMLINK+="android_adb"
ATTR{idProduct}=="2d05", SYMLINK+="android_adb"
ATTR{idProduct}=="4ee0", SYMLINK+="android_fastboot"
# Nexus 7
ATTR{idProduct}=="4e42", SYMLINK+="android_adb"
ATTR{idProduct}=="4e40", SYMLINK+="android_fastboot"
# Nexus 5, Nexus 10
ATTR{idProduct}=="4ee1", ENV{adb_adbfast}="yes"
# Nexus S (4e22=mass_storage,adb 4e24=rndis,adb)
# See https://android.googlesource.com/device/samsung/crespo/+/android-4.1.2_r2.1/init.herring.usb.rc
ATTR{idProduct}=="4e22", SYMLINK+="android_adb"
ATTR{idProduct}=="4e24", SYMLINK+="android_adb"
ATTR{idProduct}=="4e20", SYMLINK+="android_fastboot"
# Galaxy Nexus
ATTR{idProduct}=="4e30", ENV{adb_adbfast}="yes"
# Nexus One (4e11=normal,4e12=debug,0fff=debug)
ATTR{idProduct}=="4e12", SYMLINK+="android_adb"
ATTR{idProduct}=="0fff", SYMLINK+="android_fastboot"
# Generic and unspecified debug interface
ATTR{idProduct}=="d00d", SYMLINK+="android_fastboot"
# Pico i.MX7 Dual Development Board
ATTR{idProduct}=="4ee7", SYMLINK+="android_adb"
# Include: Samsung Galaxy Nexus (GSM)
ATTR{idProduct}=="4e30", SYMLINK+="android_fastboot"
# Recovery adb entry for Nexus Family (orig d001, OP3 has 18d1:d002)
ATTR{idProduct}=="d00?", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Google"
# Haier
ATTR{idVendor}=="201e", ENV{adb_user}="yes"
# Hisense
ATTR{idVendor}=="109b", ENV{adb_user}="yes"
# Honeywell/Foxconn
ATTR{idVendor}!="0c2e", GOTO="not_Honeywell"
ENV{adb_user}="yes"
# D70e
ATTR{idProduct}=="0ba3", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Honeywell"
# HTC
ATTR{idVendor}!="0bb4", GOTO="not_HTC"
ENV{adb_user}="yes"
# fastboot mode enabled
ATTR{idProduct}=="0fff", ENV{adb_adbfast}="yes", GOTO="android_usb_rule_match"
# ChaCha
ATTR{idProduct}=="0cb2", ENV{adb_adbfast}="yes"
# Desire (Bravo)
ATTR{idProduct}=="0c87", SYMLINK+="android_adb"
# Desire HD
ATTR{idProduct}=="0ca2", SYMLINK+="android_adb"
# Desire S (Saga)
ATTR{idProduct}=="0cab", SYMLINK+="android_adb"
# Desire Z
ATTR{idProduct}=="0c91", ENV{adb_adbfast}="yes"
# Evo Shift
ATTR{idProduct}=="0ca5", SYMLINK+="android_adb"
# G1
ATTR{idProduct}=="0c01", ENV{adb_adbfast}="yes"
# HD2
ATTR{idProduct}=="0c02", ENV{adb_adbfast}="yes"
# Hero H2000
ATTR{idProduct}=="0001", ENV{adb_adbfast}="yes"
# Hero (GSM), Desire
ATTR{idProduct}=="0c99", SYMLINK+="android_adb"
# Hero (CDMA)
ATTR{idProduct}=="0c9a", SYMLINK+="android_adb"
# Incredible
ATTR{idProduct}=="0c9e", SYMLINK+="android_adb"
# Incredible rev 0002
ATTR{idProduct}=="0c8d", SYMLINK+="android_adb"
# MyTouch 4G
ATTR{idProduct}=="0c96", SYMLINK+="android_adb"
# One (m7) && One (m8)
ATTR{idProduct}=="0c93"
# Sensation
ATTR{idProduct}=="0f87", SYMLINK+="android_adb"
ATTR{idProduct}=="0ff0", SYMLINK+="android_fastboot"
# One V
ATTR{idProduct}=="0ce5", SYMLINK+="android_adb"
# One X
ATTR{idProduct}=="0cd6", SYMLINK+="android_adb"
# Slide
ATTR{idProduct}=="0e03", SYMLINK+="android_adb"
# Tatoo, Dream, ADP1, G1, Magic
ATTR{idProduct}=="0c01"
ATTR{idProduct}=="0c02", ENV{adb_adbfast}="yes"
# Vision
ATTR{idProduct}=="0c91", SYMLINK+="android_adb"
# Wildfire
ATTR{idProduct}=="0c8b", ENV{adb_adbfast}="yes"
# Wildfire S
ATTR{idProduct}=="0c86", ENV{adb_adbfast}="yes"
# Zopo ZP900, Fairphone
ATTR{idProduct}=="0c03", ENV{adb_adbfast}="yes"
# Zopo C2
ATTR{idProduct}=="2008", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
GOTO="android_usb_rule_match"
LABEL="not_HTC"
# Huawei
ATTR{idVendor}!="12d1", GOTO="not_Huawei"
ENV{adb_user}="yes"
# IDEOS
ATTR{idProduct}=="1038", ENV{adb_adbfast}="yes"
# U8850 Vision
ATTR{idProduct}=="1021", ENV{adb_adbfast}="yes"
# HiKey adb
ATTR{idProduct}=="1057", SYMLINK+="android_adb"
# HiKey usbnet
ATTR{idProduct}=="1050", SYMLINK+="android_adb"
# Honor 6
ATTR{idProduct}=="103a", SYMLINK+="android_adb"
ATTR{idProduct}=="1051", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# MediaPad M2-A01L
ATTR{idProduct}=="1052", SYMLINK+="android_adb"
# Huawei Watch
ATTR{idProduct}=="1c2c", SYMLINK+="android_adb"
# Mate 9
ATTR{idProduct}=="107e", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Huawei"
# Intel
# Geeksphone Revolution
ATTR{idVendor}=="8087", ATTR{idProduct}=="0a16", SYMLINK+="android_adb", ENV{adb_user}="yes"
# Chuwi Hi 10 Pro (HQ64)
ATTR{idVendor}=="8087", ATTR{idProduct}=="2a65", SYMLINK+="android_adb", ENV{adb_user}="yes"
ATTR{idVendor}=="8087", ATTR{idProduct}=="07ef", SYMLINK+="android_adb", ENV{adb_user}="yes"
# Reference Boards using kernelflinger
# See https://github.com/intel/kernelflinger/blob/master/libefiusb/usb.c#L56
ATTR{idProduct}=="09ef", ENV{adb_adbfast}="yes"
# IUNI
ATTR{idVendor}!="271d", GOTO="not_IUNI"
ENV{adb_user}="yes"
# U3
ATTR{idProduct}=="bf39", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_IUNI"
# K-Touch
ATTR{idVendor}=="24e3", ENV{adb_user}="yes"
# KT Tech
ATTR{idVendor}=="2116", ENV{adb_user}="yes"
# Kyocera
#ATTR{idVendor}=="0482", ENV{adb_user}="yes"
# Lenovo
ATTR{idVendor}=="17ef", ENV{adb_user}="yes"
# LeTv
ATTR{idVendor}!="2b0e", GOTO="not_letv"
ENV{adb_user}="yes"
# LEX720 LeEco Pro3 6GB (610c=normal,610d=debug, 610b=camera)
ATTR{idProduct}=="610d", ENV{adb_fastboot}="yes"
GOTO="android_usb_rule_match"
LABEL="not_letv"
# LG
ATTR{idVendor}!="1004", GOTO="not_LG"
ENV{adb_user}="yes"
# Ally, Vortex, P500, P500h
ATTR{idProduct}=="618f"
ATTR{idProduct}=="618e", SYMLINK+="android_adb"
# G2 D802
ATTR{idProduct}=="61f1", SYMLINK+="android_adb"
# G2 D803
ATTR{idProduct}=="618c", SYMLINK+="android_adb"
# G2 D803 rogers
ATTR{idProduct}=="631f", SYMLINK+="android_adb"
# G2 mini D620r (PTP)
ATTR{idProduct}=="631d", SYMLINK+="android_adb"
# G3 D855
ATTR{idProduct}=="633e", SYMLINK+="android_adb"
# Optimus LTE
ATTR{idProduct}=="6315", SYMLINK+="android_adb"
ATTR{idProduct}=="61f9", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# Optimus One
ATTR{idProduct}=="61c5", SYMLINK+="android_adb"
# Swift GT540
ATTR{idProduct}=="61b4", SYMLINK+="android_adb"
# P500 CM10
ATTR{idProduct}=="61a6", SYMLINK+="android_adb"
# 4X HD P880
ATTR{idProduct}=="61f9", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_LG"
# Meizu
ATTR{idVendor}!="2a45", GOTO="not_Meizu"
ENV{adb_user}="yes"
# MX6
ATTR{idProduct}=="0c02", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Meizu"
# Micromax
ATTR{idVendor}!="2a96", GOTO="not_Micromax"
ENV{adb_user}="yes"
# P702
ATTR{idProduct}=="201d", SYMLINK+="android_adb", SYMLINK+="android_fastboot"
GOTO="android_usb_rule_match"
LABEL="not_Micromax"
# Motorola
ATTR{idVendor}!="22b8", GOTO="not_Motorola"
ENV{adb_user}="yes"
# CLIQ XT/Quench
ATTR{idProduct}=="2d66"
# Defy/MB525
ATTR{idProduct}=="428c"
# Droid
ATTR{idProduct}=="41db"
# Xoom ID 1
ATTR{idProduct}=="70a8", ENV{adb_adbfast}="yes"
# Xoom ID 2
ATTR{idProduct}=="70a9", ENV{adb_adbfast}="yes"
# Razr XT912
ATTR{idProduct}=="4362", ENV{adb_adbfast}="yes"
# Moto XT1052
ATTR{idProduct}=="2e83", ENV{adb_adbfast}="yes"
# Moto E/G
ATTR{idProduct}=="2e76", ENV{adb_adbfast}="yes"
# Moto E/G (Dual SIM)
ATTR{idProduct}=="2e80", ENV{adb_adbfast}="yes"
# Moto E/G (Global GSM)
ATTR{idProduct}=="2e82", ENV{adb_adbfast}="yes"
# Moto x4
ATTR{idProduct}=="2e81", ENV{adb_adbfast}="yes"
# Droid Turbo 2
ATTR{idProduct}=="2ea4", ENV{adb_adbfast}="yes", SYMLINK+="android%n"
GOTO="android_usb_rule_match"
LABEL="not_Motorola"
# MTK
ATTR{idVendor}=="0e8d", ENV{adb_user}="yes"
# NEC
ATTR{idVendor}=="0409", ENV{adb_user}="yes"
# Nextbit
ATTR{idVendor}=="2c3f", ENV{adb_user}="yes"
# Nokia X
ATTR{idVendor}=="0421", ENV{adb_user}="yes"
# Nokia 3
ATTR{idVendor}=="2e04", ENV{adb_user}="yes"
# Nook
ATTR{idVendor}=="2080", ENV{adb_user}="yes"
# Nvidia
ATTR{idVendor}=="0955", ENV{adb_user}="yes"
# Audi SDIS Rear Seat Entertainment Tablet
ATTR{idProduct}=="7000", SYMLINK+="android_fastboot"
# OnePlus(Oreo)
ATTR{idVendor}!="2a70", GOTO="not_OnePlus"
ENV{adb_user}="yes"
# Charging mode
ATTR{idProduct}=="4ee7", SYMLINK+="android_adb"
# MTP mode
ATTR{idProduct}=="9011", SYMLINK+="android_adb"
# PTP mode
ATTR{idProduct}=="904e", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_OnePlus"
# Oppo
ATTR{idVendor}=="22d9", ENV{adb_user}="yes"
# Find 5
ATTR{idProduct}=="2767", SYMLINK+="android_adb"
ATTR{idProduct}=="2764", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# OTGV
ATTR{idVendor}=="2257", ENV{adb_user}="yes"
# Pantech
ATTR{idVendor}=="10a9", ENV{adb_user}="yes"
# Pegatron
ATTR{idVendor}=="1d4d", ENV{adb_user}="yes"
# Philips
ATTR{idVendor}=="0471", ENV{adb_user}="yes"
# PMC-Sierra
ATTR{idVendor}=="04da", ENV{adb_user}="yes"
# Qualcomm
ATTR{idVendor}!="05c6", GOTO="not_Qualcomm"
ENV{adb_user}="yes"
# Geeksphone Zero
ATTR{idProduct}=="9025", SYMLINK+="android_adb"
# OnePlus One
ATTR{idProduct}=="676?", SYMLINK+="android_adb"
# OnePlus Two
ATTR{idProduct}=="9011", SYMLINK+="android_adb"
# OnePlus 3
ATTR{idProduct}=="900e", SYMLINK+="android_adb"
# OnePlus 3T
ATTR{idProduct}=="676c", SYMLINK+="android_adb"
# OnePlus 3T w/ Oreo MIDI mode
ATTR{idProduct}=="90bb", SYMLINK+="android_adb"
# OnePlus 5
ATTR{idProduct}=="9011", SYMLINK+="android_adb"
# Xiaomi A1 (90bb=midi+adb)
ATTR{idProduct}=="90bb", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Qualcomm"
# Research In Motion, Ltd.
ATTR{idVendor}!="0fca", GOTO="not_RIM"
ENV{adb_user}="yes"
# BlackBerry DTEK60
ATTR{idProduct}=="8042", ENV{adb_fastboot}="yes"
GOTO="android_usb_rule_match"
LABEL="not_RIM"
# SK Telesys
ATTR{idVendor}=="1f53", ENV{adb_user}="yes"
# Samsung
ATTR{idVendor}!="04e8", GOTO="not_Samsung"
# False positive printer
ATTR{idProduct}=="3???", GOTO="android_usb_rules_end"
ENV{adb_user}="yes"
# Galaxy i5700
ATTR{idProduct}=="681c", ENV{adb_adbfast}="yes"
# Galaxy i5800 (681c=debug,6601=fastboot,68a0=mediaplayer)
ATTR{idProduct}=="681c", SYMLINK+="android_adb"
ATTR{idProduct}=="6601", SYMLINK+="android_fastboot"
ATTR{idProduct}=="68a9", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# Galaxy i7500
ATTR{idProduct}=="6640", ENV{adb_adbfast}="yes"
# Galaxy i9000 S, i9300 S3
ATTR{idProduct}=="6601", SYMLINK+="android_adb"
ATTR{idProduct}=="685d", MODE="0660"
ATTR{idProduct}=="68c3", MODE="0660"
# Galaxy Ace (S5830) "Cooper"
ATTR{idProduct}=="689e", ENV{adb_adbfast}="yes"
# Galaxy Tab
ATTR{idProduct}=="6877", ENV{adb_adbfast}="yes"
# Galaxy Nexus (GSM) (6860=mtp,adb 6864=rndis,adb 6866=ptp,adb)
ATTR{idProduct}=="6860", SYMLINK+="android_adb"
ATTR{idProduct}=="6864", SYMLINK+="android_adb"
ATTR{idProduct}=="6866", SYMLINK+="android_adb"
# Galaxy Core, Tab 10.1, i9100 S2, i9300 S3, N5100 Note (8.0), Galaxy S3 SHW-M440S 3G (Korea only)
ATTR{idProduct}=="6860", SYMLINK+="android_adb"
ATTR{idProduct}=="685e", ENV{adb_adbfast}="yes"
# Galaxy i9300 S3
ATTR{idProduct}=="6866", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# Galaxy S4 GT-I9500
ATTR{idProduct}=="685d", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Samsung"
# Sharp
ATTR{idVendor}=="04dd", ENV{adb_user}="yes"
# Sony
ATTR{idVendor}=="054c", ENV{adb_user}="yes"
# Sony Ericsson
ATTR{idVendor}!="0fce", GOTO="not_Sony_Ericsson"
ENV{adb_user}="yes"
# Xperia X10 mini
ATTR{idProduct}=="3137"
ATTR{idProduct}=="2137", SYMLINK+="android_adb"
# Xperia X10 mini pro
ATTR{idProduct}=="3138"
ATTR{idProduct}=="2138", SYMLINK+="android_adb"
# Xperia X8
ATTR{idProduct}=="3149"
ATTR{idProduct}=="2149", SYMLINK+="android_adb"
# Xperia X12
ATTR{idProduct}=="e14f"
ATTR{idProduct}=="614f", SYMLINK+="android_adb"
# Xperia Arc S
ATTR{idProduct}=="414f", ENV{adb_adbfast}="yes"
# Xperia Neo V (6156=debug,0dde=fastboot)
ATTR{idProduct}=="6156", SYMLINK+="android_adb"
ATTR{idProduct}=="0dde", SYMLINK+="android_fastboot"
# Xperia S
ATTR{idProduct}=="5169", ENV{adb_adbfast}="yes"
# Xperia SP
ATTR{idProduct}=="6195", ENV{adb_adbfast}="yes"
# Xperia L
ATTR{idProduct}=="5192", ENV{adb_adbfast}="yes"
# Xperia Mini Pro
ATTR{idProduct}=="0166", ENV{adb_adbfast}="yes"
# Xperia V
ATTR{idProduct}=="0186", ENV{adb_adbfast}="yes"
# Xperia Acro S
ATTR{idProduct}=="5176", ENV{adb_adbfast}="yes"
# Xperia Z1 Compact
ATTR{idProduct}=="51a7", ENV{adb_adbfast}="yes"
# Xperia Z2
ATTR{idProduct}=="51ba", ENV{adb_adbfast}="yes"
# Xperia Z3
ATTR{idProduct}=="01af", ENV{adb_adbfast}="yes"
# Xperia Z3 Compact
ATTR{idProduct}=="01bb", ENV{adb_adbfast}="yes"
# Xperia Z3+ Dual
ATTR{idProduct}=="51c9", ENV{adb_adbfast}="yes"
GOTO="android_usb_rule_match"
LABEL="not_Sony_Ericsson"
# Spreadtrum
ATTR{idVendor}=="1782", ENV{adb_user}="yes"
# T & A Mobile Phones
ATTR{idVendor}=="1bbb", ENV{adb_user}="yes"
# Alcatel OT991D
ATTR{idProduct}=="00f2", SYMLINK+="android_adb"
# Alcatel OT6012A
ATTR{idProduct}=="0167", SYMLINK+="android_adb"
# Teleepoch
ATTR{idVendor}=="2340", ENV{adb_user}="yes"
# Texas Instruments UsbBoot
ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", ENV{adb_user}="yes"
ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", ENV{adb_user}="yes"
# Toshiba
ATTR{idVendor}=="0930", ENV{adb_user}="yes"
# WEARNERS
ATTR{idVendor}=="05c6", ENV{adb_user}="yes"
# XiaoMi
ATTR{idVendor}!="2717", GOTO="not_XiaoMi"
ENV{adb_user}="yes"
# Mi2A
ATTR{idProduct}=="904e", SYMLINK+="android_adb"
ATTR{idProduct}=="9039", SYMLINK+="android_adb"
# Mi3
ATTR{idProduct}=="0368", SYMLINK+="android_adb"
# RedMi 1S WCDMA (MTP+Debug)
ATTR{idProduct}=="1268", SYMLINK+="android_adb"
# RedMi / RedMi Note WCDMA (MTP+Debug)
ATTR{idProduct}=="1248", SYMLINK+="android_adb"
# RedMi 1S / RedMi / RedMi Note WCDMA (PTP+Debug)
ATTR{idProduct}=="1218", SYMLINK+="android_adb"
# RedMi 1S /RedMi / RedMi Note WCDMA (Usb+Debug)
ATTR{idProduct}=="1228", SYMLINK+="android_adb"
# RedMi / RedMi Note 4G WCDMA (MTP+Debug)
ATTR{idProduct}=="1368", SYMLINK+="android_adb"
# RedMi / RedMi Note 4G WCDMA (PTP+Debug)
ATTR{idProduct}=="1318", SYMLINK+="android_adb"
# RedMi / RedMi Note 4G WCDMA (Usb+Debug)
ATTR{idProduct}=="1328", SYMLINK+="android_adb"
# Mi Mix / A1 (ff88=rndis+adb, ff18=ptp+adb, ff48=mtp+adb, ff28=storage+adb)
ATTR{idProduct}=="ff88", SYMLINK+="android_adb"
ATTR{idProduct}=="ff18", SYMLINK+="android_adb"
ATTR{idProduct}=="ff48", SYMLINK+="android_adb"
ATTR{idProduct}=="ff28", SYMLINK+="android_adb"
# RedMi / RedMi Note 4G CDMA (Usb+Debug) / Mi4c / Mi5
ATTR{idProduct}=="ff68", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_XiaoMi"
# Yota
ATTR{idVendor}!="2916", GOTO="not_Yota"
ENV{adb_user}="yes"
# YotaPhone2 (f003=normal,9139=debug)
ATTR{idProduct}=="9139", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Yota"
# Wileyfox
ATTR{idVendor}=="2970", ENV{adb_user}="yes"
# YU
ATTR{idVendor}=="1ebf", ENV{adb_user}="yes"
# Zebra
ATTR{idVendor}!="05e0", GOTO="not_Zebra"
ENV{adb_user}="yes"
# TC55
ATTR{idProduct}=="2101", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_Zebra"
# ZTE
ATTR{idVendor}!="19d2", GOTO="not_ZTE"
ENV{adb_user}="yes"
# Blade (1353=normal,1351=debug)
ATTR{idProduct}=="1351", SYMLINK+="android_adb"
# Blade S (Crescent, Orange San Francisco 2) (1355=normal,1354=debug)
ATTR{idProduct}=="1354", SYMLINK+="android_adb"
GOTO="android_usb_rule_match"
LABEL="not_ZTE"
# Wileyfox
ATTR{idVendor}=="2970", ENV{adb_user}="yes"
# YU
ATTR{idVendor}=="1ebf", ENV{adb_user}="yes"
# ZUK
ATTR{idVendor}=="2b4c", ENV{adb_user}="yes"
# Skip other vendor tests
LABEL="android_usb_rule_match"
# Symlink shortcuts to reduce code in tests above
ENV{adb_adbfast}=="yes", ENV{adb_adb}="yes", ENV{adb_fast}="yes"
ENV{adb_adb}=="yes", ENV{adb_user}="yes", SYMLINK+="android_adb"
ENV{adb_fast}=="yes", ENV{adb_user}="yes", SYMLINK+="android_fastboot"
# Enable device as a user device if found (add an "android" SYMLINK)
ENV{adb_user}=="yes", MODE="0660", GROUP="adbusers", TAG+="uaccess", SYMLINK+="android"
# Devices listed here {begin...end} are connected by USB
LABEL="android_usb_rules_end"
#Suzy-Q
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0660",
GROUP="plugdev", SYMLINK+="android%n"

View file

@ -6,13 +6,18 @@ A tool to dump RAM using S-Boot Upload Mode (in python)
Thx to Nitay Artenstein's code at https://github.com/nitayart/sboot_dump, ported Thx to Nitay Artenstein's code at https://github.com/nitayart/sboot_dump, ported
to python and added full support based on reversing sboot to python and added full support based on reversing sboot
### Supported
- Samsung QC
- Samsung MTK
- Samsung Unisoc not yet supported
### Install ### Install
- Python 3.6 or higher - Python 3.6 or higher
`` ``
pip install pyusb pyserial pip install pyusb pyserial
`` ``
### Run ### Show partition table on the device
`` ``
python3 scripts/samsungupload.py python3 scripts/samsungupload.py
`` ``
@ -20,19 +25,46 @@ python3 scripts/samsungupload.py
#### For dumping all memory areas: #### For dumping all memory areas:
`` ``
python3 scripts/samsungupload.py -all python3 scripts/samsungupload.py all
``
#### For dumping a specfic memory range:
``
python3 scripts/samsungupload.py range 0x0 0xffffffff
``
#### For dumping a full memory range:
``
python3 scripts/samsungupload.py full
`` ``
#### For dumping individual areas (Index 0): #### For dumping individual areas (Index 0):
`` ``
python3 scripts/samsungupload.py -a 0 python3 scripts/samsungupload.py partition 0
`` ``
### Windows usage ### Windows install
- Install usbdk and make sure to remove old libusb dlls from windows/system32 folder. - Install usbdk and make sure to remove old libusb dlls from windows/system32 folder.
Get the usbdk installer (.msi) from [here](https://github.com/daynix/UsbDk/releases/) and install it Get the usbdk installer (.msi) from [here](https://github.com/daynix/UsbDk/releases/) and install it
- Install normal Samsung Serial Port driver (or use default Windows COM Port one, make sure no exclamation is seen) - Install normal Samsung Serial Port driver (or use default Windows COM Port one, make sure no exclamation is seen)
### Linux install
```bash
sudo apt purge ModemManager
sudo usermod -aG plugdev $USER
sudo usermod -aG dialout $USER
sudo cp Drivers/*.rules /etc/udev/rules.d
sudo udevadm control -R
```
- Log in and out user
```bash
sudo pip3 install -r requirements
```
Enjoy ! Enjoy !

3
requirements.txt Normal file
View file

@ -0,0 +1,3 @@
pyusb==1.2.1
usb==0.0.83.dev0
wheel==0.37.1

View file

@ -1,15 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
''' """
Licensed under MIT License, (c) B. Kerler Licensed under MIT License, (c) B. Kerler
''' """
import os import os
import sys import sys
import time import time
import argparse import argparse
import usb.core # pyusb import usb.core # pyusb
import usb.util import usb.util
from binascii import hexlify from struct import unpack, calcsize
from struct import unpack, pack, calcsize
from io import BytesIO from io import BytesIO
import logging import logging
import usb.backend.libusb0 import usb.backend.libusb0
@ -40,11 +39,12 @@ USB_RECIP_RPIPE = 0x05
tag = 0 tag = 0
class usb_class():
def load_windows_dll(self): class usb_class:
@staticmethod
def load_windows_dll():
if os.name == 'nt': if os.name == 'nt':
windows_dir = None
try: try:
# add pygame folder to Windows DLL search paths # add pygame folder to Windows DLL search paths
windows_dir = os.path.join(os.path.abspath(os.path.dirname(__file__))) windows_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)))
@ -189,17 +189,17 @@ class usb_class():
if EP_OUT == -1: if EP_OUT == -1:
self.EP_OUT = usb.util.find_descriptor(itf, self.EP_OUT = usb.util.find_descriptor(itf,
# match the first OUT endpoint # match the first OUT endpoint
custom_match=lambda e: \ custom_match=lambda em: \
usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.endpoint_direction(em.bEndpointAddress) ==
usb.util.ENDPOINT_OUT) usb.util.ENDPOINT_OUT)
else: else:
self.EP_OUT = EP_OUT self.EP_OUT = EP_OUT
if EP_IN == -1: if EP_IN == -1:
self.EP_IN = usb.util.find_descriptor(itf, self.EP_IN = usb.util.find_descriptor(itf,
# match the first OUT endpoint # match the first OUT endpoint
custom_match=lambda e: \ custom_match=lambda em: \
usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.endpoint_direction(em.bEndpointAddress) ==
usb.util.ENDPOINT_IN) usb.util.ENDPOINT_IN)
else: else:
self.EP_IN = EP_IN self.EP_IN = EP_IN
@ -216,7 +216,6 @@ class usb_class():
if reset: if reset:
self.device.reset() self.device.reset()
if not self.device.is_kernel_driver_active(self.interface): if not self.device.is_kernel_driver_active(self.interface):
# self.device.attach_kernel_driver(self.interface) #Do NOT uncomment
self.device.attach_kernel_driver(0) self.device.attach_kernel_driver(0)
except Exception as err: except Exception as err:
self.debug(str(err)) self.debug(str(err))
@ -237,7 +236,6 @@ class usb_class():
except usb.core.USBError as err: except usb.core.USBError as err:
error = str(err.strerror) error = str(err.strerror)
if "timeout" in error: if "timeout" in error:
# time.sleep(0.01)
try: try:
self.EP_OUT.write(b'') self.EP_OUT.write(b'')
except Exception as err: except Exception as err:
@ -254,34 +252,25 @@ class usb_class():
pos += pktsize pos += pktsize
except Exception as err: except Exception as err:
self.debug(str(err)) self.debug(str(err))
# print("Error while writing")
# time.sleep(0.01)
i += 1 i += 1
if i == 3: if i == 3:
return False return False
pass pass
return True return True
def usbread(self, resplen = -1): def usbread(self, resplen=-1):
res = bytearray() res = bytearray()
timeout = 0
loglevel = self.loglevel
epr = self.EP_IN.read epr = self.EP_IN.read
wMaxPacketSize = self.EP_IN.wMaxPacketSize
extend = res.extend extend = res.extend
cond = True
if resplen == -1: if resplen == -1:
rlen = 0xFFFFFFFF rlen = 0xFFFFFFFF
else: else:
rlen = resplen rlen = resplen
if resplen == -1: while len(res) < rlen:
resplen = self.EP_IN.wMaxPacketSize
while len(res)<rlen:
try: try:
extend(epr(resplen)) extend(epr(self.EP_IN.wMaxPacketSize))
if len(res)%self.EP_IN.wMaxPacketSize!=0: if len(res) % self.EP_IN.wMaxPacketSize != 0:
break break
except usb.core.USBError as e: except usb.core.USBError as e:
error = str(e.strerror) error = str(e.strerror)
@ -317,12 +306,10 @@ class usb_class():
if pktsize is None: if pktsize is None:
pktsize = len(data) pktsize = len(data)
res = self.write(data, pktsize) res = self.write(data, pktsize)
# port->flush()
return res return res
def usbreadwrite(self, data, resplen): def usbreadwrite(self, data, resplen):
self.usbwrite(data) # size self.usbwrite(data) # size
# port->flush()
res = self.usbread(resplen) res = self.usbread(resplen)
return res return res
@ -335,13 +322,13 @@ class usb_class():
return data return data
def rword(self, count=1, little=False): def rword(self, count=1, little=False):
rev = "<" if little else ">" rev = "little" if little else "big"
data = [] data = []
for _ in range(count): for _ in range(count):
v = self.usbread(2) v = self.usbread(2)
if len(v) == 0: if len(v) == 0:
return data return data
data.append(unpack(rev + "H", v)[0]) data.append(int.from_bytes(bytes=v,byteorder=rev))
if count == 1: if count == 1:
return data[0] return data[0]
return data return data
@ -349,6 +336,19 @@ class usb_class():
def rbyte(self, count=1): def rbyte(self, count=1):
return self.usbread(count) return self.usbread(count)
def calcProcessTime(starttime, cur_iter, max_iter):
telapsed = time.time() - starttime
if telapsed > 0 and cur_iter > 0:
testimated = (telapsed / cur_iter) * max_iter
finishtime = starttime + testimated
finishtime = dt.datetime.fromtimestamp(finishtime).strftime("%H:%M:%S") # in time
lefttime = testimated - telapsed # in seconds
return int(telapsed), int(lefttime), finishtime
else:
return 0, 0, ""
class progress: class progress:
def __init__(self, pagesize): def __init__(self, pagesize):
self.progtime = 0 self.progtime = 0
@ -357,21 +357,10 @@ class progress:
self.start = time.time() self.start = time.time()
self.pagesize = pagesize self.pagesize = pagesize
def calcProcessTime(self, starttime, cur_iter, max_iter):
telapsed = time.time() - starttime
if telapsed > 0 and cur_iter > 0:
testimated = (telapsed / cur_iter) * (max_iter)
finishtime = starttime + testimated
finishtime = dt.datetime.fromtimestamp(finishtime).strftime("%H:%M:%S") # in time
lefttime = testimated - telapsed # in seconds
return int(telapsed), int(lefttime), finishtime
else:
return 0, 0, ""
def show_progress(self, prefix, pos, total, display=True): def show_progress(self, prefix, pos, total, display=True):
if total == 0: if total == 0:
return return
prog = round(float(pos) / float(total) * float(100), 1) prog = round(pos / total * 100, 2)
if prog == 0: if prog == 0:
self.prog = 0 self.prog = 0
self.start = time.time() self.start = time.time()
@ -379,9 +368,7 @@ class progress:
self.progpos = pos self.progpos = pos
print_progress(prog, 100, prefix='Done', print_progress(prog, 100, prefix='Done',
suffix=prefix + ' (Sector 0x%X of 0x%X) %0.2f MB/s' % suffix=prefix + ' (Sector 0x%X of 0x%X) %0.2f MB/s' %
(pos // self.pagesize, (pos // self.pagesize, total // self.pagesize, 0), bar_length=50)
total // self.pagesize,
0), bar_length=50)
if prog > self.prog: if prog > self.prog:
if display: if display:
@ -389,43 +376,37 @@ class progress:
tdiff = t0 - self.progtime tdiff = t0 - self.progtime
datasize = (pos - self.progpos) / 1024 / 1024 datasize = (pos - self.progpos) / 1024 / 1024
if datasize != 0 and tdiff != 0: if datasize != 0 and tdiff != 0:
try: throughput = datasize / tdiff
throughput = datasize / tdiff
except:
throughput = 0
else: else:
throughput = 0 throughput = 0
telapsed, lefttime, finishtime = self.calcProcessTime(self.start, prog, 100) telapsed, lefttime, finishtime = calcProcessTime(self.start, prog, 100)
hinfo = "" hinfo = ""
if lefttime > 0: if lefttime > 0:
sec = lefttime sec = lefttime
if sec > 60: if sec > 60:
min = sec // 60 rmin = sec // 60
sec = sec % 60 sec = sec % 60
if min > 60: if rmin > 60:
h = min // 24 h = rmin // 24
min = min % 24 rmin = rmin % 24
hinfo = "%02dh:%02dm:%02ds left" % (h, min, sec) hinfo = "%02dh:%02dm:%02ds left" % (h, rmin, sec)
else: else:
hinfo = "%02dm:%02ds left" % (min, sec) hinfo = "%02dm:%02ds left" % (rmin, sec)
else: else:
hinfo = "%02ds left" % sec hinfo = "%02ds left" % sec
if hinfo != "": if hinfo != "":
print_progress(prog, 100, prefix='Progress:', print_progress(prog, 100, prefix='Progress:',
suffix=prefix + f' (Sector 0x%X of 0x%X, {hinfo}) %0.2f MB/s' % suffix=prefix + f' (Sector 0x%X of 0x%X, {hinfo}) %0.2f MB/s' %
(pos // self.pagesize, (pos // self.pagesize, total // self.pagesize, throughput), bar_length=50)
total // self.pagesize,
throughput), bar_length=50)
else: else:
print_progress(prog, 100, prefix='Progress:', print_progress(prog, 100, prefix='Progress:',
suffix=prefix + f' (Sector 0x%X of 0x%X) %0.2f MB/s' % suffix=prefix + f' (Sector 0x%X of 0x%X) %0.2f MB/s' %
(pos // self.pagesize, (pos // self.pagesize, total // self.pagesize, throughput), bar_length=50)
total // self.pagesize,
throughput), bar_length=50)
self.prog = prog self.prog = prog
self.progpos = pos self.progpos = pos
self.progtime = t0 self.progtime = t0
def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_length=100): def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_length=100):
""" """
Call in a loop to create terminal progress bar Call in a loop to create terminal progress bar
@ -442,7 +423,7 @@ def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_lengt
str_format = "{0:." + str(decimals) + "f}" str_format = "{0:." + str(decimals) + "f}"
percents = str_format.format(100 * (iteration / float(total))) percents = str_format.format(100 * (iteration / float(total)))
filled_length = int(round(bar_length * iteration / float(total))) filled_length = int(round(bar_length * iteration / float(total)))
bar = '' * filled_length + '-' * (bar_length - filled_length) bar = '=' * filled_length + '-' * (bar_length - filled_length)
sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)) sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix))
@ -500,7 +481,7 @@ class structhelper_io:
self.data.seek(pos) self.data.seek(pos)
class partitiontable(): class partitiontable:
ptype = None ptype = None
pname = None pname = None
pstart = None pstart = None
@ -524,7 +505,48 @@ class partitiontable():
return f"\"{self.pname}\" ({hex(self.pstart)},{hex(self.pend)})" return f"\"{self.pname}\" ({hex(self.pstart)},{hex(self.pend)})"
class samsung_upload(): def bytetostr(data):
return data.rstrip(b"\x00").decode('utf-8')
def get_probe_table(data):
count = 0
devicename = bytetostr(data[0:16])
data = BytesIO(data)
if devicename[0] != "+":
mode = 32
size = 0x1C
else:
mode = 64
size = 0x28
devicename = devicename[1:]
probetable = []
data.seek(0x10)
while data.tell() != data.getbuffer().nbytes:
pt = partitiontable(data.read(size), mode)
if pt.pstart == 0 and pt.pend == 0:
break
if pt.pstart < 20:
break
probetable.append(pt)
count += 1
return mode, devicename, probetable
def print_probe(mode, devicename, probetable):
print(f"\nProbed device:\n" +
f"---------------\n" +
f"{mode}-Bit, " +
f"Devicename: \"{devicename}\"\n")
print("Detected upload areas:\n---------------------")
count = 0
for pt in probetable:
print(f"{count}: {pt}")
count += 1
class samsung_upload:
def __init__(self): def __init__(self):
self.cdc = None self.cdc = None
@ -534,7 +556,7 @@ class samsung_upload():
VENDOR_SAMSUNG = 0x04e8 VENDOR_SAMSUNG = 0x04e8
PRODUCT_MODEM = 0x685d PRODUCT_MODEM = 0x685d
portconfig = [[VENDOR_SAMSUNG, PRODUCT_MODEM, -1]] portconfig = [[VENDOR_SAMSUNG, PRODUCT_MODEM, -1]]
self.cdc = usb_class(loglevel=logging.INFO,portconfig=portconfig,devclass=10) self.cdc = usb_class(loglevel=logging.INFO, portconfig=portconfig, devclass=10)
self.cdc.connected = self.cdc.connect() self.cdc.connected = self.cdc.connect()
if self.cdc.connected: if self.cdc.connected:
self.cdc.write(b"PrEaMbLe\0") self.cdc.write(b"PrEaMbLe\0")
@ -546,64 +568,21 @@ class samsung_upload():
return True return True
return False return False
def bytetostr(self, data):
return data.rstrip(b"\x00").decode('utf-8')
def probe(self): def probe(self):
self.cdc.write(b"PrObE\0") self.cdc.write(b"PrObE\0")
if os.name == 'nt': data = self.cdc.usbread(0x8000)
data = self.cdc.usbread(6*self.cdc.EP_IN.wMaxPacketSize) return get_probe_table(data)
else:
data = self.cdc.usbread()
#print(hexlify(data).decode('utf-8'))
return self.get_probe_table(data)
def get_probe_table(self, data):
count = 0
devicename = self.bytetostr(data[0:16])
data = BytesIO(data)
if devicename[0] != "+":
mode = 32
size = 0x1C
else:
mode = 64
size = 0x28
devicename = devicename[1:]
probetable = []
data.seek(0x10)
while data.tell() != data.getbuffer().nbytes:
pt = partitiontable(data.read(size), mode)
if pt.pstart == 0 and pt.pend == 0:
break
if pt.pstart < 20:
break
probetable.append(pt)
count += 1
return mode, devicename, probetable
def print_probe(self, mode, devicename, probetable):
print(f"\nProbed device:\n" +
f"---------------\n" +
f"{mode}-Bit, " +
f"Devicename: \"{devicename}\"\n")
print("Detected upload areas:\n---------------------")
count = 0
for pt in probetable:
print(f"{count}: {pt}")
count += 1
def command(self, command, ack=True): def command(self, command, ack=True):
command += b"\0" command += b"\0"
self.cdc.write(command) self.cdc.write(command)
if ack: if ack:
tmp = self.cdc.usbread(self.cdc.EP_IN.wMaxPacketSize) tmp = self.cdc.usbread(self.cdc.EP_IN.wMaxPacketSize)
if tmp not in [b"AcKnOwLeDgMeNt\x00",b"PoStAmBlE\x00"]: if tmp not in [b"AcKnOwLeDgMeNt\x00", b"PoStAmBlE\x00"]:
return False return False
return True return True
def download_area(self,wfilename,rstart:int, rend:int): def download_area(self, wfilename, rstart: int, rend: int):
filename = os.path.basename(wfilename) filename = os.path.basename(wfilename)
self.progress.show_progress('File: \"%s\"' % filename, 0, rend - rstart + 1, True) self.progress.show_progress('File: \"%s\"' % filename, 0, rend - rstart + 1, True)
with open(wfilename, "wb") as wf: with open(wfilename, "wb") as wf:
@ -620,7 +599,7 @@ class samsung_upload():
total = rend + 1 - rstart total = rend + 1 - rstart
pos = 0 pos = 0
while pos < total: while pos < total:
self.progress.show_progress('File: \"%s\"' % filename, pos, rend - rstart+1, True) self.progress.show_progress('File: \"%s\"' % filename, pos, rend - rstart + 1, True)
size = total - pos size = total - pos
if size > 0x80000: if size > 0x80000:
size = 0x80000 size = 0x80000
@ -629,19 +608,19 @@ class samsung_upload():
self.command(b"AcKnOwLeDgMeNt", False) self.command(b"AcKnOwLeDgMeNt", False)
wf.write(data) wf.write(data)
pos += len(data) pos += len(data)
self.progress.show_progress('File: \"%s\"' % filename, rend - rstart+1, rend - rstart+1, True) self.progress.show_progress('File: \"%s\"' % filename, rend - rstart + 1, rend - rstart + 1, True)
data = self.cdc.usbread(64) data = self.cdc.usbread(64)
if data == b'PoStAmBlE\x00': if data == b'PoStAmBlE\x00':
return True return True
return False return False
def download(self, area): def download(self, area):
if not "." in area.pname: if "." not in area.pname:
filename = "%s_%x_%x.lst" % (area.pname, area.pstart, area.pend) filename = "%s_%x_%x.lst" % (area.pname, area.pstart, area.pend)
else: else:
filename = area.pname filename = area.pname
wfilename = os.path.join("memory", filename) wfilename = os.path.join("memory", filename)
if self.download_area(wfilename,area.pstart,area.pend): if self.download_area(wfilename, area.pstart, area.pend):
return True return True
return False return False
@ -649,49 +628,70 @@ class samsung_upload():
def main(): def main():
parser = argparse.ArgumentParser(description='SUC - Samsung Upload Client (c) B.Kerler 2018-2022.') parser = argparse.ArgumentParser(description='SUC - Samsung Upload Client (c) B.Kerler 2018-2022.')
print("\nSUC - Samsung Upload Client v1.2 (c) B. Kerler 2018-2022, Email: info @ revskills.de") print("\nSUC - Samsung Upload Client v1.3 (c) B. Kerler 2018-2022, Email: info @ revskills.de")
subparser = parser.add_subparsers(dest="cmd",help="Valid commands are: \nprint, partition, all, range, full") subparser = parser.add_subparsers(dest="cmd", help="Valid commands are: \nprint, partition, all, range, full")
print_parser = subparser.add_parser("print", help="Print Memory information")
partition_parser = subparser.add_parser("partition", help="Download specific memory partition") partition_parser = subparser.add_parser("partition", help="Download specific memory partition")
partition_parser.add_argument('partition', help='Partition number to read') partition_parser.add_argument('partition', help='Partition number to read')
all_parser = subparser.add_parser("all", help="Download all memory partitions") subparser.add_parser("all", help="Download all memory partitions")
range_parser = subparser.add_parser("range", help="Download specific range") range_parser = subparser.add_parser("range", help="Download specific range")
range_parser.add_argument('start', help='Start offset in hex') range_parser.add_argument('start', help='Start offset in hex')
range_parser.add_argument('end', help='Start offset in hex') range_parser.add_argument('end', help='Start offset in hex')
full_parser = subparser.add_parser("full", help="Download full memory 1-0xFFFFFFFFFFFFFFF") subparser.add_parser("full", help="Download full memory 1-0xFFFFFFFFFFFFFFF")
file_parser = subparser.add_parser("file", help="Print partition table from file")
file_parser.add_argument('filename', help='Filename to read from')
args = parser.parse_args() args = parser.parse_args()
suc = samsung_upload() suc = samsung_upload()
if suc.connect(): cmd = args.cmd
mode, devicename, probetable = suc.probe() connected = False
cmd = args.cmd mode = ""
if cmd == "print": devicename = ""
suc.print_probe(mode,devicename,probetable) probetable = None
elif cmd == "all": if cmd != "file":
if suc.connect():
mode, devicename, probetable = suc.probe()
connected = True
if cmd is None:
if connected:
print_probe(mode, devicename, probetable)
print("\nRun 'samupload.py all' to dump all areas")
print("Run 'samupload.py partition [number]' to dump specific area")
print("Run 'samupload.py range [start_hex] [end_hex]' to dump specific memarea")
print("Run 'samupload.py full' to try to bruteforce dump memarea")
print("Run 'samupload.py file [filename]' to print the partition table from file")
elif cmd == "all":
if connected:
if os.path.exists("memory"): if os.path.exists("memory"):
shutil.rmtree("memory") shutil.rmtree("memory")
os.mkdir("memory") os.mkdir("memory")
print("\nDownloading ....\n-----------------") print("\nDownloading ....\n-----------------")
for area in probetable: for area in probetable:
suc.download(area) suc.download(area)
suc.command(b"PoStAmBlE") suc.command(b"PoStAmBlE", False)
elif cmd == "range": print("Done. Dumped memory has been written to memory directory.")
start = int(args.start,16) elif cmd == "range":
end = int(args.end,16) if connected:
start = int(args.start, 16)
end = int(args.end, 16)
print("\nDownloading ....\n-----------------") print("\nDownloading ....\n-----------------")
suc.download_area("range.bin",start,end) suc.download_area("range.bin", start, end)
elif cmd == "full": print("Done. Dumped memory was written to range.bin")
elif cmd == "full":
if connected:
start = 1 start = 1
end = 0xFFFFFFFFFFFFFFF end = 0xFFFFFFFFFFFFFFF
print("\nDownloading ....\n-----------------") print("\nDownloading ....\n-----------------")
suc.download_area("range.bin",start,end) suc.download_area("range.bin", start, end)
elif cmd == "partition": print("Done. Dumped memory was written to range.bin")
elif cmd == "partition":
if connected:
if args.partition is not None: if args.partition is not None:
print("\nDownloading ....\n-----------------") print("\nDownloading ....\n-----------------")
area = int(args.partition) area = int(args.partition)
@ -700,20 +700,13 @@ def main():
exit(0) exit(0)
suc.download(probetable[area]) suc.download(probetable[area])
suc.command(b"PoStAmBlE") suc.command(b"PoStAmBlE")
else: print("Done. Dumped memory was written the memory directory")
print("\nRun 'samupload.py -all' to dump all areas") elif cmd == "file":
print("Run 'samupload.py -a [number]' to dump specific area") with open(args.filename, "rb") as rf:
data = rf.read()
print("Done. Dumped memory has been written to memory directory.") mode, devicename, probetable = get_probe_table(data)
print_probe(mode, devicename, probetable)
def test():
with open("samsung_dump.bin", "rb") as rf:
data = rf.read()
suc = samsung_upload()
probetable = suc.get_probe_table(data)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
#test()