首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >在PetaLinux工程中调试关键模块代码

在PetaLinux工程中调试关键模块代码

作者头像
hankfu
发布2022-11-18 15:45:57
发布2022-11-18 15:45:57
1.6K0
举报
文章被收录于专栏:hankhank

在PetaLinux工程中,与单板相关的UBoot、Linux等模块,经常需要编辑、调试。

在旧版本中,可以为UBoot、Linux选择“ext-local-src”, 指定UBoot、Linux的代码,从而使PetaLinux使用工程师修改后带调试信息的代码。现在已经不建议这种模式。

对于新的的PetaLinux,建议使用命令“petalinux-devtool modify ”,导出相关模块代码,然后编辑编译,就能看到调试信息。导出的代码,在目录“components/yocto/workspace/sources/”中。

对于2020等旧版本,没有命令“petalinux-devtool”。建议先导入yocto的环境,从而得到工具“devtool”,使用“devtool”替代“petalinux-devtool”。可以参考下列命令。

代码语言:javascript
复制
source /opt/pkg/petalinux/settings.sh
source <plnx-proj-root>/components/yocto/environment-setup-aarch64-xilinx-linux
source <plnx-proj-root>/components/yocto/layers/core/oe-init-build-env

在PetaLinux工程中导出所有关键模块代码 提供了统一的脚本,可以在PetaLinux 2020、2022中,导出代码。

比如最近在u-boot-xlnx/common/usb.c的开始处,定义宏DEBUG,使能uboot的usb调试信息。其它usb相关文件也可以增加“#define DEBUG”。再编译PetaLinux工程,运行新的boot.bin,执行命令“usb stop && usb start && fatls usb 0 && usb stop”,就会有usb调试信息。

代码语言:javascript
复制
/*
 * How it works:
 *
 * Since this is a bootloader, the devices will not be automatic
 * (re)configured on hotplug, but after a restart of the USB the
 * device should work.
 *
 * For each transfer (except "Interrupt") we wait for completion.
 */

// Hank, debug_usb
#define DEBUG

#include <common.h>
#include <command.h>
#include <dm.h>

调试完成后,执行命令下列命令,还可以给原来的recipe,创建patch。

代码语言:javascript
复制
git add <filename>
git commit -s
petalinux-devtool finish <recipe-name> <destination layer path>

调试完成后,执行命令下列命令,删除对应的recipe。

代码语言:javascript
复制
petalinux-devtool reset <recipe-name> to remove the source directory for the recipe from workspace.

测试环境

X86 Ubuntu 18.04

PetaLinux 2022.1

PetaLinux 2021.1

PetaLinux 2020.1

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-11-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 测试环境
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档