在调试88e1512芯片时官方驱动无法满足我的应用方式,因此修改了marvell.c源码,但是在做bsp包重新创建新工程时发现之前的修改没有生效,因此查找了一下资料发现可以通过打补丁的方式添加到工程文件中,便于管理。
操作步骤
一、获取linux-xlnx源码
使用petalinux-devtool modify linux-xlnx 命令可以获取源码,路径为:./project/components/yocto/workspace/sources/linux-xlnx
二、操作步骤
1. 生成补丁文件
# 进入源码目录(以 Linux 内核为例)
cd ./project/components/yocto/workspace/sources/linux-xlnx
# 生成补丁(基于 Git)
git diff > marvell.patch
2. 创建补丁存放目录
在 PetaLinux 工程的 project-spec/meta-user
层中创建补丁路径:
# 创建内核补丁目录
mkdir -p project-spec/meta-user/recipes-kernel/linux/linux-xlnx/files
3. 复制补丁文件
将生成的补丁文件复制到目标路径:
cp marvell.patch project-spec/meta-user/recipes-kernel/linux/linux-xlnx/files
4. 创建或修改配方文件
通过 .bbappend
文件指定补丁:
# 创建配方追加文件
vi project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend
文件内容:
# 指定补丁文件
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://marvell.patch"
5. 重新构建工程
petalinux-build -c kernel # 仅构建内核
petalinux-build # 构建完整镜像
6. 测试验证完成后终止开发模式清理构建缓存并重新构建工程
petalinux-devtool reset linux-xlnx
petalinux-build -c kernel -x cleansstate
petalinux-build -c kernel