lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZurYndjVz7r0U6dz@skv.local>
Date: Wed, 18 Sep 2024 16:41:49 +0300
From: Andrey Skvortsov <andrej.skvortzov@...il.com>
To: Dragan Simic <dsimic@...jaro.org>
Cc: Chen-Yu Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>,
	Samuel Holland <samuel@...lland.org>,
	linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
	linux-kernel@...r.kernel.org, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Ondřej Jirman <megi@....cz>
Subject: Re: [PATCH] arm64: dts: sun50i-a64-pinephone: Add mount matrix for
 accelerometer

On 24-09-18 13:27, Dragan Simic wrote:
> > > 
> > > After going through the InvenSense MPU-6050 datasheet, [1] the
> > > MPU-6050 evaluation board user guide, the PinePhone schematic,
> > > the PinePhone mainboard component placement, [2] and the kernel
> > > bindings documentation for mount-matrix, [3] I can conslude that
> > > only the direction of the accelerometer's y-axis is inverted,
> > > while the direction of the z-axis remain unchanged, according
> > > to the right-hand rule.
> > 
> > yes, it looks so on the first glance, but in MPU-6050 datasheet there
> > is also following information:
> > 
> >  7.8 Three-Axis MEMS Accelerometer with 16-bit ADCs and Signal
> >  Conditioning
> > 
> >  When the device is placed on a flat surface, it will measure
> >  0g on the X- and Y-axes and +1g on the Z-axis.

I'll try to explain how I read sensor's documentation and what bothers me.

Picture 1.

up

         ^ Z
         !      
         ! X=Y=0
     ++++++++++ 
     !        ! 
     +--------+ 
         !      
         !      
         v      
       gravity 

down

Screen (drawn as ++++++++++) is looking upwards. Device is on the flat
surface. Sensor returns +1g, although gravity points into *apposite* direction.

Experiment:

When I put PinePhone like in the sensor's documentation with the screen
upwards (Picture 1), gravity and Z axis point into different
directions, I read positive values from the sensor. So sensor works as
it's described in the documentation.


> > 
> > So sensors reports positive acceleration values for Z-axis, when
> > the gravity points to Z-minus. I see the same on device. positive
> > values are returned, when screen and IC point upwards (not the center
> > for gravity).



> > In device tree mount-matrix documentation [3] there is
> > 
> >  users would likely expect a value of 9.81 m/s^2 upwards along the (z)
> >  axis, i.e. out of the screen when the device is held with its screen
> >  flat on the planets surface.
> > 

how I read kernel documentation.

Picture 2.

up

     +--------+ 
     !        ! 
     ++++++++++ 
         !      
         !      
         v      
       gravity, Z

down

Screen (drawn as ++++++++++) is looking downwards ("its screen flat on
the planets surface"). Gravity and Z axis point into the same
direction and it's expected to read positive value.

Notice, that Z-axis on Picture 1 and Picture 2 point into different
directions to get positive values.


Experiment: 
Now, I go to the real device and check how the sensor actually works.

When I put PinePhone like is described in the kernel documentation
with the screen downwards, "screen flat on the planets surface"
(Picture 2), gravity and Z axis point into the same direction, but I
read negative values from the sensor. So the sensor works not as
expected by kernel documentation, when I understand documentation
correctly. Z-axis inversion comes from this.

> > According to that, it looks like Z-axis here has to be inverted.
> 
> Yes, reporting +1 g on the z-axis with the device remaining stationary
> on a level surface is the normal behavior, and the returned positive
> value actually goes along with the quoted description from the kernel
> documentation.  The z-axis of the MPU-6050 goes upward and out of the
> screen, the way the MPU-6050 is placed inside the PinePhone.

> > It applies to other axes as well. And because of that I came from
> > (only Y-axis is inverted)
> > 
> > x' = -y
> > y' =  x
> > z' =  z
> > 
> > to inverted solution (Y-axis is kept, but X and Z are inverted).
> > 
> > x' =  y
> > y' = -x
> > z' = -z
> > 
> > probably should put this information into commit description.
> 
> Wouldn't inverting the direction of the z-axis go against the
> above-quoted description from the kernel documentation?
See my comments above.


> > > [1] https://rimgo.reallyaweso.me/vrBXQPq.png
> > > [2] https://rimgo.reallyaweso.me/uTmT1pr.png
> > > [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/iio/mount-matrix.txt

-- 
Best regards,
Andrey Skvortsov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