day33.串口编程之开机启动运行

第33节:串口编程之开机启动运行


1、使用已经编译好的helloworld.c的程序进行实现开机启动运行。
代码如下:
#include<stdio.h>
main()
{
        printf("Hello World!\n");
}

2、挂载U盘并查看文件是否存在并执行hello是否能执行 。
[root@iTOP-4412]# mount /dev/mmcblk1p1 /mnt                                                                                                                                           
[root@iTOP-4412]# cd /mnt
[root@iTOP-4412]# ls
System Volume Information  hello                      hello.c

[root@iTOP-4412]# ./hello                                                                                                                                            Hello World!


3、将hello文件拷贝到/bin下,并查看是否拷贝成功
[root@iTOP-4412]# cp -rp hello /bin                                                                                                                                                   
[root@iTOP-4412]# ls -l /bin/hello                                                                                                                                                    
-rwxr-xr-x    1 root     0           648462 Feb 17  2018 /bin/hello


4、让hello文件在开机状态下启动。
[root@iTOP-4412]# vi /etc/init.d/rcS


#echo "*************************************" > /dev/ttySAC2
#echo "     http://www.topeet.com.cn        " > /dev/ttySAC2
#echo "*************************************" > /dev/ttySAC2
#echo "*************************************"
#echo "     http://www.topeet.com.cn        "
#echo "*************************************"
                                                                          

mkdir /mnt/disk                      

sleep 1                
/sbin/ifconfig lo 127.0.0.1
/etc/init.d/ifconfig-eth0        
                                 
/bin/hello &               


注意:在最尾巴加入/bin/hello &     

5、重新启动看开机信息
Please press Enter to activate this console. Hello World!

6、另一种方法是在编译最小系统时写入hello程序也是可以的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

随行之旅

python国产化自动化

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值