> For the complete documentation index, see [llms.txt](https://kysonlok.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kysonlok.gitbook.io/blog/openwrt/submit_patch.md).

# 提交新平台补丁到OpenWRT社区

## Step 1: quilt 配置

```
cat > ~/.quiltrc <<EOF
QUILT_DIFF_ARGS="--no-timestamps --no-index -p ab --color=auto"
QUILT_REFRESH_ARGS="--no-timestamps --no-index -p ab"
QUILT_SERIES_ARGS="--color=auto"
QUILT_PATCH_OPTS="--unified"
QUILT_DIFF_OPTS="-p"
EDITOR="vim"
EOF
```

* `EDITOR` 指定编辑补丁使用的编辑器 &#x20;
* 其他变量控制patch的属性，如使用 **a/file** 和 **b/file** 格式代替默认的 **dir.orig/file** 和 **dir/file** &#x20;

## Step 2: 创建新patch

创建新patch，要先准备源码目录

```
make package/example/{clean,prepare} V=s QUILT=1
```

接着切换到准备的源码目录

```
cd build_dir/target-*/example-*
```

push存在的patch

```
quilt push -a
```

创建新的patch

```
quilt new 000-main_code_fix.patch
```

* patch名要以数字开头表示patch序列，后紧跟一横线和剪短的描述 &#x20;
* patch的序列号应该要高于存在的patch(**quilt series** 命令可以查看存在的patches)&#x20;

编辑文件

```
quilt edit src/main.c
```

查看修改的内容

```
quilt diff
```

生成patch

```
quilt refresh
```

切换回buildroot目录

```
cd ../../
```

更新package

```
make package/example/update V=s
```

## Step 3: 编辑已存在的patch

准备源码目录

```
make package/example/{clean,prepare} V=s QUILT=1
```

切换到已准备的源码目录

```
cd build_dir/target-*/example-*
```

应用存在的patches

```
quilt push -a
```

查看patch列表

```
quilt push -a
```

将要编辑的patch置顶

```
quilt pop 005-fix_bug.patch
```

编辑文件

```
quilt edit src/main.c
```

查看修改的内容

```
quilt diff
```

生成patch

```
quilt refresh
```

切换回buildroot目录

```
cd ../../
```

更新package

```
make package/example/update V=s
```

可以发现，添加新的patch和编辑已有的patch，步骤差不多，只是编辑已有的patch多了一步将patch置顶操作


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kysonlok.gitbook.io/blog/openwrt/submit_patch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
