回答

收藏

[评测分享] 【全志-V821 PERF2B开发板】--3.运行helloworld应用程序

#板卡评测 #板卡评测 559 人阅读 | 0 人回复 | 2025-08-03

本帖最后由 dirty123 于 2025-8-3 20:28 编辑

本篇讲述编写Hello Wrold应用程序并运行。

一.创建工程
1.在openwrt/package/目录下创建helloworld工程

main.c源码如下。Makefile脚本如上图。
  1. #include <stdio.h>

  2. int main(int argc, char const *argv[])
  3. {

  4.     printf("Hello World\n");

  5.     return 0;
  6. }
复制代码
2.配置选中helloworld工程
使用 m menuconfig命令,图形化配置如下,选中helloworld




二.配置开机自启
1.开机自启脚本路径
开机自启脚本路径在openwrt/target/v821下相应开发板型号下的init.d文件夹下,对于v821-perf2b,其路径如下
  1. openwrt/target/v821/v821-perf2b/busybox-init-base-files/etc/init.d/S99helloworld
复制代码
2.开机自启脚本准备
  1. #!/bin/sh
  2. #
  3. # Start helloworld ....
  4. #

  5. start() {
  6.       printf "Start helloworld .... "
  7.       helloworld
  8. }

  9. stop() {
  10.     printf "Stopping helloworld .... "
  11. }

  12. case "$1" in
  13.     start)
  14.     start
  15.     ;;
  16.     stop)
  17.     stop
  18.     ;;
  19.     restart|reload)
  20.     stop
  21.     start
  22.     ;;
  23.   *)
  24.     echo "Usage: $0 {start|stop|restart}"
  25.     exit 1
  26. esac

  27. exit $?
复制代码
在上述路径下创S99helloworld文件,且设置其可执行权限如下
  1. sudo chmod 777 S99helloworld
复制代码
编写脚本如下
  1. #!/bin/sh
  2. #
  3. # Start helloworld ....
  4. #

  5. start() {
  6.       printf "Start helloworld .... "
  7.       helloworld
  8. }

  9. stop() {
  10.     printf "Stopping helloworld .... "
  11. }

  12. case "$1" in
  13.     start)
  14.     start
  15.     ;;
  16.     stop)
  17.     stop
  18.     ;;
  19.     restart|reload)
  20.     stop
  21.     start
  22.     ;;
  23.   *)
  24.     echo "Usage: $0 {start|stop|restart}"
  25.     exit 1
  26. esac

  27. exit $?
复制代码

编译前先清理编译
  1. m -clean
复制代码

三.编译烧录测试
编译与烧录前面有讲过,这里不赘述。
1.初次需要连接上wifi. 若没连接,日志会一直跳跃无效显示。

硬件上准备一个2.4G天线,扣在开发板天线接口上.


在shell命令如下,设置为STA模式,连接上wifi,尝试ping网络通畅则连接上。

2.上电启动

上电后启动,日志如下

可以看到开机连接上wifi后,运行了helloworld应用。



分享到:
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

高级嵌入式软件工程师
949 积分
9 主题
+ 关注
热门推荐
关闭

站长推荐上一条 /3 下一条