mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
- Fixed autorun feature for all file systems and all file formats
(it did not autorun if sd/mmc was built and autorun.lua was in romfs) (it did not autorun .lc {Lua compiled} files) Thanks to Marcelo Politzer for the help with the fix too. - Minor doc refinement
This commit is contained in:
parent
b34171de18
commit
588411ce92
@ -106,7 +106,7 @@ notation given below:
|
||||
href="http://www.nxp.com/#/pip/pip=[pip=LPC2468_4]|pp=[t=pip,i=LPC2468_4]">LPC2468</a></td>
|
||||
<td>ARM7TDMI</td>
|
||||
<td style="color: rgb(255, 102, 0);">LPC24xx</td>
|
||||
<td><a href="http://www.giga.puc-rio.br/site/embedded/eluademoboard">PUC-Rio Demo Board</a></td>
|
||||
<td><a href="http://www.giga.puc-rio.br/site/embedded/eluademoboard">PUC-Rio Demo</a></td>
|
||||
<td style="text-align: center;"><img src="images/stat_ok.png" alt="Status: OK" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
31
src/main.c
31
src/main.c
@ -23,12 +23,19 @@
|
||||
|
||||
#include "mmcfs.h"
|
||||
#include "romfs.h"
|
||||
|
||||
// Define here your autorun/boot files,
|
||||
// in the order you want eLua to search for them
|
||||
char *boot_order[] = {
|
||||
#if defined(BUILD_MMCFS)
|
||||
#define FS_AUTORUN "/mmc/autorun.lua"
|
||||
"/mmc/autorun.lua",
|
||||
"/mmc/autorun.lc",
|
||||
#endif
|
||||
#if defined(BUILD_ROMFS) && !defined(FS_AUTORUN)
|
||||
#define FS_AUTORUN "/rom/autorun.lua"
|
||||
#if defined(BUILD_ROMFS)
|
||||
"/rom/autorun.lua",
|
||||
"/rom/autorun.lc",
|
||||
#endif
|
||||
};
|
||||
|
||||
extern char etext[];
|
||||
|
||||
@ -69,6 +76,7 @@ void boot_rpc( void )
|
||||
|
||||
int main( void )
|
||||
{
|
||||
int i;
|
||||
FILE* fp;
|
||||
|
||||
// Initialize platform first
|
||||
@ -93,14 +101,17 @@ int main( void )
|
||||
// Register the remote filesystem
|
||||
dm_register( remotefs_init() );
|
||||
|
||||
// Autorun: if "autorun.lua" is found in the file system, run it first
|
||||
if( ( fp = fopen( FS_AUTORUN, "r" ) ) != NULL )
|
||||
{
|
||||
fclose( fp );
|
||||
char* lua_argv[] = { "lua", FS_AUTORUN, NULL };
|
||||
lua_main( 2, lua_argv );
|
||||
// Search for autorun files in the defined order and execute the 1st if found
|
||||
for( i = 0; i < sizeof( boot_order )/sizeof( *boot_order ); i++ ){
|
||||
if( ( fp = fopen( boot_order[i], "r" ) ) != NULL )
|
||||
{
|
||||
fclose( fp );
|
||||
char* lua_argv[] = { "lua", boot_order[i], NULL };
|
||||
lua_main( 2, lua_argv );
|
||||
break; // autoruns only the first found
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef ELUA_BOOT_RPC
|
||||
boot_rpc();
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user