OpenWRT Begin

Open WRT 筆記


安裝步驟

事前準備

  • echo $SED 必須為空,或者unset SED
  • echo $GREP_OPTIONS 不可含有 --initial-tab
  • 添加 PATH 至 ~/.bashrc
    • /staging_dir/host/bin
    • /staging_dir/toolchain-<platform>-<gcc_ver>-<libc_ver>/bin
  • 支援硬體表
  • 不能使用 Root User 進行 Compile
安裝相依套件
1
2
3
4
apt-get update -y
# apt-get install -y make git g++ libncurses5-dev subversion libssl-dev gawk libxml-parser-perl unzip bzip2 wget python file && \
apt-get install -y python python2.7 perl imagemagick subversion git gcc g++ binutils autoconf automake libtool-bin make bzip2 libncurses5-dev libreadline-dev zlib1g-dev flex bison patch texinfo tofrodos gettext pkg-config realpath libstring-crc32-perl gawk libusb-dev unzip intltool libacl1-dev libcap-dev libc6-dev libglib2.0-dev unzip wget curl zip libssl-dev libxml-parser-perl file nano cmake && \
apt-get clean -y
下載原始碼(開發版 或 穩定版)
1
2
3
4
5
# https://wiki.openwrt.org/doc/howto/buildroot.exigence
# trunk (main development tree)
git clone git://github.com/openwrt/openwrt.git
# 15.05 branch (Chaos Calmer)
git clone -b chaos_calmer git://github.com/openwrt/openwrt.git
(optional) Download and install all available "feeds"
1
2
3
4
cp feeds.conf.default feeds.conf
# echo src-git linkit https://github.com/MediaTek-Labs/linkit-smart-7688-feed.git >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
調整 config
1
2
3
4
5
6
make prereq
make menuconfig
# y -> <*> -> built in
# m -> <M> -> package (opkg to install)
# n -> < > -> 不處理
# 存檔後會產生 /.config

Image 位置

E.g. if your is ~/openwrt/trunk, the binaries are in ~/openwrt/trunk/bin/ar71xx.

make dirclean ; make defconfig ; make V=s -j1

問題處理

‘world’ failed

target 'world' failed
1
2
3
# https://forum.openwrt.org/viewtopic.php?id=65311
# [solved]complie problem:recipe for target 'world' failed
FORCE_UNSAFE_CONFIGURE=1

尋找檔案

1
find ./ -name "ffmeg*ipk" -print

開機時自動啟動

1
2
# 修改 /etc/rc.local
chown 777 /etc/rc.local

Misc

.config - OpenWrt Configuration
编译单个软件,进入编译选项选择要编译的软件后,如果没有make需执行以下:
make tools/install
make toolchain/install
然后编译指定的软件:
make package/name/compile

mount -o remount,rw /

opkg update 失敗

Signature check failed

修改/etc/opkg.conf
註解 option check_signature 1
Signature check failed问题解决(附opkg.conf)

wget return 8

修改
/etc/opkg.conf
/etc/opkg/distfeeds.conf

Pi 3 的情況是指向空目錄
1
2
3
https://downloads.openwrt.org/snapshots/trunk/brcm2708/bcm2710/
# 改成
https://downloads.openwrt.org/snapshots/trunk/brcm2708/generic/

參考連結

Youtube:開場及OpenWrt介紹 LinkIt Smart 7688 與 Embedded Linux 快速上手 #01 MT7688與WioLink技術沙龍 mokoversity 201512
講稿
簡報:OpenWRT guide and memo
Blog:Ubuntu/CentOS下编译OpenWRT固件
官網
國外教學:Installing OpenWRT on a Raspberry Pi as a New Home Firewall

設定網路

1
2
3
4
5
6
7
8
9
mount -o remount,rw /
cd /etc/config
touch network
vi network
# uci set network.lan.proto=dhcp
# uci commit
/etc/init.d/network restart

uci show network
/etc/config/network
1
2
3
4
5
6
7
8
9
10
11
12
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0

config interface lan
option ifname eth0
option type bridge
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0

Luci module

1
2
3
4
# controller
/usr/lib/lua/luci/controller/
# model
/usr/lib/lua/luci/model/cbi/

Adding new elements to LuCI
luci ducument
寫個 LuCI 模組
开发OpenWrt路由器上LuCI的模块
HowTo: Write Modules
openwrt - 入門( opkg, uci, luci )

LinkIt Smart 7688

透過 wifi 連入後,網頁進入 mylinkit.local 設定 root 密碼

設定成 station mode 後,可透過 ssh root@mylinkit.local 連入

使用 mraa 套件來操控 GPIO

自製 ipk

Build ipk

build coova-chilli ipk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# https://wiki.openwrt.org/doc/howtobuild/single.package
# https://wiki.openwrt.org/doc/howto/obtain.firmware.sdk
# make package/example/download - download the soures of example
# make package/example/prepare - extract the sources, apply patches and download if necessary
# make package/example/compile - compile example, prepare and download if necessary
# make package/example/clean - clean the sourcecode
# make package/index - build a repository index to make the output directory usable as local opkg source

# install feeds(feeds.conf)
./scripts/feeds update -a
./scripts/feeds install coova-chilli

# make tools tools
make tools/install
make toolchain/install

make package/package/feeds/packages/coova-chilli/compile
make package/package/feeds/packages/coova-chilli/install
# bin/ramips/packages/packages/coova-chilli_1.3.0+20141128_ramips_24kec.ipk
make package/index