require and Lua path

classic Classic list List threaded Threaded
8 messages Options
Stefan Brantschen-3 Stefan Brantschen-3
Reply | Threaded
Open this post in threaded view
|

require and Lua path

As mentioned in an other e-mail, the image compiled from the current trunk for LM3S6965 is too large to flash over. TO save space and for testing, I compiled an image without the ROM filesystem. However, I copied all files in romfs onto a micro SD card, with the plan to run the demos from there.

However, running pong (on the board) resulted in:

eLua# lua /mmc/pong.lua
Press CTRL+Z to exit Lua
lua: /mmc/pong.lua:65: module 'EK-LM3S6965' not found:
        no field package.preload['EK-LM3S6965']
        no file '/rom/EK-LM3S6965.lua'
        no file '/rom/EK-LM3S6965.lc'
        no file './EK-LM3S6965.so'
        no file '/usr/local/lib/lua/5.1/EK-LM3S6965.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /mmc/pong.lua:65: in main chunk
        [C]: ?

Which triggers the question: from does the on-board "require" get its search path?

Thanks.

Cheers
-- Stefan



_______________________________________________
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: require and Lua path

Hello guys,
   On v0.7 has indeed a problem with require finding files on SD/MMC.
   This was fixed (by me and Marcelo) in the current trunk and, as far as I can remember now, the search order for a filename is:

1- .lc (Lua compiled) on sd/mmc filesystem
2- .lua on sd/mmc filesystem
3- .lc on romfs
4- .lua on romfs

   Your error log shows Lua is searching only its default paths and this is strange. Are you sure you are running the trunk version ?
   
Best
Dado




On Sun, Jun 13, 2010 at 16:24, Stefan Brantschen <[hidden email]> wrote:
As mentioned in an other e-mail, the image compiled from the current trunk for LM3S6965 is too large to flash over. TO save space and for testing, I compiled an image without the ROM filesystem. However, I copied all files in romfs onto a micro SD card, with the plan to run the demos from there.

However, running pong (on the board) resulted in:

eLua# lua /mmc/pong.lua
Press CTRL+Z to exit Lua
lua: /mmc/pong.lua:65: module 'EK-LM3S6965' not found:
       no field package.preload['EK-LM3S6965']
       no file '/rom/EK-LM3S6965.lua'
       no file '/rom/EK-LM3S6965.lc'
       no file './EK-LM3S6965.so'
       no file '/usr/local/lib/lua/5.1/EK-LM3S6965.so'
       no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
       [C]: in function 'require'
       /mmc/pong.lua:65: in main chunk
       [C]: ?

Which triggers the question: from does the on-board "require" get its search path?

Thanks.

Cheers
-- Stefan



_______________________________________________
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
Stefan Brantschen-3 Stefan Brantschen-3
Reply | Threaded
Open this post in threaded view
|

Re: require and Lua path

Hi

On 13 Jun 2010, at 21:40, Dado Sutter wrote:

>    This was fixed (by me and Marcelo) in the current trunk and, as far as I can remember now, the search order for a filename is:
>
> 1- .lc (Lua compiled) on sd/mmc filesystem
> 2- .lua on sd/mmc filesystem
> 3- .lc on romfs
> 4- .lua on romfs
>
>    Your error log shows Lua is searching only its default paths and this is strange. Are you sure you are running the trunk version ?

I just compiled the trunk (for LM3S, conf see below) and ran a test for "require" (a file req1.lua with a simple 'require "test"', with test-lua not existing), with these results

Error: [string "xmodem"]:3: module 'test' not found:
        no field package.preload['test']
        no file '/rom/test.lua'
        no file '/rom/test.lc'
        no file './test.so'
        no file '/usr/local/lib/lua/5.1/test.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'

Do I miss something to get the search also in mmc?

I compile with

#define BUILD_XMODEM
#define BUILD_SHELL
#define BUILD_ROMFS
#define BUILD_MMCFS
#define BUILD_TERM
//#define BUILD_UIP
//#define BUILD_DHCPC
//#define BUILD_DNS
#define BUILD_CON_GENERIC
#define BUILD_ADC
//#define BUILD_RPC
//#define BUILD_CON_TCP

Cheers
-- Stefan

_______________________________________________
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: require and Lua path



On Sun, Jun 20, 2010 at 12:40, Stefan Brantschen <[hidden email]> wrote:
I just compiled the trunk (for LM3S, conf see below) and ran a test for "require" (a file req1.lua with a simple 'require "test"', with test-lua not existing), with these results
..........

Please update your trunk and try again now Stephane.
Reports are welcomed.

