openwrt 中 make menuconfig, Imagebuilder

http://aboutchen.org/blog/compile-c-code-for-openwrt/


官方参考: https://dev.openwrt.org/wiki/GetSource

OpenWrt
 source repository downloads

You can either check out the OpenWrt source code via git or svn.

GIT

The recommended way of checking out the OpenWrt source code is cloning the Git repository using one of the following commands:

trunk (main development tree)
  • Main repository
    git clone git://git.openwrt.org/openwrt.git
    
14.07 branch (Barrier Breaker)
  • Main repository
    git clone git://git.openwrt.org/14.07/openwrt.git
    
12.09 branch (Attitude Adjustment)
  • Main repository
    git clone git://git.openwrt.org/12.09/openwrt.git
    
  • Packages feed
    git clone git://git.openwrt.org/12.09/packages.git
    

SVN

You can checkout the source from the OpenWrt Subversion repository using one of the following commands:

  • Development branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/trunk/
    
  • Barrier Breaker 14.07 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/barrier_breaker
    
  • Attitude Adjustment 12.09 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/attitude_adjustment
    
  • Backfire 10.03 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/backfire
    
  • Kamikaze 8.09 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/branches/8.09
    
  • Kamikaze 7.09 branch: ChangeLog
    svn co svn://svn.openwrt.org/openwrt/tags/kamikaze_7.09

#稳定分支版本 attitude_adjustment/12.09, 内核3.3.8, org.cn有镜像. 若在windows的共享目录下操作有N种意想不到的错误, 以下操作都在~目录
mkdir openwrt
cd openwrt
git clone git://git.openwrt.org/12.09/openwrt.git
svn co svn://svn.openwrt.org.cn/openwrt/branches/attitude_adjustment
cd  attitude_adjustment
./scripts/feeds update -a
./scripts/feeds install -a

make menuconfig: 界面中选择如下
Target System 选(Atheros AR7xxx/AR9xxx)
Target Profile 选(TP-LINK TL-WR703N)

Package features 选 umontu
Base system:  选中 librt, libpthread, block-mount
    <*> busybox:
    Linux System Utilities:
    <*> lsusb
    Editor: 
    <*> diff

Kernel modules: 此部分与内核版本紧密相关, 如下
   Depends: kernel (=3.2.14-1-eb30a01493673f9c92acd8243277c304), kmod-i2c-core
  Filesystem: kmod-fs-vfat, kmod-fs-ntfs, kmod-fs-ext4
  Native Language Support: 选 kmod-nls-utf8
 I2C support: 选kmod-i2c-core 
 other: 选中 kmod-input-core(r42647移到别的位置了)
  SPI Support: 选中 kmod-spi-gpio
 Sound Support: 选中kmod-sound-core, kmod-usb-audio
 usb support: 选 kmod-usb-ohci、kmod-usb-storage、kmod-usb-storage-extras、kmod- usb-uhci、kmod-usb-video、 kmod-usb2, kmod-usb-hid, kmod-usb-serial(下面的子 项目都选吧, 调试外设备用),  (新版本无kmod-usb-video? )
 video support: 选 kmod-video-core、kmod-video-uvc, kmod-video-gspca-core, kmod-video-gspca-zc3xx 
  w1 support: 全选
  wireless support: kmod-rtl8187, 后面带USB的全选

luci:  第1项 collections选luci,第5项Translate里选上luci-i18n-chinese
Multimedia: 选 mjpg-streamer

netwokr:
  FileSystem: 选 owftd, owhttp, owserver

Utilities: 
   Fielsystem: 选 Fuse-utils, owfs, owshell. 



attitude adjustment 版本


make defconfig
make clean
rm -rf ./tmp      #如果以前编译过一次,删除./tmp目录及该目录下的所有文件
#此时可以把备份的同版本的dl目录拷贝到本目录下的dl目录下, 可以大大加快编译的速度

