Loadable C modules

classic Classic list List threaded Threaded
4 messages Options
Dado Sutter Dado Sutter
Reply | Threaded
Open this post in threaded view
|

Loadable C modules

Hello folks,
   I'm back in Rio, the trip to the Old World was nice and we've planted some nice eLua seeds up there too.
   A while ago, we discussed some ideas on Loadable C Modules for eLua here on the list and someone told me that we already had an example implemented in one of the ports. I think it was Mike Panetta but I'm not sure and I couldn't find it now.
   One of my students (Marcelo Politzer) is willing to play with some ideas and it would be nice to have something to base on to start with.
   It would definetely be a nice feature to have and some of our projects call for it already.

Best
Dado

  

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Tim Michals Tim Michals
Reply | Threaded
Open this post in threaded view
|

Re: Loadable C modules



From: Dado Sutter <[hidden email]>
To: eLua Users and Development List <[hidden email]>
Sent: Wed, June 9, 2010 5:24:13 AM
Subject: [eLua-dev] Loadable C modules

Hello folks,
   I'm back in Rio, the trip to the Old World was nice and we've planted some nice eLua seeds up there too.
   A while ago, we discussed some ideas on Loadable C Modules for eLua here on the list and someone told me that we already had an example implemented in one of the ports. I think it was Mike Panetta but I'm not sure and I couldn't find it now.
   One of my students (Marcelo Politzer) is willing to play with some ideas and it would be nice to have something to base on to start with.
   It would definetely be a nice feature to have and some of our projects call for it already.

Best
Dado

  


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Dado Sutter Dado Sutter
Reply | Threaded
Open this post in threaded view
|

Re: Loadable C modules

Thank you for the links Tim !

Meanwhile, I was able to find the message I mentioned and it was indeed Mike Panetta who have implemented it.
His original message is here below:

--------------------------------
We also have loadable modules, at least on STM32.  Take a look at modcommon.c in the modules dir, function luaopen_mod, and the lua_lcd.c file in platform/stm32/ for an example of how its used. 

At the end of the file I create a luaL_reg struct with a single entry that gets placed in a special location in memory via the linker script and the section attribute. luaopen_mod uses the package.preload table entry to push a handler to call the luaopen_lcd init function when someone does a require 'stm3210lcd'. 

So while the FLASH space is always used for the module, the RAM space required for the module table and etc are not loaded until someone calls require.

Comments on this methodology are very welcome!

Mike
----------------------------------

Best
Dado



On Wed, Jun 9, 2010 at 11:07, Tim michals <[hidden email]> wrote:


From: Dado Sutter <[hidden email]>
To: eLua Users and Development List <[hidden email]>
Sent: Wed, June 9, 2010 5:24:13 AM
Subject: [eLua-dev] Loadable C modules

Hello folks,
   I'm back in Rio, the trip to the Old World was nice and we've planted some nice eLua seeds up there too.
   A while ago, we discussed some ideas on Loadable C Modules for eLua here on the list and someone told me that we already had an example implemented in one of the ports. I think it was Mike Panetta but I'm not sure and I couldn't find it now.
   One of my students (Marcelo Politzer) is willing to play with some ideas and it would be nice to have something to base on to start with.
   It would definetely be a nice feature to have and some of our projects call for it already.

Best
Dado

  


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev



_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Loadable C modules

Hi Dado (and welcome back :) ),

We never actually had dynamic loadable C modules. What Mike implemented was a sort of lazy loading of modules, but they still had to be compiled in the image, and this was made obsolete by the LTR patch, so we removed it meanwhile. Loadable C modules on a barebone system isn't exactly a child's play, but I feel we can do it. I'll look at Tim's links (thanks!)
My idea was somewhat crazy "cross platform loadable C modules support", and it involved letting the toolchain do most of the work, then taking over from there (as in, NOT having to take care of all the possible relocation types ourselves, I don't think this is the way to go unless we really have to). I can go in more detail if anyone wants, although there are still a lot of things to consider before deciding if this could actually work in practice or not.

Best,
Bogdan

On Wed, Jun 9, 2010 at 7:52 PM, Dado Sutter <[hidden email]> wrote:
Thank you for the links Tim !

Meanwhile, I was able to find the message I mentioned and it was indeed Mike Panetta who have implemented it.
His original message is here below:

--------------------------------
We also have loadable modules, at least on STM32.  Take a look at modcommon.c in the modules dir, function luaopen_mod, and the lua_lcd.c file in platform/stm32/ for an example of how its used. 

At the end of the file I create a luaL_reg struct with a single entry that gets placed in a special location in memory via the linker script and the section attribute. luaopen_mod uses the package.preload table entry to push a handler to call the luaopen_lcd init function when someone does a require 'stm3210lcd'. 

So while the FLASH space is always used for the module, the RAM space required for the module table and etc are not loaded until someone calls require.

Comments on this methodology are very welcome!

Mike
----------------------------------

Best
Dado



On Wed, Jun 9, 2010 at 11:07, Tim michals <[hidden email]> wrote:


From: Dado Sutter <[hidden email]>
To: eLua Users and Development List <[hidden email]>
Sent: Wed, June 9, 2010 5:24:13 AM
Subject: [eLua-dev] Loadable C modules

Hello folks,
   I'm back in Rio, the trip to the Old World was nice and we've planted some nice eLua seeds up there too.
   A while ago, we discussed some ideas on Loadable C Modules for eLua here on the list and someone told me that we already had an example implemented in one of the ports. I think it was Mike Panetta but I'm not sure and I couldn't find it now.
   One of my students (Marcelo Politzer) is willing to play with some ideas and it would be nice to have something to base on to start with.
   It would definetely be a nice feature to have and some of our projects call for it already.

Best
Dado

  


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev



_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev



_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev