SlideShare uma empresa Scribd logo
1 de 75
Baixar para ler offline
COPYRIGHT 2016 – Fundação CERTI
eLua – Lua for
Microcontrollers
Vinicius Zein
Bruno Herrera
COPYRIGHT 2016 – Fundação CERTI
https://br.linkedin.com/in/viniciuszein	
Vinicius Tadeu Zein
	
www.linkedin.com/in/bherrera
Bruno Herrera
COPYRIGHT 2016 – Fundação CERTI
R&D Institute
Founded in 1984 with the mission to
develop technology solutions for products
and processes
500 employees
Private, but results are reinvested in R&D
MCTI and SUFRAMA accredited – projects
with “Lei de Informática”, “Lei do Bem” and
Embrapii
More than 500 clients around the world
The information in this presentation was compiled from sources believed to be
reliable for informational purposes only.
Content includes opinions, presentations, articles, hyperlinks or other third
party content (“Third Party Material”) that is not intended to, nor constitutes an
endorsement by CERTI of the author or the Third Party Materials. The content
and views within the Third Party Material are solely those of the third party and
do not reflect the opinions of CERTI.
The opinions expressed in this presentation and on the following slides are
solely those of the
presenter and not necessarily those of CERTI. CERTI does not guarantee the
accuracy or
reliability of the information provided herein.
.	Disclaimer
COPYRIGHT 2016 – Fundação CERTI
Ag
en
da
CAPÍTULO 1
Introdução
CAPÍTULO 2
Lógica de
negócios
CAPÍTULO 3
Embedded Lua
CAPÍTULO 4
DevKits e build
CAPÍTULO 5
eLua demo
CAPÍTULO 6
Wrap-up
COPYRIGHT 2016 – Fundação CERTI
INTRODUÇÃO
CAPÍTULO 1
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 1 | INTRODUÇÃO
O que é Lua?
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 1 | INTRODUÇÃO
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 1 | INTRODUÇÃO
Onde está Lua?
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 1 | INTRODUÇÃO
COPYRIGHT 2016 – Fundação CERTI
LÓGICA DE
NEGÓCIOS
CAPÍTULO 2
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
Business Logic with script > Motivação
Processo de
Desenvolvimento
e.g. em C
1.  Alterar código
2.  Compilar
3.  Deploy
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
Business Logic with script > Processo de
desenvolvimento
com script	
1.  Alterar código
2.  Compilar
3.  Deploy
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
Business Logic with script > Linguagens de script são
simples de se apreender
Menor complexidade
Precisa ser
integrável à
linguagem
compilada
(C, C++)
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
Business Logic with script Lua
Por que Lua?
COPYRIGHT 2016 – Fundação CERTI
Porque Lua
é leve x86	–	171K		
arm	–	160K	
arm	–	124K	
liblua.so
COPYRIGHT 2016 – Fundação CERTI
Porque Lua é leve
180K		
171K	
160K	
124K
COPYRIGHT 2016 – Fundação CERTI
Robusta &
estabelecida
COPYRIGHT 2016 – Fundação CERTI
Portátil &
livre
COPYRIGHT 2016 – Fundação CERTI
PODEROSA>permite orientação a objetos
>permite estender aplicações em outras
linguagens
>pode ser estendida por bibliotecas
escritas em outras linguagens
e também
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
Business Logic with script Lua
Exemplo 1:
User interface do Set-Top Box CERTI
COPYRIGHT 2016 – Fundação CERTI
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C
CAPÍTULO 2 | INTEGRAÇÃO LUA E C
	
Módulo	C	
	
Lua
Bind	
	
Módulo	C	
	
Bind	
	
Módulo	C	
	
Bind	
	
Módulo	C	
	
