[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua on Microcontrollers
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Tue, 10 Dec 2013 14:02:34 +0000
Hi,
2013/12/10 John Hind <john.hind@zen.co.uk>:
> This is interesting:
>
> http://micropython.org/
>
> If only it was Lua! I know there has been some work on this sort of thing (i.e. http://www.eluaproject.net/) but nothing as elegant as this hardware implementation of Python. Just plug it into any USB host computer and edit the scripts as if on a flash drive, whilst a virtual com port gives you a console channel over the same USB.
>
> The main issue for these single chip systems is RAM - typically at the highest end you are working with 100-200KiB of RAM and 1-2MiB of Flash. This is plenty for a basic "bare metal" Lua implementation running a test script, but not enough RAM to do really serious work. Problem is there is a huge complexity step between the top end of on-chip RAM and boards with separate RAM chips such as the Raspberry Pi and Beaglebone Black - the RAM interface requires a lot of chip pins reducing the IO availability, and much more complex PCB routing. In practice a large RAM approach only becomes cost effective with very big production runs.
I've been thinking about creating an electronics dev board based on
Lua for quite some years, but as you say there is a large gap between
higher end microcontrollers, and low end system-on-chip-s, and stock
Lua (or Python for that matter) requirements fall just in that gap.
In one direction, going to the next higher device increase complexity
a lot, since SoCs are so complex it's hard to create firmwares without
reusing existing operating systems like Linux (if nothing else because
required drivers need to be so complex). And running Lua on top of a
Linux quickly reduce the low level capability of such an embedded
system.
In the other direction, reducing the language requirements, is what
Micro Python or eLua are trying to do. But not only does that require
extensive work on the interpreter, it can severly constraint the
programs running in it.
Recently, triggered in large part by the recent Micro Python
announcement, I've had a more in-depth look at solutions bridging the
gap I mention above. Basically I've been looking at an elegant way to
design an elegant board using a microcontroller (typically a Cortex-M,
probably a M4F to allow Lua to use floats) and large RAM.
The main problem is that micro-controllers most often only support
SRAM to simplify the memory controller, and SRAM has relatively poor
density compared to SDRAM used by SoCs. A typical SDRAM chip can get
to 32Mbytes [1] (some at $2), while an SRAM one of the same size and
price range usually tops at 1 or 2Mbytes [2].
However I just found out that there are some micro controllers based
on a Cortex-M4 of M4F that have an SDRAM controller. Two examples I
found are the STM32F427xx series from ST [3], and the Tiva TM4C129x
series from TI [4]. For example a 128 pins Tiva would only use 30 or
so to access the RAM, leaving plenty of I/O pins for various purposes.
I think they could be good candidates for a small dev board that you
can program in Lua, along with a large SDRAM chip, a micro-SD card
reader and a micro-USB connector.
And if 1 or 2 megabytes is enough, there are plenty of alternatives
(most Cortex-M-based MCUs have variants with an external SRAM
controller).
> I realise that Lua was not designed with precisely these priorities, but neither was Python. I'm interested in views of the feasibility of adapting Lua in the same direction that Damian has adapted Python.
I hope you don't mind related views going in another direction :D
Jérôme.
[1] http://www.digikey.co.uk/product-search/en?pv142=1052&FV=fff40027%2Cfff80434%2C2380053%2C2380057%2C238007c%2C2380083%2C2380084%2C2380085%2C2380087%2C2380088%2C2380089%2C23800e0%2C2380106%2C2380116%2C2380119%2C238011c%2C238011e%2C238012d%2C2380131%2C2380132%2C2380137%2C2380162%2C238016c%2C238016d%2C238016f%2C2380182%2C2380183%2C2380234%2C2380235%2C238023d%2C238023e%2C23802ac%2C2380365%2C2380371%2C2380374%2C238037c%2C2380418%2C238041c%2C2380422%2C2380433%2C2380434%2C2380435%2C2540016%2C26801f7%2C142c00a9&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25
[2] http://www.digikey.co.uk/product-search/en?FV=fff40027%2Cfff80434%2C4002ea%2C401215%2C40353a%2C4037cd%2C2380053%2C2380057%2C238007c%2C2380083%2C2380084%2C2380085%2C2380087%2C2380088%2C2380089%2C23800e0%2C2380106%2C2380116%2C2380119%2C238011c%2C238011e%2C238012d%2C2380131%2C2380132%2C2380137%2C2380162%2C238016c%2C238016d%2C238016f%2C2380182%2C2380183%2C2380234%2C2380235%2C238023d%2C238023e%2C23802ac%2C2380365%2C2380371%2C2380374%2C238037c%2C2380418%2C238041c%2C2380422%2C2380433%2C2380434%2C2380435%2C2540008%2C2540033%2C26801f7&mnonly=0&newproducts=0&ColumnSort=1000011&page=1&stock=1&pbfree=0&rohs=0&quantity=&ptm=0&fid=0&pageSize=25
[3] http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1577/LN1789?icmp=stm32f4pr_pron_p3436s_sep2013
[4] http://www.ti.com/lsds/ti/microcontroller/tiva_arm_cortex/c_series/tm4c129x_series/overview.page?paramCriteria=no