elua学习(三)--定制elua的编译选项

第二篇关于elua的文章讲了,elua的编译和烧写。不过编译选项比较简单,全按照默认的配置,在这篇文章中主要讲怎么定制编译选项。当然还是以stm32f4discovery平台为例子。

关于参考文献

这里首先提参考文献,是因为以下的内容出处比较混乱,提前说一下,省的读者混淆。

elua为开源项目,文档还算齐全,但是文档更新的比较混乱:存在多个版本,且有的地方代码和文档不一致。

例如:

http://www.eluaproject.net/doc/v0.9/en_index.html

http://www.eluaproject.net/doc/v0.8/en_index.html

在elua的安装目录下/Doc/En

我采取的原则是:离代码越近的文档可信度越高。所以首选/Doc/En,之后是v0.9的版本,之后才是0.8的版本。(编译elua时就因为文档更新不及时“codecourcery问题”,导致走了很多弯路)。

以下以elua/Doc/En/Building.txt为准

还可以参考:

自动编译器的变化

【Building.txt】

IMPORTANT:Starting with eLua 0.10, a new Lua-based build system replaces theprevious Python based (scons) build system. You‘ll need to use thenew build system to build eLua

现在(0.9)的自动编译工具不同于elua0.7版本scons(例如:sconscpu=at91sam7x256)

而是已经采用基于lua的自动编译器,请注意这里的文档有误导性:

http://www.eluaproject.net/doc/v0.9/en_building.html
(没有改过来)

http://www.eluaproject.net/doc/master/en_building.html
(新的)

定制eluaimage
大致分为两步(两者是有先后顺序的):

Configuringthe build image。(配置)

Invokethe build system (build_elua) with the right arguments。(编译选项)

[[configuring]]

参考elua/Doc/En/configurator.txt

