Na webu OpenWrt jsou ke stazeni uz hotove obrazy pro ruzne procesorove architektury a konkretni zarizeni. Kdyz vsak potrebujeme neco upravit, musime si pomoct sami. Dale se budu zabyvat pouze nejnovejsi verzi OpenWrt backfire. Jak jsem uz psal minule, pouzivam Router Station od Ubiquity. Proto se zamerim na praci s touto deskou. Pro ostatni bude postup pravdepodobne podobny.
RouterStation ma Atheros procesor (Atheros AR7161 MIPS 24K running @ 680MHz) architektura ar71xx. Pokud chcete mit nad vsim totalni kontrolu, stahnete si zdrojaky a zkompilujte si vse (celou distribuci) samy. Ovsem to neni taky jednoduche a ani to vetsinou neni potreba.
Ja pouzivam Image Builder. Pomoci tohoto baliku se da zmenit obraz ciloveho systemu. Je mozne pridavat ruzne balicky a menit nastaveni. Samozrejme by slo pouzit vychozi obraz, nahrat ho do RouterStation a potom si vse potrebne nastavit a doinstalovat. Tohle je ale jednodussi. Kdyz budete delat velkou serii, nebo budete chtit svuj obraz uverejnit na Internetu, je tento postup nejlepsi. Dulezite je stahnou Image Builder pro svou architekturu!
Vse se da stahnout tady: http://downloads.openwrt.org/backfire/10.03/ar71xx/
1 2 3 4 5 6 7 8 9 10 |
<strong>packages/</strong> 06-Apr-2010 12:58 - <strong>OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2</strong> 03-Apr-2010 18:55 340411713 OpenWrt.config 06-Apr-2010 12:10 123802 md5sums 06-Apr-2010 13:03 9400 ... <strong>openwrt-ar71xx-ubnt-rs-jffs2-factory.bin</strong> 06-Apr-2010 13:02 3146136 openwrt-ar71xx-ubnt-rs-jffs2-sysupgrade.bin 06-Apr-2010 13:02 3211264 openwrt-ar71xx-ubnt-rs-squashfs-factory.bin 06-Apr-2010 13:03 2359704 openwrt-ar71xx-ubnt-rs-squashfs-sysupgrade.bin 06-Apr-2010 13:03 2424832 ... |
openwrt-ar71xx-ubnt-rs-jffs2-factory.bin je vychozi obraz, jestlize se vam vsechno po**re, nahrajte do RouterStation tento obraz a vse bude OK V adresari packages/ jsou vsechny dostupne balicky. Pro nas bude nejzajimavejsi soubor OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2 ten obsahuje nastroj pro sestaveni vlasniho obrazu.
Stahneme si tedy OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2. Ve svem domovskem adresari si vytvorime slozku openwrt a rozbalime v ni tento soubor:
1 2 3 4 5 6 7 8 9 10 |
martin@martin-laptop:~$ <strong>mkdir openwrt</strong> martin@martin-laptop:~$ <strong>cd openwrt</strong> martin@martin-laptop:~/openwrt$ <strong>pwd</strong> /home/martin/openwrt martin@martin-laptop:~/openwrt$ <strong>tar xjf OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2</strong> martin@martin-laptop:~/openwrt$ <strong>ls -lh</strong> celkem 325M drwxr-xr-x 8 martin martin 4,0K 2010-04-03 20:51 OpenWrt-ImageBuilder-ar71xx-for-Linux-i686 -rw-r--r-- 1 martin martin 325M 2010-06-16 13:26 OpenWrt-ImageBuilder-ar71xx-for-Linux-i686.tar.bz2 martin@martin-laptop:~/openwrt$ |
Po rozbaleni dostaneme adresar. Prejdeme tedy do neho a zkusime spustit make pro zobrazeni informaci:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>make</strong> Available Commands: <span class="Apple-tab-span" style="white-space:pre"> </span>help:<span class="Apple-tab-span" style="white-space:pre"> </span>This help text <span class="Apple-tab-span" style="white-space:pre"> </span>info:<span class="Apple-tab-span" style="white-space:pre"> </span>Show a list of available target profiles <span class="Apple-tab-span" style="white-space:pre"> </span>clean:<span class="Apple-tab-span" style="white-space:pre"> </span>Remove images and temporary build files <span class="Apple-tab-span" style="white-space:pre"> </span>image:<span class="Apple-tab-span" style="white-space:pre"> </span>Build an image (see below for more information). Building images: <span class="Apple-tab-span" style="white-space:pre"> </span>By default 'make image' will create an image with the default <span class="Apple-tab-span" style="white-space:pre"> </span>target profile and package set. You can use the following parameters <span class="Apple-tab-span" style="white-space:pre"> </span>to change that:<span class="Apple-tab-span" style="white-space:pre"> </span> <span class="Apple-tab-span" style="white-space:pre"> </span>make image PROFILE="<profilename>" # override the default target profile <span class="Apple-tab-span" style="white-space:pre"> </span>make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages <span class="Apple-tab-span" style="white-space:pre"> </span>make image FILES="<path>" # include extra files from <path> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ |
Nyni si vypiseme prikazem make info dostupne profily:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>make info</strong> Current Target: "<strong>ar71xx</strong>" Default Packages: <strong>base-files libc libgcc busybox dropbear mtd uci opkg udevtrigger <br />Mhotplug2 dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall kmod-leds-gpio<br /> kmod-input-core kmod-input-polldev kmod-input-gpio-buttons kmod-button-hotplug swconfig</strong> Available Profiles: ... <strong>UBNTRS:<br /> <span class="Apple-tab-span" style="white-space:pre"> </span>Ubiquiti RouterStation<br /> <span class="Apple-tab-span" style="white-space:pre"> </span>Packages: kmod-usb-core kmod-usb-ohci kmod-usb2</strong> UBNTRSPRO: <span class="Apple-tab-span" style="white-space:pre"> </span>Ubiquiti RouterStation Pro <span class="Apple-tab-span" style="white-space:pre"> </span>Packages: kmod-usb-core kmod-usb-ohci kmod-usb2 UBNT:<br /> <span class="Apple-tab-span" style="white-space:pre"> </span>Ubiquiti Products<br /> <span class="Apple-tab-span" style="white-space:pre"> </span>Packages: kmod-usb-core kmod-usb-ohci kmod-usb2 Default: <span class="Apple-tab-span" style="white-space:pre"> </span>Default Profile (no WiFi) <span class="Apple-tab-span" style="white-space:pre"> </span>Packages: ... martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ |
Z tohoto vypisu je videt architektura, vychozi balicky, ktere se vzdy pouziji a seznam profilu. Pro RouterStation je to UBNT.
Profily nas ale nazajimaji. My si budeme chit pridat vlasni balicky a soubory s nastavenim. V adresari packages/ jsou vsechny dostupne balicky, ktere muzeme pouzit. Ted je potreba rict make co chceme, podle make info:
1 2 3 4 |
... make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages make image FILES="<path>" # include extra files from <path> ... |
Balicek (z adresare packages/) se jmenuje napr. tar_1.22-1_ar71xx.ipk ale mi budeme uvadet nazev tar, u syslog-ng_1.6.12-2_ar71xx.ipk uvedeme syslog-ng.
Dale budeme chtit nahradit soubor /etc/config/network, ve kterem je nastavena sit. vytvorime si tedy v adresari ImageBuilderu adresar nastaveni a v nem odpovidajici adresarovou strukturu a soubory:
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 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>mkdir nastaveni</strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>cd nastaveni/</strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni$ <strong>mkdir -p etc/config</strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni$ <strong>cd etc/config/</strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni/etc/config$ <strong>nano network</strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni/etc/config$ <strong>cat network </strong> # moje nastaveni :-) config interface loopback <span class="Apple-tab-span" style="white-space:pre"> </span>option ifname<span class="Apple-tab-span" style="white-space:pre"> </span>lo <span class="Apple-tab-span" style="white-space:pre"> </span>option proto<span class="Apple-tab-span" style="white-space:pre"> </span>static <span class="Apple-tab-span" style="white-space:pre"> </span>option ipaddr<span class="Apple-tab-span" style="white-space:pre"> </span>127.0.0.1 <span class="Apple-tab-span" style="white-space:pre"> </span>option netmask<span class="Apple-tab-span" style="white-space:pre"> </span>255.0.0.0 config interface wan <span class="Apple-tab-span" style="white-space:pre"> </span>option ifname<span class="Apple-tab-span" style="white-space:pre"> </span>eth0 <span class="Apple-tab-span" style="white-space:pre"> </span>option proto<span class="Apple-tab-span" style="white-space:pre"> </span>dhcp config interface lan <span class="Apple-tab-span" style="white-space:pre"> </span>option ifname<span class="Apple-tab-span" style="white-space:pre"> </span>"eth0 eth1" <span class="Apple-tab-span" style="white-space:pre"> </span>option type <span class="Apple-tab-span" style="white-space:pre"> </span>bridge <span class="Apple-tab-span" style="white-space:pre"> </span>option proto<span class="Apple-tab-span" style="white-space:pre"> </span>static <span class="Apple-tab-span" style="white-space:pre"> </span>option ipaddr<span class="Apple-tab-span" style="white-space:pre"> </span>192.168.1.20 <span class="Apple-tab-span" style="white-space:pre"> </span>option netmask<span class="Apple-tab-span" style="white-space:pre"> </span>255.255.255.0 <span class="Apple-tab-span" style="white-space:pre"> </span>option dns<span class="Apple-tab-span" style="white-space:pre"> </span>192.168.1.1 <span class="Apple-tab-span" style="white-space:pre"> </span>option gateway<span class="Apple-tab-span" style="white-space:pre"> </span>192.168.1.1 martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni/etc/config$ <strong>cd ../../../</strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ |
Nyni se muzeme pustit do samotneho sestaveni, nejdrive spustime make clean (vycisti nepovedene blbosti) a pote uz samotny make, kteremu v parametrech predame nazvy balicku a cestu k nastaveni:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>make clean</strong> rm -rf tmp /home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/build_dir/ target-mips_r2_uClibc-0.9.30.1/root-ar71xx /home/martin/openwrt/ OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/bin/ar71xx martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>make <br /> image PACKAGES="kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-acm python mc" <br /> FILES="/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni"</strong> Building images for ar71xx - Atheros AP81 reference board Packages: base-files busybox dnsmasq dropbear firewall hotplug2 iptables kernel kmod-button-hotplug kmod-input-core kmod-input-gpio-buttons kmod-input-polldev kmod-ipt-nathelper kmod-leds-gpio kmod-usb-acm kmod-usb-core kmod-usb-ohci kmod-usb2 libc libgcc mc mtd opkg ppp ppp-mod-pppoe python swconfig uci udevtrigger make[1]: Entering directory `/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686' Building package index... (cd /home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/packages; /home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/scripts/ ipkg-make-index.sh . > Packages && \ gzip -9c Packages > Packages.gz \ ) >/dev/null 2>/dev/null ... |
Nyni uz jenom staci cekat. Format prikazu je vic nez jasny:
make image PACKAGES="kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-acm python mc" FILES="/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni"
Kdyz mame hodne balicku, muzeme si to trochu usnadnit. Vytvorime si soubor, nazveme ho treba balicky a tam je vsechny napiseme na jeden radek oddelene mezerou. Pri volani make misto seznamu vypiseme obsah souboru PACKAGES="cat balicky
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>nano balicky </strong> martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>cat balicky </strong> kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-madwifi wpad-mini kmod-usb-acm bluez-hcidump bluez-libs bluez-utils bmon kmod-bluetooth pyserial python-bluez python mc martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>make <br /> image PACKAGES="`cat balicky`" FILES="/home/martin/openwrt/</strong> OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/nastaveni" Building images for ar71xx - Atheros AP81 reference board Packages: base-files bluez-hcidump bluez-libs bluez-utils bmon busybox dnsmasq dropbear firewall hotplug2 iptables kernel kmod-bluetooth kmod-button-hotplug kmod-input-core kmod-input-gpio-buttons kmod-input-polldev kmod-ipt-nathelper kmod-leds-gpio kmod-madwifi kmod-usb-acm kmod-usb-core kmod-usb-ohci kmod-usb2 libc libgcc mc mtd opkg ppp ppp-mod-pppoe pyserial python python-bluez swconfig uci udevtrigger wpad-mini make[1]: Entering directory `/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686' Building package index... (cd /home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/packages; /home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/scripts/ ipkg-make-index.sh . > Packages && \ <span class="Apple-tab-span" style="white-space:pre"> </span>gzip -9c Packages > Packages.gz \ <span class="Apple-tab-span" style="white-space:pre"> </span>) >/dev/null 2>/dev/null ... |
a zase pul dne cekat
Skoro vzdy, kdyz vybereme velke mnozstvi balicku, skonci ImageBuilder chybou:
1 2 3 4 5 6 7 8 9 10 11 |
... -32 -f /home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/build_dir/linux-ar71xx/root.jffs2-64k mjn3's trx replacement - v0.81.1 fread failure or file "/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx- for-Linux-i686/build_dir/linux-ar71xx/root.jffs2-64k" <strong>too large</strong> make[2]: *** [install] Error 1 make[2]: Leaving directory `/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686/target/linux/ar71xx/image' make[1]: *** [build_image] Error 2 make[1]: Leaving directory `/home/martin/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686' make: *** [image] Error 2 martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ |
Vetsinou neni duvod kazit si radost, chyba vetsinou nastane az po sestaveni obrazu pro RouterStation, ktery potrebujeme. To si muzeme snadno overit v adresari bin/ar71xx/.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>ls -lh <br /> build_dir/target-mips_r2_uClibc-0.9.30.1/root-ar71xx/</strong> celkem 60K drwxr-xr-x 2 martin martin 4,0K 2010-03-31 05:30 bin drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 dev drwxr-xr-x 14 martin martin 4,0K 2010-06-16 16:02 etc -rwxr-xr-x 1 martin martin 1,9K 2010-03-19 21:08 init drwxr-xr-x 12 martin martin 4,0K 2010-03-31 21:05 lib drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 mnt drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 overlay drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 proc drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 rom drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 root drwxr-xr-x 2 martin martin 4,0K 2010-03-28 15:18 sbin drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 sys drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 tmp drwxr-xr-x 6 martin martin 4,0K 2010-03-31 21:05 usr lrwxrwxrwx 1 martin martin 4 2010-06-16 16:24 var -> /tmp drwxr-xr-x 2 martin martin 4,0K 2010-04-02 17:18 www martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ |
To je ale spis pro kontrolu, nejdulezitejsi je adresar bin/ar71xx/ prave ten obsahuje vysledne obrazy, ktere budeme nahravat do zarizeni:
1 2 3 4 5 6 7 |
martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ <strong>ls -lh bin/ar71xx/</strong> celkem 162M ... -rw-r--r-- 1 martin martin 9,6M 2010-06-16 16:25 <strong>openwrt-ar71xx-ubnt-rs-jffs2-factory.bin</strong> -rw-r--r-- 1 martin martin 9,6M 2010-06-16 16:25 openwrt-ar71xx-ubnt-rs-jffs2-sysupgrade.bin ... martin@martin-laptop:~/openwrt/OpenWrt-ImageBuilder-ar71xx-for-Linux-i686$ |
Obrazu tam bude asi hodne, nas vsak zajima pouze openwrt-ar71xx-ubnt-rs-jffs2-factory.bin. Prave ten budeme nahravat do sveho RouterStation. Kdyby tam tento soubor nebyl, stala se nekde chyba. Nejpravdepodobnejsi je, ze jsme vybrali moc balicku a vysledny obraz tak byl moc velky.
A to je vse Nyni uz staci jenom nahrat soubor do zarizeni a melo by to fungovat. Chapu, ze je postup hodne neprehledny, ale psal jsem to narychlo. Funkcni to ale je a to je hlavni.
Dalsi clanky o OpenWrt.