<div dir="ltr"><div dir="ltr"><br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 12, 2019 at 9:16 PM Christian Mauderer <<a href="mailto:list@c-mauderer.de">list@c-mauderer.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am 12.04.19 um 16:26 schrieb Vijay Kumar Banerjee:<br>> <br>> <br>> On Wed, Apr 10, 2019 at 12:50 PM Christian Mauderer<br>> <<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a><br>> <mailto:<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a>>> wrote:<br>> <br>> Am 09.04.19 um 18:12 schrieb Vijay Kumar Banerjee:<br>> > Hi,<br>> ><br>> > I have imported and ported the the drivers in 2 pairs(import and port)<br>> > of commits <br>> > for each one. Please have a look at this branch <br>> > <a href="https://github.com/thelunatic/rtems-libbsd/commits/tda19988" rel="noreferrer" target="_blank">https://github.com/thelunatic/rtems-libbsd/commits/tda19988</a><br>> <br>> One detail: You have a commit named "tda19988.c: import from FreeBSD".<br>> Please remove the ".c".<br>> <br>> Noted. <br>> <br>> Maybe it would be a good idea to split of the I2C part and put it in<br>> front of the other two parts. You can develop and test that independent<br>> with a test that just accesses some of the I2C devices on the board via<br>> the FreeBSD API and the translation driver discussed below.<br>> <br>> This is a good idea, I'll import iicbus separately and add the other <br>> two on top of it. <br>> <br>> ><br>> > I have also tried running the media01.exe and have seen it running<br>> fine<br>> > without<br>> > throwing any exceptions.<br>> ><br>> > I have used the fb.c and iicbus.c codes from the freebsd source. From<br>> > what I <br>> > understand, I think the next big steps would be to write an RTEMS <br>> > implementation layer for these portions of the code? And then a<br>> test in the <br>> > libbsd, like media01, to write to the /dev/fb0 <br>> ><br>> > Can you please help me chalk out a rough outline of the next set of<br>> > actions? :)<br>> <br>> As far as I can tell, there are two possible I2C buses here:<br>> <br>> 1. The one between the AM335x and the TDA19988.<br>> <br>> 2. The one directly on the HDMI connector (called HDMI_DSCL and<br>> HDMI_DSDA). I assume that's an I2C bus too.<br>> <br>> For 1. the RTEMS driver should be used. You'll need some code that<br>> translates the FreeBSD API to the one used in RTEMS. Basically that will<br>> just be a FreeBSD-I2C-driver.<br>> <br>> For 2: If that even is an independent I2C bus, you can use the driver<br>> provided by FreeBSD. I don't think that it is necessary to translate to<br>> the RTEMS API here.<br>> <br>> I had a look at the iic and iicbus codes in freebsd and the bbb-i2c.c<br>> This looks very confusing to me. Are we looking for something like a<br>> rtems-iicbus.c in the rtemsbsd that works like a wrapper to the bbb-i2c<br>> code, and uses the freebsd api of DEVMETHODs?<br>
<br>Yes correct. Basically it would be necessary to have a I2C device driver<br>for FreeBSD that translates to the RTEMS API.<br>
<br>> <br>> I've not been able to figure out at one look, how to relate them and <br>> get a wrapper like that. Any suggestions on how to approach this?<br>
<br>I haven't had a look at the FreeBSD drivers yet. The first part that I<br>would have a look at is the description of the user facing FreeBSD API:<br>
<br>
<a href="https://www.freebsd.org/cgi/man.cgi?query=iic&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE+and+Ports&arch=default&format=html" rel="noreferrer" target="_blank">https://www.freebsd.org/cgi/man.cgi?query=iic&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE+and+Ports&arch=default&format=html</a><br>
<br>Nice thing: They use a struct iic_msg that is compatible with Linux's<br>struct i2c_msg (according to the man page). We are Linux compatible too.<br>Can be a big advantage.<br>
<br>Then take a look at the simplest i2c driver that you can find in FreeBSD<br>that uses the transfer API.<br>freebsd-org/sys/dev/drm2/radeon/atombios_i2c.c looks good to me.<br>Basically you have to implement the following functions (replace<br>radeon_atom... by a useful prefix):<br>
<br>static device_method_t radeon_atom_hw_i2c_methods[] = {<br> DEVMETHOD(device_probe, radeon_atom_hw_i2c_probe),<br> DEVMETHOD(device_attach, radeon_atom_hw_i2c_attach),<br> DEVMETHOD(device_detach, radeon_atom_hw_i2c_detach),<br> DEVMETHOD(iicbus_reset, radeon_atom_hw_i2c_reset),<br> DEVMETHOD(iicbus_transfer, radeon_atom_hw_i2c_xfer),<br> DEVMETHOD_END<br>};<br>
<br>The iicbus_transfer function seems to get a struct iic_msg as a<br>parameter. Now that's really lucky.<br>
<br>With that you should be able to open the i2c device in RTEMS and just<br>pass the structure via the correct ioctl call to the RTEMS driver.<br>
<br>Basically you just have to pass the bus to use as a parameter to the<br>driver. Take a look at some of the other drivers in nexus-devices.h that<br>have for example an address as a parameter to see how you can do that.<br>
<br></blockquote><div>This gave a good idea of the objective. :)</div><div><br></div><div>I had a look at the bbb-i2c.c code and how it's registering</div><div>and setting up the i2c_bus struct with the transfer, set and destroy</div><div>fucntions. </div><div>I have a question from the fundamentals, the only function</div><div>of <a href="https://git.rtems.org/rtems/tree/bsps/arm/beagle/i2c/bbb-i2c.c#n414">bbb-i2c.c</a> that is 'accessible' with the header file is am335x_i2c_bus_register which basically sets the i2c_bus struct</div><div>and calls the i2c_bus_register function from the dev/i2c.c .</div><div>To use the DEVMETHOD api, we need to be able to call the </div><div>transfer, destroy etc. functions of the bbb-i2c.c from the translation</div><div>layer in rtemsbsd. How do I #include the bbb-i2c.c in the new </div><div>translation driver that I'll write?</div><div><br></div><div>Hope my question is stated clearly, please correct me if I'm getting</div><div>some fundamentals wrong. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> <br>> Can we not totally use the iicbus in the freebsd source?<br>
<br>We already have a I2C driver for that BSP in RTEMS. If you would use the<br>FreeBSD code, they would fight for the hardware. Of course it would be<br>possible to replace the RTEMS driver by a FreeBSD one. But that would<br>potentially break some applications. Besides that I think that a lot of<br>RTEMS BSPs already have an I2C driver so a generic wrapper could be<br>helpful for other BSPs too.<br>
<br>> <br>> ><br>> > Thanks<br>> ><br>> > On Tue, Apr 9, 2019 at 5:28 AM Chris Johns <<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a><br>> <mailto:<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>><br>> > <mailto:<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a> <mailto:<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>>>> wrote:<br>> ><br>> > On 8/4/19 12:30 am, Vijay Kumar Banerjee wrote:<br>> > > On Sun, Apr 7, 2019 at 6:24 PM Christian Mauderer<br>> > <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>>> wrote:<br>> > > Am 07.04.19 um 14:50 schrieb Vijay Kumar Banerjee:<br>> > > > On Sun, Apr 7, 2019 at 6:08 PM Christian Mauderer<br>> > <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>><br>> > > > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>>>> wrote:<br>> > > > Am 07.04.19 um 14:35 schrieb Vijay Kumar Banerjee:<br>> > > > > On Sun, Apr 7, 2019 at 5:37 PM Christian Mauderer<br>> > > > <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>><br>> > > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>>><br>> > > > > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>><br>> > > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>><br>> > <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>><br>> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a> <mailto:<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>>>>>>> wrote:<br>> > > > > Am 07.04.19 um 13:08 schrieb Vijay Kumar<br>> Banerjee:<br>> > ><br>> > > I don't think that there are a lot of docs for how to test.<br>> > Although I'm<br>> > > sure that there are some scripts to run a number of libbsd<br>> > tests, I'm<br>> > > not sure where. Maybe in the RTEMS tester but I think<br>> that is<br>> > mainly for<br>> > > the core tests?<br>> ><br>> > The documentation for testing can be found here ...<br>> ><br>> > <a href="https://docs.rtems.org/branches/master/user/testing/index.html" rel="noreferrer" target="_blank">https://docs.rtems.org/branches/master/user/testing/index.html</a><br>> ><br>> > > so far I know, RTEMS Tester is only for core tests.<br>> ><br>> > The `rtems-test` command checks the for test start and end<br>> banners.<br>> > I am not<br>> > sure if libbsd supports the test banners. Maybe it could now with<br>> > Sebastian's<br>> > movement of the test support code into libtest.<br>> ><br>> > > I'll ask in the devel if there's some way to run libbsd test<br>> with<br>> > the tester.<br>> ><br>> > There is the `rtems-run` command which has similar args to<br>> > `rtems-test`. It does<br>> > suffer from a limitation I have not fixed which is stdin is not<br>> > passed through<br>> > to the console of the target. I also think the command has a<br>> timeout<br>> > running,<br>> > but I am not sure about this one.<br>> ><br>> > Chris<br>> ><br>> <br>> -- <br>> --------------------------------------------<br>> embedded brains GmbH<br>> Herr Christian Mauderer<br>> Dornierstr. 4<br>> D-82178 Puchheim<br>> Germany<br>> email: <a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a><br>> <mailto:<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a>><br>> Phone: +49-89-18 94 741 - 18<br>> Fax: +49-89-18 94 741 - 08<br>> PGP: Public key available on request.<br>> <br>> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>> <br>
<br>
</blockquote></div></div>