Using OatLua4 under DS

You will need Fastrack modem with IESM Ethernet card installed.

File / New OpenAtLua Project. Name it HelloWorld.

Again we manage configuration, this time we select Executable EABI instead of Static Library, and do similar steps.

In Project Properties / Open AT Application / Package selection we select OAT ESS 2.36 as Framework Profile and in libraries tab do deselect LUA library Package.

Use following main.c and main.lua
Main.c:

#include "adl_global.h"
#include "wip.h"
#include "oatlua.h"
#include "Ethernet.h"
#include "Shell.h"
#include "HelloWorld.h"

/* Comment/Remove this define out to turn off verbose logs. */
#define VERBOSE

#define K 1024

const u16 wm_apmCustomStackSize       = 32*K;
const u32 wm_apmIRQLowLevelStackSize  =  2*K;
const u32 wm_apmIRQHighLevelStackSize =  8*K;

#ifdef LUAW_USE_POOLS
static unsigned pools[] = {
	/* block size, number of blocks */
	0 };
#endif

static const luaW_initSetup setup =
	{ .gc_limit        = 700*K
	, .dlmalloc_total  = 800*K
	, .dlmalloc_buffer = NULL
#	ifdef LUAW_USE_POOLS
	, .pool_total      = 0
	, .pool_buffer     = NULL
	, .pool_config     = pools
#	endif
	};

void DelayedMain(u8 id, void *Ctx) {

	TRACE((1, "Delayed"));
	wip_debug( "[APP] start the VM\r\n");
	luaW_start( & setup);

#	ifndef VERBOSE
	luaW_setLogLevel( "WARNING");
#	endif

	wip_debug( "[APP] preload the application & libraries\r\n");
	luapreload_HelloWorld(L);

	wip_debug( "[APP] run\r\n");
	luaW_run( "require 'HelloWorld.main'");
}


void adl_main( adl_InitType_e InitType) {
	s8 r;

/* initialize the internet & TCP/IP plug-In */
	r = wip_netInitOpts(
#		ifdef VERBOSE
		WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_USB, // low level traces
#		endif
		WIP_NET_OPT_END);
	adl_tmrSubscribe(FALSE, 100,  ADL_TMR_TYPE_100MS, DelayedMain);
}

void _exit(int i) {
}

char _fini(char i) {
	return(0);
}

char _fstat(char i) {
	return(0);
}

char _getpid(char i) {
	return(0);
}

char _isatty(char i) {
	return(0);
}

char _kill(char i) {
	return(0);
}

Main.lua:

require 'strict'       -- Cause an error on undefined global variables
require 'flashvars'    -- save and reload Lua variables in flash objects
require 'at'           -- Send AT commands to the modem
require 'at.atpluslua' -- Execute Lua code through "AT+LUA=" AT commands
require 'ethernet'     -- Ethernet driver
require 'shell'        -- Shell over Telnet
require 'shell.telnet'
require 'varispeed'

function main()
	varispeed.boost()
	at.unsollicited '\r\n+OATLUA: "Open AT Hello World"\r\n'

	run(bearer.new, 'ETH', {ip_dhcp=true, device="fastrack"})
	shell.telnet.init {
		port        = 23,
		editmode    = 'edit',
		historysize = 20,
	}
end

main()

In Project Properties / C/C++ general / Includes add oatlua/itf, Ethernet/itf and Shell/itf paths.
In Symbols tab add LUA_PLUGIN_VERSION with value 400. OK.
In Project/src delete lua_init.c file.
In Project Properties / C/C++ Build / Settings / ARM EABI GCC Linker / Misc / Add other objects add all three built libraries in workspace: oatlua.lib, Ethernet.lib, Shell.lib

If linker complains about: no memory region specified for loadable section .init_array.00000, locate autogenerated file gcc.lkopt in [Target]_ARM_EABI_GCC_Debug subfolder and add trailing zeros to init.array entry. This can be annoying, so if anyone has a solution to this, please let us know.

The file luapreload_HelloWorld.c should include following code:

#	define PRELOADLIB( name) do { \
		extern int luapreload_##name( lua_State *L); \
		luapreload_##name( L); \
	} while( 0)
	PRELOADLIB( Ethernet);
	PRELOADLIB( Shell);
#	undef PRELOADLIB

If PRELOADLIB( Shell) is missing, tweak Shell.h file from previous post.

Clean and Build. Download dwl into device.
If device is Ethernet connected, yellow LED should turn on, AT+ETH command gives assigned IP address.
Connect with Telnet client and enjoy.

Now you are on your own.