zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.08k stars 6.2k forks source link

openamp_rsc_table example with MBOX: bus fault on TI SK-AM62 M4 #72250

Open aleeraser opened 2 months ago

aleeraser commented 2 months ago

I'm using a TI SK-AM62 board running Linux on the main A53 and Zephyr on the M4 core. The Linux image is the stock image provided by TI.

I've been trying to adapt the openamp_rsc_table example for using the newer MBOX subsystem. The MBOX driver is provided by https://github.com/zephyrproject-rtos/zephyr/pull/71241.

Here's the implementation I'm working on: https://github.com/aleeraser/zephyr/tree/feat/ti-mailbox, in particular this commit contains the changes for the example.

According to TI's documentation, the resource table is correctly loaded at the beginning of the M4 external memory section at 0x9cc00000, while the IPC virtio and vring buffers must be located at 0x9cb00000.

I have therefore created the following device tree overlay:

 / {
    chosen {
        zephyr,ipc_shm = &ipc_shm;
    };

    ipc_shm: memory@9cb00000 {
        compatible = "mmio-sram";
        reg = <0x9cb00000 DT_SIZE_M(1)>;
    };

    mbox-consumer {
        compatible = "vnd,mbox-consumer";
        mboxes = <&mbox0 0>, <&mbox0 1>;
        mbox-names = "tx", "rx";
    };
};

When running the example, I have the following Bus Fault / Precise data bus error:

[00:00:00.000,000] <err> os: ***** BUS FAULT *****
[00:00:00.000,000] <err> os:   Precise data bus error
[00:00:00.000,000] <err> os:   BFAR Address: 0x9cc0002d
[00:00:00.000,000] <err> os: r0/a1:  0x00000048  r1/a2:  0x000000ff  r2/a3:  0x9cc00014
[00:00:00.000,000] <err> os: r3/a4:  0x000077b8 r12/ip:  0x00000000 r14/lr:  0x000006e3
[00:00:00.000,000] <err> os:  xpsr:  0x01000000
[00:00:00.000,000] <err> os: Faulting instruction address (r15/pc): 0x00002bde
[00:00:00.000,000] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:00.000,000] <err> os: Current thread: 0x75c0 (main)
[00:00:00.000,000] <err> os: Halting system

The BFAR address (0x9cc0002d) should be within the resource table, and in fact addr2line 0x00002bde blames this as the faulting instruction.

github-actions[bot] commented 2 months ago

Hi @aleeraser! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

aleeraser commented 2 months ago

@vaishnavachath any idea or suggestion to share?

vaishnavachath commented 2 months ago

@glneo I believe you have got this working, do you have any pointers regarding the issue?

glneo commented 2 months ago

Yes, here is my working branch with openamp_rsc_table example running on M4 with Vaishnav's MBOX driver: https://github.com/glneo/zephyr/tree/openamp-am62x-sk-m4

Our solutions seem similar, we should be able to work together to find a clean way to update the current IPM based examples to the newer MBOX (maybe have it selected based on what is found in DT).

The change you need to fix your data fault is this one: https://github.com/zephyrproject-rtos/zephyr/commit/4a04044155839f978b281cd3b39dd9e9311edf6e

The default RAT configuration is a bit of a mess right now, I'll send this patch upstream after a couple other bug fixes I've sent get through the pipeline.

aleeraser commented 2 months ago

Yes, here is my working branch with openamp_rsc_table example running on M4 with Vaishnav's MBOX driver: https://github.com/glneo/zephyr/tree/openamp-am62x-sk-m4

The change you need to fix your data fault is this one: 4a04044

Thank you very much!

The default RAT configuration is a bit of a mess right now, I'll send this patch upstream after a couple other bug fixes I've sent get through the pipeline.

I've seen your other patches. I agree this is definitely needed as well.

Our solutions seem similar, we should be able to work together to find a clean way to update the current IPM based examples to the newer MBOX (maybe have it selected based on what is found in DT).

Unfortunately I'll be unavailable until the end of the month. Depending on the status of this when I'll be back, I'll be happy to join you if needed.

github-actions[bot] commented 2 days ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.