折腾2天多,把elua开发环境搭起来了
本帖最后由 billtian 于 2014-11-20 22:52 编辑抛砖引玉,吸引更多朋友研究elua
操作系统:WIN7 64bit
开发板:ek-lm3s8962
安装编译器
从GNU官方下载地址:https://launchpad.net/gcc-arm-embedded/+download下载
我下载的最新版,文件名:gcc-arm-none-eabi-4_8-2014q3-20140805-win32.exe
安装没有什么问题,直接下一步,找编译器时费了一些周折,最初用的编译器不对,出现错误,这是后话
安装lua for win,编译elua文件时,编译选项使用到了lua语言,所以需要安装
从http://luaforwindows.luaforge.net/下载
安装git,从git代码库获得elua代码
安装完成后 运行Git Bash
输入命令git clone git://github.com/elua/elua.git
完成后可在c:/用户/billtian(用户名) 下看到elua 文件夹即为源代码
安装LM3烧写工具LM Flash Programmer
编译
把源代码拷贝到一个目录(不拷可能也行,但有个中文名字,怕出问题)
我的电脑中打开此文件夹,在空白处按shift 同时按鼠标右键 在此处打开命令窗口
输入命令 build_elua.lua board=ek-lm3s8962 toolchain=codesourcery prog
回车没有错误的话,文件夹可产生elua_lua_ek-lm3s8962.bin 此文件烧入板子
即可运行
打开超级终端 设置板子串口号 115200 N 8 1
复位板子可看到
eLua v0.9Copyright (C) 2007-2013 www.eluaproject.net
elua#
说明elua已经跑起来了
输入help 回车
Shell commands:
help - shell help
lua - start a Lua session
ls - lists files and directories
dir - lists files and directories
cat - list the contents of a file
type - list the contents of a file
recv - receive files via XMODEM
cp - copy files
ver - show version information
mkdir- create directories
wofmt- WOFS format
exit - exit the shell
For more information use 'help <command>'.
eLua#
下面就可以写代码了,打开任意编译工具编写hello.lua 文件内容为print("elua hello world.")
在终端敲recv 命令,点超级终端传送按钮,选择hello.lua文件,协议Xmodem
发送完成可看到代码已经跑起来了,终端窗口出现elua hello world.
恭喜,下面可以进行深入研究了
写点心得吧 不错,发点心得经验造福一下后来者吧 不错,发点心得经验造福一下后来者吧 贴段测试用代码,功能LED闪,在OLED屏上显示一行字符,SELECT按键,发送2路AD值到串口
local ledpin,keypin,i
local disp = lm3s.disp
ledpin = pio.PF_0
keypin = pio.PF_1
i = 0
pio.pin.setdir(pio.OUTPUT,ledpin)
pio.pin.setdir(pio.INPUT,keypin)
pio.pin.setpull( pio.PULLUP,keypin)
function cycle()
--pio.pin.setlow( ledpin )
pio.pin.setval(1,ledpin)
--i = i + 1
--print(i)
tmr.delay( 0, 500000 )
--pio.pin.sethigh( ledpin )
pio.pin.setval(0,ledpin)
tmr.delay( 0, 500000 )
adc.sample(0, 8)
sample = adc.getsample(0)
print(sample)
adc.sample(2, 8)
sample = adc.getsample(2)
print(sample)
i = pio.pin.getval(keypin)
print(i)
--disp.clear()
if i == 1 then
disp.print("key is not pressed.", 16, 64, 15 )
--disp.print("Lua Hello World.", 16, 40, 15 )
else
disp.print("key is pressed. ", 16, 64, 15 )
--disp.print("Lua Hello World.", 16, 40, 15 )
end
end
print("Lua Hello World.")
disp.init( 1000000 )
disp.clear()
adc.setclock(0,64,1)
adc.setsmoothing(0,8)
adc.setclock(2,64,1)
adc.setsmoothing(2,8)
disp.print("Lua Hello World.", 16, 40, 15 )
while 1 do
cycle()
end
ek-lm3s8962 正好有 多谢 楼主 有空试一下 资源占用情况怎么样?堆栈如何分配??
看了一下,elua需要有点耗资源。
ua硬件要求
l RAM >= 7.5Kb,建议16KB以上
l ROM >= 65kb,建议128kb以上
Lua在MDK下编译后的大小约60kb,最小运行内存约7.5kb。 我也想学lua! “虚度37春”不如改成“37岁仍在坚守嵌入式前线” {:lol:} lua RAM越大越好 luaeclipse 都是集成开发环境吧?二者有什么不同呢?? lushanlq 发表于 2014-11-25 20:37
luaeclipse 都是集成开发环境吧?二者有什么不同呢??
lua是一门解释型编程语言. 通常嵌入(配合)其它到宿主语言一块使用. 所以称之为胶水语言. 据说大量应用于游戏软件, 魔兽等(通常搜索lua, 会伴随这游戏, 游戏编程的字眼) 挺有特色的一种语言.
没有系统学习过, 对着手册解决过一个pc平台软件(C++写的)一直不太好解决的问题. 所以对它非常有好感. 感谢楼主!
这个东西折腾过一次,后来放弃了,关键感觉,现在用上来太占资源了啊;
现在一般自己搭建一个类似于LUA的系统,如:
/w led 1
/r led
/w beep 1
/r beep
这样简单的,也蛮好的;
找时间,验证一下楼主的的心得; 感谢分享,以前搭过一次环境,有人用ELUA开发过产品吗? 也在关注eLua 支持一下,NODEMCU开源项目也是LUA的,还支持WiFi呢。 不知道用在MCU上有啥子优势 LZ能否简要说明一下为什么要用elua吗? 我正在openwrt下折腾nginx+lua 我也想学习elua,楼主能不能普及知识。 liyang121316 发表于 2015-1-4 08:48
我也想学习elua,楼主能不能普及知识。
我也是初学,大家一起学习吧。 cwei 发表于 2015-1-4 08:23
不知道用在MCU上有啥子优势
可以参考下这个朋友的帖子,
http://www.amobbs.com/forum.php?mod=viewthread&tid=5165014&highlight=lua 收了,等周末去研究一下,TKS 这是干什么用的啊 话说lua的变量默认为全局变量略蛋疼啊. lua是解释型的吧? Kevin.U 发表于 2015-1-6 12:20
lua是解释型的吧?
类似Java,先由“编译”模块编译成字节码,近似为Lua的高级汇编,然后由VM“解释”运行。不是Basic那种老的纯解释方案。
在有系统的环境下,X86和ARM平台有JIT加速,执行速度比较快。 dr2001 发表于 2015-1-6 12:26
类似Java,先由“编译”模块编译成字节码,近似为Lua的高级汇编,然后由VM“解释”运行。不是Basic那种老 ...
非常感谢!
“编译”模块编译成字节码,这个“编译”模块是如何运作的?
我的意思是 我们是否有可能把 hello.lua文件先编译成 “hello.高级汇编” 的文件,然后下载到CPU里面去运行? 字节码各种不兼容,以前搞过,板子上老跑不起来。 hi,你好,按照http://www.amobbs.com/forum.php?mod=viewthread&tid=5605271&highlight=LUA的方法WIN7编译出现arm-none-eabi-gcc 不是内部或外部…………是什么问题? 国际领先的路由器采用LUA语言进行开发的! 本帖最后由 xuysh 于 2015-4-28 19:04 编辑
谢谢,已经可以在stm32上跑了
local ledpin,keypin,i
local disp = stm32.disp
ledpin = pio.PA_8
keypin = pio.PA_0
i = 0
pio.pin.setdir(pio.OUTPUT,ledpin)
pio.pin.setdir(pio.INPUT,keypin)
pio.pin.setpull( pio.PULLDOWN,keypin)
function cycle()
pio.pin.setval(1,ledpin)
tmr.delay( 0, 500000 )
pio.pin.setval(0,ledpin)
tmr.delay( 0, 500000 )
i = pio.pin.getval(keypin)
print(i)
if i == 1 then
print("key is pressed. ")
else
print("key is not pressed.")
end
end
print("Lua Hello World.")
while 1 do
cycle()
end 楼主,有没有用里面的mmcfs?spi flash做? xuysh 发表于 2015-4-30 08:30
楼主,有没有用里面的mmcfs?spi flash做?
终于把mmcfs文件做出来
eLua# ls
/rom
Total on /rom: 0 bytes
/mmc
AUTORUN.LUA 650 bytes
AUTORU~1.LUA 650 bytes
APP.LUA 650 bytes
Total on /mmc: 1950 bytes
eLua# {:handshake:}支持个,没接触过这个东东,学习了 收藏以备持续关注,谢谢分享~
页:
[1]