summaryrefslogtreecommitdiff
path: root/docs/hammer.md
blob: 6048f1c44161a46fd4bd9db8f6411fa9bb99acaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# Hammer care and feeding

Original: [go/hammercare](http://go/hammercare)

Last updated: 2021-03-18

[TOC]

## Servo

### Start servod

```
cros_sdk --no-ns-pid
sudo servod --port=9000 -b hammer -c hammer.xml
```

### UART console

The simplest solution for most people is to use the `dut-console` script.

First, add this line into your .bashrc (or other shell init script; needed once
only):
``` bash
alias dut-console="~/chromiumos/src/platform/dev/contrib/dut-console"
```

Then simply run `dut-console -c ec`. `dut-console` uses `cu` under the hood, and
works like ssh - to leave, press `<ENTER> <~> <.> <ENTER>`.


``` bash
src/platform/dev/contrib/dut-console -p 9000 -c ec
```

## Build EC

(Inside chroot)
``` bash
cd ~/trunk/src/platform/ec
make BOARD=<BOARD> -j
```

## Flash EC

### Prerequisites

#### Find the USB VID:PID of the device

USB VID:PID is listed in [hammer/variants.h](../board/hammer/variants.h).
Many scripts below requires correct PID to work.

#### Stop hammerd

Remove rootfs verification:
``` bash
/usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --force
```

Reboot the DUT then rename hammerd
``` bash
mv /usr/bin/hammerd /usr/bin/hammerd.bak
```

### Hammer connected to Chromebook, flash via USB

(Inside chroot) Copy-paste the script below to a file named
"flash_hammer.usbremote", run
``` bash
bash flash_hammer.usbremote <BOARD> <VID:PID> <IP> [ro]
```

``` bash
#!/bin/bash
# flash_hammer.usbremote
set -x -e

BOARD=$1
ID=$2
IP=$3
EXTRA="-d $ID"

ssh $IP sh -c "'rm -f /usr/local/ec.bin'"
scp ~/trunk/src/platform/ec/build/${BOARD}/ec.bin $IP:/usr/local/ec.bin

if [ "$4" = 'ro' ]; then
   ssh $IP sh -x -c "'usb_updater2 $EXTRA -j;
   sleep 1.0;
   usb_updater2 $EXTRA /usr/local/ec.bin;
   sleep 0.5;
   usb_updater2 $EXTRA -s;
   usb_updater2 $EXTRA /usr/local/ec.bin'"
else
   ssh $IP sh -x -c "'usb_updater2 $EXTRA -w;
   usb_updater2 $EXTRA -r; sleep 0.5;
   usb_updater2 $EXTRA -s;
   usb_updater2 $EXTRA /usr/local/ec.bin'"
fi
```

### Hammer connected to Chromebook, flash via servo

(Inside chroot) Copy-paste the script below to a file named "flash_hammer",
run `bash flash_hammer <IP> </path/to/ec.bin>`

``` bash
#!/bin/bash
# Recommended to use a USB 3.0 Ethernet adapter for this to work, otherwise the
# network on the DUT will temporarily go down when the root USB hub is taken
# down.

set -e
IP=$1
shift

# USB 2.0 root hub
USBID="usb1"

set -x

# unbind, then rebind, the root hub (in the mean time, we'll start programming)
ssh $IP sh -c "'echo $USBID > /sys/bus/usb/drivers/usb/unbind; sleep 3; echo $USBID > /sys/bus/usb/drivers/usb/bind'" &

util/flash_ec --board=hammer --port 9000 --image "$@"
```

### Hammer connected via servo only

Do not connect hammer to Chromebook in this case, or at least make sure
Chromebook is either suspended (S3) or off (when put into programming mode,
STM32 always prefers USB interface when available)

For Servo V2:

``` bash
dut-control -p 9000 spi1_vref:pp3300 spi1_buf_en:on spi1_buf_on_flex_en:on
util/flash_ec --board=hammer --port=9000 [--image=/path/to/ec.bin]

# To disable power from servo to Hammer
dut-control -p 9000 spi1_vref:off spi1_buf_en:off spi1_buf_on_flex_en:off
```

For Servo Micro (there is only one buffer in the power delivery path,
so don't include the spi1_buf_on_flex_en control):

``` bash
dut-control -p 9000 spi1_vref:pp3300 spi1_buf_en:on
util/flash_ec --board=hammer --port=9000 [--image=/path/to/ec.bin]

# To disable power from servo to Hammer
dut-control -p 9000 spi1_vref:off spi1_buf_en:off
```

### Hammer connected via POGO-PIN-USB to Linux

So this is very similar to Hammer connected to poppy, flash via USB, but you
are directly running commands on the machine connected to Hammer, so you don’t
need to SSH to it.

``` bash
#!/bin/bash
# flash_hammer.usblocal

EXTRA=
EC=build/${BOARD:-hammer}/ec.bin
UPDATER=usb_updater2

if [ -n "$ID" ]; then
   EXTRA="-d $ID"
fi

if [ "$1" = 'ro' ]; then
   "${UPDATER}" $EXTRA -j;
   sleep 1.0;
   "${UPDATER}" $EXTRA "${EC}";
   sleep 1.0;
   "${UPDATER}" $EXTRA -s;
   "${UPDATER}" $EXTRA "${EC}";
else
   "${UPDATER}" $EXTRA -w;
   "${UPDATER}" $EXTRA -r;
   sleep 1.0;
   "${UPDATER}" $EXTRA -s;
   "${UPDATER}" $EXTRA "${EC}";
fi

# To use this script: BOARD=<BOARD> ID=<VID:PID> ./flash_hammer.usblocal [ro]
```

## Update touchpad firmware

(Inside DUT)
``` bash
usb_updater2 --tp_update <FILE> --device=<VID:PID>
```
or
``` bash
ec_touchpad_updater -p <PID> <FILE>
```