[评测分享]
【全志-V821 PERF2B开发板】--3.运行helloworld应用程序
#板卡评测
559 人阅读
|
0 人回复
|
2025-08-03
TA的每日心情 | 奋斗 2025-8-10 16:22 |
|---|
签到天数: 36 天 连续签到: 1 天 [LV.5]常住居民I
举人
- 积分
- 949
|
本帖最后由 dirty123 于 2025-8-3 20:28 编辑
本篇讲述编写Hello Wrold应用程序并运行。
一.创建工程
1.在openwrt/package/目录下创建helloworld工程
main.c源码如下。Makefile脚本如上图。
- #include <stdio.h>
- int main(int argc, char const *argv[])
- {
- printf("Hello World\n");
- return 0;
- }
复制代码 2.配置选中helloworld工程
使用 m menuconfig命令,图形化配置如下,选中helloworld
二.配置开机自启
1.开机自启脚本路径
开机自启脚本路径在openwrt/target/v821下相应开发板型号下的init.d文件夹下,对于v821-perf2b,其路径如下
- openwrt/target/v821/v821-perf2b/busybox-init-base-files/etc/init.d/S99helloworld
复制代码 2.开机自启脚本准备
- #!/bin/sh
- #
- # Start helloworld ....
- #
- start() {
- printf "Start helloworld .... "
- helloworld
- }
- stop() {
- printf "Stopping helloworld .... "
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- stop
- start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- esac
- exit $?
复制代码 在上述路径下创建S99helloworld文件,且设置其可执行权限如下
- sudo chmod 777 S99helloworld
复制代码 编写脚本如下
- #!/bin/sh
- #
- # Start helloworld ....
- #
- start() {
- printf "Start helloworld .... "
- helloworld
- }
- stop() {
- printf "Stopping helloworld .... "
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload)
- stop
- start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- esac
- exit $?
复制代码
编译前先清理编译
三.编译烧录测试
编译与烧录前面有讲过,这里不赘述。
1.初次需要连接上wifi. 若没连接,日志会一直跳跃无效显示。
硬件上准备一个2.4G天线,扣在开发板天线接口上.
在shell命令如下,设置为STA模式,连接上wifi,尝试ping网络通畅则连接上。
2.上电启动
上电后启动,日志如下
可以看到开机连接上wifi后,运行了helloworld应用。
|
|
|
|
|
|
|
|
|