- 开发机需要使用linux环境,ubuntu16以上即可
- 下载我们提供的交叉编译器,就是很简单的交叉编译,具体使用可以百度或者问AI 点我下载编译器
- 解压到开发机工作目录, 比如
/home/test/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf
- 编写你的程序,比如我提供一个测试程序
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Hello World from ARM Linux!\n");
// 显示一些系统信息
printf("编译器: GCC\n");
printf("架构: ARM\n");
printf("操作系统: Linux\n");
return 0;
}
- 编译程序,非常需要注意
必须要使用静态链接参数-static
,否则程序最后无法再板子上运行。
- 比如编译上面的程序使用命令
/home/test/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -static -o test test.c
, 生成可执行程序test
- 为了方便直接给你个脚本
export PATH=$PATH:/home/test/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
$CC -static -o test test.c
- 使用ftp工具比如filezilla客户端,连接网关任意接口ip ,比如LAN口
192.168.10.1
, 用户名zlftp
,密码zlftp123
- 上传文件到upload目录

- 进入到nodered流程编辑页面,直接给你个测试流程,右上角导入。右边就是运行结果
[{"id":"2581b348b9d82858","type":"tab","label":"流程 1","disabled":false,"info":"","env":[]},{"id":"0d138bd4f56436b8","type":"exec","z":"2581b348b9d82858","command":"ls /mnt/upload","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":440,"y":120,"wires":[["6ca7cd774df0ed0a"],[],[]]},{"id":"6ca7cd774df0ed0a","type":"debug","z":"2581b348b9d82858","name":"ls结果","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":100,"wires":[]},{"id":"ed401c9ed68e15b5","type":"inject","z":"2581b348b9d82858","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":120,"wires":[["0d138bd4f56436b8","eb56eec133192b91"]]},{"id":"eb56eec133192b91","type":"file","z":"2581b348b9d82858","name":"","filename":"/mnt/upload/test.txt","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":450,"y":180,"wires":[["434607cb678a8891"]]},{"id":"434607cb678a8891","type":"debug","z":"2581b348b9d82858","name":"写入文件结果","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":180,"wires":[]},{"id":"5457cdf51b11fd6d","type":"exec","z":"2581b348b9d82858","command":"chmod +x /mnt/upload/test","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":480,"y":240,"wires":[["57222b0a75d4b769"],[],[]]},{"id":"99b7c6f6f1617c01","type":"inject","z":"2581b348b9d82858","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":240,"wires":[["5457cdf51b11fd6d"]]},{"id":"1bc90766d92db4bd","type":"debug","z":"2581b348b9d82858","name":"运行输出","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":360,"wires":[]},{"id":"49516c877e375538","type":"exec","z":"2581b348b9d82858","command":" /mnt/upload/test","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":440,"y":340,"wires":[["1bc90766d92db4bd"],["03c4781dc28304a6"],[]]},{"id":"759b0f51a6da1844","type":"inject","z":"2581b348b9d82858","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":340,"wires":[["49516c877e375538"]]},{"id":"03c4781dc28304a6","type":"debug","z":"2581b348b9d82858","name":"运行错误","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":420,"wires":[]},{"id":"57222b0a75d4b769","type":"debug","z":"2581b348b9d82858","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":240,"wires":[]}]
