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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdfM=Seaa=K6f=zium+2jYusccy6oEF6GuMCZDL5SM_YA@mail.gmail.com>
Date:   Wed, 21 Apr 2021 23:11:01 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Lars-Peter Clausen <lars@...afoo.de>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Dmitry Osipenko <digetx@...il.com>,
        Jonathan Cameron <jic23@...nel.org>,
        "linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Svyatoslav Ryhel <clamor95@...il.com>,
        Jean-Baptiste Maneyrol <jmaneyrol@...ensense.com>
Subject: Re: BUG: iio: mpu3050: Wrong temperature scale

On Wed, Apr 21, 2021 at 11:00 PM Lars-Peter Clausen <lars@...afoo.de> wrote:
> On 4/21/21 9:41 PM, Andy Shevchenko wrote:
> > On Wed, Apr 21, 2021 at 10:05 PM Andy Shevchenko
> > <andy.shevchenko@...il.com> wrote:
> >> On Wed, Apr 21, 2021 at 1:14 PM Linus Walleij <linus.walleij@...aro.org> wrote:
> >>> On Tue, Apr 20, 2021 at 11:26 PM Dmitry Osipenko <digetx@...il.com> wrote:
> >>>
> >>>> I found a non-kernel example
> >>>> which uses a similar equation [1], but in a different form. The main
> >>>> difference is that the Arduino code interprets a raw temperature value
> >>>> as a signed integer, while upstream assumes it's unsigned.
> >>>>
> >>>> [1]
> >>>> https://github.com/blaisejarrett/Arduino-Lib.MPU3050/blob/master/MPU3050lib.cpp#L111
> >>> Oh that's nice. Room temperature as mentioned is 20 deg C
> >>> I think?
> >>>
> >>> The divide by 280 part seems coherent in all examples.
> >>>
> >>>> Still, even if assume that the raw temperature is a signed s16 value, it
> >>>> gives us ~35C in a result, which should be off by ~10C.
> >> Actually here [1] it says in chapter 3.1 that room temperature is 35°C.
> >>
> >> Range: -30°C .. +85°C
> >> Sensitivity: 280 LSB/°C
> >> Room temperature offset: 35°C = -13200 LSB
> >>
> >> [1]: https://www.cdiweb.com/datasheets/invensense/mpu-3000a.pdf
> >
> > So, if I'm reading this and the register description right the value
> > is in the range
> > -32768..32767.
> > -13200 defines 35°C
> >
> > 50000 as mentioned by Dmitry is actually -15536. So, it means that the
> > more negative a value is the higher temperature is shown.

s/higher/lower/
Sorry for my signness.

> > Since it's linearized scale, now we can see that
> >
> > (13200 -15536)/280 + 35 gives us 26.66.
> >
> > Does it make sense?
> (13200 + x)/280 + 35 = (23000 + x)/280, which is what is in the driver.
> So the only bit missing is the cast to s16.


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