1.由于LUA需要至少50K的RAM(经验值),所以stack和heap设置的尽量大,当前分别都设置为了64K。在文件rt1052_flexspi_scf.scf里面改动:

#define Stack_Size                   0x10000

#define Heap_Size                    0x10000

2.LUA解释器代码的__stdout和本体程序的__stdout重复定义,如下:

“..\OBJ\test.axf: Error: L6200E: Symbol __stdout multiply defined (by stdio_streams.o and lpuart.o).”

解决过程:

2.1单纯的把多处定义的__stdout前面加extern,会报如下错误:

“..\OBJ\test.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _sys_open was referenced

嵌入式程序编译时如果出现sys_open,printf、fopen、fclose等文件操作,因程序中并没有对这些函数的底层实现,使得设备运行时会进入软件中断BAEB处,程序一直死在这里不能运行。这时就需要__use_no_semihosting这 个声明,使程序遇到这些文件操作函数时不停在此中断处,具体操作如下,将下列程序加入你的工程中:

#if 1

#pragma import(__use_no_semihosting)//_swi

#pragma import(_main_redirection)

const char __stdin_name[150];

const char __stdout_name[150];

const char __stderr_name[150];

typedef int FILEHANDLE;

typedef unsigned int clock_t;    /* cpu time type */

typedef unsigned int time_t;     /* date/time in unix secs past 1-Jan-70 */

extern FILE __stdout;

//重写标准库函数,这时printf、fopen、fclose等文件操作函数运行时就会调用你的重写函数,这些重写函数只是几个简单的例子,并没有重写所有的文件操作函数

void _sys_exit(int status)

{

while(1);

}

FILEHANDLE _sys_open(const char *name, int openmode)

{

return 0;

}

int _sys_close(FILEHANDLE fh)

{

return 0;

}

int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)

{

return 0;

}

int _sys_read(FILEHANDLE fh, unsigned char*buf, unsigned len, int mode)

{

return 0;

}

int _sys_istty(FILEHANDLE fh)

{

return 0;

}

int _sys_seek(FILEHANDLE fh, long pos)

{

return 0;

}

int _sys_ensure(FILEHANDLE fh)

{

return 0;

}

long _sys_flen(FILEHANDLE fh)

{

return 0;

}

int _sys_tmpnam(char *name, int fileno, unsigned maxlength)

{

return 0;

}

void _ttywrch(int ch)

{

}

time_t time(time_t *t)

{

return 0;

}

int remove(const char *filename)

{

return 0;

}

int rename(const char *oldname, const char *newname)

{

return 0;

}

int system(const char *command)

{

return 0;

}

char *_sys_command_string(char *cmd, int len)

{

return 0;

}

clock_t clock(void)

{

return 0;

}

//重定义fputc函数

int fputc(int ch, FILE *f)

{

while((LPUART1->STAT&LPUART_STAT_TDRE_MASK)==0);

LPUART1->DATA=(u8)ch;

return ch;

}

#endif

---------------------------------------------------------END----------------------------------------------------------------------------

