MT7688开发板_Widora-Neo_从零开始上手过程记录

0. 环境

笔记本:win7 64bit笔记本 4G内存 i5-5200U。100G硬盘。

开发板:widora-neo

1. 过程

1.1 PC

安装vmware 10.0.1,选择安装路径,其他一路默认,安装完成后输入注册码。
虚拟机内安装Ubuntu14(32位)。配置2核心,每个核心2个线程。Linux系统(建议使用Ubuntu14.04/16.04 32位/64位版本)。

1.2 虚拟机内安装好依赖

$ sudo apt-get update 
$ sudo apt-get install git g++ make libncurses5-dev subversion libssl-dev gawk libxml-parser-perl unzip wget python xz-utils vim zlibc zlib1g zlib1g-dev openjdk-7-jdk build-essential ccache gettext xsltproc

1.3 下载固件源码

$ git clone https://github.com/widora/openwrt_widora.git
//或者
$ git clone https://dev.tencent.com/u/widora/p/openwrt_widora

更新源码

$ git pull

更新并安装软件包 

$ ./scripts/feeds update -a   
$ ./scripts/feeds install -a

配置OpenWrt 

$ rm .config
$ make menuconfig

32MB+128MB配置(BIT3 BIT4,32MB FLASH):  

Target System: Ralink RT288x/RT3xxx
   Subtarget: MT7688 based boards
     Target Profile: WIDORA32128

保存退出 

$ make -j4 V=s

编译完会在bin/ramips目录生成固件,大概6MB,名字类似如下
 

openwrt-ramips-mt7688-WIDORAxxxx-squashfs-sysupgrade.bin 

1.4 U-Boot编译


使用git工具下载u-boot-mt7688源码 

$ git clone https://github.com/widora/u-boot-mt7688.git

解压编译工具链到/opt/目录下 

$ cd u-boot-mt7688
$ sudo tar xvfj buildroot-gcc342.tar.bz2 -C /opt/


进入u-boot-mt7688源码,编译 

$ cd u-boot-mt7688
$ make clean
$ make -j4 V=s

编译完,生成到本目录下uboot.bin
 

$ls uboot.bin

1.5 其他资料

官方固件
https://www.widora.io/zh/firmware

1.6 刷机

https://www.widora.io/zh/flash

我拿到开发板已经是带有出厂固件的。我就不修改uboot了。而是使用以下的方法:


基于已有的OpenWrt刷机
条件:该方式操作的前提是7688模块中已经有了OpenWrt正常固件。借助已有的固件的sysupgrade命令而已。所以要使用该更新方式,有两步: 
将新固件拷贝至模块的文件系统中,最好是/tmp内存目录。
在板子的控制台运行sysupgrade /tmp/newimage.bin 命令更新固件。
运行完重启后,运行firstboot -y。
传输固件到Widora
实用SCP将固件传输到Widora。 
进入板子控制台执行更新命令

root@widora:/# cd /tmp  
root@widora:/# sysupgrade openwrt.bin

执行一次清理操作

root@widora:/# firstboot -y


该操作执行后重启生效

2. 交叉编译helloworld.c

正常执行完成上节的1.3后,会在openwrt_widora里面生成适配板子的toolchain。

2.1 设置环境变量

将toolchain加到PATH里面 
执行命令

sudo vi /etc/bash.bashrc    

并在文件最后添加以下两行配置 

export STAGING_DIR=/path/to/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin 
export PATH=$STAGING_DIR/:$PATH


注意上面的/path/to/openwrt是openwrt_widora的路径。

执行以下命令是配置生效。

source /etc/bash.bashrc 

2.2 测试

执行 mipsel-openwrt-linux-uclibc-gcc -v 如果能正常输出版本信息则代表安装成功 

2.3 应用程序编译

hello_world 编写 
在ubuntu中新建文件

gedit ~/helloworld.c


输入以下内容:

#include "stdio.h"
int main(int argc, char *argv)
{
    printf("hello world!\r\n");
    return 0;
}


执行:

$ mipsel-openwrt-linux-uclibc-gcc -o helloworld.out helloworld.c
$ file helloworld.out

file命令可以查看到生成的out文件格式是MIPS的。

2.4 拷贝到widora中

电脑连接widora-neo的WIFI,后在CMD中输入ipconfig可查看到无线网卡的IP地址和路由器地址,路由器地址即开发板地址。
用winscp,SCP协议,输入widora-neo的地址,端号是22. 默认账号root,密码12345678.

用鼠标点着文件拉到widora的文件系统中即可。

2.5 开发板中执行程序

$ chmod +x helloworld.out 
$ ./helloworld.out

效果图:

意外问题1:line 1: syntax error: word unexpected (expecting ")")

出现这种情况是gcc编译文件时候,使用了错误的参数-c。导致只生成了库,而不是执行文件。如果是生成执行文件,不需要-c。

参考资料:

1. 搭建编译环境, https://www.widora.io/zh/compile
2. 【已解决】可执行程序无法在Linux上运行,显示line 1: syntax error: word unexpected (expecting “), https://www.crifan.com/resolved_executable_program_can_not_run_on_linux_display_line_1_syntax_error_word_unexpected_expecting_quot/

3. openwrt MT7688开发板 从零教程, https://blog.csdn.net/u014624241/article/details/78844331
4. 在Ubuntu下mips-openwrt-linux-gcc编译openwrt上运行的c, http://blog.chinaunix.net/uid-28790518-id-5113217.html

猜你喜欢

转载自blog.csdn.net/qq_27158179/article/details/103136476