概述
之前一直在学MT7688,发现要想真正利用这个开发板并在上面做出一些东西确实不容易。我花了很长的时间去学习Linux中的知识,包括怎样在Ubuntu中搭建samba、tftp、vim、makefile、shell,以及烧写程序等方法,常见错误的排除。我不得不说,自己缺的东西太多了。后来终于利用这些东西实现了开发板、Ubuntu、MT7688三者之间的文件访问,但是却还迟迟不知道怎样编写自己的程序并在开发板上运行。经过1天多的学习终于可以写一个简单的程序了。我是初学者也是菜鸟一枚,希望我的文章可以帮助初学者,请大神勿喷自行绕过。同时,我是想在MT7688上面做应用开发,也希望朋友们就基于MT7688开发板的用户应用程序设计不吝赐教,吾不胜感激!!!
我用的是原厂的SDK:MediaTek_ApSoC_SDK_4300_20140916.tar
我在/MT7688/RT288x_SDK/source/user中建立了music文件夹,并将我的用户程序写到这个文件夹下。我的第一个程序很简单,编写music.c文件,运行这个文件时 ,输出:Welcome to use wireless music service!
root@openwrt:~# cd ~/MT7688/RT288x_SDK/source/user/
root@openwrt:~/MT7688/RT288x_SDK/source/user# pwd
/root/MT7688/RT288x_SDK/source/user
root@openwrt:~/MT7688/RT288x_SDK/source/user# mkdir music
root@openwrt:~/MT7688/RT288x_SDK/source/user# cd music
root@openwrt:~/MT7688/RT288x_SDK/source/user/test# pwd
/root/MT7688/RT288x_SDK/source/user/music
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# pwd
/root/MT7688/RT288x_SDK/source/user/music
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# touch music.c
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# vim music.c
程序内容如下:
#include<stdio.h>
int main()
{
printf("Welcome to use wireless music service!n");
return 0;
}
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# ls
music.c
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# touch Makefile
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# ls
Makefile music.c
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# vim Makefile
编写如下内容:
EXE = music
OBJS = music.o
#stdlibc++ known issue:
#If your program needs libstdc++, please turn off code optimization
CFLAGS += -O0
all: $(OBJS)
$(CXX) -o $(EXE) $(OBJS) $(LDFLAGS)
.cpp.o:
$(CXX) $(CFLAGS) -c $<
romfs:
$(ROMFSINST) /bin/$(EXE)
clean:
@rm -rf $(EXE) *.o
四、编辑RT288x_SDK/source/config/config.in文件
root@openwrt:~/MT7688/RT288x_SDK/source/user/music# vim ../../config/config.in
添加如下内容:
comment 'XXX Add-on Applications'
bool 'music_server' CONFIG_USER_MUSIC
五、编辑RT288x_SDK/source/user/中的Makefile文件
root@openwrt:~/MT7688/RT288x_SDK/source/user# pwd
/root/MT7688/RT288x_SDK/source/user
root@openwrt:~/MT7688/RT288x_SDK/source/user# vim Makefile
添加如下内容:
dir_$(CONFIG_USER_MUSIC) += music
六、/root/MT7688/RT288x_SDK/source中运行make menuconfig
root@openwrt:~/MT7688/RT288x_SDK/source/user# pwd
/root/MT7688/RT288x_SDK/source/user
root@openwrt:~/MT7688/RT288x_SDK/source/user# cd ..
root@openwrt:~/MT7688/RT288x_SDK/source# pwd
/root/MT7688/RT288x_SDK/source
root@openwrt:~/MT7688/RT288x_SDK/source# make menuconfig
在执行的过程中会出现一个选项:这就是刚刚添加的程序,选择y
* Force build (Normally built when required)
*
music_server (CONFIG_USER_MUSIC) [N/y/?] (NEW) y
七、编译新的镜像文件
root@openwrt:~/MT7688/RT288x_SDK/source# make dep
root@openwrt:~/MT7688/RT288x_SDK/source# make
八、编译完成后
Image Name: Linux Kernel Image
Created: Wed May 11 00:53:33 2016
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 4009600 Bytes = 3915.62 kB = 3.82 MB
Load Address: 0x80000000
Entry Point: 0x8000C150
Kernel Size: 0x00000000
make[2]: Leaving directory `/root/MT7688/RT288x_SDK/source/vendors/Ralink/MT7628'
make[1]: Leaving directory `/root/MT7688/RT288x_SDK/source/vendors'
if [ -d /tftpboot ]; then
cp /root/MT7688/RT288x_SDK/source/images/root_uImage /tftpboot;
fi
九、测试music文件是否正确
root@openwrt:~/MT7688/RT288x_SDK/source# pwd
/root/MT7688/RT288x_SDK/source
root@openwrt:~/MT7688/RT288x_SDK/source# cd romfs/bin/
root@openwrt:~/MT7688/RT288x_SDK/source/romfs/bin# file music
music: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x3040000, stripped
root@openwrt:~/MT7688/RT288x_SDK/source/romfs/bin#
十、把镜像烧写到MT7688,方法跟烧写Uboot类似,但是 操作的时候选择方式2
##### The CPU freq = 575 MHZ ####
estimate memory size =64 Mbytes
RESET MT7628 PHY!!!!!!
Please choose the operation:
1: Load system code to SDRAM via TFTP.
2: Load system code then write to Flash via TFTP.
3: Boot system code via Flash (default).
4: Entr boot command line interface.
7: Load Boot Loader code then write to Flash via Serial.
9: Load Boot Loader code then write to Flash via TFTP.
You choosed 2
0
2: System Load Linux Kernel then write to Flash via TFTP.
Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N)
Please Input new ones /or Ctrl-C to discard
Input device IP (10.10.10.123) ==:192.168.1.1
Input server IP (10.10.10.3) ==:192.168.1.32
Input Linux Kernel filename () ==:root_uImage
netboot_common, argc= 3
NetTxPacket = 0x83FE4E00
KSEG1ADDR(NetTxPacket) = 0xA3FE4E00
NetLoop,call eth_halt !
NetLoop,call eth_init !
Trying Eth0 (10/100-M)
Waitting for RX_DMA_BUSY status Start... done
ETH_STATE_ACTIVE!!
TFTP from server 192.168.1.32; our IP address is 192.168.1.1
Filename 'root_uImage'.
TIMEOUT_COUNT=10,Load address: 0x80100000
Loading: checksum bad
Got ARP REQUEST, return our IP
checksum bad
checksum bad
checksum bad
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
checksum bad
checksum bad
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
checksum bad
checksum bad
Got ARP REQUEST, return our IP
checksum bad
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REQUEST, return our IP
Got ARP REPLY, set server/gtwy eth addr (b8:88:e3:7a:66:3a)
Got it
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
####
done
Bytes transferred = 4009664 (3d2ec0 hex)
NetBootFileXferSize= 003d2ec0
.............................................................
.............................................................
.
.
Done!
十一、在开发板中就可以使用自己编写的程序了
# help
Built-in commands:
-------------------
. : break cd chdir continue eval exec exit export false hash
help local pwd read readonly return set shift source times trap
true type ulimit umask unset wait
# music
Welcome to using wireless music service!
#
最后
以上就是迷路钢笔为你收集整理的基于MT7688模块的开发笔记11——编写我的第一个程序并在MT7688中运行的全部内容,希望文章能够帮你解决基于MT7688模块的开发笔记11——编写我的第一个程序并在MT7688中运行所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复