@cyysu
2017-11-17T07:57:16.000000Z
字数 8270
阅读 1461
- 时间:2017年11月6日10:32:34
- 作者:Kali
- 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
- 版本:4.0
- 描述:测试openwrt
路由器开发
本文编译遇到的所有问题均已经解决,出错问题的解决方案均在路由器开发目录下。
务必源码存放路径为英文路径,不要带有中文
务必源码存放路径为英文路径,不要带有中文
务必源码存放路径为英文路径,不要带有中文
编译机器环境
mj@DZ:~$ cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
mj@DZ:~$ cat /proc/version
Linux version 4.10.0-37-generic (buildd@lgw01-amd64-037) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #41~16.04.1-Ubuntu SMP Fri Oct 6 22:42:59 UTC 2017
mj@DZ:~$
安装所需依赖软件包
sudo apt-get install subversion build-essential git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip
下载地址
git clone git://git.openwrt.org/openwrt.git
或者下面这个
git clone git://git.openwrt.org/15.05/openwrt.git
简介如下
* packages - 提供众多库、工具等基本功能;也是其他feed所依赖的软件源,因此在安装其他feed前一定要先安装packages!
* luci - OpenWrt默认的GUI(WEB管理界面)
* xwrt - 另一种可替换LuCI的GUI
* qpe - DreamBox维护的基于Qt的图形界面,包含Qt2,Qt4,Qtopia,OPIE,SMPlayer等众多图形界面。
* device - DreamBox维护与硬件密切相关的软件,如uboot,qemu等。
* dreambox_packages - DreamBox维护的国内常用网络工具,如oh3c,njit8021xclient等
* desktop -
* xfce - 基于Xorg的著名轻量级桌面环境。Xfce建基在GTK+2.x之上,它使用Xfwm作为窗口管理器。
* efl - 针对enlightenment
* phone - 针对fso, paroli
openwrt之间的依赖关系
packages --> luci
packages --> xwrt
packages --> qpe
packages --> device
packages --> dreambox_packages
packages --> desktop --> xfce
packages --> desktop --> efl --> phone
比如可以按照下面的安装方式进行安装,然后在进行install -a 操作
$ ./scripts/feeds install -p packages -a
$ ./scripts/feeds install -p xwrt -a
$ ./scripts/feeds install -p luci -a
$ ./scripts/feeds install -p desktop -a
$ ./scripts/feeds install -p efl -a
$ ./scripts/feeds install -p phone -a
如果想要安装某个软件包,如下面的方式蓝牙的地方
openwrt@DZ:~/openwrt$ ./scripts/feeds search bluetooth
Search results in feed 'packages':
bluelog Bluetooth scanner and logger
bluelog-live Bluetooth scanner and logger (live output)
bluez-daemon Bluetooth daemon
bluez-examples Bluetooth python example apps
bluez-libs Bluetooth library
bluez-utils Bluetooth utilities
gnunet-transport-bluetooth GNUnet bluetooth transport
hidapi Library to talk to HID devices
sbc sbc encoding library
然后我们就可以使用./scripts/feeds install 具体的包名
下面给出feeds详细的使用说明
openwrt@DZ:~/openwrt$ ./scripts/feeds
Usage: ./scripts/feeds <command> [options]
Commands:
list [options]: List feeds, their content and revisions (if installed)
Options:
-n : List of feed names.
-s : List of feed names and their URL.
-r <feedname>: List packages of specified feed.
-d <delimiter>: Use specified delimiter to distinguish rows (default: spaces)
-f : List feeds in feeds.conf compatible format (when using -s).
install [options] <package>: Install a package
Options:
-a : Install all packages from all feeds or from the specified feed using the -p option.
-p <feedname>: Prefer this feed when installing packages.
-d <y|m|n>: Set default for newly installed packages.
-f : Install will be forced even if the package exists in core OpenWrt (override)
search [options] <substring>: Search for a package
Options:
-r <feedname>: Only search in this feed
uninstall -a|<package>: Uninstall a package
Options:
-a : Uninstalls all packages.
update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
Options:
-a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
-i : Recreate the index only. No feed update from repository is performed.
clean: Remove downloaded/generated files.
其中feeds默认下载的链接地址如下
mj@DZ:/home/openwrt/openwrt$ cat feeds.conf.default
src-git packages https://github.com/openwrt/packages.git
src-git luci https://github.com/openwrt/luci.git
src-git routing https://github.com/openwrt-routing/packages.git
src-git telephony https://github.com/openwrt/telephony.git
src-git management https://github.com/openwrt-management/packages.git
src-git targets https://github.com/openwrt/targets.git
#src-git oldpackages http://git.openwrt.org/packages.git
#src-link custom /usr/src/openwrt/custom-feed
配置信息主要需要配置下面的信息。
配置主要包括 4 个部分
Target system(目标系统)
Package selection(软件包选择)
Build system settings(编译系统设置)
Kernel modules(内核模块配置)
详细的配置信息如下
Target System (x86) #目标平台选择
Target Images --->
[*] ext4 #生成.EXT4.IMG文件
Base system --->
<*> block-mount
<*> busybox ---> #用于今后`initramfs`支持,可以将所有lib编译到busybox
[*] Customize busybox options
Busybox Settings --->
General Configuration --->
[*] Support --install [-s] to install applet links at runtime
[*] Don't use /usr
Linux Module Utilities --->
[*] modinfo
[*] Simplified modutils
[*] Accept module options on modprobe command line
[*] Skip loading of already loaded modules
(/lib/modules) Default directory containing modules
Linux System Utilities --->
[*] mdev
[*] Support /etc/mdev.conf
[*] Support subdirs/symlinks
[*] Support regular expressions substitutions when renaming
[*] Support command execution at device addition/removal
[*] Support loading of firmwares
[*] findfs
[*] blkid
[*] Print filesystem type
[*] losetup
[*] lspci
[*] lsusb
[*] mount
[*] Support specifying devices by label or UUID
Filesystem/Volume identification --->
[*] Ext filesystem
[*] fat filesystem
Networking Utilities --->
[*] ftpd
[*] Enable upload commands
[*] Enable workaround for RFC-violating clients
[*] inetd
[*] telnetd
[*] Support standalone telnetd (not inetd only)
[*] tcpsvd
[*] udpsvd
`kernel` modules --->
Block Devices --->
<*> kmod-ata-core
<*> kmod-ata-ahci
<*> kmod-loop
-*- kmod-scsi-core
<*> kmod-scsi-generic
Filesystems --->
<*> kmod-fs-ext4
<*> kmod-fs-ntfs
<*> kmod-fs-vfat
Input modules --->#键盘
-*- kmod-hid
<*> kmod-hid-generic
-*- kmod-input-core
-*- kmod-input-evdev
Native Language Support --->
<*> kmod-nls-cp437 #vfat需要这个
<*> kmod-nls-iso8859-1
<*> kmod-nls-utf8
Network Devices ---> #网卡驱动
<*> kmod-macvlan
USB Support --->
-*- kmod-usb-core
<*> kmod-usb-hid #usb键盘
<*> kmod-usb-ohci
<*> kmod-usb-storage
<*> kmod-usb2
<*> kmod-usb3
Wireless Drivers --->#wifi卡驱动
Network --->
<*> hostapd #wifi ap模式
<*> hostapd-common
<*> hostapd-utils
<*> wpa-supplicant
Utilities --->#自选 fdisk等
于此同时我们还可以单独对内核进行配置。
make kernel_menuconfig
Processor type and features --->
[*] Symmetric multi-processing support
Processor family (Core 2/newer Xeon) --->#自行选择处理器平台
[*] Supported processor vendors --->#自行选择处理器平台
(2) Maximum number of CPUs #自行编辑
[*] SMT (Hyperthreading) scheduler support#超线程支持
[*] Multi-core scheduler support
High Memory Support (4GB) --->
如果想要更换内核版版本可以如下这么做
链接地址:http://blog.csdn.net/flexman09/article/details/51862858
直接修改include/prereq-build.mk这个文件,在最新的版本中已经去掉这个限制了。
mj@DZ:/home/openwrt/openwrt$ ls
bin Config.in feeds.conf.default LICENSE rules.mk tmp
BSDmakefile dl include Makefile scripts toolchain
build_dir docs key-build package staging_dir tools
config feeds key-build.pub README target
# 查看对应的目标平台
mj@DZ:/home/openwrt/openwrt$ ls bin/x86/
md5sums openwrt-x86-64-rootfs-squashfs.img
openwrt-x86-64-combined-ext4.img.gz openwrt-x86-64-vmlinuz
openwrt-x86-64-combined-squashfs.img packages
openwrt-x86-64-generic-rootfs.tar.gz sha256sums
openwrt-x86-64-rootfs-ext4.img.gz
mj@DZ:/home/openwrt/openwrt$
make toolchain/clean V=99 -j
make toolchain/compile V=99 -j
具体解决方法连接如下:
http://see.sl088.com/wiki/Openwrt_%E7%BC%96%E8%AF%91toolchain%E5%87%BA%E9%94%99
如果出现这个问题那么可以按照下图操作一下。
将其中文件夹下的软件应用程序复制到指定目录下面。出现这个问题的原因可能是编译成功一次之后有些内容不会重新编译,这样有些文件他又需要用到,就造成了文件找不到。
如果出现下面这个情况,你用root用户去编译就可以。但是在没有出现之前不要用root用户去编译,原因是你的openwrt源码可能是不允许root编译。
如果以上无法解决问题,可以尝试清除编译文件,然后重新编译。
# 如果需要用到将img文件格式文件转换为vmware虚拟机的格式,可以采用如下方式转换
qemu-img convert -f raw openwrt-15.05-x86.img -O vmdk openwrt.vmdk
编译过程还是比较顺利的,中间遇到几次下载文件出错的问题,所以这里建议大家在进行编译的时候采用make V=99进行编译,同时建议最好不要用make -j参数进行编译。下面我给出我这里编译成功的完整openwrt。
我这边测试时用VMware去启动怎么都启动不了,但是通过做U盘镜像的方式在电脑上运行就可以运行。这个原因目前还不知道,虚拟机中一直停留在下面这个界面。后面继续了解openwrt之后再更新这里。
启动u盘做出来之后的效果是下图这样,记住不要格式化之后的启动盘。
那么上图的10M和48M这空间是如何划分的呢?我们看一下我们menuconfig的界面
也就是说这个10M是内核大小空间,48M是根文件系统大小。
登录界面如下
当我们登录系统之后先设置完ip地址,首先让这个路由器先上网。我这里演示的也是先配置完ip,在做的教程记录。
# 网络配置
root@OpenWrt:~# cat /etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fdf2:a041:a1ba::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'dhcp'
然后就是配置一下我们的web界面,如果你在编译的时候没有安装,那么我们可以等路由器连上网之后我们在进行下载安装。详细的步骤如下:
# 依次执行下面命令
opkg update
opkg install luci
/etc/init.d/uhttpd start
root@OpenWrt:~# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:20001 0.0.0.0:* LISTEN 2573/autossh
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4897/uhttpd
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 2515/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1352/dropbear
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 5701/dropbear
tcp 0 0 :::80 :::* LISTEN 4897/uhttpd
tcp 0 0 :::53 :::* LISTEN 2515/dnsmasq
tcp 0 0 :::22 :::* LISTEN 1352/dropbear
udp 0 0 0.0.0.0:53 0.0.0.0:* 2515/dnsmasq
udp 0 0 0.0.0.0:5353 0.0.0.0:* 1440/avahi-daemon:
udp 0 0 :::53 :::* 2515/dnsmasq
udp 0 0 :::547 :::* 1303/odhcpd
udp 0 0 :::5353 :::* 1440/avahi-daemon:
执行完之后我们就可以登录我们的web界面了
下面就是我们的开发了。这个就单独另外写一篇文章进行整理了。
支付宝 微信