飞凌嵌入式全志A40i的试用体验之交叉编译

今日头条

1096人已加入

描述

环境:Unbuntu20.4LTS

交叉编译工具链:arm-linux-gnueabihf-gcc

软件:VsCode

选择下载交叉编译工具链(我就按照其他教程下载配置的)

在开发板上配置sftp用于文件传输,将编译完成的可执行文件传到开发板上运行

通过其他教程学习了一下Makefile文件的构成及简单实现,make编译得到可执行文件main

编写gpio_test.c文件,这里参考了文章https://www.jianshu.com/p/e5ecd92c0787

#include 《stdio.h》 #include 《stdlib.h》 #include 《unistd.h》 #include 《sys/stat.h》 #include 《sys/types.h》 #include 《fcntl.h》 char *GPIO_PATH = “/sys/class/gpio/gpio43/value”; int main(int argc, char *argv[]) { int res = 0; int fd; char *path; printf(“Gpio test demo ”); if(argc 》= 2) { path = argv[1]; } else { path = GPIO_PATH; } fd = open(path, O_WRONLY); if(fd《0) { printf(“Failed to Open gpio %s/n”, path); exit(1); } while(1) { write(fd, “1”, 1); sleep(1); write(fd, “0”, 1); sleep(1); } close(fd); }

编写Makefile文件进行编译

将生成的可执行文件gpio_flash复制到开发板目录中,不加任何参数运行可以看到核心板上的LED闪烁

嵌入式

带参数可以换一个gpio进行控制

嵌入式

fqj

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分