xxg@xxg-desktop:~/openwrt/r31296/trunk$ make -j 2
 make[1] world
 make[2] target/compile
 make[3] -C target/linux compile
 make[2] package/cleanup
 make[2] package/compile
 make[3] -C package/opkg host-compile
 make[3] -C package/busybox compile
 make[3] -C package/libnl-tiny compile
 make[3] -C package/dnsmasq compile
 make[3] -C package/dropbear compile
 make[3] -C feeds/luci/freifunk-common compile
 make[3] -C feeds/packages/net/olsrd compile
 make[3] -C package/iptables compile
 make[3] -C package/iproute2 compile
 make[3] -C feeds/luci/freifunk-mapupdate compile
 make[3] -C package/lua compile
 make[3] -C package/lua host-compile
 make[3] -C package/px5g compile
 make[3] -C package/uci compile
 make[3] -C package/uhttpd compile
 make[3] -C package/libtool compile
 make[3] -C package/fuse compile
 make[3] -C package/gpio-button-hotplug compile
 make[3] -C package/hostapd compile
 make[3] -C package/hotplug2 compile
 make[3] -C package/iw compile
 make[3] -C package/kernel compile
 make[3] -C package/libjson-c compile
 make[3] -C package/wireless-tools compile
 make[3] -C package/mtd compile
 make[3] -C package/opkg compile
 make[3] -C package/libpcap compile
 make[3] -C package/linux-atm compile
 make[3] -C package/swconfig compile
 make[3] -C package/zlib compile
 make[3] -C package/w1-gpio-custom compile
 make[3] -C package/base-files-network compile
 make[3] -C package/crda compile
 make[3] -C feeds/luci/community-profiles compile
 make[3] -C package/firewall compile
 make[3] -C package/iwinfo compile
 make[3] -C feeds/packages/libs/jpeg compile
 make[3] -C package/libubox compile
 make[3] -C package/mac80211 compile
 make[3] -C package/ppp compile
 make[3] -C package/uboot-envtools compile
 make[3] -C package/ubus compile
 make[3] -C package/base-files compile
 make[3] -C feeds/luci/freifunk-gwcheck compile
 make[3] -C feeds/packages/multimedia/mjpg-streamer compile
 make[3] -C feeds/luci/luci compile
 make[2] package/install
 make[3] -C package/base-files-network install
 make[3] -C package/busybox install
 make[3] -C package/crda install
 make[3] -C package/dnsmasq install
 make[3] -C package/dropbear install
 make[3] -C feeds/luci/luci install
 make[3] -C package/firewall install
 make[3] -C package/gpio-button-hotplug install
 make[3] -C package/hostapd install
 make[3] -C package/hotplug2 install
 make[3] -C package/iptables install
 make[3] -C package/iw install
 make[3] -C package/kernel install
 make[3] -C package/libnl-tiny install
 make[3] -C package/mac80211 install
 make[3] -C package/mtd install
 make[3] -C package/opkg install
 make[3] -C package/ppp install
 make[3] -C package/swconfig install
 make[3] -C package/uboot-envtools install
 make[3] -C package/uci install
 make[3] -C package/wireless-tools install
 make[3] -C package/base-files install
 make[2] package/rootfs-prepare
 make[3] package/preconfig
 make[2] target/install
 make[3] -C target/linux compile
 make[3] -C target/linux install
 make[3] -C target/imagebuilder compile
 make[3] -C target/imagebuilder install
 make[2] package/index
xxg@xxg-desktop:~/openwrt/r31296/trunk$ 

#2014-11-18重新编译AA版本, make 不带-j的参数, 以避免发生意想不到的错误. 
xxg@EmbeddedLab:~/openwrt/attitude_adjustment$ make clean
 make[1] clean
 make[2] target/linux/clean
 make[3] -C target/linux clean