Theconfigurator works by reading a Lua based board configuration fileand generating the corresponding C header file (which for the mostpart has the same role as the platform_conf.h file that was
usedbefore the configurator). The board name is given by the _board_argument to build_elua (see link:building.html#buildoptions[thislink] for more details about building your eLua image). Theconfigurator looks for a file named _<board>.lua_ in twolocations:

**boards/custom* is searched first. The files under this directory arenot part of the eLua source tree, so this is the place where you canadd configuration files for your custom board or customize
theconfiguration for one of the standard boards (seelink:#config_customize[here] for more details about this).

**boards/known* is searched if _<board>.lua_ is not found in_boards/custom_. It contains the configuration of the boards on whicheLua is known to run properly. The files under this directory arepart
of the eLua source tree.

Afterfinding _<board>.lua_ in one of these locations, theconfigurator runs and generates the corresponding header file in__boards/headers/board_<board>.h__. The files under_boards/headers_ are also
not part of the eLua source tree, so theycan be edited manually if needed (see link:#manualedit[here] for moredetails). After this, the configurator is done and the build processcontinues with the usual steps (compiling and linking the sourcefiles).

三个目录

均在elua/board/下

其中配置程序(configurator)首先搜索custom目录,需找<board>.lua文件,其中<board通过buildoptions中的[board=<board>]给出。开始时这个目录为空。

如果configurator在custom目录搜索不到配置信息后(如果找到了就不会访问known目录的文件了),转向known目录,同样搜索<board>.lua。如果buildoptions中的[board=<board>]填写正确,就可以找到对应的<board>.lua。例如:stm32f4discovery.lua稍后我们详细解释该文件

最后,生成board_stm32f4discovery.h文件,该文件类似于以前自动编译器的platform_conf.h。这个文件可以手动修改。稍后我们将解释该文件。

这里需要说明的是,尽量不要修改known目录下的文件,可以在custom目录进行变更。

详解known/stm32f4discovery.lua

-- STM32F4DISCOVERY build configuration

return {

cpu = ‘stm32f407vg‘,

components = {

sercon = { uart = "cdc",speed = 115200 },

romfs = true,

cdc = { buf_size = 128 },

advanced_shell = true,

term = { lines = 25, cols = 80},

linenoise = { shell_lines = 10,lua_lines = 50 },

stm32f4_enc = true,

rpc = { uart = 0, speed =115200 },

adc = { buf_size = 2 },

xmodem = true,

cints = true,

luaints = true

},

config = {

egc = { mode = "alloc"},

vtmr = { num = 4, freq = 10 },

ram = { internal_rams = 2 },

clocks = { external = 8000000,cpu = 168000000 }

},

modules = {

generic = { ‘all‘, "-i2c","-net" },

platform = ‘all‘,

},

}

首先看一下分为几部分:

[[config_cpu]]

The CPU is given by the *cpu* key in the configuration table. The CPUmust be already known to the build system. A list of the known CPUscan be found in the *build_data.lua*file
in the __platform_list__ table.

cpu = ‘stm32f407vg‘,

【build_data.lua】

local platform_list =

{

at91sam7x = { cpus = { ‘AT91SAM7X256‘, ‘AT91SAM7X512‘ }, arch =‘arm‘ },

lm3s = { cpus = { ‘LM3S1968‘, ‘LM3S8962‘, ‘LM3S6965‘, ‘LM3S6918‘,‘LM3S9B92‘, ‘LM3S9D92‘ }, arch = ‘cortexm‘ },

str9 = { cpus = { ‘STR912FAW44‘ }, arch = ‘arm‘ },

i386 = { cpus = { ‘I386‘ }, arch = ‘i386‘ },

sim = { cpus = { ‘LINUX‘ }, arch = ‘i386‘ },

lpc288x = { cpus = { ‘LPC2888‘ }, arch = ‘arm‘ },

str7 = { cpus = { ‘STR711FR2‘ }, arch = ‘arm‘ },

stm32f2 = { cpus = { ‘STM32F205RF‘ }, arch = ‘cortexm‘ },

stm32 = { cpus = { ‘STM32F103ZE‘, ‘STM32F103RE‘ }, arch = ‘cortexm‘},

stm32f4 = { cpus = { ‘STM32F401RE‘,‘STM32F407VG‘, ‘STM32F407ZG‘ }, arch = ‘cortexm‘ },

avr32 = { cpus = { ‘AT32UC3A0128‘, ‘AT32UC3A0256‘, ‘AT32UC3A0512‘,‘AT32UC3B0256‘ }, arch = ‘avr32‘ },

lpc24xx = { cpus = { ‘LPC2468‘ }, arch = ‘arm‘ },

lpc17xx = { cpus = { ‘LPC1768‘ }, arch = ‘cortexm‘ }

}

如果你不作porting,那么cpu为以上其中一个。(porting详见elua/doc/en/arch_newport.txt)

[[config_components]]

涉及文件系统(romfs,wofs,mmcfs,rfs)shell,adnvance_shell(sercon,xmoden,term),中断(luaints,cints),dns,dhcp,tcpip,rpc等参数配置

详见elua/Doc/En/configurator.txt

[[config_config]]

The *config* section containsvarious build time configuration data.

虚拟时钟vtmr,垃圾收集egc,内存大小起始地址ram,系统时钟clock

[[config_modules]]

The configurator has supportfor fine-grained selections of the Lua modules that are going to bepart of the eLua firmware.

The module chooser knows how todifferentiate between 3 categories of modules:

1. *Lua modules*: the standardLua modules that are compiled in eLua (_mlmath, _mlio, _mlstring,_mltable, _mldebug, _mlpackage, _mlco). These can
be referenced as agroup under the name *all_lua*.

2. *Generic eLua modules*:these are _madc, _mbit, _mcan, _mcpu, _melua, _mi2c, _mpack, _mrpc,_mnet, _mpd, _mpio, _mpwm, _mspi, _mterm, _mtmr, _muart.
These can bereferenced as a group under the name *all_elua*.

3. *Platform specific eLuamodules*: these are added by each platform as needed.

*
ifused in *generic*, *all* is equivalent with *all_lua* + *all_elua*(all the standard Lua modules and the generic eLua modules)

* if used in *platform*, *all*is a list of all the platform specific modules.

A module name can be prefixedwith
a dash (*-*) if thatmodule must be _excluded_ from the image instead of being included.Generally, this makes sense only when a group name (*all*, *all_lua*or*all_elua*) is also
used in the list of modules.

注意:allall_lua和all_elua,"-i2c"表示不包括I2c组件

[[config_headers]]

the configurator compiles theLua board description file into a C header file (*board_<board>.h*)that is later used to compile the eLua firmware.
If additionalheaders must be included in the generated header file, they can bespecified in the *headers* section:

headers = { "specific1.h","specific2.h" }

[[config_macros]]

Besides the macros generated bythe configurator, it is sometimes useful to add other macros to the*board_<board>.h* file. These can be specified
in the *macros*section. If present, *macros* must be a table with two kinds of keys:

* strings: these define simplemacros (macros without a value)

* arrays with two entries:these define macros with values.

For example, this definition:

[source, lua]

macros = { ‘MACRO1‘, {‘MACRO2‘, 0 } }

[source, c]

#define MACRO1

#define MACRO2 0

定制编译属性时,一般不修改/known目录下的文件,而是采用在/custom目录下添加文件。注意文件名要与对应的平台相同,例如custom/stm32f4discovery.lua

[source,lua]

-- Fileboards/custom/stm32f4discovery .lua

local t =dofile( "boards/known/stm32f4discovery .lua" )

t.components.wofs=true

return t

例如:增加wofs文件系统的支持,(stm32f4discovery平台默认只支持romfs文件系统,只读,不能动态添加文件,限制lua的应用,advanced_shell中的recv命令也不能用,所以添加可读写的文件系统wofs)

[[buildoptions]]

参考elua/Doc/En/Building.txt

luabuild_elua.lua[board=<boardname>](支持的平台详见boards/known文件夹)

[target=lua | lualong | lualonglong]

[allocator=newlib | multiple | simple]

[toolchain=<toolchain name>]

[optram=true | false]

[boot=standard | luarpc]

[romfs=verbatim | compress | compile]

[cpumode=arm | thumb]

[bootloader=none | emblod]

[output_dir=<directory>]

[romfs_dir=<directory>]

[board_config_file=<file>]

[skip_conf=true | false]

[config_only=true | false]

[build_mode=keep_dir | build_dir_linearized]

[build_dir=<directory>]

[disp_mode=all | summary | minimal]

[-E | -S]

[-h]

[prog]

target=lua| lualong | lualonglong: specify if you want to build"regular" Lua (with floating point support). 32 bit integeronly Lua (lualong) or 64 bit integer only Lua (lualonglong,
startingwith version 0.9). The default is "lua". "lualong"and "lualonglong" run faster on targets that don’t have afloating point co-processor, but they completely lack support forfloating point operations, they can only handle integers. Also,"lualonglong"
doesn’t support cross-compilation of Luasource files to bytecode

默认lua,为float类型,在stm32f4discovery平台下发现,如果编译选项为-mfloat-abi=softfp时,选择target=lua,elua中的lua解释器无法正常工作,只能便以为lualong

optram=true| false: enables of disables the LTR patch, see the
LTRdocumentation for more details. The default istrue, which enables the LTR patch. Keep LTR enabled unless
you have avery good reason to do otherwise, eLua might notfunction properly with LTR disabled.

默认打开,目的是节约RAM,详见elua/doc/en/arch_ltr.html

prog:by default, the above
build_eluacommand will build only the
elf(executable) file. Specify "prog" to build also theplatform-specific programming file where appropriate (for example, ona AT91SAM7X256 this results in a .bin file that
can be programmed inthe CPU).

生成bin文件

缺少参数:-c: clean target

其它参数详见http://www.eluaproject.net/doc/master/en_building.html

本文介绍了如何定制elua的编译选项,主要是configurator和buildoptions两部分。下一篇文章讲解如何使用elua,主要讲解elua的链接和shell

时间: 2024-09-30 03:06:05

elua学习(三)--定制elua的编译选项的相关文章

Android开发学习之 定制界面风格

统一的用户界面是可以使得应用程序更友好.要做到用户界面的统一,我们就必须用到风格(style)和主题(theme).OPhone系统提供了很多系统默认的风格和主题,但是很多情况下,这些不能满足我们的需要.例如我们不可能总是希望背景色是系统规定的,我们也不希望字体大小一成不变.当然我们可以在每个空间里面进行修改,但是如果放到风格里面去做,可以更容易的做到用户界面统一.如果有朋友还不清楚什么是风格什么是主题,你可以在Andoird的Dev Guide文档里面找到详细的解释,这篇文章要描述的是开发者怎

算法学习三阶段

?? 第一阶段:练经典经常使用算法,以下的每一个算法给我打上十到二十遍,同一时候自己精简代码, 由于太经常使用,所以要练到写时不用想,10-15分钟内打完,甚至关掉显示器都能够把程序打 出来. 1.最短路(Floyd.Dijstra,BellmanFord) 2.最小生成树(先写个prim,kruscal 要用并查集,不好写) 3.大数(高精度)加减乘除 4.二分查找. (代码可在五行以内) 5.叉乘.判线段相交.然后写个凸包. 6.BFS.DFS,同一时候熟练hash 表(要熟,要灵活,代码要

Jetty学习三:配置概览-需要配置什么

上一节讲述了怎么配置Jetty,这节将告诉你使用Jetty你需要配置些什么. 配置Server Server实例是Jetty服务端的中心协调对象,它为所有其他Jetty服务端组件提供服务和生命周期管理.在标准Jetty发布中,核心的服务端配置是在etc/jetty.xml文件中,你也能在其中包含其他服务端配置,可以包括: 1)ThreadPool Server实例提供了一个线程池,你可以在etc/jetty.xml中配置最大线程数和最小线程数. 2)Handlers Jetty服务端只能有一个H

ZigBee学习三 UART通信

ZigBee学习三 UART通信 本实验只对coordinator.c文件进行改动就可以实现串口的收发. 修改coordinator.c文件 byte GenericApp_TransID; // This is the unique message ID (counter) afAddrType_t GenericApp_DstAddr; unsigned char uartbuf[128];/**************************************************

Spark学习三:Spark Schedule以及idea的安装和导入源码

Spark学习三:Spark Schedule以及idea的安装和导入源码 标签(空格分隔): Spark Spark学习三Spark Schedule以及idea的安装和导入源码 一RDD操作过程中的数据位置 二Spark Schedule 三Idea导入spark源码 一,RDD操作过程中的数据位置 [hadoop001@xingyunfei001 spark-1.3.0-bin-2.5.0]$ bin/spark-shell --master local[2] val rdd = sc.t

mongodb学习(三)

菜鸟啊...先吐槽一下自己 一 准备工作: 1.安装服务端: 去官网下载 http://www.mongodb.org/downloads 其实也自带了客户端 shell 2.安装客户端: mongoVUE http://blog.mongovue.com/ 并不是完全免费 破解方法: http://yhv5.com/mongovue_480.html 将服务端下载下来后直接安装 我下载在D盘也安装在D盘的... 启动mongodb的服务端不需要各种命令....直接鼠标左键双击bin中的mong

c++ boost库学习三:实用工具

noncopyable 大家都知道定义一个空类的时候,它实际包含了构造函数,拷贝构造函数,赋值操作符和析构函数等. 这样就很容易产生一个问题,就是当用户调用A a(“^_^") 或者A c="^_^" 时会发生一些意想不到的行为,所以很多时候我们需要禁用这样的用法. 一种方法就是把拷贝构造函数和赋值操作符显式的定义为private,但是这样需要很多代码. 于是boost库为大家提供了一个简单的方法:只需要将类继承于noncopyable就可以了. #include "

scala学习三---文件里读取文本行

学习了scala的基本知识后,发现了scala是集函数式和指令式结合为一体的一种语言,代码更加简洁,但是对于用习惯了java的人来说,还真的不是一件易事~~ 今天学习scala脚本读取文本文件 列子如下: import scala.io.Source if(args.length>0){ for(line <- Source.fromFile(args(0)).getLines) print(line.length+" "+line) }else{ Console.err.

Oracle学习(三):单行函数

1.知识点:可以对照下面的录屏进行阅读 SQL> --字符函数 SQL> --字符串的转换 SQL> select lower('hellO WORld') 转小写,upper('hellO WORld') 转大写,initcap('hello world') 首字母大写 2 from dual; SQL> --substr(a,b) 从a中,第b位开始取,取右边所有的字符 SQL> select substr('Hello World',4) from dual; SQL&