Bind
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C
CAPÍTULO 3 | EMBEDDED LUA
2 flavors:
>	Aplicação	C	inicializa	scripts	Lua	
>	Script	Lua	carrega	biblioteca	naNva	
É possível ter
a combinação
dos dois
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C
Aplicação C inicializa máquina Lua
> lua_State *lua_newstate (lua_Alloc f,
void *ud);
> void luaL_openlibs (lua_State *L);
> int luaL_dofile (lua_State *L, const
char *filename);
> int lua_pcall (lua_State *L, int nargs,
int nresults, int msgh);
> void lua_close (lua_State *L);
CAPÍTULO 2 | INTEGRAÇÃO LUA E C
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C > Inicialização da máquina Lua
CAPÍTULO 2 | INTEGRAÇÃO LUA E C
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C > Bind para ser usado em Lua
CAPÍTULO 2 | INTEGRAÇÃO LUA E C
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C > Bind para ser usado em Lua
CAPÍTULO 2 | INTEGRAÇÃO LUA E C
COPYRIGHT 2016 – Fundação CERTI
IntegraçãoLuaeC
COPYRIGHT 2016 – Fundação CERTI
IntegraçãoLuaeC
COPYRIGHT 2016 – Fundação CERTI
IntegraçãoLuaeC
COPYRIGHT 2016 – Fundação CERTI
Integração Lua e C > Biblioteca C ( ? ) em Lua
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | EXEMPLOS
Business Logic with script Lua
Exemplo 1:
Modificação do menu do STB Certi
COPYRIGHT 2016 – Fundação CERTI
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | EXEMPLOS
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
COPYRIGHT 2016 – Fundação CERTI
Business Logic with script Lua
Exemplo 2:
Modificação da interface do IP Phone
	