Best
Dado



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

Re: require and Lua path

Hi Dado

On 21 Jun 2010, at 23:15, Dado Sutter wrote:

> On Sun, Jun 20, 2010 at 12:40, Stefan Brantschen <[hidden email]> wrote:
> I just compiled the trunk (for LM3S, conf see below) and ran a test for "require" (a file req1.lua with a simple 'require "test"', with test-lua not existing), with these results
> ..........
>
> Please update your trunk and try again now Stephane.
> Reports are welcomed.

Problem persists. Shouldn't line 108 in src/lua/luaconf.h read

  #define LUA_PATH_DEFAULT  "/mmc/?.lua;/mmc/?.lc;/rom/?.lua;/rom/?.lc"

in lieu of the current

  #define LUA_PATH_DEFAULT  "/rom/?.lua;/rom/?.lc"

Cheers
-- Stefan

_______________________________________________
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: require and Lua path



On Tue, Jun 22, 2010 at 02:02, Stefan Brantschen <[hidden email]> wrote:
...................

Problem persists. Shouldn't line 108 in src/lua/luaconf.h read ...........

Yes Stefan. I had fixed it only on line 93 and this is also needed on line 108. I've already commited the fix so you can update your trunk and try again, if you haven't done it locally already.

   Those #defines look a bit confusing to me, since we added the #ifdefs for LUA_RPC (and kept the original Lua checks for WIN32).
   I don't know for example, why we need to keep searching the original (Lua) paths of /, /lua for .lua and .lc files and even for the init.lua file.
   To respect the Lua feature of running an init.lua or init.lc file if found, we should instead add it to our /rom and /mmc search paths or to better merge this feature with our autorun right ?

Tks for helping us to test it
Best
Dado










 #define LUA_PATH_DEFAULT  "/mmc/?.lua;/mmc/?.lc;/rom/?.lua;/rom/?.lc"

in lieu of the current

 #define LUA_PATH_DEFAULT  "/rom/?.lua;/rom/?.lc"

Cheers
-- Stefan

_______________________________________________
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
Dado Sutter Dado Sutter
Reply | Threaded
Open this post in threaded view
|

Re: require and Lua path

Hello,
   I could finally test it on a kit and require() is now working fine for modules on ROMFS and on MMC.
   eLua first search the SD/MMC for filename.lua, then filename.lc (lua compiled bytecodes). Then this search is repeated for files on ROMFS.
   The init.lua and init.lc is a Lua feature and eLua does not change it at all. For more information, see the PIL2, section 15.5, page 145.

   Stepan seem to still have another problem with Pong though.
   Could you explain it again, in another thread, if you haven't fixed it ?

Best
Dado



On Tue, Jun 22, 2010 at 11:23, Dado Sutter <[hidden email]> wrote:


On Tue, Jun 22, 2010 at 02:02, Stefan Brantschen <[hidden email]> wrote:
...................

Problem persists. Shouldn't line 108 in src/lua/luaconf.h read ...........

Yes Stefan. I had fixed it only on line 93 and this is also needed on line 108. I've already commited the fix so you can update your trunk and try again, if you haven't done it locally already.

   Those #defines look a bit confusing to me, since we added the #ifdefs for LUA_RPC (and kept the original Lua checks for WIN32).
   I don't know for example, why we need to keep searching the original (Lua) paths of /, /lua for .lua and .lc files and even for the init.lua file.
   To respect the Lua feature of running an init.lua or init.lc file if found, we should instead add it to our /rom and /mmc search paths or to better merge this feature with our autorun right ?

Tks for helping us to test it
Best
Dado










 #define LUA_PATH_DEFAULT  "/mmc/?.lua;/mmc/?.lc;/rom/?.lua;/rom/?.lc"

in lieu of the current

 #define LUA_PATH_DEFAULT  "/rom/?.lua;/rom/?.lc"

Cheers
-- Stefan

_______________________________________________
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
Stefan Brantschen-3 Stefan Brantschen-3
Reply | Threaded
Open this post in threaded view
|

Re: require and Lua path

In reply to this post by Stefan Brantschen-3
On 25 Jun 2010, at 21:16, Dado Sutter <[hidden email]> wrote:

Stepan seem to still have another problem with Pong though.
   Could you explain it again, in another thread, if you haven't fixed it ?

This was caused by the missing "local lm3s = lm3s" in the file EK-LM3S6965, as discussed here, which should be fixed in the trunk, but I didn't check lately, sorry (also in EK-LM3S8962).

Cheers
-- Stefan

Sent from my microwave.


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