This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: AM5728读写问题请教

Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS

您好,

我想问一下CMEM shared memory的问题,我的 DTS,CMEM_allocPool(64kBytes)代码如下:

问题1. 我用DDR 0xa0000000 ~ 0x0c000000,CMEM_allocPool 都成功,CMEM_NONCACHED也设了,只是我host arm端分配好后,将指针传递到DSP,未通过MessageQ put给DSP,DSP写操作后,ARM一直未看到实际的data,感觉有Cache,没有更新。

设置了CMEM_NONCACHED属性的这种情况下,还需要做cache_wb, cache_invalidate操作吗?

还是,必需通过MessageQ put给DSP?也就是MessageQ put除了pass 指针,传递拥有权的同时,也刷了cache吗?

问题2. CMEM 使用了reg = <0x0 0x40500000 0x0 0x100000>;(ARM linux reserved memory)同样设CMEM_NONCACHED了,CMEM_allocPool 都成功

load DSP firmware正常,但是加载ARM app_host程序时,出现remsg之类的问题,

[ 7965.898889] virtio_rpmsg_bus virtio0: msg received with no recipient

想知道,OCMC_RAM3区域有被IPC主件隐式使用吗?还是说,只要可以Linux reserved了,CMEM_allocPool 指定成功,就肯定可以作为共享内存用?

问题3. 如果设置CMEM_NONCACHED属性有效,是使用CMEM_NONCACHED,还是CACHED后再cache_wb, cache_invalidate操作,性能高一些?应用场景,在一个处理器上RAM分批小块写入后,在另一个处理器上大块读走。

问题4. BIGDATA_BUF_SIZE > 512bytes, 都需要用BIGDATA的user case吗? CMEM_allocPool, HeapMem_alloc的应用本质区别是什么?

问题5. 如果只使用一个以太网口,ARM连PC需要用,可以将此网口用于DSP EMAC的应用吗?

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

cmem_block_mem_0: cmem_block_mem@a0000000 {
reg = <0x0 0xa0000000 0x0 0x0c000000>;
no-map;
status = "okay";
};

cmem_block_mem_1_ocmc3: cmem_block_mem@40500000 {
reg = <0x0 0x40500000 0x0 0x100000>;
no-map;
status = "okay";
};

cmem_block_mem_2_gpmc: cmem_block_mem@01000000 {
reg = <0x0 0x01000000 0x0 0x100000>;
no-map;
status = "okay";
};
};

-------------------------------------------

CMEM_AllocParams cmemAttrs;
cmemAttrs.type = CMEM_HEAP;
cmemAttrs.flags = CMEM_NONCACHED;
cmemAttrs.alignment = 0;

printf("--> App_exec:\n");

/* fill process pipeline */
printf("App_exec: sending message\n");
/* allocate message */
msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);
if (msg == NULL) {
status = -1;
goto leave;
}

/* set data size */
msg->dataByteSize = PAYLOADSIZE;

/* alloc cmem memory for input data */
msg->dataIn = CMEM_allocPool(CMEM_getPool(PAYLOADSIZE * sizeof(float)), &cmemAttrs);