CAPÍTULO 2 | EXEMPLOS
COPYRIGHT 2016 – Fundação CERTI
COPYRIGHT 2016 – Fundação CERTI
Business Logic with script Lua
CAPÍTULO 2 | EXEMPLOS
COPYRIGHT 2016 – Fundação CERTI
Business Logic with script Lua
CAPÍTULO 2 | EXEMPLOS
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 2 | EXEMPLOS
Business Logic with script Lua
COPYRIGHT 2016 – Fundação CERTI
Embedded Lua
CAPÍTULO 3
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 3 | EMBEDDED LUA
“Microcontrollers are designed for
embedded applications, in contrast to
the microprocessors used in personal
computers or other general purpose
applications consisting of various
discrete chips.”
-Wikipedia
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 3 | EMBEDDED LUA
BSP(board support package) / HAL
(hardware abstraction layer) provided
by the “Chip” vendor
Hardware dependent code, not
portable
No operating system
Hard to port applications
Hard to update on the field
Do not forget: it is all about
registers!!
without
addition; basic
and simple
Bare Metal
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 3 | EMBEDDED LUA
eLua www.eluaproject.net
Embedded power, driven by Lua
Quickly prototype and develop embedded
software applications with the power of Lua and
run them on a wide range of microcontroller
architectures
MicroPython micropython.org
MicroPython is a lean and efficient
implementation of the Python 3 programming
language that includes a small subset of the
Python standard library and is optimised to run
on microcontrollers and in constrained
environments.
Netduino www.netduino.com
Netduino, an open-source electronics platform
using the .NET Micro Framework.
Cont: JavaME,
Not so bare
Bare Metal
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 3 | EMBEDDED LUA
e-Lua Embedded Lua
On a wide range of
microncontrollers
The power of Lua
Flexibility
Rapid prototyping
Reduced time-to-market
COPYRIGHT 2016 – Fundação CERTI
eLua is not an operational system
commercial software
nor GPL
reduced Lua
platform specific
CAPÍTULO 3 | EMBEDDED LUA
COPYRIGHT 2016 – Fundação CERTI
Lightweight,
but...
COPYRIGHT 2016 – Fundação CERTI
Porting eLua > prerequisites
Program memory
128kB (basic image)
256kB (full image)
RAM
minimum 32kB*
Recommended 64kB
* LTR (Lua Tiny RAM) – less than 32kB
CAPÍTULO 3 | EMBEDDED LUA
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 3 | EMBEDDED LUA
eLuaArchitecture
COPYRIGHT 2016 – Fundação CERTI
adc
elua
bit
i2c
can
net
cpu
pack
pd
spi
pio
term
pwm
tmr
rpc
uart
eLuaGenericmodules
CAPÍTULO 3 | EMBEDDED LUA
COPYRIGHT 2016 – Fundação CERTI
eLuaPlatformmodules
mbed.pio
lm3.disp
str9.pio
mizar32.lcd
Mizar32.rtc
CAPÍTULO 3 | EMBEDDED LUA
COPYRIGHT 2016 – Fundação CERTI
DevKits e Build
CAPÍTULO 4
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 4 | DEVKITS AND BUILD
eLuaSupportedtargets
COPYRIGHT 2016 – Fundação CERTI
src/platform/<name>
> type.h – specific data types
> conf.lua – build configuration file
> stacks.h – stack size definition
> platform.c – platform interface impl
> platform_conf.h – info about platform
and build config
> others: network config, start up,
linker, CPU support package
Porting eLua > structure
CAPÍTULO 4 | DEVKITS AND BUILD
COPYRIGHT 2016 – Fundação CERTI
>type.h–specificdatatypes
Porting eLua >
structure
COPYRIGHT 2016 – Fundação CERTI
>conf.lua–buildconfigurationfile
Porting eLua >
structure
COPYRIGHT 2016 – Fundação CERTI
Porting eLua >
structure
>stacks.h–stacksizedefinition
COPYRIGHT 2016 – Fundação CERTI
>platform.c–platforminterfaceimpl
COPYRIGHT 2016 – Fundação CERTI
>stm32f4xx_conf.h–infoabout
platformandbuildconfig
COPYRIGHT 2016 – Fundação CERTI
Porting eLua > new CPU
CAPÍTULO 3 | EMBEDDED LUA
1.  edit build_data.lua
2.  add a new board to eLua
3.  customize the list of source file and/or
compilation flags
COPYRIGHT 2016 – Fundação CERTI
Porting eLua > new board
CAPÍTULO 3 | EMBEDDED LUA
1.  Name your board - stm32f429disco
2.  Write a configuration file
3.  Change the file list according to the board name
> cp boards/known/stm32-port407z.lua boards/
known/stm32f429disco.lua
> edit stm32f429disco.lua to set up UART and RX/
TX pins
COPYRIGHT 2016 – Fundação CERTI
eLua demo
CAPÍTULO 6
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 6 | eLUA DEMO
Target
Action
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 6 | eLUA DEMO
Tools
Toolchain
https://launchpad.net/gcc-arm-
embedded/4.9/4.9-2014-q4-major
sudo add-apt-repository ppa:terry.guo/gcc-
arm-embedded
sudo apt-get update
sudo apt-get install gcc-arm-none-eabi
Open OCD
git clone git://git.code.sf.net/p/openocd/
code openocd
cd openocd
git submodule init && git submodule update
&& ./bootstrap && ./configure --enable-
stlink && make && sudo make install
Action
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 6 | eLUA DEMO
GPIO
The famous hello world “led blink” at
user space
pio.pin.setdir(pio.OUTPUT, pio.PG_14)
pio.pin.sethigh(pio.PG_14)
pio.pin.setlow(pio.PG_14)
Action
COPYRIGHT 2016 – Fundação CERTI
Wrap-up
CAPÍTULO 6
COPYRIGHT 2016 – Fundação CERTI
CAPÍTULO 6 | WRAP-UP
Take away
Use a script language for
app development
Lua is lightweight,
portable and easy to use
eLua runs in
microcontrollers
CAPÍTULO 6 | WRAP-UP
COPYRIGHT 2016 – Fundação CERTI
?
COPYRIGHT 2016 – Fundação CERTI
Obrigado!
https://br.linkedin.com/in/viniciuszein	
https://www.linkedin.com/in/bherrera
COPYRIGHT 2016 – Fundação CERTI
Links úteis
www.lua.org		
site principal para todas as coisas Lua
www.eluaproject.net	
site do projeto eLua
COPYRIGHT 2016 – Fundação CERTI
Referências
Slide 6 h)p://www.lua.org/	
Slide 33, 35 e 36 h)p://www.eluaproject.net

Mais conteúdo relacionado

Semelhante a eLua - Lua for Microcontrollers

DevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIs
DevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIsDevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIs
DevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIsJúnior Porfirio
 
LAB 03 - Programação Estruturada 2
LAB 03 - Programação Estruturada 2LAB 03 - Programação Estruturada 2
LAB 03 - Programação Estruturada 2thomasdacosta
 
Utilizando Sistemas Multi-agentes para a Programação de Plataformas Robóticas
Utilizando Sistemas Multi-agentes para a Programação de Plataformas RobóticasUtilizando Sistemas Multi-agentes para a Programação de Plataformas Robóticas
Utilizando Sistemas Multi-agentes para a Programação de Plataformas RobóticasCarlos Eduardo Pantoja
 
