一、安装quilt
1、sudo apt-get install quilt
2、修改quilit配置文件, vim ~/.quiltrc
QUILT_DIFF_ARGS="--no-timestamps --no-index -pab --color=auto"
QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"
QUILT_PATCH_OPTS="--unified"
QUILT_DIFF_OPTS="-p"
EDITOR="vim"
//指定编辑器使用vim, 但Ubuntu14.04默认情况下使用的是nano,即使这边指定了quilt edit用的还是Nano, 可在~/.bashrc 里添加export EDITOR=/usr/bin/vim. quilt edit就会使用vim了
二、使用quilt
进入openwrt kernel源码目录下:
xxx/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/linux-3.10.14
执行cat patches/series
可看到很多已经存在的patch,如下:
platform/0601-splice.patch
platform/0602-ufsd.patch
platform/064-compile-error.patch
platform/065-hnat-interface.patch
platform/066-support-RA_HW_NAT_WIFI_NEW_ARCH.patch
platform/067-lanwan-vlan.patch
platform/067-whnat.patch
platform/070-fix-br0.patch
1、quilt push 或者 quilt top可以查看当前最后一条patch文件
2、以修改kernel的波特率为例
<1>新增patch文件,新增patch的文件名序号要满足比已存在的任何一个patch文件的序号都要打
quilt new platform/080-set-mt7688-uart.patch
此时080-set-mt7688-uart.patch会被quilt当成是top patch,针对kernel的一切修改都会被自动diff到这个patch文件中。
<2>修改kernel 内容
quilt edit arch/mips/ralink/cmdline.c
quilt edit arch/mips/ralink/init.c
<3>把针对arch目录下文件的修改同步到patch文件,并保存到080-set-mt7688-uart.patch
quilt refresh
<4>查看修改内容是否正确
cat patches/platform/080-set-mt7688-uart.patch
把patches/platform/080-set-mt7688-uart.patch拷贝到openwrt根目录下的openwrt-sdk/target/linux/ramips/patches
下。080-set-mt7688-uart.patch在下次解压缩kernel源码的时候会自动打上。