Skip to content

Commit aebdc39

Browse files
EmpierJoshuaDoes
authored andcommitted
Bump to v0.2.0
- Introduce device detection to fix bootloader cases for P8 series (thanks to @Empier for pointing out that I forgot to add this in the first place!)
1 parent 429c88c commit aebdc39

2 files changed

Lines changed: 75 additions & 2 deletions

File tree

‎cmd/tensor-usbdl/identify.go‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package main
2+
3+
import (
4+
"strings"
5+
)
6+
7+
type Device struct {
8+
Brand string
9+
Model string
10+
Variant string
11+
}
12+
13+
func (dev *Device) Set(brand, model, variant string) *Device {
14+
dev.Brand = brand
15+
dev.Model = model
16+
dev.Variant = variant
17+
return dev
18+
}
19+
20+
func (dev *Device) String() (s string) {
21+
a := make([]string, 0)
22+
if dev.Brand != "" {
23+
a = append(a, dev.Brand)
24+
}
25+
if dev.Model != "" {
26+
a = append(a, dev.Model)
27+
}
28+
if dev.Variant != "" {
29+
a = append(a, dev.Variant)
30+
}
31+
s = strings.Join(a, " ")
32+
return
33+
}
34+
35+
func Identify(id string) (dev *Device) {
36+
dev = new(Device)
37+
if id == "" {
38+
return
39+
}
40+
41+
if len(id) < 9 {
42+
return
43+
}
44+
switch id {
45+
case "18D1:4F00":
46+
dev.Set("Google", "Pixel ROM Recovery", "Tensor")
47+
}
48+
49+
if len(id) < 20 {
50+
return
51+
}
52+
s := string(id[1:5])
53+
switch s {
54+
case "9845":
55+
dev.Set("Google", "Pixel 6 series", "")
56+
case "9855":
57+
dev.Set("Google", "Pixel 7 series", "")
58+
case "9865":
59+
dev.Set("Google", "Pixel 8 series", "")
60+
}
61+
62+
return
63+
}

‎cmd/tensor-usbdl/main.go‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ DNW:
4848

4949
const (
5050
app = "Tensor-USBDL"
51-
ver = "v0.1.0"
51+
ver = "v0.2.0"
5252
dev = "JoshuaDoes"
5353
)
5454

@@ -324,6 +324,7 @@ func main() {
324324
log.Traceln("- ID: ", dnw.GetID())
325325
log.Traceln("- Serial:", dnw.GetSerial())
326326
log.Traceln("- USB: ", dnw.GetUSB())
327+
device := Identify(dnw.GetID())
327328

328329
//Send a newline character to make sure the device sends us the first message
329330
dnw.Write([]byte{'\n'})
@@ -375,7 +376,14 @@ func main() {
375376
op = 0
376377
case "EPBL":
377378
bl = bootloaders["PBL"]
378-
op = 0
379+
if device.Brand == "Google" && device.Model == "Pixel 8 series" {
380+
op = 1
381+
} else {
382+
op = 0
383+
}
384+
case "EPBB":
385+
bl = bootloaders["PBL"]
386+
op = 2
379387
case "BL2":
380388
bl = bootloaders["BL2"]
381389
op = 1
@@ -440,7 +448,9 @@ func main() {
440448
case "\x00":
441449
log.Tracef("Received control: 0x%0X", msg.Command())
442450
case "exynos_usb_booting":
451+
device = Identify(msg.Device())
443452
log.Debugln("Device identified as", msg.Device())
453+
log.Infoln("Device detected:", device.String())
444454
case "eub":
445455
bootloader := strings.ToUpper(msg.Argument())
446456
switch msg.SubCommand() {

0 commit comments

Comments
 (0)