【OpenWrt】编译环境搭建、U-boot、OpenWrt源码编译
【OpenWrt】编译环境搭建、U-boot、OpenWrt源码编译
使用开发板:hiwooya-MT7628
一、安装依赖
$ 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-8-jdk build-essential ccache gettext xsltproc
如果是 64 位操作系统,需要多操作如下步骤:(注意libc6:i386 libncurses5:i386 libstdc++6:i386 中间要加冒号)
$ sudo dpkg --add-architecture i386
$ sudo apt-get update
$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
二、编译U-boot
1、进入U-boot源码目录
$ cd u-boot-hiwooya/
2、解压交叉编译工具链到 /opt 目录(交叉编译工具链在u-boot目录里面)
$ sudo tar xvfj buildroot-gcc342.tar.bz2 -C /opt/
3、图形界面配置参数
$ make clean
$ make menuconfig
以 MT7628 内存 DDR2 为 128MBye,SPI Flash 为 16MBye 为例进行配置,配置如下:
Chip ID: MT7628 // 选择主控芯片,MT7688 和 MT7628 通用
DRAM Type: DDR2 // 选择 DDR 类型,用的是 DDR2
DDR Component: 512Mb // 选择 DDR 大小,128MBye 就是 1024Mb,但是要考虑位宽
DDR Width: 16bits // 选择位宽
4、编译 U-Boot 源码
make
报错:
/bin/sh: 1: /opt/buildroot-gcc342/bin/mipsel-linux-as: not found
/bin/sh: 1: [: Illegal number:
make: /opt/buildroot-gcc342/bin/mipsel-linux-gcc:命令未找到
/home/pjw/linux/MTK/MT7628/SDK/u-boot-hiwooya/config.mk:797: recipe for target 'cpu/ralink_soc/start.o' failed
make: *** [cpu/ralink_soc/start.o] Error 127
问题:64位系统中缺少32位库文件导致的
解决:安装步骤一中的64位系统需要安装的依赖。
编译成功:
三、编译OpenWrt源码
1、直接使用配置好的配置文件
$ cp config-HIWOOYA16128 .config
2、图形界面配置参数
$ make menuconfig
16MB+128MB 配置:
Target System: Ralink RT288x/RT3xxx
Subtarget: MT7688 based boards
Target Profile: HIWOOYA1612832MB+128MB 配置:
Target System: Ralink RT288x/RT3xxx
Subtarget: MT7688 based boards
Target Profile: HIWOOYA3212816MB+64MB 配置:
Target System: Ralink RT288x/RT3xxx
Subtarget: MT7688 based boards
Target Profile: HIWOOYA166432MB+64MB 配置:
Target System: Ralink RT288x/RT3xxx
Subtarget: MT7688 based boards
Target Profile: HIWOOYA3264
3、下载 dl 放到源码顶层目录
在国内编译 OpenWrt 很困难,有很多包被墙无法下载。先单独下载下来,下载后解压放到 openwrt-hiwooya 根目录中的 dl 文件夹内即可,减少编译时间。已上传到CSDN:dl包下载地址。
4、编译源码(编译时间较久)
$ make V=99
最终编译出来的固件存放在 openwrt-hiwooya/bin/ramips 目录,固件名为 *-squashfs-sysupgrade.bin。
【OpenWrt】编译环境搭建、U-boot、OpenWrt源码编译相关教程