Finally a PIC32 with FPU for embedded Lua on MIPS

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

Finally a PIC32 with FPU for embedded Lua on MIPS

John Hind

@KHMan – Why do you regard this PIC32/MIPS chip a breakthrough? ARM microcontrollers with FPU and on-chip memory matching or exceeding these specs have been available for several years now. Loading eLua on a blank chip or a standard prototyping board usually involves setting up a C cross-compiler tool chain and purchasing an ICE – once you’ve done that you may as well program in C! The kickstarters provide simple, low cost, ready to go system that you can immediately start programming in the scripting language. There is a big step from a single chip to a two-chip board (although the latter can be amazingly low cost if the volume is sufficient). This is because a RAM interface needs a lot of pins which generally requires a BGA package which in turn requires a multi-layer PCB.

 

@Bogdan Marinescu – JavaScript was originally (and still is of course) a browser embedded language designed from the start to be event-driven (if indeed it was ever consciously designed!). Node.JS is a much more recent development that leverages this legacy as an event-driven server language. Of course, other languages can be used in the same way, but it will be more of a force-fit since they were not originally designed to be event-driven. However Lua’s coroutines suggest a further evolution of the event-driven model. Rather than running functions in response to events, we could resume coroutines on events. This would avoid some of the problems with maintaining context in Node.JS. For example you could have a coroutine to respond to an input stream which could execute “yield until more data arrives” and the buffering could all be implemented in local variables. Similarly, “yield for x milliseconds” would be a useful construct to have available in a real-time system.

 


smime.p7s (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

KHMan
On 1/11/2015 10:18 PM, John Hind wrote:
> @KHMan – Why do you regard this PIC32/MIPS chip a breakthrough?
> [snip]

*sigh* Of course I know the market is crawling with ARM parts...

I quote myself, first sentence of the OP:
   "specifically on the topic of Lua on a MIPS chip"

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia


Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

BogdanM
In reply to this post by John Hind

[snip]

@Bogdan Marinescu – JavaScript was originally (and still is of course) a browser embedded language designed from the start to be event-driven (if indeed it was ever consciously designed!). Node.JS is a much more recent development that leverages this legacy as an event-driven server language. Of course, other languages can be used in the same way, but it will be more of a force-fit since they were not originally designed to be event-driven. However Lua’s coroutines suggest a further evolution of the event-driven model. Rather than running functions in response to events, we could resume coroutines on events. This would avoid some of the problems with maintaining context in Node.JS. For example you could have a coroutine to respond to an input stream which could execute “yield until more data arrives” and the buffering could all be implemented in local variables. Similarly, “yield for x milliseconds” would be a useful construct to have available in a real-time system.


Based on my (admitedly limited) experience with asynchronous event-based systems, the main things that help a lot when using such a system is closure support in your language. Both JavaScript and Lua can handle that very well (https://luvit.io/ is a good example of that). I really hope I'll have time to experiment with that concept on bare metal in the future. Coroutines in the context of event-based systems are definitely worth a second look :)

Best,
Bogdan

Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

Roberto Ierusalimschy
In reply to this post by John Hind
> @Bogdan Marinescu - JavaScript was originally (and still is of course) a
> browser embedded language designed from the start to be event-driven (if
> indeed it was ever consciously designed!).

Lua is an *embeddable* language designed from the start to be used
embedded in other applications (that is, all actions start in the
host). To me, this sounds remarcably similar to event-driven.

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

John Hind
In reply to this post by John Hind

> @Bogdan Marinescu - JavaScript was originally (and still is of course)
> a browser embedded language designed from the start to be event-driven
> (if indeed it was ever consciously designed!).

Lua is an *embeddable* language designed from the start to be used embedded
in other applications (that is, all actions start in the host). To me, this
sounds remarcably similar to event-driven.

-- Roberto

[John Hind] You are right of course - when Lua is used as an embedded
language in games it is generally event-driven analogous to JavaScript in a
browser. My point was about the design of runtime environments for Lua not
the language itself. My view is that when a scripting language is put on a
microcontroller it should be implemented within an event-driven framework
(were the events are essentially the hardware interrupts).  The tendency has
been to implement a simple command line environment based on lua.exe with
libraries to access the hardware essentially forcing the programmer to write
a non-terminating polling loop in Lua. It sounds like Bogdan is already
thinking along these lines.


smime.p7s (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

BogdanM


On Mon, Jan 12, 2015 at 8:26 PM, John Hind <[hidden email]> wrote:

> @Bogdan Marinescu - JavaScript was originally (and still is of course)
> a browser embedded language designed from the start to be event-driven
> (if indeed it was ever consciously designed!).

Lua is an *embeddable* language designed from the start to be used embedded
in other applications (that is, all actions start in the host). To me, this
sounds remarcably similar to event-driven.

-- Roberto

[John Hind] You are right of course - when Lua is used as an embedded
language in games it is generally event-driven analogous to JavaScript in a
browser. My point was about the design of runtime environments for Lua not
the language itself. My view is that when a scripting language is put on a
microcontroller it should be implemented within an event-driven framework
(were the events are essentially the hardware interrupts).  The tendency has
been to implement a simple command line environment based on lua.exe with
libraries to access the hardware essentially forcing the programmer to write
a non-terminating polling loop in Lua. It sounds like Bogdan is already
thinking along these lines.

Bogdan is already thinking along those lines, yes :) When I get some time, I'll definitely play a bit with event loops and Lua on bare metal. Maybe something built around a stripped down version of libuv, or even something simpler than that. Goodbye, weird and yet heroic attempts of implementing interrupt handlers directly in Lua, and hello sleep modes and low power! When I get some time ...

Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

Jorge Visca
In reply to this post by John Hind
On 12/01/15 18:26, John Hind wrote:
> The tendency has been to implement a simple command line environment
> based on lua.exe with libraries to access the hardware essentially
> forcing the programmer to write a non-terminating polling loop in Lua.

Well, a microcontroller is perhaps the only platform where a polling
loop would be at home. If you *need* a polling loop, then use a
microcontroller. If on top of a polling loop you have interesting logic,
add a SBC for said logic, and make it event-driven with events generated
from the microcotroller (say, trough a serial line).

Said this, the urge to cram everything on a microcotroller is strong[1]

Jorge

[1]
http://elua-development.2368040.n2.nabble.com/Pure-Lua-multitasking-with-eLua-td7578258.html

Reply | Threaded
Open this post in threaded view
|

Re: Finally a PIC32 with FPU for embedded Lua on MIPS

Jay Carlson
In reply to this post by Roberto Ierusalimschy
[Has Microchip finally decided how their toolchain vendors will be paid? avr-gcc ate the world because it didn't have a "buy me" button attached.]

On Jan 12, 2015, at 10:01 AM, Roberto Ierusalimschy <[hidden email]> wrote:

> Lua is an *embeddable* language designed from the start to be used
> embedded in other applications (that is, all actions start in the
> host).

I think that's an interesting characterization of language implementations. Perhaps a little more formally:

Lua is designed in a way that:

  o  The lifetime of the interpreter's state is not tied to having a live activation record on a C stack.

The mechanism for coroutine yield-across-C-calls is related.

--
Jay