xxg@EmbeddedLab:~/openwrt/attitude_adjustment$ make
 make[1] world
 make[2] target/compile
 make[3] -C target/linux compile
 make[2] package/cleanup
 make[2] package/compile
 make[3] -C package/toolchain compile
 make[3] -C package/libnl-tiny compile
 make[3] -C package/libjson-c compile
 make[3] -C package/lua compile
 make[3] -C package/libubox compile
 make[3] -C package/ubus compile
 make[3] -C package/uci compile
 make[3] -C package/netifd compile
 make[3] -C package/opkg host-compile
 make[3] -C package/base-files compile
 make[3] -C package/ncurses compile
 make[3] -C package/util-linux compile
 make[3] -C package/block-mount compile
 make[3] -C package/busybox compile
 make[3] -C package/dnsmasq compile
 make[3] -C package/dropbear compile
 make[3] -C feeds/luci/freifunk-common compile
 make[3] -C feeds/luci/community-profiles compile
 make[3] -C feeds/routing/olsrd compile
 make[3] -C package/iptables compile
 make[3] -C package/firewall compile
 make[3] -C package/iproute2 compile
 make[3] -C feeds/luci/freifunk-gwcheck compile
 make[3] -C feeds/luci/freifunk-mapupdate compile
 make[3] -C package/iwinfo compile
 make[3] -C package/lua host-compile
 make[3] -C package/px5g compile
 make[3] -C package/uhttpd compile
 make[3] -C feeds/luci/luci compile
 make[3] -C package/libtool compile
 make[3] -C feeds/packages/libs/jpeg compile
 make[3] -C package/uclibc++ compile
 make[3] -C feeds/packages/libs/libusb compile
 make[3] -C feeds/packages/multimedia/mjpg-streamer compile
 make[3] -C package/fuse compile
 make[3] -C package/librpc compile
 make[3] -C feeds/packages/utils/owfs compile
 make[3] -C package/gpio-button-hotplug compile
 make[3] -C package/hostapd compile
 make[3] -C package/hotplug2 compile
 make[3] -C package/iw compile
 make[3] -C package/kernel compile
 make[3] -C package/mac80211 compile
 make[3] -C package/mtd compile
 make[3] -C package/opkg compile
 make[3] -C package/libpcap compile
 make[3] -C package/linux-atm compile
 make[3] -C package/resolveip compile
 make[3] -C package/ppp compile
 make[3] -C package/swconfig compile
 make[3] -C package/uboot-ar71xx compile
 make[3] -C package/zlib compile
 make[3] -C package/uboot-envtools compile
 make[3] -C package/w1-gpio-custom compile
 make[2] package/install
 make[3] -C package/busybox install
 make[3] -C package/dnsmasq install
 make[3] -C package/dropbear install
 make[3] -C package/firewall install
 make[3] -C package/gpio-button-hotplug install
 make[3] -C package/hostapd install
 make[3] -C package/hotplug2 install
 make[3] -C package/iptables install
 make[3] -C package/iw install
 make[3] -C package/kernel install
 make[3] -C package/libjson-c install
 make[3] -C package/libnl-tiny install
 make[3] -C package/libubox install
 make[3] -C package/mac80211 install
 make[3] -C package/mtd install
 make[3] -C package/netifd install
 make[3] -C package/opkg install
 make[3] -C package/ppp install
 make[3] -C package/swconfig install
 make[3] -C package/toolchain install
 make[3] -C package/uboot-ar71xx install
 make[3] -C package/uboot-envtools install
 make[3] -C package/ubus install
 make[3] -C package/uci install
 make[3] -C package/base-files install
 make[2] package/rootfs-prepare
 make[3] package/preconfig
 make[2] target/install
 make[3] -C target/linux install
 make[3] -C target/imagebuilder install
 make[3] -C target/toolchain install
 make[2] package/index
xxg@EmbeddedLab:~/openwrt/attitude_adjustment$ 

--------------------------------------------------------------------------------------------------------------------
Image Builder, 快速固件生成器, 用此创建固件可以省去重新编译的麻烦,大大缩短编译时间。
利用 Imagebuilder 可以生成自己所需要的固件, 告别和别人伸手乞讨固件的磨练

1. mkdir ImageBuilder-ar71xx
2. cd ImageBuilder-ar71xx
     OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2, 利用winscp 将本文件传到本目录下
3. 解压
tar jxvf OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2

4. 进入目录
cd OpenWrt-ImageBuilder-ar71xx-for-Linux-i686

5. 查看可编译的路由型号
make info
#比如703N, 可以看到如下信息
TLWR703:
TP-LINK TL-WR703N
Packages: kmod-usb-core kmod-usb2

