[Openpvrsgx-devgroup] trying to get SGX 1.14 running on DM3730 (SGX530)

H. Nikolaus Schaller hns at goldelico.com
Thu Nov 21 17:14:25 CET 2019


Hi Tony,

> Am 21.11.2019 um 16:39 schrieb Tony Lindgren <tony at atomide.com>:
> 
> * H. Nikolaus Schaller <hns at goldelico.com> [191121 15:24]:
>> Hi Tomi,
>> 
>>> Am 21.11.2019 um 16:13 schrieb Tomi Valkeinen <tomi.valkeinen at ti.com>:
>>> 
>>> On 21/11/2019 16:51, H. Nikolaus Schaller wrote:
>>> 
>>>> Just after submitting this mail I got an idea what is going wrong and what
>>>> libsrv_um.so is looking for.
>>>> Firstly, it is PVRDRMOpenDisplay() which fails. I.e. looking for a display DRM
>>>> device. Not the SGX (which is found by PVRDRMOpenRender).
>>>> What if it does not look for maj=14 or min=0 but for name=tilcdc or even
>>>> desc="TI LCD Controller DRM"?
>>> 
>>> Did you try ltrace? I haven't used it, but it should show what the parameters are.
>> 
>> I have looked into what gdb shows in the disassembler window. And it seems my
>> assumption about the algorithm isn't very wrong... open(), close(), snprintf(),
>> drmGetVersion() and strcmp() are called. There is only one additional call to
>> drmFreeVersion(). Otherwise one would have to decipher the ARM assembly.
>> 
>>> I guess an option is to use LD_PRELOAD to catch the "bad" calls and modify them as needed.
>> 
>> Yes, that could be a workaround which does not need patching the binary blobs.
>> 
>> Another trick could be to tell omapdrm to report itself as "tilcdc". At least for
>> verifying this idea.
>> 
>> I assume you know where the name="omapdrm" or name="tilcdc" string is defined :)
>> 
>> Or maybe the easiest thing to try in my setup is to make drmGetVersion() return
>> "tilcdc" if it gets "omapdrm" from the ioctl..
> 
> Heh so maybe try with the ti437x binaries on omap3 instead?

Maybe...

> That should be the same sgx530 with dispc instead of tilcd.
> 
> It would be silly if the name is the only reason for a pile of
> different binary blobs..

It is...

See: https://youtu.be/DDAEnDMVV3U
and compare: https://www.youtube.com/watch?v=G_QGU6e3eyA (I forgot to make it public)

My trick to return "tilcdc" by drmGetVersion() worked.

Full instructions what I did to make it work:

> take Debian Stretch
> install DDK1.14 um (e.g. through https://github.com/openpvrsgx-devgroup/linux_openpvrsgx/blob/letux-pvrsrvkm/Letux/root/gpu-demo)
> 
> vi /etc/apt/sources.list
>   deb http://httpredir.debian.org/debian stretch main
>   deb-src http://httpredir.debian.org/debian stretch main
> 
> apt-get update
> apt-get install dpkg-dev build-essential fakeroot
> rm -rf libdrm_2.4.74
> apt-get source libdrm2
> apt-get install debhelper quilt xsltproc docbook-xsl libx11-dev pkg-config xutils-dev libpthread-stubs0-dev libudev-dev libpciaccess-dev valgrind
> 
> cd libdrm-2.4.74/
> vi xf86drm.c
>   static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s)
>   {
>     d->version_major      = s->version_major;
>     d->version_minor      = s->version_minor;
>     d->version_patchlevel = s->version_patchlevel;
>     d->name_len           = s->name_len;
>     d->name               = strdup(s->name);
>     if (strcmp(d->name, "omapdrm") == 0) {
> 	d->name=strdup("tilcdc"); /* leaks previous strdup */
> 	d->name_len=strlen(d->name);
>     }
>     d->date_len           = s->date_len;
>     d->date               = strdup(s->date);
>     d->desc_len           = s->desc_len;
>     d->desc               = strdup(s->desc);
>   }
> 
> dpkg-buildpackage -rfakeroot -b -uc -nc
> cd ..
> dpkg -i libdrm*_2.4.74-*_armhf.deb
> 
> gles1test1

The interesting question is now how to proceed.

We have several options:
a) hack the kernel to return "tilcdc" for "omapdrm"
b) hack libdrm as above (and fix the strdup leak)
c) patch binary libsrv_um.so
d) someone rewrites libsrv_um.so from scratch as open source and we get the display identification algorithm right
e) try ti437x binaries on omap3

Anyways we have again reached a big milestone! Having DDK1.14 run on OMAP3/DM3730 in DRM mode.

BR,
Nikolaus



More information about the openpvrsgx-devgroup mailing list