2015年8月

OpenWrt Buildroot – About 编译过程

OpenWrt Buildroot is a set of Makefiles and patches that allows users to easily generate both a cross-compilation toolchain and a root filesystem for embedded systems. It is a heavily modified Buildroot. The cross-compilation toolchain uses uClibc, a tiny C standard library.

A compilation toolchain is the set of tools used to compile code for your system. It consists of:

◾ a compiler (in our case, gcc / deb: gcc)
◾ binary utils like assembler and linker (in our case, binutils / deb: binutils )
◾ a C standard library (for example GNU Libc, uClibc or dietlibc).

Using a PC, the compilation toolchain runs on an x86 processor and generates code for a x86 processor. On most Linux systems, the compilation toolchain uses the GNU libc as C standard library. It is called the "host compilation toolchain", and the machine it is running on is called the "host system". The compilation toolchain is provided by the distribution, and has nothing to do with OpenWrt Buildroot.

Embedded systems use a different processor and require a cross-compilation toolchain - a compilation toolchain that runs on a host system but that generates code for a target system (and target processor's instruction set architecture (ISA)). For example, if your host system uses x86 and your target system uses MIPS32, the regular compilation toolchain of your host runs on x86 and generates code for x86, while the cross-compilation toolchain runs on x86 and generates code for MIPS32.

While it is possible to manually configure and compile your own software, OpenWrt Buildroot automates this process to work on the instruction set architecture of most embedded systems.

While the OpenWrt Buildroot was designed for developers, inexperienced users can also use it to easily build their own custom firmware!

The OpenWrt Makefile has its own syntax, different from the conventional Makefile of Linux make tool. The OpenWrt Makefile defines the meta information of the package, where to download the package, how to compile, where to install the compiled binaries, etc. See How to Build OpenWrt Application Package for more detail.

OpenWrt Buildroot – Features
◾ Makes it easy to port software
◾ Uses kconfig (Linux Kernel menuconfig) for configuration of features
◾ Provides integrated cross-compiler toolchain (gcc, ld, …)
◾ Provides abstraction for autotools (automake, autoconf), cmake, scons
◾ Handles standard download, patch, configure, compile and packaging workflow
◾ Provides a number of common fixups for badly behaving packages

OpenWrt Buildroot – Make Targets
◾ Offers a number of high level make targets for standard package workflows
◾ Targets always in the format "component/name/action", e.g. "toolchain/gdb/compile" or "package/mtd/install"
◾ Prepare a package source tree: package/foo/prepare
◾ Compile a package: package/foo/compile
◾ Clean a package: package/foo/clean

OpenWrt Buildroot – Build sequence

  1. tools – automake, autoconf, sed, cmake
  2. toolchain/binutils – as, ld, …
  3. toolchain/gcc – gcc, g++, cpp, …
  4. target/linux – kernel modules
  5. package – core and feed packages
  6. target/linux – kernel image
  7. target/linux/image – firmware image file generation

Patch management
◾ Many packages will not work as-is and need patches to work on the target or to even compile
◾ OpenWrt Buildroot integrates quilt for easy patch management
◾ Turn package patches into quilt series: make package/foo/prepare QUILT=1
◾ Update patches from modified series: make package/foo/update
◾ Automatically rebase patches after an update: make package/foo/refresh

Packaging considerations
◾ Main objective is small memory and size footprint
◾ Features that make no sense on embedded systems get disabled through configure or are patched out
◾ Packages must be compilable regardless of the host system, should be self contained
◾ Shipped "configure" scripts are often faulty or unusable in a cross-compile setting, autoreconf or patching needed
◾ Build variants and kconfig includes allow for configurable compile-time settings
◾ There is no standard way for porting software, in many cases it "just works" but often the package build process needs tweaks

本文章由http://www.wifidog.pro/2015/08/07/openwrt-%E7%BC%96%E8%AF%91%E8%BF%87%E7%A8%8B.html整理编辑,转载请注明出处

openwrt 配置文件功能简介

配置文件

文件位置 描述
基本配置

/etc/config/dhcp    dnsmasq和DHCP的配置
/etc/config/dropbear    SSH服务端选项
/etc/config/firewall    中央防火墙配置
/etc/config/network 交换,接口和路由配置
/etc/config/system  杂项与系统配置
/etc/config/timeserver  rdate的时间服务器列表
/etc/config/wireless    无线设置和无线网络的定义

IPv6

/etc/config/ahcpd   Ad-Hoc配置协议(AHCP) 服务端配置以及转发器配置
/etc/config/aiccu   AICCU 客户端配置
/etc/config/dhcp6c  WIDE-DHCPv6 客户端配置
/etc/config/dhcp6s  WIDE-DHCPv6 服务端配置
/etc/config/gw6c    GW6c 客户端配置
/etc/config/radvd   路由通告 (radvd) 配置

其他

/etc/config/etherwake   以太网唤醒: etherwake
/etc/config/fstab   挂载点及swap
/etc/config/hd-idle 另一个可选的硬盘空闲休眠进程(需要路由器支持usb硬盘)
/etc/config/httpd   网页服务器配置选项(Busybox 自带httpd, 已被舍弃)
/etc/config/luci    基础 LuCI 配置
/etc/config/luci_statistics 包统计配置
/etc/config/mini_snmpd  mini_snmpd 配置
/etc/config/mountd  OpenWrt 自动挂载进程(类似autofs)
/etc/config/multiwan    简单多WAN出口配置
/etc/config/ntpclient   ntp客户端配置,用以获取正确时间
/etc/config/pure-ftpd   Pure-FTPd 服务端配置
/etc/config/qos QoS配置(流量限制与整形)
/etc/config/samba   samba配置(Microsoft文件共享)
/etc/config/snmpd   SNMPd(snmp服务进程) 配置
/etc/config/sshtunnel   sshtunnel配置
/etc/config/stund   STUN 服务端配置
/etc/config/transmission    BitTorrent配置
/etc/config/uhttpd  Web服务器配置(uHTTPd)
/etc/config/upnpd   miniupnpd UPnP服务器配置
/etc/config/ushare  uShare UPnP 服务器配置
/etc/config/vblade  vblade 用户空间AOE(ATA over Ethernet)配置
/etc/config/vnstat  vnstat 下载器配置
/etc/config/wifitoogle  使用按钮来开关WiFi的脚本
/etc/config/wol Wake-on-Lan: wol
/etc/config/znc ZNC 配置

本文章由http://www.wifidog.pro/2015/08/05/openwrt%E9%85%8D%E7%BD%AE.html整理编辑,转载请注明出处

openwrt TTL uboot刷机

Openwrt常用烧写命令
AR系列分区地址
4M flash的分区地址:

分区名        起始地址        结束地址         分区长度
uboot        0x9f000000    0x9f020000     0x20000
firmware     0x9f020000    0x9f3e0000     0x3c0000
art          0x9f3f0000    0x9f3e0000     0x10000

8M flash的分区地址:

分区名        起始地址        结束地址         分区长度
uboot        0x9f000000    0x9f020000     0x20000
firmware     0x9f020000    0x9f7e0000     0x7c0000
art          0x9f7f0000    0x9f7e0000     0x10000

16M flash的分区地址:

分区名        起始地址        结束地址         分区长度
uboot        0x9f000000    0x9f020000     0x20000
firmware     0x9f020000    0x9ffe0000     0xfc0000
art          0x9fff0000    0x9ffe0000     0x10000

1.命令行刷系统
固件传至/tmp:

cd /tmp
cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00010000 “u-boot”
mtd1: 000e01c4 00010000 “kernel”
mtd2: 002efe3c 00010000 “rootfs”
mtd3: 00060000 00010000 “rootfs_data”
mtd4: 00010000 00010000 “art”
mtd5: 003d0000 00010000 “firmware”

从上面的命令可以得知,mtd5是 firmare
使用mtd更新系统

mtd -r write factory.bin firmware

使用sysupgrade更新系统,推荐。

sysupgrade factory.bin

2.ttl刷新编程器固件、fw、uboot、art
4M的:
刷编程器固件:

tftp 0x80000000 full.bin  (可能 printenv 地址不是0x80000000,没有关系)
erase 0x9f000000 +0x400000
cp.b 0x80000000 0x9f000000 0x400000

刷uboot:

tftp 0x80000000 uboot.bin
erase 0x9f000000 +0x20000
cp.b 0x80000000 0x9f000000 0x20000

刷fw:

tftp 0x80000000 fw.bin
erase 0x9f020000 +0x3c0000
cp.b 0x80000000 0x9f020000 0x3c0000

刷art:

tftp 0x80000000 art.bin
erase 0x9f3f0000 +0x10000
cp.b 0x80000000 0x9f3f0000 0x10000

8M的:
刷编程器全部固件(uboot+fs+art):

tftp 0x80000000 full.bin
erase 0x9f000000 +0x800000
cp.b 0x80000000 0x9f000000 0x800000

刷uboot:

tftp 0x80000000 uboot.bin
erase 0x9f000000 +0x20000
cp.b 0x80000000 0x9f000000 0x20000

刷fw:

tftp 0x80000000 fw.bin
erase 0x9f020000 +0x7c0000
cp.b 0x80000000 0x9f020000 0x7c0000

刷art:

tftp 0x80000000 art.bin
erase 0x9f7f0000 +0x10000
cp.b 0x80000000 0x9f7f0000 0x10000

16M:

FW:
tftp 0x80000000 fw.bin
erase 0x9f020000 +0xfc0000
cp.b 0x80000000 0x9f020000 0xfc0000

本文章由http://www.wifidog.pro/2015/08/04/openwrt-uboot%E5%88%B7%E6%9C%BA.html整理编辑,转载请注明出处

OpenWrt Buildroot 基础教程

Prerequisites

to generate an installable OpenWrt firmware image file with a size of e.g. 8MB:

Install OpenWrt Buildroot and its prerequisites on your OS.
ca. 3-4 GB of available hard disk space
environment variables:
SED should not be set. If it is, run unset SED before compiling. (See Ticket 10612.)
GREP_OPTIONS should not have –initial-tab or other options affecting its output
Add /staging_dir/host/bin and /staging_dir/toolchain---/bin in front of your PATH variable in ~/.bashrc. The staging directory is created shortly after starting the build and the toolchain directory is created when the toolchain build begins. The build spawns multiple shells, some of which expect the toolchain binaries to be present in the PATH.
Procedure

  1. Update OpenWrt sources.
  2. Update and install package feeds.
  3. Configure the firmware image you want to obtain.
  4. Start the build. This will automatically compile toolchain,cross-compile sources, package packages, and finally generate an image ready to be flashed.
  5. Proceed to Installing OpenWrt

Updating Sources with Git

git pull

Updating Feeds
Update feeds:

./scripts/feeds update -a

Make downloaded package/packages available in make menuconfig:
single package:

./scripts/feeds install <PACKAGENAME>

all packages:

./scripts/feeds install -a

Image Configuration
Typical actions:

  1. run make menuconfig and set target;
  2. run make defconfig;
  3. run make menuconfig and modify set of package;
  4. run scripts/diffconfig.sh >mydiffconfig (save your changes in the
    text file mydiffconfig);
  5. run make V=s (build OpenWRT with console logging, you will look
    where build failed.).

Make menuconfig
The OpenWrt Buildroot configuration interface handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc.
Start the OpenWrt Buildroot configuration interface by issuing the following command:

make menuconfig

This will update the dependencies of your existing configuration automatically, and you can now proceed to build your updated images.

You have three options: y, m, n which are represented as follows:

pressing y sets the <*> built-in label
This package will be compiled and included in the firmware image file.
pressing m sets the package label
This package will be compiled, but not included in the firmware image file. (E.g. to be installed with opkg after flashing the firmware image file to the device.)
pressing n sets the < > excluded label
The source code will not be processed.
When you save your configuration, the file /.config will be created according to your configuration.

make kernel_menuconfig CONFIG_TARGET=subtarget
make defconfig
make or make world

The make sequience

Top command make world calls the following sequence of the commands:

make target/compile
make package/cleanup
make package/compile
make package/install
make package/preconfig
make target/install
make package/index

You may run each command independency. For example, if the process of compilation of packages stops on error, you may fix problem and next continue without cleanup:

make package/compile
make package/install
make package/preconfig
make target/install
make package/index

Warnings, errors and tracing

make V=s or make V=99

本文章由http://www.wifidog.pro/2015/08/02/OpenWrt-%E7%BC%96%E8%AF%91.html整理编辑,转载请注明出处