6. 将自己的配置文件 放在本目录下, 比如我自己的目录就是 wr703n
   有 /etc/config, /etc/init.d, ...(此部分可以从好用的路由器上用winscp备份出来即可)
   比如配置wireless,只需把备份出来的wireless复制到config就可以了
 保留root密码: password和shadow 放在 /etc 目录下
   同时packages 目录下可以看到已经带的ipk安装包
   
7. 生成指定路由型号, 在 bin/ar71xx 目录下可以看到自己所生产的固件. 这里就是你大展伸手的地方
  PACKAGES 选项中加上自己所需要的安装包, FILES 选项中加上自己的配置文件
#还是以703N为例, 
#最精简的固件, 也就是官网上的, 但配置部分已经是自己的了
make image PROFILE=TLWR703 FILES=wr703n

#只加上luci和
make image PROFILE=TLWR703 PACKAGES="luci" FILES=wr703n

#usb 摄像头, 新版本好像无kmod-usb-video, 摄像头必须有 kmod-video-core, kmod-video-uvc
make image PROFILE=TLWR703 PACKAGES="librt libpthread libjpeg kmod-nls-utf8 kmod-i2c-core kmod-input-core kmod-usb-ohci kmod-usb-storage kmod-usb-storage-extras kmod-usb-uhci kmod-video-core kmod-video-uvc mjpg-streamer" FILES=wr703n

#增加 usb hid: kmod-usb-hid kmod-hid kmod-input-evdev
make image PROFILE=TLWR703 PACKAGES="librt libpthread libjpeg kmod-nls-utf8 kmod-i2c-core kmod-input-core kmod-usb-ohci kmod-usb-storage kmod-usb-storage-extras kmod-usb-uhci kmod-video-core kmod-video-uvc mjpg-streamer kmod-usb-hid kmod-hid kmod-input-evdev" FILES=wr703n

#增加中微星 kmod-video-gspca-core kmod-video-gspca-zc3xx
make image PROFILE=TLWR703 PACKAGES="librt libpthread libjpeg kmod-nls-utf8 kmod-i2c-core kmod-input-core kmod-usb-ohci kmod-usb-storage kmod-usb-storage-extras kmod-usb-uhci kmod-video-core kmod-video-uvc kmod-video-gspca-core kmod-video-gspca-zc3xx mjpg-streamer kmod-usb-hid kmod-hid kmod-input-evdev" FILES=wr703n

#8M专用: luci,中文语言包,DDNS,硬盘休眠,openvpn,打印服务器,QOS,samba,upnp,relay,网络唤醒,USB挂载,硬盘格式支持(ntfs-3g/ext4/ntfs),UTF8编码,USB扩展支持,USB驱动,复位键支持,transmission下载工具.

make image PROFILE=TLWR703 PACKAGES="block-mount librt libpthread luci luci-i18n-chinese luci-app-ddns luci-proto-3g luci-app-hd-idle luci-app-p910nd luci-app-qos luci-app-samba luci-app-upnp luci-app-wol openvpn openvpn-easy-rsa kmod-scsi-core kmod-scsi-generic kmod-fs-ext4 kmod-fs-ntfs kmod-fs-vfat kmod-nls-utf8 kmod-usb-storage-extras kmod-usb-ohci kmod-usb-storage kmod-usb-uhci kmod-usb-acm kmod-usb-serial kmod-usb-serial-ftdi kmod-usb-serial-pl2303 kmod-video-core kmod-video-uvc kmod-video-gspca-core kmod-video-gspca-zc3xx mjpg-streamer ser2net badblocks restorefactory coreutils transmission-daemon transmission-remote transmission-web vsftpd" FILES=wr703n


http://cadenwu.blog.chinaunix.net/uid-27194309-id-3408165.html


======================

1.1 Root无密码时: 可用HFS构建HTTP文件服务器. 如:http://192.168.1.224/wr703n-eok.bin, 然后CMD命令窗口中输入命令:
telnet 192.168.1.1
cd /tmp
wget http://192.168.1.224/wr703n-eok.bin
1.2 Root有密码时: 先将固件用winscp上传到/tmp/下或者用上面的wget命令, 然后用putty或者securecrt登陆路由器
2. mtd -r write /tmp/固件.bin firmware, 成功后会出现 rebooting...

