linux子系统编译openwrt固件,OpenWrt:编译系统

环境要求

编译一个可以安装的OpenWrt固件镜像文件(大约8MB大小的),有如下需求:

一个纯净的OpenWrt编译系统大约需要200MB的空间。

一个包含feeds的OpenWrt编译系统大约需要300MB的空间。

编译feeds中的软件包大约需要2.1GB的空间用于存放下载来的源代码。

构建OpenWrt并生成固件文件需要大约3-4 GB的空间。

编译OpenWrt需要大约1-4 GB的内存。

编译

安装需要的工具:

$ sudo apt-get update

$ sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip subversion mercurial

从官方源下载15.05分支(Chaos Calmer):

$ git clone git://git.openwrt.org/15.05/openwrt.git

下载并安装所有可用的feeds:

$ cd openwrt

$ ./scripts/feeds update -a

$ ./scripts/feeds install -a

在编译OpenWrt系统之前,首先要对它进行配置,让它能够支持我们的开发板。OpenWrt系统也是一个Linux系统,通过make menuconfig来进行配置,最后运行make -j8 V=99即可。

编译完成后,在bin/ramips/目录下会生成如下文件:

$ ls bin/ramips/

md5sums openwrt-ramips-mt7628-uImage.bin

OpenWrt-ImageBuilder-ramips-mt7628.Linux-x86_64.tar.bz2 openwrt-ramips-mt7628-uImage-initramfs.bin

openwrt-ramips-mt7628-LinkIt7688-initramfs-uImage.bin openwrt-ramips-mt7628-vmlinux.bin

openwrt-ramips-mt7628-LinkIt7688-squashfs-sysupgrade.bin openwrt-ramips-mt7628-vmlinux.elf

openwrt-ramips-mt7628-mt7628-initramfs-uImage.bin openwrt-ramips-mt7628-vmlinux-initramfs.bin

openwrt-ramips-mt7628-mt7628-squashfs-sysupgrade.bin openwrt-ramips-mt7628-vmlinux-initramfs.elf

openwrt-ramips-mt7628-root.jffs2-128k OpenWrt-SDK-ramips-mt7628_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2

openwrt-ramips-mt7628-root.jffs2-64k packages

openwrt-ramips-mt7628-root.squashfs sha256sums

做路由器应用开发并不需要整个源码环境,只要制作一个可以编译生成ipk的特定的SDK环境就好,恰巧openwrt配置提供了这样的选项功能。若要给应用开发人员提供SDK开发环境,只要在make menuconfig的时候选上:

[*] Build the OpenWrt SDK

make V=99编译之后,在bin/ramips/目录下生成OpenWrt-SDK-ramips-mt7628_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2,解压后目录和源码目录一样。

导出uboot.bin

为了防止uboot.bin被破坏而无法恢复的问题,可以把uboot.bin从Flash中导出来。可以采用如下的方法:

root@OpenWrt:/tmp# cat /proc/mtd

dev: size erasesize name

mtd0: 00030000 00010000 "u-boot"

mtd1: 00010000 00010000 "u-boot-env"

mtd2: 00010000 00010000 "factory"

mtd3: 007b0000 00010000 "firmware"

mtd4: 006bfd4b 00010000 "rootfs"

mtd5: 00300000 00010000 "rootfs_data"

root@OpenWrt:/tmp# dd if=/dev/mtdblock0 of=/tmp/uboot.bin

384+0 records in

384+0 records out

root@OpenWrt:/tmp# ln -s /tmp /www/tmp

root@OpenWrt:/tmp# ls -l

-rw-r--r-- 1 root root 196608 Jul 10 11:57 uboot.bin

root@OpenWrt:/tmp# md5sum uboot.bin

db70ae5ae66f6efbb7f334e71b95f1d0 uboot.bin

接着就可以利用scp命令上传出uboot.bin了。

Opkg

Opkg是一个轻量快速的套件管理系统,目前已成为Opensource界嵌入式系统标准。常用于路由、交换机等嵌入式设备中,用来管理软件包的安装升级与下载。

常用命令:

opkg update 更新可以获取的软件包列表

opkg upgrade 对已经安装的软件包升级

opkg list 获取软件列表

opkg install 安装指定的软件包

opkg remove 卸载已经安装的指定的软件包

参考文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值