am5728核间通信流程(基于TI BeagleBoard-X15)

am2578核间通信流程(基于TI BeagleBoard-X15)

注意事项

1、必须熟悉X15开发过程文档,且按照文档操作成功。

2、设备树文件要匹配开发板。

3、在X15开发过程文档 基础上添加对IRC02-B的支持。

4、使用IPC机制时LINUX内核必须打开CMA。会稍降低Xenomai的性能。

5、提供的补丁文件有:KERNEL, ex42_myforwardmsg,defconfig。KERNEL是设备树相关的文档兼容IRC02-B。ex42_myforwardmsg是IPC通信例程。Defconfig带xenomai补丁的内核配置文件

源文件下载

使用linux的IPC需要 LINUX SDK 和 TI-RTOS SDK,在X15开发文档中已经描述了ti-processor-sdk-linux-am57xx-evm-03.03.00.04的下载和安装方法。

Linux sdk: http://software-dl.ti.com/processor-sdk-linux/esd/AM57X/03_03_00_04/index_FDS.html

Rtos sdk: http://software-dl.ti.com/processor-sdk-rtos/esd/AM57X/03_03_00_04/index_FDS.html

下载完源文件后在命令行下安装。

默认安装位置为

$HOME/ti 
#和 
$HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04

保证有如下文件:

$HOME/ti

$HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04

$HOME/ti-linux-kernel-dev

安装processor-sdk-rtos时需要先安装ccs:

