New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 675263 link

Starred by 2 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocking:
issue 653300



Sign in to add a comment

EC: Add the ability to spoof accel readings

Project Member Reported by aaboagye@chromium.org, Dec 16 2016

Issue description

In order to test certain situations such as tablet mode or device rotation, it would be helpful if we could spoof the readings of the accelerometers. gwendal@ and I brainstormed and here's what we decided to do:

===

Add a command in ectool motionsensor: named spoof and in EC console named accel_spoof:


spoof [sensor_id] [on|off] [X Y Z]

sensor_id is the sensor we want to spoof.
[on|off] : if none, return status
on : enable spoof
off : disable spoof
[X Y Z]: if none, lock the current sensor values
       : otherwise, set the sensor: for accel, in 1/1024g units, android/html5 referential (https://source.android.com/devices/sensors/sensor-types.html#phone_axes,  X is the hinge.


We store that information in motion_sensor_t and modify motion_sense_read() and drivers load_fifo() to check the data to feed raw_xyz (raw_xyz is already in android referential).

===

We could even get fancy later on and "playback" recorded readings to simulate common gestures or movements.
 
Cc: rjahagir@chromium.org
Status: Started (was: Assigned)
Got a basic prototype working. draft CL here: https://chromium-review.googlesource.com/c/421280/

I still need to consider the FIFOs, modifications to ectool, servod controls/drivers/etc.
Cc: -dchan@chromium.org hennessywill@chromium.org
Project Member

Comment 4 by bugdroid1@chromium.org, Jan 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/ec/+/b3a9e1b64c25a4e35345903f5e20a841817962f6

commit b3a9e1b64c25a4e35345903f5e20a841817962f6
Author: Aseda Aboagye <aaboagye@google.com>
Date: Sat Dec 17 02:24:08 2016

motion_sense: Add "spoof" mode

This commit adds a "spoof" mode feature to the motionsense stack.  It
allows the user to arbitrarily set the outputs of the sensor in order to
"spoof" the readings of the sensor.  This can be useful in emulating
tablet mode or device rotations.  A command is available from the EC
console named `accelspoof` and there is a corresponding motionsense
command in ectool called `spoof`.

The usage is as follows:

- EC console
 > accelspoof [id] [on/off] [X Y Z]

- ectool
 # ectool motionsense spoof -- [id] [0/1] [X Y Z]

If on or off(or 0/1) is not specified, the current spoof mode status of
the sensor is returned.  If on is specified, but no components are
provided, the sensor will lock the current values and provide those as
the spoofed values.  If the components are provided, those will be used
as the spoofed values.

BUG=chromium:675263
BRANCH=cyan,glados,gru,oak
TEST=Flash a DUT with accels.  From AP console, run `ectool motionsense
lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed
values.  Verify that the angle is fixed regardless of the actual angle
of the DUT.
TEST=Flash a DUT with accels.  From AP console, use `ectool motionsense
spoof` to spoof values and verify that `ectool motionsense` reflects the
spoofed values.  Test with both provided component values and no
component values.

Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/421280
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>

[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/common/motion_sense.c
[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/util/ectool.c
[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/driver/accelgyro_bmi160.c
[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/include/config.h
[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/include/motion_sense.h
[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/include/ec_commands.h
[modify] https://crrev.com/b3a9e1b64c25a4e35345903f5e20a841817962f6/include/accelgyro.h

Awesome, thanks for setting this up. However, I'm giving it a try on Cyan ToT and I'm not getting it to work for me.

Here are the commands and responses I'm getting:
>>ectool motionsense spoof -- 1 1 14640 -6080 -1888
EC result 3 (INVALID_PARAM) 

>>ectool motionsense spoof -- 1
EC result 3 (INVALID_PARAM)

>>ectool motionsense spoof
(gives me a list of usage: motionsense spoof -- NUM [0/1] [X Y Z])

Am I using an incorrect format? Ectool is working normally apart from this. 

Comment 6 Deleted

The format is correct, but you would also need ToT cyan EC FW. I'm now going to cherry-pick the change to the firmware branches, then you can build a new EC FW to use with the image.
I resolved the merge conflicts, but unfortunately the spoof patch pushes many boards over their space limit. I'll have to see if I can free up any more space.
Any update on this? 
Project Member

Comment 10 by bugdroid1@chromium.org, Jan 21 2017

Labels: merge-merged-firmware-cyan-7287.57.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/ec/+/39f4893aa93d446b012cd5cc4f3d1a14f479ff37

commit 39f4893aa93d446b012cd5cc4f3d1a14f479ff37
Author: Aseda Aboagye <aaboagye@google.com>
Date: Sat Dec 17 02:24:08 2016

motion_sense: Add "spoof" mode

This commit adds a "spoof" mode feature to the motionsense stack.  It
allows the user to arbitrarily set the outputs of the sensor in order to
"spoof" the readings of the sensor.  This can be useful in emulating
tablet mode or device rotations.  A command is available from the EC
console named `accelspoof` and there is a corresponding motionsense
command in ectool called `spoof`.

The usage is as follows:

- EC console
 > accelspoof [id] [on/off] [X Y Z]

- ectool
 # ectool motionsense spoof -- [id] [0/1] [X Y Z]

If on or off(or 0/1) is not specified, the current spoof mode status of
the sensor is returned.  If on is specified, but no components are
provided, the sensor will lock the current values and provide those as
the spoofed values.  If the components are provided, those will be used
as the spoofed values.

BUG=chromium:675263
BRANCH=cyan,glados,gru,oak
TEST=Flash a DUT with accels.  From AP console, run `ectool motionsense
lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed
values.  Verify that the angle is fixed regardless of the actual angle
of the DUT.
TEST=Flash a DUT with accels.  From AP console, use `ectool motionsense
spoof` to spoof values and verify that `ectool motionsense` reflects the
spoofed values.  Test with both provided component values and no
component values.

Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/426373
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>

[modify] https://crrev.com/39f4893aa93d446b012cd5cc4f3d1a14f479ff37/common/motion_sense.c
[modify] https://crrev.com/39f4893aa93d446b012cd5cc4f3d1a14f479ff37/util/ectool.c
[modify] https://crrev.com/39f4893aa93d446b012cd5cc4f3d1a14f479ff37/include/config.h
[modify] https://crrev.com/39f4893aa93d446b012cd5cc4f3d1a14f479ff37/include/motion_sense.h
[modify] https://crrev.com/39f4893aa93d446b012cd5cc4f3d1a14f479ff37/include/ec_commands.h
[modify] https://crrev.com/39f4893aa93d446b012cd5cc4f3d1a14f479ff37/include/accelgyro.h

Project Member

Comment 11 by bugdroid1@chromium.org, Jan 21 2017

Labels: merge-merged-firmware-oak-8438.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/ec/+/13439b8baee33249e703d5161232f1cea3d0454a

commit 13439b8baee33249e703d5161232f1cea3d0454a
Author: Aseda Aboagye <aaboagye@google.com>
Date: Sat Dec 17 02:24:08 2016

motion_sense: Add "spoof" mode

This commit adds a "spoof" mode feature to the motionsense stack.  It
allows the user to arbitrarily set the outputs of the sensor in order to
"spoof" the readings of the sensor.  This can be useful in emulating
tablet mode or device rotations.  A command is available from the EC
console named `accelspoof` and there is a corresponding motionsense
command in ectool called `spoof`.

The usage is as follows:

- EC console
 > accelspoof [id] [on/off] [X Y Z]

- ectool
 # ectool motionsense spoof -- [id] [0/1] [X Y Z]

If on or off(or 0/1) is not specified, the current spoof mode status of
the sensor is returned.  If on is specified, but no components are
provided, the sensor will lock the current values and provide those as
the spoofed values.  If the components are provided, those will be used
as the spoofed values.

BUG=chromium:675263
BRANCH=cyan,glados,gru,oak
TEST=Flash a DUT with accels.  From AP console, run `ectool motionsense
lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed
values.  Verify that the angle is fixed regardless of the actual angle
of the DUT.
TEST=Flash a DUT with accels.  From AP console, use `ectool motionsense
spoof` to spoof values and verify that `ectool motionsense` reflects the
spoofed values.  Test with both provided component values and no
component values.

Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/425855
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>

[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/common/motion_sense.c
[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/util/ectool.c
[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/driver/accelgyro_bmi160.c
[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/include/config.h
[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/include/motion_sense.h
[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/include/ec_commands.h
[modify] https://crrev.com/13439b8baee33249e703d5161232f1cea3d0454a/include/accelgyro.h

Cc: amstan@chromium.org
Hi rjahagir@,

In order to unblock you, I went forward and merged my spoof mode changes to the the cyan and oak firmware branches so you can at least have something to play with. You should be able to build a new firmware from those branches and use those for your work. I'll continue to work on merging the changes to the other branches.
Thanks, I can access the spoof tool now.
Testing it on Caroline and Kevin. Chrome 66.0.3344.0 + Platform 10394.0.0 and I can't spoof anything.

I'm getting similar results as in Comment #5.

is this supposed to work on Caroline and Kevin?

Thanks!


Cc: ricardoq@chromium.org
Currently? Not yet. I believe I ran out of space on those firmware branches and frankly just forgot to come back to it.

Sign in to add a comment