Análise de Ameaças Cibernéticas em Protocolos Industriais
Análise de Ameaças Cibernéticas em Protocolos Industriais Análise de Ameaças Cibernéticas em Protocolos Industriais
Análise de Ameaças Cibernéticas em Protocolos Industriais Alexandre Freire
 
TDCSP2019 - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...
TDCSP2019  - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...TDCSP2019  - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...
TDCSP2019 - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...Fulvio Mascara
 
Compondo uma plataforma de software
Compondo uma plataforma de softwareCompondo uma plataforma de software
Compondo uma plataforma de softwareIsaac de Souza
 
1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental
1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental
1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade AmbientalGustavo Aquino
 
Software livre - Parte 3
Software livre - Parte 3Software livre - Parte 3
Software livre - Parte 3Fabrício Basto
 
Minicurso IOT com javascript - SBTI
Minicurso IOT com javascript - SBTIMinicurso IOT com javascript - SBTI
Minicurso IOT com javascript - SBTImarcochella
 
Testes em uma arquitetura com messageria/streaming (Kafka)
Testes em uma arquitetura com messageria/streaming (Kafka)Testes em uma arquitetura com messageria/streaming (Kafka)
Testes em uma arquitetura com messageria/streaming (Kafka)Robson Agapito Correa
 
Mini curso - Ionic Framework
Mini curso - Ionic FrameworkMini curso - Ionic Framework
Mini curso - Ionic Frameworkjuniorschroder
 
Javascript State of the Union 2015
Javascript State of the Union 2015Javascript State of the Union 2015
Javascript State of the Union 2015Huge
 

Semelhante a eLua - Lua for Microcontrollers (20)

DevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIs
DevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIsDevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIs
DevPira Festival 21 - .NET6 Uma nova forma de construir apis MinimalAPIs
 
LAB 03 - Programação Estruturada 2
LAB 03 - Programação Estruturada 2LAB 03 - Programação Estruturada 2
LAB 03 - Programação Estruturada 2
 
Transforme suas APIs em Negócio
Transforme suas APIs em NegócioTransforme suas APIs em Negócio
Transforme suas APIs em Negócio
 
Remobile
RemobileRemobile
Remobile
 
Do código ao Sucesso com Source-To-Image
Do código ao Sucesso com Source-To-ImageDo código ao Sucesso com Source-To-Image
Do código ao Sucesso com Source-To-Image
 
Utilizando Sistemas Multi-agentes para a Programação de Plataformas Robóticas
Utilizando Sistemas Multi-agentes para a Programação de Plataformas RobóticasUtilizando Sistemas Multi-agentes para a Programação de Plataformas Robóticas
Utilizando Sistemas Multi-agentes para a Programação de Plataformas Robóticas
 
Apresentação QtConBr
Apresentação QtConBrApresentação QtConBr
Apresentação QtConBr
 
c++-esc-brazil-presentation_v1.0
c++-esc-brazil-presentation_v1.0c++-esc-brazil-presentation_v1.0
c++-esc-brazil-presentation_v1.0
 
Análise de Ameaças Cibernéticas em Protocolos Industriais
Análise de Ameaças Cibernéticas em Protocolos Industriais Análise de Ameaças Cibernéticas em Protocolos Industriais
Análise de Ameaças Cibernéticas em Protocolos Industriais
 
Raspberry Pi: o hardware para Python
Raspberry Pi: o hardware para PythonRaspberry Pi: o hardware para Python
Raspberry Pi: o hardware para Python
 
Introdução Ao Desenvolvimento Para Iphone
Introdução Ao Desenvolvimento Para IphoneIntrodução Ao Desenvolvimento Para Iphone
Introdução Ao Desenvolvimento Para Iphone
 
TDCSP2019 - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...
TDCSP2019  - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...TDCSP2019  - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...
TDCSP2019 - Trilha: Machine Learning - Uso de PyTorch para aplicações de Vis...
 
Apresentacao
ApresentacaoApresentacao
Apresentacao
 
Compondo uma plataforma de software
Compondo uma plataforma de softwareCompondo uma plataforma de software
Compondo uma plataforma de software
 
1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental
1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental
1° BootCamp - Workshop Internet Das Coisas Para Sustentabilidade Ambiental
 
