linux 驱动-匹配2 (amba_bustype)

目录

1.实例分析

   a. 设备树实例

  b. 驱动实例

2. amba匹配流程

 a. 创建amba_device

b. 确定总线以及总线的匹配函数

c. 分析总线的匹配函数


1.实例分析

   a. 设备树实例

serial@7e201000 {
    compatible = "brcm,bcm2835-pl011\0arm,pl011\0arm,primecell"; //创建amba_device
    reg = <0x7e201000 0x200>;
    interrupts = <0x02 0x19>;
    clocks = <0x03 0x13 0x03 0x14>;
    clock-names = "uartclk\0apb_pclk";
    arm,primecell-periphid = <0x241011>; // 用于匹配amba_driver 的id_table
    cts-event-workaround;
    pinctrl-names = "default";
    pinctrl-0 = <0x08 0x09>;
    status = "okay";
    phandle = <0x21>;
};

## remove /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output.64/out ## LD /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf LD_MAP /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.map /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(logical_adapter_truck_rear.o): in function `logical_adapter::cmsTrackRearMove::~cmsTrackRearMove()': logical_adapter_truck_rear.cpp:(.text+0x2bc): undefined reference to `operator delete(void*, unsigned int)' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(truck_rear_tyre_pt.o): in function `view_init': truck_rear_tyre_pt.cpp:(.text+0x1dc): undefined reference to `__dso_handle' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: truck_rear_tyre_pt.cpp:(.text+0x1e0): undefined reference to `__dso_handle' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: truck_rear_tyre_pt.cpp:(.text+0x1f0): undefined reference to `__aeabi_atexit' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(camera_rotation_cotr.o): in function `camera_rot_cotransform::PositionRotation::~PositionRotation()': camera_rotation_cotr.cpp:(.text+0x10): undefined reference to `operator delete(void*, unsigned int)' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/vendors/ambarella/lib/cv2fs/libview_rear_pt.a(trace.o): in function `trace_track::TraceTrack::~TraceTrack()': trace.cpp:(.text+0x10): undefined reference to `operator delete(void*, unsigned int)' /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf: hidden symbol `__dso_handle' isn't defined /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/arm-none-eabi-ld: final link failed: bad value /home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/svc/Makefile.Amba:176: recipe for target '/home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf' failed make[1]: *** [/home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output/out/amba_svc.elf] Error 1 make[1]: Leaving directory '/home/lubuntu/workspace/RTOS_Beacon_ZhuJiaFuJia/cortex_a/output' Makefile:190: recipe for target 'sub-make' failed make: *** [sub-make] Error 2
最新发布
03-18
<think>嗯,用户遇到了编译错误,需要分析这些错误信息。首先,错误信息中有多个“undefined reference”,这通常是链接阶段的错误,说明编译器找不到某些函数或符号的定义。 第一个错误是“undefined reference to `operator delete(void*, unsigned int)'”。这应该和C++的delete操作符有关。可能的问题是没有链接到libstdc++或者使用的编译器配置有问题。需要检查是否在链接时添加了必要的C++库,比如-lstdc++或者-lgcc。 接下来的错误是“undefined reference to `__dso_handle'”和“__aeabi_atexit”。这些符号通常与全局对象的构造和析构有关,特别是在静态存储期的对象。当使用C++的静态对象时,需要确保编译器提供了这些支持函数。可能缺少了特定的启动文件或库,比如crt0.o或者libc.a,或者链接顺序不对。 还有错误提到隐藏符号`__dso_handle'未定义,这可能意味着链接时没有正确包含实现这些符号的目标文件或库。可能需要检查链接脚本或者Makefile中的库链接顺序,确保所有必要的库都被正确包含。 用户使用的编译器是arm-none-eabi-gcc,针对嵌入式系统,通常需要正确配置标准库,比如使用newlib或类似的库。需要确认是否链接了正确的标准库,并且库的路径正确。 可能的解决步骤包括:首先确认链接命令中是否包含-lstdc++,其次检查是否链接了libgcc,然后确保启动文件和标准库正确包含。此外,检查是否有缺失的源文件或目标文件,或者某些库的版本不兼容问题。如果问题依旧,可能需要查看编译器文档或社区,看看是否有类似的已知问题。</think>这个错误信息显示在编译链接过程中出现了多个未定义的符号引用(undefined reference),主要涉及C++运行时库相关的内容。以下是分步分析和解决方案建议: $\textcolor{blue}{一、错误类型分析}$ 1. $\text{operator delete(void*, unsigned int)}$ - 这是C++动态内存管理相关符号,通常需要链接$\texttt{libstdc++}$库 - 常见于使用new/delete操作符但未正确配置C++运行时环境 2. $\text{__dso_handle}$ 和 $\text{__aeabi_atexit}$ - 这些符号属于C++全局对象析构机制 - 需要编译器运行时支持库($\texttt{libgcc}$) $\textcolor{blue}{二、根本原因推测}$ 1. 编译器工具链配置不完整 - 使用的$\texttt{arm-none-eabi-gcc}$工具链缺少C++标准库支持 2. 链接器参数缺失 - 未指定必要的标准库链接参数 3. 异常处理配置冲突 - 项目设置可能与工具链的异常实现方式不兼容 $\textcolor{blue}{三、解决方案步骤}$ 1. 检查链接参数 在Makefile的LDFLAGS中添加: ```makefile LDFLAGS += -lstdc++ -lc -lm -lgcc ``` 2. 验证工具链配置 确保工具链路径正确: ```bash /usr/local/gcc-arm-none-eabi-10-2020-q4-major-amba-A_R-Profile_r1_20210623/bin/ ``` 检查是否存在$\texttt{libstdc++.a}$等库文件 3. 添加运行时支持 在链接阶段显式指定nostartfiles: ```makefile LDFLAGS += -nostartfiles ``` 同时确保链接了正确的启动文件(如$\texttt{startup_ARMCA9.S}$) 4. 检查异常处理配置 如果项目使用C++异常,需要添加: ```makefile LDFLAGS += -fexceptions -frtti ``` $\textcolor{blue}{四、补充验证}$ 1. 使用$\texttt{nm}$工具验证目标文件: ```bash arm-none-eabi-nm libview_rear_pt.a | grep delete ``` 2. 检查链接顺序: - 确保C++库链接在最后 - 示例正确顺序: ```makefile $(LD) $(OBJS) -lstdc++ -lgcc ... ``` $\textcolor{blue}{五、典型修复案例}$ 某嵌入式项目出现相同错误后,通过以下修改解决: ```diff -LDFLAGS = -mcpu=cortex-a9 -nostdlib +LDFLAGS = -mcpu=cortex-a9 -nostdlib -lstdc++ -lgcc -lc ``` 建议优先检查项目的链接脚本(.ld文件)是否包含必要的内存区域定义,特别是堆内存分配设置,这对C++动态内存操作至关重要。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乐分享-程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值