RT1502移植LUA成功的总结的更多相关文章

  1. 单片机脚本语言-移植lua到stm32-MDK

    Lua简单介绍 Lua[1]  是一个小巧的脚本语言.作者是巴西人.该语言的设计目的是为了嵌入应用程序中,从而为应用程序提供灵活的扩展和定制功能. Lua脚本能够非常easy的被C/C++ 代码调用, ...

  2. 移植X264成功

    http://blog.csdn.net/mashang123456789/article/details/8673426 http://blog.csdn.net/b5w2p0/article/de ...

  3. 开源物联网通讯框架ServerSuperIO,成功移植到Windows10 IOT,在物联网和集成系统建设中降低成本。附:“物联网”交流大纲

    [开源]C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 一.概述 经过一个多月晚上的时间,终于把开源物联网通讯框架ServerSuperIO成功移植到Windows10 IOT上, ...

  4. Lua 与 OC 相互调用

    本文主要讲如何完成lua和object-c的相互调用.       lua是一种脚本语言,可以方便的移植到各种宿主语言中,并且可以支持热更新,在游戏开发中也能当做主要的语言来编写游戏的逻辑,但是要接入 ...

  5. 来了!STM32移植LuatOS,潘多拉示例全新教程

    进击的五月,继上期<使用Air724UG制作简易贪吃蛇>教程之后,@打盹的消防车 又为大家带来基于STM32的潘多拉LuatOS移植全新教程: 为什么使用潘多拉作为教程呢? STM32不能 ...

  6. [转载]tslib1.4与Qt4.8.6的交叉编译与移植

    原文:http://www.cnblogs.com/Jasonsblog/p/3757985.html http://blog.csdn.net/sno_guo/article/details/168 ...

  7. QM UML状态机建模实例之移植 cortex-m0

    ---恢复内容开始--- 在上一期“Blinky for cortex-m0”中我们介绍了如何在QM中建立一个工程和生成代码,如何使生成的代码在我们的工程师运行起来,为此这一期要介绍如何将QP-NAN ...

  8. 【转】(笔记)CANopen协议【CANFestival】移植方法

    一.背景 CAN组网就必须得要应用层协议,原因就在于 * 便于网络管理与控制 * 确认数据的收发 * 发送大于8个字节的数据块(CAN每帧数据传输大小为8字节) * 为不同节点分配不同的报文标识符 * ...

  9. tslib1.4与Qt4.8.6的交叉编译与移植

    最近开始正式接触QT开发,网上看了些移植教程都写的有点乱,博客园的emouse思·睿有一篇写的很好的文章,下面是文章的链接 http://www.cnblogs.com/emouse/archive/ ...

随机推荐

  1. ubuntu之路——day1(一点十五分 MMP终于把显卡装好了)

    因为要上手深度学习的原因,购置了一台RTX2080TI+ubuntu18.04的机器 例行两条命令 sudo apt-get update sudo apt-get upgrade 开启巨坑第一天,以 ...

  2. peomethues 参数设置 监控网站 /usr/local/prometheus-2.13.0.linux-amd64/prometheus --config.file=/usr/local/prometheus-2.13.0.linux-amd64/prometheus.yml --web.listen-address=:9999 --web.enable-lifecycle

    probe_http_status_code{instance="xxxx",job="web_status"} probe_http_status_code{ ...

  3. 获取div下的input type为file的所有对象

    var files = $(".profile-content").find("input[type='file']"); files.each(functio ...

  4. 阿里云 商标 SAAS

    商标注册-注册商标查询-商标交易平台-阿里云商标https://tm.aliyun.com/#/ 阿里云商标查询入口-云栖社区-阿里云https://yq.aliyun.com/articles/69 ...

  5. redis-cli 使用密码登录

    #./redis-cli 输入auth +空格+ 刚才设置的密码 成功

  6. Python3基础 函数 返回值 利用元组返回多个值

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  7. osg 渲染ifc数据-测试

    直接使用osg渲染ifc数据,提高渲染速度. #include "teslamanage.h" #include <QtWidgets/QApplication> #i ...

  8. 解决:error: Cannot find libmysqlclient_r under /usr/local/mysql.

    libodb-mysql-2.4.0.tar.gz 解压完安装libodb-mysql时,执行完./cofigure后,出现如下错误: checking for libmysqlclient_r... ...

  9. case when 性能优化

    背景:性能应该是功能的一个重要参考,特别是在大数据的背景之下!写SQL语句时如果仅考虑业务逻辑,而不去考虑语句效率问题,有可能导致严重的效率问题,导致功能不可用或者资源消耗过大.其中的一种情况是,处理 ...

  10. mysql存储过程中declare 和set 定义变量的区别

    declare为对变量进行声明,声明必须制定变量的数据类型,只能写在过程的前面set是对变量赋值,可以放在过程的任何地方对没有declare声明过的变量赋值,该变量必须以加上@号,否则会报错 DECL ...