Re: [PATCH v3] platform/chrome: Add cros_ec_readmem() helpers for I2C/SPI based ECs

From: Enric Balletbo Serra
Date: Wed Jan 23 2019 - 06:33:37 EST


Missatge de Moritz Fischer <mdf@xxxxxxxxxx> del dia dt., 22 de gen.
2019 a les 22:09:
>
> Hi Enrico,
>
> On Mon, Jan 21, 2019 at 11:19:34PM +0100, Enric Balletbo Serra wrote:
> > I tried with a Samsung Chromebook Plus (arm64 Chromebook)
> >
> > > What was the ioctl you ran?
> > >
> >
> > The code that I ran is this: https://hastebin.com/cupecuvowi.py
> > No guarantee :) I'll try to look deeper tomorrow.
>
> I fixed it up to run with python3, but on my device I got either a
> protocol error if len is > 120:
>
> root@ni-n3xx-313ABDC:~# python3 foo
> Testing EC_DEV_IOCRDMEM cmd
> I/O error(71): Protocol error
>
> or it worked for lengths <= 120:
>
> root@ni-n3xx-313ABDC:~# python3 foo
> Testing EC_DEV_IOCRDMEM cmd
> 6b 6f ff ff ff ff ff ff ff ff ff ff ff ff ff ff f0 0f f0 0f ff ff ff ff
> ff ff ff ff ff ff ff ff 45 43 01 02 00 01 01 00 00 00 00 00 00 00 00 00
> 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> [...]
>
> Did you try smaller reads? If that works maybe we'll have to filter in
> the kernel to prevent large reads from crashing the EC?
>

So looks like I can read up to 161 bytes, if I read 162 to 169 bytes
the EC fails to respond and if I read more than 169 bytes it simply
resets the machine. I didn't look the code yet.

root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 160
Testing EC_DEV_IOCRDMEM cmd (size 160)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 45 43 01 00 01 01 01 00 00 00 00 00 00 00
00 00
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9f 21 00 00 0e 01 00
00 59 13 00 00 0b 00 00 00 14 14 00 00 b0 1d 00 00 9a 13 00 00 35 01
00 00
53 44 49 00 00 00 00 00 34 33 35 32 44 35 31 00 30 46 38 32 00 00 00
00 4c 49 4f 4e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 161
Testing EC_DEV_IOCRDMEM cmd (size 161)
[ 425.053205] cros-ec-spi spi2.0: cannot read mapped reg: -71/14
I/O error(71): Protocol error
root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 162
Testing EC_DEV_IOCRDMEM cmd (size 162)
[ 427.208065] cros-ec-spi spi2.0: cannot read mapped reg: -71/14
I/O error(71): Protocol error

root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 163
Testing EC_DEV_IOCRDMEM cmd (size 163)
[ 429.845069] cros-ec-spi spi2.0: cannot read mapped reg: -71/14
I/O error(71): Protocol error
root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 164
Testing EC_DEV_IOCRDMEM cmd (size 164)[ 431.968014] cros-ec-spi
spi2.0: cannot read mapped reg: -71/14

I/O error(71): Protocol error

root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 165
Testing EC_DEV_IOCRDMEM cmd (size 165)
[ 440.289340] cros-ec-spi spi2.0: EC failed to respond in time
[ 440.296271] cros-ec-spi spi2.0: Command xfer error (err:-110)
[ 440.302732] cros-ec-spi spi2.0: cannot read mapped reg: -110/0
I/O error(110): Connection timed out

root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 166
Testing EC_DEV_IOCRDMEM cmd (size 166)
[ 443.953212] cros-ec-spi spi2.0: EC failed to respond in time
[ 443.960095] cros-ec-spi spi2.0: Command xfer error (err:-110)
[ 443.966554] cros-ec-spi spi2.0: cannot read mapped reg: -110/0
I/O error(110): Connection timed out

root@debian:~# python
/home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 167
Testing EC_DEV_IOCRDMEM cmd (size 167)
[ 446.585416] cros-ec-spi spi2.0: EC failed to respond in time
[ 446.592335] cros-ec-spi spi2.0: Command xfer error (err:-110)
[ 446.598798] cros-ec-spi spi2.0: cannot read mapped reg: -110/0
I/O error(110): Connection timed out

root@debian:~# python /home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 168
Testing EC_DEV_IOCRDMEM cmd (size 168)
[ 449.337255] cros-ec-spi spi2.0: EC failed to respond in time
[ 449.344140] cros-ec-spi spi2.0: Command xfer error (err:-110)
[ 449.350588] cros-ec-spi spi2.0: cannot read mapped reg: -110/0
I/O error(110): Connection timed out

root@debian:~# python /home/debian/Tests/cros_ec/scripts/cros-ec-readmem.py 169
Testing EC_DEV_IOCRDMEM cmd (size 169)
l%(NAPEK@ @%vZ__|+~/g?sÚ}mj}u??UwWo;_ÛI6go{]uw]{m}w.Íïß

And the machine reboots ...


> Thanks,
>
> Moritz