注: dd下用 linux,openwrt下用 firmware


#--- mtd 源码中的相关部分:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
static void usage( void )
{
     fprintf (stderr, "Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]\n\n"
     "The device is in the format of mtdX (eg: mtd4) or its label.\n"
     "mtd recognizes these commands:\n"
     "        unlock                  unlock the device\n"
     "        refresh                 refresh mtd partition\n"
     "        erase                   erase all data on device\n"
     "        write <imagefile>|-     write <imagefile> (use - for stdin) to device\n"
     "        jffs2write <file>       append <file> to the jffs2 partition on the device\n" );
     if (mtd_fixtrx) {
         fprintf (stderr,
     "        fixtrx                  fix the checksum in a trx header on first boot\n" );
     }
     fprintf (stderr,
     "Following options are available:\n"
     "        -q                      quiet mode (once: no [w] on writing,\n"
     "                                           twice: no status messages)\n"
     "        -n                      write without first erasing the blocks\n"
     "        -r                      reboot after successful command\n"
     "        -f                      force write without trx checks\n"
     "        -e <device>             erase <device> before executing the command\n"
     "        -d <name>               directory for jffs2write, defaults to \"tmp\"\n"
     "        -j <name>               integrate <file> into jffs2 data when writing an image\n" );
     if (mtd_fixtrx) {
         fprintf (stderr,
     "        -o offset               offset of the image header in the partition(for fixtrx)\n" );
     }
     fprintf (stderr,
#ifdef FIS_SUPPORT
     "        -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
     "                                alter the fis partition table to create new partitions replacing\n"
     "                                the partitions provided as argument to the write command\n"
     "                                (only valid together with the write command)\n"
#endif
     "\n"
     "Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
     "         mtd -r write linux.trx linux\n\n" );
     exit (1);
}

1
 


Opkg 是一个轻量快速的套件管理系统,目前已成为 Opensource 界嵌入式系统标准。

常用于路由、交换机等嵌入式设备中,用来管理软件包的安装升级与下载。常用命令如下:
opkg update 更新可以获取的软件包列表 
opkg upgrade 对已经安装的软件包升级
opkg install 安装指定的软件包
opkg instal /tmp/xxx.ipk
opkg install http://openwrt.8800.org:82/nwan.ipk
opkg install http://openwrt.8800.org/luci-app-nwan.ipk
opkg install --force-reinstall http://192.168.1.224/uhttpd_32_ar71xx.ipk
opkg remove 卸载已经安装的指定的软件包. opkg remove luci-i18n-chinese
opkg list
opkg list-installed


Force Options:
--force-depends         Install/remove despite failed dependencies
--force-maintainer      Overwrite preexisting config files
--force-reinstall       Reinstall package(s)
--force-overwrite       Overwrite files from other package(s)
--force-downgrade       Allow opkg to downgrade packages
--force-space           Disable free space checks
--force-postinstall     Run postinstall scripts even in offline mode
--force-remove  Remove package even if prerm script fails
--noaction              No action -- test only
--download-only No action -- download only
--nodeps                Do not follow dependencies
--force-removal-of-dependent-packages
                       Remove package and all dependencies
--autoremove            Remove packages that were installed
                       automatically to satisfy dependencies
-t                      Specify tmp-dir.
--tmp-dir               Specify tmp-dir.


一般我们在openwrt下用opkg安装软件有两种:
1. 连上网络后从官方网站安装 opkg update; opkg install XXX.ipk;
opkg install http://openwrt.8800.org/luci-app-nwan.ipk
2. PC上把软件下载下来,传到路由器tmp目录安装 opkg install /tmp/XXX.ipk


对于1来说,如果路由暂时上不了网,就无法使用,方法2又有些麻烦. 这里提供的方法是:
1. 修改/etc/opkg.conf, 把里边第一行那个网址改成本地服务器放安装包的服务目录, 
    #src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
    src/gz snapshots http://192.168.1.224/packages-r31296
2. 把相关的 packages 目录下的文件都放在上步定义的目录下(packages-r31296为目录名)
3. 在本机上用 HTS 开启http服务, 添加上面的目录
4. 现在可以像方法1一样使用升级了


工作图片如下: 


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值