OpenWRT: Build Firmware

From OnnoWiki
Jump to navigation Jump to search

WARNING: ini akan membutuhkan banyak akses ke Internet untuk download, termasuk waktu proses make. Termasuk download kernel linux, waktu compile toolchain :( ... Tampaknya tidak bisa OFFLINE :(


Sumber:


Prosedur

  • Lakukan sebagai non-root user
  • Lakukan semua perintah di <buildroot dir> misalnya ~/openwrt/trunk/
  • Update OpenWrt source
  • Update & install package feeds.
  • Configure build.
  • Start build. Ini akan secara automatis compile Ttoolchain, cross-compile sources, package packages, dan generate image siap untuk di flashed.
  • Proceed to Installing OpenWrt

Persiapan

Lakukan

sudo su
apt-get update
apt-get install subversion gawk flex sharutils bison libz-dev patch fakeroot lzma

Menggunakan SVN

Sebagai user biasa lakukan

svn co svn://svn.openwrt.org/openwrt/branches/backfire ~/openwrt/trunk/
cd ~/openwrt/trunk/
./scripts/feeds update
./scripts/feeds install <pkg_name_1> <pkg_name_2> ... <pkg_name_N>
make defconfig
make menuconfig
make world

Update SVN

cd ~/openwrt/trunk/
svn update
./scripts/feeds update

Menggunakan GIT

git clone git://nbd.name/openwrt.git ~/openwrt/trunk/
cd ~/openwrt/trunk/
./scripts/feeds update # You have to change feeds.conf to use the git packages repo. See the patch below.
./scripts/feeds install <pkg_name_1> <pkg_name_2> ... <pkg_name_N> # After installing the package (creates the symlink for you, you can select it in menuconfig)
make menuconfig # Choose your Target System/Subtarget/Target Profile and select packages/features
make world

Update GIT

cd ~/openwrt/trunk/
git pull
./scripts/feeds update

Tips

Kita dapat menentukan / menset chipset mana yang akan kita gunakan. Di target/linux/chipname/, ada makefile yang mengatakan kernel mana yang akan dibuat, contoh di Kamikaze tepatnya kamikaze/target/linux/atheros/Makefile.

LINUX_VERSION:=2.6.23.17

Ubah ini sesuai dengan subversion yang anda inginkan.

Build di multi-core CPU

Proses build dapat di percepat dengan menjalankan beberapa concurrent job process mengunakan option -j seperti

make -j 3

Gunakan standard formula <jumlah CPU + 1>. Jika cara ini menyebabkan error saat build, coba compile tanpa option -j.


Build di background

Jika anda ingin menggunakan sistem / mesin anda waktu anda build, kita dapat membuat proses build hanya menggunakan I/O dan kapasitas CPU yang ide, contoh untuk CPU dualcore:

ionice -c 3 nice -n 20 make -j 2

Build single Packages

Saat kita melakukan developing atau packaging software untuk OpenWrt, akan lebih memudahkan jika kita dapat membuat untuk package yang kita inginkan saja (misalnya untuk package cups):

make package/cups/compile V=99

Untuk package mc (midnight commander), yang kebetulan berada feed packages perintahnya akan seperti

make package/feeds/packages/mc/compile v=99

Melihat build errors

Jika build gagal, cara yang paling gampang untuk melihat error adalah melalui perintah

make V=99 2>&1 | tee build.log | grep -i error

Perintah di atas akan menyimpan copy full verbose dari output build (dengan stdout di pipe ke stderr) di /openwrt/trunk/build.log dan hanya memperlihatkan error saja ke screen

Contoh lain

ionice -c 3 nice -n 20 make -j 2 V=99 CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '(warn|error)'

Cara di atas menyimpan copy full verbose dari output build (dengan stdout di pipe ke stderr) di build.log dan akan mengeluarkan hanya warning dan error saat building menggunakan resource background di dual core CPU.

Notifikasi Beep

Depending on your CPU, the process will take a while, or while longer. If you want an acoustic notification, you could use echo -e '\a':

make V=99 ; echo -e '\a'

Locating Images

Jika berhasil image yang kita buat akan berada di bawah directory

<buildroot dir>/bin

Jika kita buat firmware untuk ar71xx maka ada di bawah

<buildroot dir>/bin/ar71xx directory.

Jika <buildroot dir> adalah /openwrt/trunk, maka binary ada di

/openwrt/trunk/bin/ar71xx.

Cleaning Up

You might need to clean your build environment every now and then. The following make-targets are useful for that job:

Clean

Delete isi bin dan directory build_dir

make clean

Dirclean

make dirclean

deletes contents of /bin and /build_dir directories and additionally /staging_dir and /toolchain (=the cross-compile tools). 'Dirclean' is your basic "Full clean" operation.

Distclean

make distclean

nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.

CAUTION: In addition to all else, this will erase your build configuration (.config), your toolchain and all other sources. Use with care!

There are numerous other functionalities in the OpenWrt build system, but the above should have covered some of the fundamentals.

Referensi

Pranala Menarik