Difference between revisions of "OpenWRT: Build Firmware"

From OnnoWiki
Jump to navigation Jump to search
Line 62: Line 62:
 
==Tips==
 
==Tips==
  
You should specify which chipset you are using. But on your target/linux/chipname/, there should be a makefile that tells you which build you are supposed to build.
+
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.
  
For my case it was in kamikaze/target/linux/atheros/Makefile.
+
LINUX_VERSION:=2.6.23.17
  
LINUX_VERSION:=2.6.23.17 <-- just change this to whatever is your rev is you probably need to know the subversion.
+
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
  
==Building on multi-core CPU==
+
make -j 3
  
The build process can be accelerated by running multiple concurrent job processes using the -j-option:
+
Gunakan standard formula <jumlah CPU + 1>. Jika cara ini menyebabkan error saat build, coba compile tanpa option -j.
 
 
make -j 3
 
  
    Use the standard formula <your number of CPUs + 1>
 
    If this produces random build errors try compiling again without the -j-option
 
  
==Building in the background==
+
==Build di background==
  
If you intend to use your system while building, you can have the build process use only idle I/O and CPU capacity like this (dualcore CPU):
+
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
 
  ionice -c 3 nice -n 20 make -j 2
  
==Building single Packages==
+
==Build  single Packages==
  
When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package cups):
+
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
 
  make package/cups/compile V=99
  
For the package mc (midnight commander), which is contained the feed packages it looks like this:
+
Untuk  package mc (midnight commander), yang kebetulan berada feed packages perintahnya akan seperti
  
 
  make package/feeds/packages/mc/compile v=99
 
  make package/feeds/packages/mc/compile v=99
  
==Spotting build errors==
+
==Melihat build errors==
  
 
If for some reason the build fails, the easiest way to spot the error is to do:
 
If for some reason the build fails, the easiest way to spot the error is to do:

Revision as of 06:53, 25 July 2012

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

If for some reason the build fails, the easiest way to spot the error is to do:

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

The above saves a full verbose copy of the build output (with stdout piped to stderr) in /openwrt/trunk/build.log and only shows errors on the screen.

Another example:

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)'

The above saves a full verbose copy of the build output (with stdout piped to stderr) in build.log and outputs only warnings and errors while building using only background resources on a dual core CPU. Getting beep notification

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

make clean

deletes contents of bin and build_dir directories.

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