1. 程式人生 > >openwrt 打PATCH方法

openwrt 打PATCH方法

http://wiki.openwrt.org/doc/devel/patches

全來官網

package目錄打法
Adding a new patch
1>make package/example/{clean,prepare} V=s QUILT=1
make package/procd/{clean,prepare} V=s QUILT=1


2> cd build_dir/target-*/example-*
quilt new 010-main_code_fix.patch


3>quilt edit src/main.c
src/main.c gets added to 010-main_code_fix.patch


4>quilt refresh
Change back to the toplevel directory of the buildroot.
cd ../../../
To move the new patch file over to the buildroot, run update on the package:


5>make package/example/update V=s
make package/procd/update V=s
Finally rebuild the package to test the changes:


6>make package/example/{clean,compile} package/index V=s
make package/procd/{clean,compile} package/index V=s


tools目錄打法
make tools/mkimage/{clean,prepare} V=s QUILT=1
cd build_dir/host/u-boot-2013.07-rc1/
quilt series
quilt new 080-image_h_fangshuaji.patch
quilt edit include/image.h 
quilt refresh 
cd ../../../
make tools/mkimage/update V=s
ls tools/mkimage/patches/
cat tools/mkimage/patches/080-image_h_fangshuaji.patch 
make tools/mkimage/{clean,compile,install} V=s  




核心的打法:
操作步驟:
1、進入Openwrt目錄, make target/linux/{clean,prepare} V=s QUILT=1,這一步將linux核心清理乾淨,準備修改
2、進入解壓出來的linux核心目錄,cd build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7621/linux-2.6.36/
3、可以用quilt series來檢視對當前核心有什麼patch,
4、使用quilt new platform/0928-sky-mtd.patch,準備開始新patch
5.      quilt edit drivers/mtd/mtdpart.c
5、進入drivers/mtd目錄,編輯mtdpart.c,函式split_rootfs完成flash分割槽切分
ROOTFS_SPLIT_NAME就是rootfs_data,你模仿這個方式,劃分好分割槽name,size和offset,然後呼叫add_one_partition新增分割槽。
6、將程式碼修改好後,執行 quilt refresh
7、回到最頂層目錄,執行 make target/linux/update,這時候會生成patch,你可以在target/linux/ramips/patches-2.6.36目錄下看到0928-sky-mtd.patch這個patch
8、客戶還要在升級的時候寫入一個分割槽,還要做一個標記,這個你可以直接修改package/base-files/files/sbin/sysupgrade指令碼,這個不是用patch形式來修改的
9、執行make V=s編譯生成image。