EC: Add the ability to spoof accel readings |
|||||||
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.
,
Dec 17 2016
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.
,
Jan 6 2017
,
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
,
Jan 9 2017
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.
,
Jan 9 2017
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.
,
Jan 10 2017
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.
,
Jan 20 2017
Any update on this?
,
Jan 21 2017
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
,
Jan 21 2017
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
,
Jan 21 2017
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.
,
Jan 24 2017
Thanks, I can access the spoof tool now.
,
Feb 23 2018
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!
,
Feb 23 2018
,
Feb 26 2018
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 |
|||||||
Comment 1 by rjahagir@chromium.org
, Dec 17 2016