Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/attila-lendvai/moonboots

Bootstraping/compiling Lua on embedded devices
https://github.com/attila-lendvai/moonboots

Last synced: about 1 month ago
JSON representation

Bootstraping/compiling Lua on embedded devices

Awesome Lists containing this project

README

        

# MoonBoots #

Compile and integrate the [Lua](http://www.lua.org/) language in various hardware/software environments, but focusing on embedded devices. Integration means a platform specific FFI and a layer abstracting away (some of) the differences between the supported environments.

License: BSD 3-clause.

## Status ##

2013-01-23 First publishing:

Lua works stable on the two supported platforms ([_vega5000_](#vega5000) and [_pc1000_](#pc1000)), and basic FFI works together with the beginnings of a platform abstraction layer.

The project was initially written as a proof of concept with internal use in mind, so as of now approachability is probably less than ideal.

Contribution is welcome.

### Noteworthy features ###

It's possible to connect the Lua runtime with Emacs either using the serial port or using TCP/IP (e.g. mobile internet). You can find the [Emacs side](https://github.com/attila-lendvai/moonboots/blob/master/emacs/bst-server.el) and the [Lua side](https://github.com/attila-lendvai/moonboots/blob/master/lua/bst-client.lua) in the repo.

Once the connection has been successfully established, it becomes possible to evaluate Lua expressions from inside your Emacs with a keyboard shortcut (i.e. you can **remotely redefine Lua functions on the fly** while your code is running on the PoS terminal). This greatly improves development speed compared to working in C.

### Partial list of possible improvements ###

Consider using [luabind](https://github.com/luabind/luabind).

## Implementation policies ##

Regarding the Lua FFI bindings:

* Every parameter is in its natural unit regardless of the API (e.g. time is always expected and returned in seconds)
* To keep the platform docs useful, functions and variables are never renamed (not even e.g. DelayMS, even though its Lua binding expects seconds). Redundant prefixes are removed though.
* Functions raise Lua errors, unless return codes are part of the normal usage (e.g. Wls_CheckNetLink returns the network link state)

## Build instructions ##

The makefiles expect the following directories:

* ../dependencies/squish (build-time Lua lib to concatenate many .lua files into one; hg clone http://code.matthewwild.co.uk/squish/)
* ../$(PLATFORM)/dependencies/lua-5.2.0 (Lua compiled with the platform compiler. The source distribution is available from [Lua.org](http://www.lua.org/download.html). Look for possible diff files in $(PLATFORM)/patches that helps the compilation.)
* ../$(PLATFORM)/api/include (C header files of the platform API)
* ../$(PLATFORM)/api/lib (binary link libraries of the platform)
* ../$(PLATFORM)/gcc/bin/ (a gcc from the platform toolchain, can be copied from the platform SDK, but take care of multiple incompatible cygwin.dll's lying around)

## Supported hardware platforms ##

### [Vega 5000](http://www.castech.com.tw/en/in-products-03.aspx?id=P_00000109&cid=C_00000018&pname=VEGA5000&cname=EFT-POS+Terminal) by [Castles Technology](http://www.castech.com.tw/) ###

A MIPS based POS terminal with 32MB flash and 32MB RAM running Linux.

#### SDK ####

Cygwin compiled gcc binary (v3.4.6).

#### Issues ####

* no support for floats on the C side (unless my memory fails me)

### [PC 1000](http://www.justtide.com/products_detail/&productId=897969ac-a238-4fc8-b2b6-163e506edf8c.html) by [Shenzhen Justtide Technology](http://www.justtide.com) ###

An ARM (ARM9 32-bit) based POS terminal with 8MB flash and 16MB RAM running a custom kernel.

#### SDK ####

Cygwin compiled gcc binary (v3.0.2).

#### Issues ####

* There's no malloc/free on this platform (the firmware binaries need to be raw bits compiled to a specific memory address). I had to write a custom _ldscript_ to layout a heap and compile in an external malloc.c.
* %f in printf doesn't work (C side issue)
* no support for floats on the C side (unless my memory fails me)

## Credits ##

The project was initially written by Attila Lendvai ([email protected]) and used in projects at [iSoft.kz](http://isoft.kz)

The project's name was suggested by Rob Hoelz (hoelzro). 'Lua' means 'moon' in Portuguese, and 'boot' comes from 'bootstrap'.