谢谢
  • 您好,

    问题1:设置了CMEM_NONCACHED属性的情况下,需要使用cache_wb和cache_invalidate操作,才能保证数据在不同处理器之间的一致性。如果通过MessageQ put传递指针,同时传递了拥有权,那么这些操作也会隐式地执行。

    问题2:OCMC_RAM3区域通常被DSP使用,但是如果已经在设备树中进行了Linux reserved,那么就可以使用该区域作为共享内存。CMEM_allocPool指定成功并不意味着可以作为共享内存使用,还需要进行相应的操作,例如cache_wb和cache_invalidate。

    问题3:如果只需要在一个处理器上进行读写操作,那么使用CMEM_NONCACHED属性可以提高性能。如果需要在不同处理器之间传递数据,那么还是需要使用cache_wb和cache_invalidate操作。

    问题4:BIGDATA_BUF_SIZE > 512bytes时,可以使用HeapMem_alloc分配内存,也可以使用CMEM_allocPool分配内存。CMEM_allocPool分配的内存可以被多个处理器共享,而HeapMem_alloc分配的内存只能在单个处理器上使用。

    问题5:如果只使用一个以太网口,那么可以将此网口用于DSP EMAC的应用。

    总的来说,个人认为使用CMEM共享内存需要注意cache一致性和拥有权的传递。在使用CMEM_allocPool分配内存时,需要确保映射到的物理地址与设备树中的地址一致,并进行相应的cache操作。在使用HeapMem_alloc分配内存时,可以在单个处理器上使用,但不能被多个处理器共享。

  • 谢谢Gary,

    再double comfirm一下,

    问题1:使用CMEM_NONCACHED属性, 通过MessageQ put传递指针,同时传递了拥有权,那么就不需要再使用cache_wb和cache_invalidate操作,对吧?

    问题5:只使用一个以太网口,那么可以将此网口用于DSP EMAC的应用,同时也可以将此网口用于ARM  linux TCP应用?

    问题2:OCMC_RAM3, Linux reserved, CMEM_allocPool指定成功, 通过MessageQ put传递指针,load-firmware, app_host后 报如下错误,估计是什么问题?

    是堆栈溢出了吗?有什么定位方法?

    另外,我今天遇到的问题,在如下连接,帮忙分析一下,谢谢!

    https://e2echina.ti.com/support/processors/f/processors-forum/791001/am5728-messageq 

    [ 886.535177] omap-iommu 40d01000.mmu: iommu fault: da 0x405fffe0 flags 0x0
    [ 886.542800] remoteproc remoteproc2: crash detected in 40800000.dsp: type mmufault
    receive msg = , cmd=0x10000004
    Message put
    Message get
    [ 886.550327] omap-iommu 40d01000.mmu: 40d01000.mmu: errs:0x00000002 da:0x405fffe0 pgd:0xee245014 *pgd:px00000000
    [ 886.569161] remoteproc remoteproc2: handling crash #1 in 40800000.dsp
    [ 886.575638] remoteproc remoteproc2: recovering 40800000.dsp
    recvfrom failed: Link has been severed (67)
    rpmsgThreadFxn: transportGet failed on fd 14, returned -20
    re[ 886.590842] omap_hwmod: timer6: _wait_target_disable failed
    cvfrom failed: Link has been severed (67)
    rpmsgThreadFxn: transportGet failed on fd 15, returned -20
    [ 886.604780] remoteproc remoteproc2: failed to unmap 16777216/0
    [ 886.652210] remoteproc remoteproc2: stopped remote processor 40800000.dsp
    [ 886.659118] remoteproc remoteproc2: powering up 40800000.dsp
    [ 886.678142] remoteproc remoteproc2: Booting fw image dra7-dsp1-fw.xe66, size 4828760
    [ 886.693385] omap-iommu 40d01000.mmu: 40d01000.mmu: version 3.0
    [ 886.699289] omap-iommu 40d02000.mmu: 40d02000.mmu: version 3.0
    [ 886.801153] virtio_rpmsg_bus virtio1: rpmsg host is online
    [ 886.807528] remoteproc remoteproc2: registered virtio1 (type 7)
    [ 886.819493] remoteproc remoteproc2: remote processor 40800000.dsp is now up
    [ 886.828902] virtio_rpmsg_bus virtio1: creating channel rpmsg-proto addr 0x3d
    [ 886.841201] prueth pruss2_eth: pruss MC Mask 0:0:0:0:0:0
    [ 886.848525] prueth pruss2_eth: port 1: using random MAC addr: aa:df:2d:ad:a8:d2

  • 您好,

    问题1:使用CMEM_NONCACHED属性,通过MessageQ put传递指针并且传递了拥有权,确实不需要再使用cache_wb和cache_invalidate操作。

    问题5:只使用一个以太网口,可以将此网口用于DSP EMAC的应用,同时也可以将此网口用于ARM Linux TCP应用。

    问题2:如果在使用OCMC_RAM3,Linux reserved,CMEM_allocPool指定成功后,通过MessageQ put传递指针并且load-firmware和app_host后出现错误,可能是堆栈溢出。定位方法可以通过查看堆栈大小和使用情况来确认。可以使用调试工具或者打印堆栈信息来定位问题。

  • Hi Gary,

    1. 我的CMEM msg->DataIn, 和DataOut, 只能ARM 写DataIn, DSP写DataOut,不能ARM、DSP都写一块区域,否则不同步。此现象正常吗?

    2. 当我的Arm 要send以太网数据,应该是没有及时返回buffer,导致 “virtio_rpmsg_bus virtio1: msg received with no recipient”, 有什么版本的问题吗?

    我的版本是,ti-processor-sdk-rtos-am57xx-evm-04.03.00.05, ipc_3_47_01_00_v1.1.tar.gz

    3.另外,我的程序用OCMC_RAM3作为共享CMEM,ARM报以下错误,你说是堆栈的问题,需要怎样加大堆栈呢?我DSP的设置是,heapMemParams.size = 0x8000;

    可以改这个吗?

    4. EMAC需要com.ti.rtsc.SYSBIOS组件吗?

    Creating project 'EMAC_BasicExample_idkAM572x_c66xExampleProject'...

    !ERROR: No products of type 'com.ti.rtsc.SYSBIOS' are currently installed!

    [10614.117204] omap-iommu 40d02000.mmu: iommu fault: da 0x405f0010 flags 0x0
    [10614.129080] remoteproc remoteproc2: crash detected in 40800000.dsp: type mmufault
    [10614.136616] omap-iommu 40d02000.mmu: 40d02000.mmu: errs:0x00000002 da:0x405f0010 pgd:0xed609014 *pgd:px00000000
    [10614.146799] remoteproc remoteproc2: handling crash #1 in 40800000.dsp
    [10614.153274] remoteproc remoteproc2: recovering 40800000.dsp
    recvfrom failed: Link has been severed (67)
    rpmsgThreadFxn: transportGet failed on fd 14, returned -20
    recvfrom failed: Link has been severed (67)
    rpmsgThreadFxn: transportGet failed on fd 15, returned -20
    [10614.187321] omap_hwmod: timer6: _wait_target_disable failed
    [10614.206379] remoteproc remoteproc2: failed to unmap 16777216/0
    [10614.242711] remoteproc remoteproc2: stopped remote processor 40800000.dsp
    [10614.249542] remoteproc remoteproc2: powering up 40800000.dsp
    [10614.266125] remoteproc remoteproc2: Booting fw image dra7-dsp1-fw.xe66, size 4832640
    [10614.282544] omap-iommu 40d01000.mmu: 40d01000.mmu: version 3.0
    [10614.288449] omap-iommu 40d02000.mmu: 40d02000.mmu: version 3.0
    [10614.331111] virtio_rpmsg_bus virtio1: rpmsg host is online
    [10614.338079] remoteproc remoteproc2: registered virtio1 (type 7)
    [10614.346671] remoteproc remoteproc2: remote processor 40800000.dsp is now up
    [10614.359773] virtio_rpmsg_bus virtio1: creating channel rpmsg-proto addr 0x3d
    [10614.375910] prueth pruss2_eth: pruss MC Mask 0:0:0:0:0:0
    [10614.383399] prueth pruss2_eth: port 1: using random MAC addr: 3a:fc:12:d8:d1:38

    谢谢!

  • 1. 这种现象可能不正常,可能需要调查是否有任何配置错误或者硬件问题导致了这种不同步的现象。

    2. 这可能是版本兼容性问题

    3. 堆栈问题可能导致ARM报错,可以尝试增大堆栈大小来解决这个问题。

    4. EMAC可能需要com.ti.rtsc.SYSBIOS组件,但是当前系统中未安装该组件,可能需要安装或者配置相关组件以解决问题。

  • 您好,请问,

    1.可不可以让DSP代码不包含IPC组件?那样的话,linux可以加载DSP代码吗?

    2.Linux下的shmem_open(),read/write,共享OCMC_RAM3, 或DDR, 与DSP通信,需要做cache_wb,cache_invalidate()吗?

    linux下的API是怎么样的?有csl_API()吗?

    谢谢

  • 您好,

    1. 可以让DSP代码不包含IPC组件,但这取决于你的具体需求和系统架构。如果你不需要在DSP和Linux之间进行通信,那么可以不包含IPC组件。但如果需要通信,你可能需要考虑其他方式来实现通信,比如使用共享内存或消息队列等方式。

    2. 在Linux下使用shmem_open(), read/write来与DSP通信时,如果涉及到共享内存的操作,通常需要考虑cache一致性的问题。具体是否需要做cache_wb, cache_invalidate()取决于你的具体应用场景和硬件架构。如果涉及到共享内存的操作,通常需要考虑cache一致性的问题,以确保数据的正确性和一致性。

    在Linux下,你可以使用POSIX共享内存API来实现共享内存操作,具体的API包括shmem_open(), shm_unlink(), mmap()等。另外,你也可以使用Linux内核提供的IPC机制来实现进程间通信,比如使用消息队列、信号量、共享内存等方式。

    关于csl_API(),个人理解,csl是TI提供的一套针对DSP和ARM处理器的底层硬件访问接口库。它提供了一系列的API来访问硬件资源,比如寄存器访问、中断控制、时钟控制等。在Linux下使用csl_API可能需要对其进行适配和移植,具体取决于你的硬件平台和系统架构。

  • 好的,那此贴就关闭了,谢谢!