Software livre - Parte 3
Software livre - Parte 3Software livre - Parte 3
Software livre - Parte 3
 
Minicurso IOT com javascript - SBTI
Minicurso IOT com javascript - SBTIMinicurso IOT com javascript - SBTI
Minicurso IOT com javascript - SBTI
 
Testes em uma arquitetura com messageria/streaming (Kafka)
Testes em uma arquitetura com messageria/streaming (Kafka)Testes em uma arquitetura com messageria/streaming (Kafka)
Testes em uma arquitetura com messageria/streaming (Kafka)
 
Mini curso - Ionic Framework
Mini curso - Ionic FrameworkMini curso - Ionic Framework
Mini curso - Ionic Framework
 
Javascript State of the Union 2015
Javascript State of the Union 2015Javascript State of the Union 2015
Javascript State of the Union 2015
 

eLua - Lua for Microcontrollers

  • 1. COPYRIGHT 2016 – Fundação CERTI eLua – Lua for Microcontrollers Vinicius Zein Bruno Herrera
  • 2. COPYRIGHT 2016 – Fundação CERTI https://br.linkedin.com/in/viniciuszein Vinicius Tadeu Zein www.linkedin.com/in/bherrera Bruno Herrera
  • 3. COPYRIGHT 2016 – Fundação CERTI R&D Institute Founded in 1984 with the mission to develop technology solutions for products and processes 500 employees Private, but results are reinvested in R&D MCTI and SUFRAMA accredited – projects with “Lei de Informática”, “Lei do Bem” and Embrapii More than 500 clients around the world
  • 4. The information in this presentation was compiled from sources believed to be reliable for informational purposes only. Content includes opinions, presentations, articles, hyperlinks or other third party content (“Third Party Material”) that is not intended to, nor constitutes an endorsement by CERTI of the author or the Third Party Materials. The content and views within the Third Party Material are solely those of the third party and do not reflect the opinions of CERTI. The opinions expressed in this presentation and on the following slides are solely those of the presenter and not necessarily those of CERTI. CERTI does not guarantee the accuracy or reliability of the information provided herein. . Disclaimer
  • 5. COPYRIGHT 2016 – Fundação CERTI Ag en da CAPÍTULO 1 Introdução CAPÍTULO 2 Lógica de negócios CAPÍTULO 3 Embedded Lua CAPÍTULO 4 DevKits e build CAPÍTULO 5 eLua demo CAPÍTULO 6 Wrap-up
  • 6. COPYRIGHT 2016 – Fundação CERTI INTRODUÇÃO CAPÍTULO 1
  • 7. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 1 | INTRODUÇÃO O que é Lua?
  • 8. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 1 | INTRODUÇÃO
  • 9. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 1 | INTRODUÇÃO Onde está Lua?
  • 10. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 1 | INTRODUÇÃO
  • 11. COPYRIGHT 2016 – Fundação CERTI LÓGICA DE NEGÓCIOS CAPÍTULO 2
  • 12. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS Business Logic with script > Motivação Processo de Desenvolvimento e.g. em C 1.  Alterar código 2.  Compilar 3.  Deploy
  • 13. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS Business Logic with script > Processo de desenvolvimento com script 1.  Alterar código 2.  Compilar 3.  Deploy
  • 14. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS Business Logic with script > Linguagens de script são simples de se apreender Menor complexidade Precisa ser integrável à linguagem compilada (C, C++)
  • 15. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS Business Logic with script Lua Por que Lua?
  • 16. COPYRIGHT 2016 – Fundação CERTI Porque Lua é leve x86 – 171K arm – 160K arm – 124K liblua.so
  • 17. COPYRIGHT 2016 – Fundação CERTI Porque Lua é leve 180K 171K 160K 124K
  • 18. COPYRIGHT 2016 – Fundação CERTI Robusta & estabelecida
  • 19. COPYRIGHT 2016 – Fundação CERTI Portátil & livre
  • 20. COPYRIGHT 2016 – Fundação CERTI PODEROSA>permite orientação a objetos >permite estender aplicações em outras linguagens >pode ser estendida por bibliotecas escritas em outras linguagens e também
  • 21. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS Business Logic with script Lua Exemplo 1: User interface do Set-Top Box CERTI
  • 22. COPYRIGHT 2016 – Fundação CERTI
  • 23. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C CAPÍTULO 2 | INTEGRAÇÃO LUA E C Módulo C Lua Bind Módulo C Bind Módulo C Bind Módulo C Bind
  • 24. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C CAPÍTULO 3 | EMBEDDED LUA 2 flavors: > Aplicação C inicializa scripts Lua > Script Lua carrega biblioteca naNva É possível ter a combinação dos dois
  • 25. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C Aplicação C inicializa máquina Lua > lua_State *lua_newstate (lua_Alloc f, void *ud); > void luaL_openlibs (lua_State *L); > int luaL_dofile (lua_State *L, const char *filename); > int lua_pcall (lua_State *L, int nargs, int nresults, int msgh); > void lua_close (lua_State *L); CAPÍTULO 2 | INTEGRAÇÃO LUA E C
  • 26. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C > Inicialização da máquina Lua CAPÍTULO 2 | INTEGRAÇÃO LUA E C
  • 27. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C > Bind para ser usado em Lua CAPÍTULO 2 | INTEGRAÇÃO LUA E C
  • 28. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C > Bind para ser usado em Lua CAPÍTULO 2 | INTEGRAÇÃO LUA E C
  • 29. COPYRIGHT 2016 – Fundação CERTI IntegraçãoLuaeC
  • 30. COPYRIGHT 2016 – Fundação CERTI IntegraçãoLuaeC
  • 31. COPYRIGHT 2016 – Fundação CERTI IntegraçãoLuaeC
  • 32. COPYRIGHT 2016 – Fundação CERTI Integração Lua e C > Biblioteca C ( ? ) em Lua
  • 33. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | EXEMPLOS Business Logic with script Lua Exemplo 1: Modificação do menu do STB Certi
  • 34. COPYRIGHT 2016 – Fundação CERTI
  • 35. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | EXEMPLOS
  • 36. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
  • 37. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
  • 38. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | LÓGICA DE NEGÓCIOS
  • 39. COPYRIGHT 2016 – Fundação CERTI Business Logic with script Lua Exemplo 2: Modificação da interface do IP Phone CAPÍTULO 2 | EXEMPLOS
  • 40. COPYRIGHT 2016 – Fundação CERTI
  • 41. COPYRIGHT 2016 – Fundação CERTI Business Logic with script Lua CAPÍTULO 2 | EXEMPLOS
  • 42. COPYRIGHT 2016 – Fundação CERTI Business Logic with script Lua CAPÍTULO 2 | EXEMPLOS
  • 43. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 2 | EXEMPLOS Business Logic with script Lua
  • 44. COPYRIGHT 2016 – Fundação CERTI Embedded Lua CAPÍTULO 3
  • 45. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 3 | EMBEDDED LUA “Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications consisting of various discrete chips.” -Wikipedia
  • 46. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 3 | EMBEDDED LUA BSP(board support package) / HAL (hardware abstraction layer) provided by the “Chip” vendor Hardware dependent code, not portable No operating system Hard to port applications Hard to update on the field Do not forget: it is all about registers!! without addition; basic and simple Bare Metal
  • 47. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 3 | EMBEDDED LUA eLua www.eluaproject.net Embedded power, driven by Lua Quickly prototype and develop embedded software applications with the power of Lua and run them on a wide range of microcontroller architectures MicroPython micropython.org MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments. Netduino www.netduino.com Netduino, an open-source electronics platform using the .NET Micro Framework. Cont: JavaME, Not so bare Bare Metal
  • 48. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 3 | EMBEDDED LUA e-Lua Embedded Lua On a wide range of microncontrollers The power of Lua Flexibility Rapid prototyping Reduced time-to-market
  • 49. COPYRIGHT 2016 – Fundação CERTI eLua is not an operational system commercial software nor GPL reduced Lua platform specific CAPÍTULO 3 | EMBEDDED LUA
  • 50. COPYRIGHT 2016 – Fundação CERTI Lightweight, but...
  • 51. COPYRIGHT 2016 – Fundação CERTI Porting eLua > prerequisites Program memory 128kB (basic image) 256kB (full image) RAM minimum 32kB* Recommended 64kB * LTR (Lua Tiny RAM) – less than 32kB CAPÍTULO 3 | EMBEDDED LUA
  • 52. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 3 | EMBEDDED LUA eLuaArchitecture
  • 53. COPYRIGHT 2016 – Fundação CERTI adc elua bit i2c can net cpu pack pd spi pio term pwm tmr rpc uart eLuaGenericmodules CAPÍTULO 3 | EMBEDDED LUA
  • 54. COPYRIGHT 2016 – Fundação CERTI eLuaPlatformmodules mbed.pio lm3.disp str9.pio mizar32.lcd Mizar32.rtc CAPÍTULO 3 | EMBEDDED LUA
  • 55. COPYRIGHT 2016 – Fundação CERTI DevKits e Build CAPÍTULO 4
  • 56. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 4 | DEVKITS AND BUILD eLuaSupportedtargets
  • 57. COPYRIGHT 2016 – Fundação CERTI src/platform/<name> > type.h – specific data types > conf.lua – build configuration file > stacks.h – stack size definition > platform.c – platform interface impl > platform_conf.h – info about platform and build config > others: network config, start up, linker, CPU support package Porting eLua > structure CAPÍTULO 4 | DEVKITS AND BUILD
  • 58. COPYRIGHT 2016 – Fundação CERTI >type.h–specificdatatypes Porting eLua > structure
  • 59. COPYRIGHT 2016 – Fundação CERTI >conf.lua–buildconfigurationfile Porting eLua > structure
  • 60. COPYRIGHT 2016 – Fundação CERTI Porting eLua > structure >stacks.h–stacksizedefinition
  • 61. COPYRIGHT 2016 – Fundação CERTI >platform.c–platforminterfaceimpl
  • 62. COPYRIGHT 2016 – Fundação CERTI >stm32f4xx_conf.h–infoabout platformandbuildconfig
  • 63. COPYRIGHT 2016 – Fundação CERTI Porting eLua > new CPU CAPÍTULO 3 | EMBEDDED LUA 1.  edit build_data.lua 2.  add a new board to eLua 3.  customize the list of source file and/or compilation flags
  • 64. COPYRIGHT 2016 – Fundação CERTI Porting eLua > new board CAPÍTULO 3 | EMBEDDED LUA 1.  Name your board - stm32f429disco 2.  Write a configuration file 3.  Change the file list according to the board name > cp boards/known/stm32-port407z.lua boards/ known/stm32f429disco.lua > edit stm32f429disco.lua to set up UART and RX/ TX pins
  • 65. COPYRIGHT 2016 – Fundação CERTI eLua demo CAPÍTULO 6
  • 66. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 6 | eLUA DEMO Target Action
  • 67. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 6 | eLUA DEMO Tools Toolchain https://launchpad.net/gcc-arm- embedded/4.9/4.9-2014-q4-major sudo add-apt-repository ppa:terry.guo/gcc- arm-embedded sudo apt-get update sudo apt-get install gcc-arm-none-eabi Open OCD git clone git://git.code.sf.net/p/openocd/ code openocd cd openocd git submodule init && git submodule update && ./bootstrap && ./configure --enable- stlink && make && sudo make install Action
  • 68. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 6 | eLUA DEMO GPIO The famous hello world “led blink” at user space pio.pin.setdir(pio.OUTPUT, pio.PG_14) pio.pin.sethigh(pio.PG_14) pio.pin.setlow(pio.PG_14) Action
  • 69. COPYRIGHT 2016 – Fundação CERTI Wrap-up CAPÍTULO 6
  • 70. COPYRIGHT 2016 – Fundação CERTI CAPÍTULO 6 | WRAP-UP
  • 71. Take away Use a script language for app development Lua is lightweight, portable and easy to use eLua runs in microcontrollers CAPÍTULO 6 | WRAP-UP
  • 72. COPYRIGHT 2016 – Fundação CERTI ?
  • 73. COPYRIGHT 2016 – Fundação CERTI Obrigado! https://br.linkedin.com/in/viniciuszein https://www.linkedin.com/in/bherrera
  • 74. COPYRIGHT 2016 – Fundação CERTI Links úteis www.lua.org site principal para todas as coisas Lua www.eluaproject.net site do projeto eLua
  • 75. COPYRIGHT 2016 – Fundação CERTI Referências Slide 6 h)p://www.lua.org/ Slide 33, 35 e 36 h)p://www.eluaproject.net