In reply to [Pavel Botev](https://e2e.ti.com/support/processors/f/791/p/770173/2849122#2849122):

Hi,

Thank you very much for your kindness.
I really appreciate your help.
**It seems to be success of the SDK installation after CCS installed.**

Best regards,

ccs下载地址:http://software-dl.ti.com/ccs/esd/documents/ccs_downloads.html

ccs安装参考:Linux Host Support CCSv7.md

安装时:选择Sitara系列处理器

重新编译内核

验证IPC时有两种内核验证方案,官方内核和带xenomai补丁的内核。使用官方内核时,不需要重新编译。使用Xenomai内核需要更改配置重新编译。

复制配置文件:

#提供的.config/deconfig(两个文件内容一致)复制到
~/ti-linux-kernel-dev/KERNEL/.config
#和
~/ti-linux-kernel-dev/patches/defconfig

复制设备树文件:

#提供的KERNEL覆盖掉
~/ti-linux-kernel-dev/KERNEL

补丁更改:

安装新版本的 后续更正 章节更新源码

编译:

cd ~/ti-linux-kernel-dev

./tools/rebuild.sh

编译 ipc demo程序

Ipc demo程序验证am5728核心间通信是否正常。通信采用请求回答形式。其主要验证两部分内容:

(1) arm<->DSP1,arm<->dsp2, arm<->ipu1,arm<->ipu2.

(2) arm<->DSP1<->DSP2<->IPU1<->IPU2

编译步骤如下:

  1. 复制提供的ex42_myforwardmsg 到
~/ti/ipc_3_44_01_01/examples/DRA7XX_linux_elf/
  1. 设置编译前环境变量
source ~/ti/processor_sdk_rtos_am57xx_3_03_00_04/setupenv.sh
export PATH=/home/ubuntu/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin:$PATH
export TI_RTOS_PATH=/home/ubuntu/ti
export IPC_INSTALL_PATH=/home/ubuntu/ti/ipc_3_44_01_01
  1. 编译
cd ~/ti-processor-sdk-linux-am57xx-evm-03.03.00.04

make ti-ipc-linux-examples

以上步骤已经完成了所有的编译工作。

准备文件系统

文件系统采用网络文件系统,从网络文件系统启动。这样便于测试。

构建网络文件系统:

cd ~/ti-processor-sdk-linux-am57xx-evm-03.03.00.04

sudo ./bin/setup-targetfs-nfs.sh

sudo ./bin/setup-tftp.sh

执行完成后会有

/tftpboot/

#和

~/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS 

#两个文件夹生成。

拷贝相应的启动文件:

  1. 拷贝内核设备树
sudo cp ~/ti-linux-kernel-dev/deploy/4.4.113-ti-xenomai-r149.zImage /tftpboot/zImage

sudo cp ~/ti-linux-kernel-dev/KERNEL/arch/arm/boot/dts/am572x-irc02-rev*.dtb /tftpboot/
  1. 解压驱动
sudo tar xfvp ~/ti-linux-kernel-dev/deploy/4.4.113-ti-xenomai-r149-modules.tar.gz -C ~/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS
  1. 准备测试文件:

    ex42_myforwardmsg:

rm -rf $HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware/myforwardmsg

mkdir -p $HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware/myforwardmsg

export SRCDIR=$HOME/ti/ipc_3_44_01_01/examples/DRA7XX_linux_elf/ex42_myforwardmsg

export DSTDIR=$HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware/myforwardmsg

#拷贝固件
cp $SRCDIR/dsp1/bin/release/server_dsp1.xe66 $DSTDIR

cp $SRCDIR/dsp2/bin/release/server_dsp2.xe66 $DSTDIR

cp $SRCDIR/ipu1/bin/release/server_ipu1.xem4 $DSTDIR

cp $SRCDIR/ipu2/bin/release/server_ipu2.xem4 $DSTDIR


#拷贝host主程序
cp $SRCDIR/host/bin/release/app_host $DSTDIR

#为固件建立软连接
cd $HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware

rm -f am57xx-pru*-fw

rm -f dra7-dsp1-fw.xe66

rm -f dra7-dsp2-fw.xe66

rm -f dra7-ipu1-fw.xem4

rm -f dra7-ipu2-fw.xem4

ln -s ./myforwardmsg/server_dsp1.xe66 dra7-dsp1-fw.xe66

ln -s ./myforwardmsg/server_dsp2.xe66 dra7-dsp2-fw.xe66

ln -s ./myforwardmsg/server_ipu1.xem4 dra7-ipu1-fw.xem4

ln -s ./myforwardmsg/server_ipu2.xem4 dra7-ipu2-fw.xem4

ex43_myforwardmsg:

rm -rf $HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware/myforwardmsg

mkdir -p $HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware/myforwardmsg

export SRCDIR=$HOME/ti/ipc_3_44_01_01/examples/DRA7XX_linux_elf/ex43_forwardmsg

export DSTDIR=$HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware/myforwardmsg

cp $SRCDIR/dsp1/bin/release/server_dsp1.xe66 $DSTDIR

#cp $SRCDIR/dsp2/bin/release/server_dsp2.xe66 $DSTDIR

cp $SRCDIR/ipu1/bin/release/server_ipu1.xem4 $DSTDIR

#cp $SRCDIR/ipu2/bin/release/server_ipu2.xem4 $DSTDIR

cp $SRCDIR/host/bin/release/app_host $DSTDIR

cd $HOME/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS/lib/firmware

rm -f am57xx-pru*-fw

rm -f dra7-dsp1-fw.xe66

#rm -f dra7-dsp2-fw.xe66

rm -f dra7-ipu1-fw.xem4

#rm -f dra7-ipu2-fw.xem4

ln -s ./myforwardmsg/server_dsp1.xe66 dra7-dsp1-fw.xe66

#ln -s ./myforwardmsg/server_dsp2.xe66 dra7-dsp2-fw.xe66

ln -s ./myforwardmsg/server_ipu1.xem4 dra7-ipu1-fw.xem4

#ln -s ./myforwardmsg/server_ipu2.xem4 dra7-ipu2-fw.xem4

至此完成所有固件的准备。

ex43_myforwardmsg_sd:

export SRCDIR=$HOME/ti/ipc_3_44_01_01/examples/DRA7XX_linux_elf/ex43_forwardmsg
export DSTDIR=/media/ubuntu/rootfs/lib/firmware/myforwardmsg

rm -rf $DSTDIR
mkdir -p $DSTDIR

cp $SRCDIR/dsp1/bin/release/server_dsp1.xe66 $DSTDIR
#cp $SRCDIR/dsp2/bin/release/server_dsp2.xe66 $DSTDIR
cp $SRCDIR/ipu1/bin/release/server_ipu1.xem4 $DSTDIR
#cp $SRCDIR/ipu2/bin/release/server_ipu2.xem4 $DSTDIR
cp $SRCDIR/host/bin/release/app_host $DSTDIR

cd $DSTDIR
cd ..

rm -f am57xx-pru*-fw
rm -f dra7-dsp1-fw.xe66
#rm -f dra7-dsp2-fw.xe66
rm -f dra7-ipu1-fw.xem4
#rm -f dra7-ipu2-fw.xem4

ln -s ./myforwardmsg/server_dsp1.xe66 dra7-dsp1-fw.xe66
#ln -s ./myforwardmsg/server_dsp2.xe66 dra7-dsp2-fw.xe66
ln -s ./myforwardmsg/server_ipu1.xem4 dra7-ipu1-fw.xem4
#ln -s ./myforwardmsg/server_ipu2.xem4 dra7-ipu2-fw.xem4

启动开发板

将上述得到的SD卡插入开发板,给开发板供电,连接TTL电平的串口通过串口连接终端,如果以上步骤没有问题,则可以看到开发板已经启动,终端能够输出启动信息。

启动UBOOT引导

使用xshell软件通过串口连接开发板,在开发板启动uboot的时候,会有等待3s的提示,在此期间按下键盘的任意按键,阻止uboot启动。

U-Boot SPL 2016.05-00320-g4270d815e5-dirty (Jul 02 2020 - 15:26:12)
DRA752-GP ES2.0
Trying to boot from MMC2_2
reading args
spl_load_image_fat_os: error reading image args, err - -1
reading u-boot.img
reading u-boot.img
reading u-boot.img
reading u-boot.img


U-Boot 2016.05-00320-g4270d815e5-dirty (Jul 02 2020 - 15:26:12 +0800)

CPU  : DRA752-GP ES2.0
Model: TI AM5728 BeagleBoard-X15
Board: BeagleBoard X15 REV C.00
DRAM:  2 GiB
MMC:   no pinctrl for sdr104
no pinctrl for ddr50
no pinctrl for sdr50
no pinctrl for sdr25
no pinctrl for sdr12
OMAP SD/MMC: 0, OMAP SD/MMC: 1
MMC: no card present
** Bad device mmc 0 **
Using default environment

SCSI:  SATA link 0 timeout.
AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst 
scanning bus for devices...
Found 0 device(s).
Net:   
Warning: ethernet@48484000 using MAC address from ROM
eth0: ethernet@48484000
Hit any key to stop autoboot:  0 
=> 

启动内核及nfs文件系统

连接网线,必须是第一个网口

如果是IRC02-a版硬件在终端输入

setenv loadaddr 0x82000000;setenv fdtaddr 0x88000000;setenv bootfile zImage;setenv fdtfile am572x-irc02-revA.dtb;setenv serverip 192.168.30.27;setenv rootpath /home/ubuntu/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS;run netboot

如果是IRC02-b版硬件在终端输入

setenv netmask 255.255.255.0;setenv gatewayip 192.168.30.254;setenv ipaddr 192.168.30.66;setenv loadaddr 0x82000000;setenv fdtaddr 0x88000000;setenv bootfile zImage;setenv fdtfile am572x-irc02-revB.dtb;setenv serverip 192.168.30.27;setenv rootpath /home/ubuntu/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS;run netboot

回车键启动。

启动完成后 root用户登录。

用户名:root

密码:空

相关调试手段:(可选)

  1. 虚拟机和嵌入式板子要建立nfs和tftp服务先要能ping通,板子进入uboot cmd 来ping虚拟机
  2. tftp服务可先行在Windows上验证(filezilla软件)一般能ssh的基本上tftp都能行。
  3. 关闭中继路由的DHCP服务并且不适用WLAN口(当交换机使用)
  4. 可在5728的板子上验证nfs服务:
#test
cd  /mnt
makdir nfsroot
sudo mount -o vers=4 192.168.30.27:home/ubuntu/ti-processor-sdk-linux-am57xx-evm-03.03.00.04/targetNFS /mnt/nfsroot
ls /mnt/nfsroot
sudo umount /mnt/nfsroot

相关uboot环境变量设置:(可选)

setenv ipaddr 192.168.30.66      //arm开发板ip

setenv serverip 192.168.30.27    //ubuntu ip地址

setenv gatewayip 192.168.30.254     //网关

setenv netmask 255.255.255.0     //子网掩码

save

saveenv

printenv
  1. u-boot 通过tftp调试:
setenv netmask 255.255.255.0;setenv gatewayip 192.168.30.254;setenv ipaddr 192.168.30.66;setenv serverip 192.168.30.27;tftp 0x82000000 u-boot.bin;go 0x82000000

测试IPC

在串口中断输入:

cd /lib/firmware/myforwardmsg/

打印各个核心的log

cat /sys/kernel/debug/remoteproc/remoteproc2/trace0

cat /sys/kernel/debug/remoteproc/remoteproc3/trace0

cat /sys/kernel/debug/remoteproc/remoteproc0/trace0

cat /sys/kernel/debug/remoteproc/remoteproc1/trace0

打印如下:

root@am57xx-evm:~# cd /lib/firmware/myforwardmsg/
root@am57xx-evm:/lib/firmware/myforwardmsg# cat /sys/kernel/debug/remoteproc/remoteproc2/trace0
[      0.000] 19 Resource entries at 0x95000000
[      0.000] [t=0x00025595] xdc.runtime.Main: --> main:
[      0.000] registering rpmsg-proto:rpmsg-proto service on 61 with HOST
[      0.000] [t=0x00a584d5] xdc.runtime.Main: NameMap_sendMessage: HOST 53, port=61
[      0.000] [t=0x00a7ba64] xdc.runtime.Main: --> smain:
[      0.000] [t=0x00a84806] xdc.runtime.Main: DSP1 4: 
[      0.000] [t=0x00a88de7] xdc.runtime.Main: DSP2 3: 
[      0.000] [t=0x00a8d383] xdc.runtime.Main: IPU1 2: 
[      0.000] [t=0x00a91802] xdc.runtime.Main: IPU2 1: 
[      0.346] [t=0x0fed3cc3] xdc.runtime.Main: attach IPU2...
[      0.352] [t=0x102f3e97] Server: Creating HeapBufMP...
[      1.354] [t=0x3b2f6503] Server: Server_create: server is ready
[      1.354] [t=0x3b2ffea8] Server: <-- Server_create: 0
[      1.354] [t=0x3b3058d5] Server: --> Server_exec:
root@am57xx-evm:/lib/firmware/myforwardmsg# 

测试通信:

cd /lib/firmware/myforwardmsg/
./app_host DSP
#或者
/lib/firmware/myforwardmsg/app_host DSP

如果出现如下打印说明通信正常:

 root@am57xx-evm:/lib/firmware/myforwardmsg# ./app_host DSP
--> main:
[  106.793144] omap-iommu 55082000.mmu: 55082000.mmu: version 2.1
[  106.830879] omap-iommu 58882000.mmu: 58882000.mmu: version 2.1
--> Main_main:
--> App_create:
App_create: Host is ready
<-- App_create:
--> App_exec:
App_exec: sending message 0
App_exec: message received, sending message 0
App_exec: sending message 1
App_exec: message received, sending message 1
App_exec: sending message 2
App_exec: message received, sending message 2
App_exec: sending message 3
App_exec: message received, sending message 3
App_exec: enum finished !
<-- App_exec: 0
--> App_delete:
<-- App_delete:
<-- Main_main:
<-- main:
root@am57xx-evm:/lib/firmware/myforwardmsg# 

再次查看log可以看出多了很多通信信息:

root@am57xx-evm:/lib/firmware/myforwardmsg# cat /sys/kernel/debug/remoteproc/remoteproc2/trace0
[      0.000] 19 Resource entries at 0x95000000
[      0.000] [t=0x00025595] xdc.runtime.Main: --> main:
[      0.000] registering rpmsg-proto:rpmsg-proto service on 61 with HOST
[      0.000] [t=0x00a584d5] xdc.runtime.Main: NameMap_sendMessage: HOST 53, port=61
[      0.000] [t=0x00a7ba64] xdc.runtime.Main: --> smain:
[      0.000] [t=0x00a84806] xdc.runtime.Main: DSP1 4: 
[      0.000] [t=0x00a88de7] xdc.runtime.Main: DSP2 3: 
[      0.000] [t=0x00a8d383] xdc.runtime.Main: IPU1 2: 
[      0.000] [t=0x00a91802] xdc.runtime.Main: IPU2 1: 
[      0.346] [t=0x0fed3cc3] xdc.runtime.Main: attach IPU2...
[      0.352] [t=0x102f3e97] Server: Creating HeapBufMP...
[      1.354] [t=0x3b2f6503] Server: Server_create: server is ready
[      1.354] [t=0x3b2ffea8] Server: <-- Server_create: 0
[      1.354] [t=0x3b3058d5] Server: --> Server_exec:
[     97.210] [t=0x00000010:4ce1378d] Server: Server_exec: processed cmd=0x6000000
[     97.211] [t=0x00000010:4cf0857b] Server: Server_exec: processed cmd=0x1000000
[     97.214] [t=0x00000010:4d14f29b] Server: Server_exec: processed cmd=0x2000000
root@am57xx-evm:/lib/firmware/myforwardmsg# 

主核(ARM A15 )和其它核是如何启动的:

  1. 主核随Linux系统启动

  2. 其它核在在Linux内核引导过程中被linux系统启动

For AM57x platforms, Modify the symbolic links in /lib/firmware of the default image names to the built binaries. The images pointed by the symbolic links will be downloaded to and started execution on the corresponding processors by remoteproc during Linux Kernel boots.

DSP image files: dra7-dsp1-fw.xe66  dra7-dsp2-fw.xe66
IPU image files: dra7-ipu1-fw.xem4  dra7-ipu2-fw.xem4

相关头文件位置:

/home/ubuntu/ti/ipc_3_44_01_01/packages/ti/ipc/MessageQ.h
/home/ubuntu/ti/ipc_3_44_01_01/packages/ti/sdo/ipc/MessageQ.h

C:\ti\ipc_3_47_01_00\packages\ti\ipc

传参demo打印:

root@am57xx-evm:~# /lib/firmware/myforwardmsg/app_host
--> main:
--> Main_main:
--> App_create:
App_create: Host is ready
<-- App_create:
--> App_exec:
App_exec: sending 1st message
App_exec: sending 2nd message
App_exec: Waiting for message 0...
App_exec: : a(9),b(9),rst(18),fun(1)
App_exec: : a(9) + b(9) is rst(18)
App_exec: message 0 received
App_exec: Waiting for message 1...
App_exec: : a(9),b(9),rst(81),fun(2)
App_exec: : a(9) * b(9) is rst(81)
App_exec: message 1 received
<-- App_exec: 0
--> App_delete:
<-- App_delete:
<-- Main_main:
<-- main:
root@am57xx-evm:~# 

如何安装固件:

#!/bin/sh

if [ -f "server_dsp1.xe66" ];then
    path=$(cd "$(dirname "$0")"; pwd)"/server_dsp1.xe66"
    rm /lib/firmware/dra7-dsp1-fw.xe66
    ln -s $path /lib/firmware/dra7-dsp1-fw.xe66
    echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/unbind
    echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/bind
fi

if [ -f "server_dsp2.xe66" ];then
    path=$(cd "$(dirname "$0")"; pwd)"/server_dsp2.xe66"
    rm /lib/firmware/dra7-dsp2-fw.xe66
    ln -s $path /lib/firmware/dra7-dsp2-fw.xe66
    echo 41000000.dsp > /sys/bus/platform/drivers/omap-rproc/unbind
    echo 41000000.dsp > /sys/bus/platform/drivers/omap-rproc/bind
fi

if [ -f "server_ipu1.xem4" ];then
    path=$(cd "$(dirname "$0")"; pwd)"/server_ipu1.xem4"
    rm /lib/firmware/dra7-ipu1-fw.xem4
    ln -s $path /lib/firmware/dra7-ipu1-fw.xem4
    echo 58820000.ipu > /sys/bus/platform/drivers/omap-rproc/unbind
    echo 58820000.ipu > /sys/bus/platform/drivers/omap-rproc/bind
fi

if [ -f "server_ipu2.xem4" ];then
    path=$(cd "$(dirname "$0")"; pwd)"/server_ipu2.xem4"
    rm /lib/firmware/dra7-ipu2-fw.xem4
    ln -s $path /lib/firmware/dra7-ipu2-fw.xem4
    echo 55020000.ipu > /sys/bus/platform/drivers/omap-rproc/unbind
    echo 55020000.ipu > /sys/bus/platform/drivers/omap-rproc/bind
fi

参考文档:

http://software-dl.ti.com/processor-sdk-linux/esd/docs/05_01_00_11/linux/Foundational_Components_IPC.html

rt_demo

ubuntu@arm:~$ sudo ./rt_demo 
deug_001 !
deug_002 !
deug_004 !
deug_006 !
deug_007 !
deug_005 !
100000 cycle !
100000 cycle !
100000 cycle !
ubuntu@ubuntu:~/demo/demo_mpu/rt_demo/_build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/demo/demo_mpu/rt_demo/_build
ubuntu@ubuntu:~/demo/demo_mpu/rt_demo/_build$ make
Scanning dependencies of target rt_demo
[100%] Building C object CMakeFiles/rt_demo.dir/rt_demo.c.o
Linking C executable rt_demo
[100%] Built target rt_demo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值