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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章