全志T113双核异构处理器的使用基于Tina Linux5.0——异构双核通信的具体实现
**5、TinaLinux异构双核通信的具体实现:**本章节以SBC-T113S4主板的TinaLinux为例,介绍异构双核通信的实现。该方法也同样适用于T113i平台。
本章节主要涉及到Tina Linux内核的配置、Tina Linux文件系统(openwrt)的配置、Freertos的配置。其中Tina Linux内核的配置包括设备树的配置及相关内核驱动及协议的配置;Tina Linux文件系统(openwrt)的配置包括异构双核通信测试程序和小核C906终端的配置;Freertos的配置包括通信协议的配置。
**5.1、TinaLinux的配置**
**5.1.1、Tina内核设备树配置**
在Tina根目录下,进入设备树目录(根据不同的处理器,进入不同的处理器目录),如下演示的是以SBC-T113S主板为例,该主板的主处理器是T113-S4,其配置文件都放在device/config/chips/t113_s4/configs/sbc_t113s4_nand/的目录下,内核的设备树则放在device/config/chips/t113_s4/configs/sbc_t113s4_nand/linux-5.4目录:
```
xxx@xxx:~/workspaces/t113_tina5.0$ cd device/config/chips/t113_s4/configs/sbc_t113s4_nand/
```
**编辑设备树**
```
xxx@xxx:~/workspaces/t113_tina5.0/device/config/chips t113_s4/configs/sbc_t113s4_nand/linux-5.4 $ vi board.dts
```
在设备树文件中找到C906相关的设备树节点,设备树默认设置为:
```
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
/* c906 */
c906_ddr: c906_ddr@42300000 {
reg = <0x0 0x42300000 0x0 0x00600000>;
no-map;
};
/*
* The name should be "vdev%dbuffer".
* Its size should be not less than
* RPMSG_BUF_SIZE * (num of buffers in a vring) * 2
* = 512 * (num of buffers in a vring) * 2
*/
rv_vdev0buffer: vdev0buffer@42900000 {
compatible = "shared-dma-pool";
reg = <0x0 0x42900000 0x0 0x40000>;
no-map;
};
/*
* The name should be "vdev%dvring%d".
* The size of each should be not less than
* PAGE_ALIGN(vring_size(num, align))
* = PAGE_ALIGN(16 * num + 6 + 2 * num + (pads for align) + 6 + 8 * num)
*
* (Please refer to the vring layout in include/uapi/linux/virtio_ring.h)
*/
rv_vdev0vring0: vdev0vring0@42940000 {
reg = <0x0 0x42940000 0x0 0x2000>;
no-map;
};
rv_vdev0vring1: vdev0vring1@42942000 {
reg = <0x0 0x42942000 0x0 0x2000>;
no-map;
};
/* dsp0 */
dsp0ddr: dsp0ddr@42000000 {
reg = <0x0 0x42000000 0x0 0x00100000>;
no-map;
};
dsp0_rpbuf_reserved: dsp0_rpbuf@42244000 {
compatible = "shared-dma-pool";
no-map;
reg = <0x0 0x42244000 0x0 0x8000>;
};
/*
* The name should be "vdev%dbuffer".
* Its size should be not less than
* RPMSG_BUF_SIZE * (num of buffers in a vring) * 2
* = 512 * (num of buffers in a vring) * 2
*/
vdev0buffer: vdev0buffer@42200000 {
compatible = "shared-dma-pool";
reg = <0x0 0x42200000 0x0 0x40000>;
no-map;
};
/*
* The name should be "vdev%dvring%d".
* The size of each should be not less than
* PAGE_ALIGN(vring_size(num, align))
* = PAGE_ALIGN(16 * num + 6 + 2 * num + (pads for align) + 6 + 8 * num)
*
* (Please refer to the vring layout in include/uapi/linux/virtio_ring.h)
*/
vdev0vring0: vdev0vring0@42240000 {
reg = <0x0 0x42240000 0x0 0x2000>;
no-map;
};
vdev0vring1: vdev0vring1@42242000 {
reg = <0x0 0x42242000 0x0 0x2000>;
no-map;
};
/*
* dsp ram addr
*/
dsp0dram: dsp0dram@400000 {
reg = <0x0 0x400000 0x0 0x10000>;
no-map;
};
dsp0iram0: dsp0iram0@420000 {
reg = <0x0 0x420000 0x0 0x8000>;
no-map;
};
dsp0iram1: dsp0iram1@440000 {
reg = <0x0 0x440000 0x0 0x8000>;
no-map;
};
};
mailbox_heartbeat: mailbox_heartbeat@0 {
compatible = "mailbox-heartbeat";
rproc-np = <&c906_rproc>;
mboxes = <&msgbox 6>, <&msgbox 7>;
mbox-names = "tx", "rx";
status = "okay";
};
dsp0_rproc: dsp_rproc@0 {
compatible = "allwinner,hifi4-rproc", "simple-bus";
clock-frequency = <600000000>;
clocks = <&ccu CLK_PLL_PERIPH0_2X>, <&ccu CLK_DSP>, <&ccu CLK_BUS_DSP_CFG>, <&r_ccu CLK_R_AHB>;
clock-names = "pll", "mod", "cfg", "ahbs";
resets = <&ccu RST_BUS_DSP>, <&ccu RST_BUS_DSP_CFG>, <&ccu RST_BUS_DSP_DBG>, <&ccu RST_BUS_MSGBOX1>;
reset-names = "mod-rst", "cfg-rst", "dbg-rst", "msg-rst";
reg = <0x0 0x03000008 0x0 0x04>,
<0x0 0x01700000 0x0 0x40>;
reg-names = "sram-for-cpux", "hifi4-cfg";
mboxes = <&msgbox 0>;
mbox-names = "arm-kick";
memory-region = <&dsp0ddr>, <&vdev0buffer>, <&vdev0vring0>, <&vdev0vring1>,
<&dsp0dram>, <&dsp0iram0>, <&dsp0iram1>;
memory-mappings =
/* < DA len PA > */
/* local SRAM via external bus */
< 0x28000 0x20000 0x28000 >,
/* local SRAM via internal bus */
< 0x400000 0x10000 0x400000 >,
< 0x420000 0x8000 0x420000 >,
< 0x440000 0x8000 0x440000 >,
/* DDR front 256MB */
< 0x10000000 0x10000000 0x40000000 >,
/* local SRAM via internal bus */
< 0x20028000 0x10000 0x400000 >,
< 0x20038000 0x8000 0x420000 >,
< 0x20040000 0x8000 0x440000 >,
/* DDR front 256MB */
< 0x30000000 0x10000000 0x40000000 >,
/* DDR front 1GB */
< 0x40000000 0x40000000 0x40000000 >,
/* DDR front 1GB */
< 0x80000000 0x40000000 0x40000000 >,
/* DDR front 1GB */
< 0xC0000000 0x40000000 0x40000000 >;
id = <0>;
status = "okay";
};
rpbuf_controller0: rpbuf_controller@0 {
compatible = "allwinner,rpbuf-controller";
remoteproc = <&dsp0_rproc>;
ctrl_id = <0>; /* index of /dev/rpbuf_ctrl */
//iommus = <&mmu_aw 5 1>;
memory-region = <&dsp0_rpbuf_reserved>;
status = "okay";
};
rpbuf_sample: rpbuf_sample@0 {
compatible = "allwinner,rpbuf-sample";
rpbuf = <&rpbuf_controller0>;
status = "okay";
};
c906_rproc: c906_rproc@0 {
compatible = "allwinner,c906-rproc";
clock-frequency = <800000000>;
clocks = <&ccu CLK_PLL_PERIPH0_800M>, <&ccu CLK_RISCV>, <&ccu CLK_BUS_RISCV_CFG>, <&ccu CLK_RISCV_RST>, <&ccu CLK_BUS_RISCV>;
clock-names = "pll", "mod", "cfg", "riscv-rst", "riscv-gate";
resets = <&ccu RST_BUS_RISCV_CFG>, <&ccu RST_BUS_MSGBOX2>;
reset-names = "cfg-rst", "msg-rst";
memory-region = <&c906_ddr>, <&rv_vdev0buffer>, <&rv_vdev0vring0>, <&rv_vdev0vring1>;
reg = <0x0 0x06010000 0x0 0x1000>;
reg-names = "c906-cfg";
mboxes = <&msgbox 4>;
mbox-names = "arm-kick";
memory-mappings =
/* DA len PA */
/* DDR for c906*/
< 0x40000000 0x10000000 0x40000000 >;
firmware-name = "amp_rv0.bin";
status = "okay";
};
```
SBC-T113S主板暂时使用uart3打印C906小核的打印信息(可以分配其他串口作为C906的终端,只要大核和小核的分配不冲突即可),为防止Tina内核抢占uart3,所以务必禁用uart3节点。
```
&uart3 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&uart3_pins_a>;
pinctrl-1 = <&uart3_pins_b>;
status = "disabled";
};
```
**5.1.2、Tina内核配置**
在Tina根目录下,执行make kernel_menuconfig,例如:
```
xxx@xxx:~/workspaces/t113_tina5.0$ make kernel_menuconfig
```
* **使能硬件支持**
进入内核配置界面后,进入Device Drivers 目录,选中Mailbox Hardware Support:
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979568775-9140a6ef-b546-41b4-968d-4766c0248be4-image.png)
选中后进入Mailbox Hardware Support选项中,选中Allwinner Mailbox support:
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979583564-459fda62-69d7-4b3f-999c-92af0dddccc8-image.png)
* **使能RPMsg驱动**
进入如下目录中
→ Device Drivers
→ Rpmsg drivers
选中如下配置
<*> allwinnertech rpmsg hearbeat driver
<*> allwinner rpmsg tty driver
<*> sunxi rpmsg ctrl driver
<*> Virtio RPMSG bus driver
选中完成后如下图所示:
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979619834-5fe56d87-3005-4552-aa3b-5398d3390679-image.png)
* **使能RPBuf驱动**
进入如下目录中
→ Device Drivers
→ Rpbuf drivers
-*- Rpbuf device interface
<*> Rpmsg-based Rpbuf service driver
<*> Allwinner Rpbuf controller driver
<*> Allwinner Rpbuf sample driver
注:
1)Allwinner Rpbuf sample driver只是内核层的一个demo程序,可以不选。
2)如果异构双核不进行大数据传输,RPBuf驱动可以不选。
选中完成后如下图所示:
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979662300-8810021b-226a-4785-b61f-4fc582b3cef5-image.png)
* **使能共享内存驱动**
进入如下目录中
→ Device Drivers
→ Remoteproc drivers
选中如下配置
<*> SUNXI remote processor support --->
<*>Allwinner remoteproc support
<*>Allwinner remoteproc hifi4 boot//控制hifi4 dsp小核
<*>Allwinner remoteproc c906 boot ////控制c906小核
如下图所示:
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979694675-07da5097-ed02-4f1e-a62f-b09002e00414-image.png)
修改完成后,保存内核配置并退出。
**5.1.3、Tina文件系统配置(Openwrt)**
配置中增加了amp_shell,这个是C906的控制台。另外也增加了rpbuf和rpmsg的演示程序,便于后续测试验证。
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979735077-8a7bfefd-5684-48dc-8f8b-bd56a7c69c54-image.png)
**5.1.4、编译Tina新固件**
在Tina根目录下,输入mkernel指令编译刚刚选中的内核驱动,编译完成后,输入pack,打包生成新镜像(此时RTOS的固件并没有进行更新),例如:
```
xxx@xxx:~/workspaces/t113_tina5.0$ mkernel
...
xxx@xxx:~/workspaces/t113_tina5.0$ pack
...
```
如果需要将RTOS更新一并打包到固件,只要执行make –j32(32表示计算机处理器的线程数,根据具体计算机而定),编译结束后执行pack指令将生成的t113_s4_linux_sbc_t113s4_xxx.img(以SBC-T113S4主板为例)文件拷贝到Windows主机端,此时Tina的固件里面已经包含了新配置的RTOS。
**5.2、C906 FreeRTOS内核配置及应用**
麻雀虽小,一应俱全!FreeRTOS是一个实时的微型操作系统,它和大多数操作系统都一样,都具备内核和文件系统两个部分,内核重点是任务调度和文件系统管理等,文件系统则集成部分现成的指令和相关应用库并方便启动应用(APP)。另外,FreeRTOS还可以配置终端,刚刚说的指令,就是在终端里面执行的。有了调试终端给FreeRTOS应用调试带来了很大的方便。以下将如何配置FreeRTOS终端、如何配置FreeRTOS驱动组件、如何配置FreeRTOS异构通信演示程序等进行说明。
**5.2.1、修改C906链接脚本**
C906的FreeRTOS是有运行地址的,该运行地址在Tina内核的DTS中有明确,在RTOS对应的项目中也必须一致。以t113_s4_c906_evb1_auto项目为例,这里说的项目该项目涉及的相关代码核配置信息在SDK所在目录/rtos/lichee/rtos/projects/t113_s4_c906/evb1_auto中,该目录中有如下文件:
```
xxx@xxx:~/workspace/t113_tina5.0/rtos/lichee/rtos/projects/t113_s4_c906/evb1_auto$ tree -l
.
├── defconfig
├── defconfig_org
├── freertos.lds.S
├── Kconfig
├── Makefile
└── src
├── alsa_config.c
├── assert.c
├── card_default.c
├── FreeRTOSConfig.h
├── hooks.c
└── main.c
```
找到freertos.lds.S文件,该文件保存有C906小核的链接信息。
修改freertos.lds.S,找到MEMORY节点,确认起始地址为0x42300000,长度为0x00600000。此参数需要和Tina设备树中的C906内存参数一致,查看kernel.lds 中MEMORY节点参数为:
```
/* Linker script to configure memory regions. */
MEMORY
{
RAM (rwx) : ORIGIN = CONFIG_ARCH_START_ADDRESS, LENGTH = CONFIG_ARCH_MEM_LENGTH
}
```
CONFIG_ARCH_START_ADDRESS和CONFIG_ARCH_MEM_LENGTH这两个参数在defconfig(和freertos.lds.S同一目录)中,查看defconfig内容如下:
```
#
# Architecture Options
#
# CONFIG_ARCH_ARM is not set
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_START_ADDRESS=0x42300000
CONFIG_ARCH_MEM_LENGTH=0x600000
CONFIG_LITTLE_ENDIAN=y
CONFIG_BITS_PER_LONG=64
# CONFIG_CACHE_ALIGN_CHECK is not set
CONFIG_TOOLCHAIN_FLOAT_HARD=y
CONFIG_PANIC_CLI=y
CONFIG_PANIC_CLI_PWD=y
CONFIG_IMG_VERSION_MESSAGE=y
```
确认和Tina Linux内核的dts配置一致。
Tina Linux内核的dts的配置如下:
```
/* c906 */
c906_ddr: c906_ddr@42300000 {
reg = <0x0 0x42300000 0x0 0x00600000>;
no-map;
};
```
**5.2.2、RTOS终端使用uart3**
在RTOS定制中,修改引脚分配也是通过修改sys_config.fex来完成的,以t113_s4_c906_evb1_auto项目为例,该文件在在SDK所在目录/rtos/board/t113_s4_c906/evb1_auto/configs目录下。
通过查询数据手册,查看引脚复用功能,假如我们使用PE8和PE9作为uart3作为终端串口:
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979924630-51d97141-803f-4c54-8324-2a9a0fa12fb8-image.png)
修改uart3节点作为终端串口:
```
uart_debug_port = 3
uart_debug_tx = port:PE08<5><1><default><default>
uart_debug_rx = port:PE09<5><1><default><default>
```
**5.3、修改RTOS相关组件的配置并编译**
进入SDK所在目录/rtos/,执行source envsetup.sh,单独开起RTOS的编译环境。
然后按照3.2.2章节进入RTOS方案的选择和配置,执行配置指令mrtos_menuconfig,
进入后选中如下配置:
```
→ Drivers Options
→ soc related device drviers
→ UART Decives
[*] support uart3 device
cli uart port number
```
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731979983847-3eae4129-7af5-49ac-801b-03b6b807a05a-image.png)
进入如下目录,选中[*] enable sysconfig,启用读取解析 sys_config.fex 功能
```
→ Drivers Options
→ soc related device drivers
→ Common Option
[*] enable sysconfig
```
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731980011889-c75c4609-f137-4a3e-a944-1be021dccca6-image.png)
分别进入如下界面,选择对应的rpmsg/rpbuf/messagebox驱动,这些驱动与Tina Linux中的驱动对应。
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731980023832-22f32ad2-0dd7-4991-99ac-c48d8f1d31e9-image.png)
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731980029764-720ad873-a333-457f-be05-b4754dba8a71-image.png)
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731980040628-c593e5d8-7f5e-4409-8fad-253e08086cc9-image.png)
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731980046634-c6cb74ef-097e-48c1-9968-bdc9f25fb65b-image.png)
进入如下界面,选中Freertos终端相关配置
[*] Multi Console Support
[*] Uart Multi Console Support
[ ] Uart Multi Console As Main Console
[*] Rpmsg Multi Console Support
[*] Rpmsg Multi Console Enable Cache Cmd
![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://bbs.aw-ol.com/assets/uploads/files/1731980088972-0285106f-cb98-47ab-9887-f331d1814fe5-image.png)
注:Rpmsg Multi Console Support这个配置是和Tina Linux中的amp_shell控制台对应。
本次演示主要为了演示异构双核通信,配置基本完成。如果用户有其他应用需求,用户可以根据自己的需求进行配置。保存配置退出后,接下来进行编译。
```
ping@embedall:~/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos$ m
build rtos ...
===There isn't tina environment.===
Note: will use shell command origin rather than the functon.
Dark Builder
Version (1.6.0 - BiCEP2 (Gravitational Waves))
* build/t113_s4_c906_evb1_auto/img/sys_config.fex
projects/t113_s4_c906/evb1_auto/freertos.lds
CC build/t113_s4_c906_evb1_auto/arch/common/common.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/common/exception.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/common/clocksource.o
AS build/t113_s4_c906_evb1_auto/arch/common/sys_config.o
CC build/t113_s4_c906_evb1_auto/arch/common/version.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/sun8iw20p1/sun8i.o
AS build/t113_s4_c906_evb1_auto/arch/risc-v/c906/head_s.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/c906/plic.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/c906/cache.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/c906/spinlock.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/c906/clic.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/c906/platform/platform_sun8iw20.o
CC build/t113_s4_c906_evb1_auto/arch/risc-v/c906/interrupt.o
CC build/t113_s4_c906_evb1_auto/components/thirdparty/console/FreeRTOS_CLI.o
CC build/t113_s4_c906_evb1_auto/components/common/thirdparty/md5/md5.o
……
LD build/t113_s4_c906_evb1_auto/components/common/thirdparty/openamp/open-amp/obj-in.o
LD build/t113_s4_c906_evb1_auto/components/common/thirdparty/openamp/obj-in.o
LD build/t113_s4_c906_evb1_auto/components/common/thirdparty/obj-in.o
LD build/t113_s4_c906_evb1_auto/components/obj-in.o
LD build/t113_s4_c906_evb1_auto/drivers/rtos-hal/hal/source/ccmu/sunxi-ng/obj-in.o
LD build/t113_s4_c906_evb1_auto/drivers/rtos-hal/hal/source/ccmu/obj-in.o
LD build/t113_s4_c906_evb1_auto/drivers/rtos-hal/hal/source/twi/obj-in.o
LD build/t113_s4_c906_evb1_auto/drivers/rtos-hal/hal/source/obj-in.o
LD build/t113_s4_c906_evb1_auto/drivers/rtos-hal/hal/obj-in.o
LD build/t113_s4_c906_evb1_auto/drivers/obj-in.o
LD build/t113_s4_c906_evb1_auto/kernel/FreeRTOS-orig/obj-in.o
LD build/t113_s4_c906_evb1_auto/kernel/obj-in.o
build/t113_s4_c906_evb1_auto/img/rt_system.elf
if [ -n /home/ping/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos/lichee/rtos/build/t113_s4_c906_evb1_auto/img/]; then mkdir -p /home/ping/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos/lichee/rtos/build/t113_s4_c906_evb1_auto/img; fi
Memory region Used SizeRegion Size%age Used
RAM: 214096 B 6 MB 3.40%
* build/t113_s4_c906_evb1_auto/img/rt_system.bin
* build/t113_s4_c906_evb1_auto/img/rt_system.syms
text data bss dec hex filename
134576 69048 10472214096 34450 build/t113_s4_c906_evb1_auto/img/rt_system.elf
copying /home/ping/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos/lichee/rtos/build/t113_s4_c906_evb1_auto/img/rt_system.bin to /home/ping/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos/board/t113_s4_c906/evb1_auto/bin/freertos.fex
#### make completed successfully
'/home/ping/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos/lichee/rtos/build/t113_s4_c906_evb1_auto/img/rt_system.bin' -> '/home/ping/workspace/t113_tina5.0/t113_tinasdk5.0-v1/rtos/board/t113_s4_c906/evb1_auto/bin/rtos_riscv_sun8iw20p1.f
```
编译完成后会在SDK目录下的/rtos/board/t113_s4_c906/evb1_auto/bin目录生成rtos_riscv_sun8iw20p1.fex和freertos.fex,这两个文件是一样的。
**5.4、核对所选FreeRTOS组件**
配置FreeRTOS组件是为了完成FreeRTOS APP的开发。本次的APP要完成的是异构通信,我们查看t113_s4_c906_evb1_auto项目代码了解其运行过程。
t113_s4_c906_evb1_auto项目的相关代码核配置信息在SDK所在目录/rtos/lichee/rtos/projects/t113_s4_c906/evb1_auto中,该目录中有如下文件:
```
xxx@xxx:~/workspace/t113_tina5.0/rtos/lichee/rtos/projects/t113_s4_c906/evb1_auto$ tree -l
.
├── defconfig
├── defconfig_org
├── freertos.lds.S
├── Kconfig
├── Makefile
└── src
├── alsa_config.c
├── assert.c
├── card_default.c
├── FreeRTOSConfig.h
├── hooks.c
└── main.c
```
重点查看main.c文件,该文件内容如下:
```
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "interrupt.h"
#include <portmacro.h>
#include "FreeRTOS.h"
#include "task.h"
#include <openamp/sunxi_helper/openamp.h>
#include <console.h>
#ifdef CONFIG_DRIVERS_MSGBOX
#include <hal_msgbox.h>
#endif
#ifdef CONFIG_COMPONENTS_AW_DEVFS
#include <devfs.h>
#endif
#ifdef CONFIG_COMPONENTS_OPENAMP
#include <openamp/sunxi_helper/rpmsg_master.h>
extern int openamp_init(void);
extern int rpbuf_init(void);
void openamp_init_thread(void *param)
{
(void)param;
openamp_init();
#ifdef CONFIG_RPMSG_CLIENT
rpmsg_ctrldev_create();
#endif
#ifdef CONFIG_RPMSG_HEARBEAT
extern int rpmsg_heart_init(void);
rpmsg_heart_init();
#endif
#ifdef CONFIG_MULTI_CONSOLE
extern int multiple_console_init(void);
multiple_console_init();
#endif
#ifdef CONFIG_COMPONENTS_RPBUF
extern int rpbuf_init(void);
rpbuf_init();
#endif
hal_thread_stop(NULL);
}
#endif
void cpu0_app_entry(void *param)
{
(void)param;
#ifdef CONFIG_COMPONENTS_AW_DEVFS
devfs_mount("/dev");
#endif
#if defined CONFIG_COMPONENTS_OPENAMP
void *thread;
thread = hal_thread_create(openamp_init_thread, NULL,
"amp_init", 8 * 1024, HAL_THREAD_PRIORITY_SYS);
if (thread != NULL)
hal_thread_start(thread);
#endif
#ifdef CONFIG_COMPONENT_CLI
vCommandConsoleStart(0x1000, HAL_THREAD_PRIORITY_CLI, NULL);
#endif
vTaskDelete(NULL);
}
```
该程序的入口函数是cpu0_app_entry,该程序通过函数hal_thread_create建立了openamp_init_thread线程。该线程通过openamp_init函数进行了openamp框架的初始化,同时如果选择了rpmsg通信,也进行了rpmsg通信的初始化等。可判定所选的FreeRTOS相关组件可以满足要求。
**5.5、主板内使能C906**
启动主板,打开串口终端进入主板控制台,将freertos.fex拷贝到/lib/firmware目录下。假设使用ADB功能将文件拷贝到主板的root/目录下
```
root@TinaLinux:~# cd /root/
root@TinaLinux:~# ls
freertos.fex
```
将root目录下的freertos.fex拷贝到/lib/firmware目录下
```
root@TinaLinux:~# cp freertos.fex /lib/firmware/
root@TinaLinux:~# ls /lib/firmware/
boot_xr829.bin fw_xr829.bin freertos.fex sdd_xr829.bin
etf_xr829.bin fw_xr829_bt.bin regulatory.db
```
拷贝完成后,可以在/lib/firmware目录下看到小核固件。接下来把主板的UART3(在RTOS配置中已经把UART3配置成终端串口)与计算机的串口连接起来,并配置计算机串口波特率为115200,通过计算机串口可以查看小核的相关信息。在Tina Linux主板串口终端输入指令:
```
root@TinaLinux:~# echo freertos.fex > /sys/class/remoteproc/remoteproc1/firmware
```
这一步是将freertos.fex固件放在硬件节点firmware 。接下来启动C906固件,指令如下:
```
root@TinaLinux:~#echo start > /sys/class/remoteproc/remoteproc1/state
remoteproc remoteproc1: powering up c906_rproc
[ 1489.549950] remoteproc remoteproc1: Booting fw image amp_rv0.bin, size 224392
[ 1489.558282] remoteproc remoteproc1: the version: UTS - Thu, 24 Oct 2024 14:39:36 +0800
[ 1489.558282] Compile Time - 14:39:36
[ 1489.571527]remoteproc1#vdev0buffer: assigned reserved memory node vdev0buffer@42900000
[ 1489.581143] virtio_rpmsg_bus virtio0: rpmsg host is online
[ 1489.587680]remoteproc1#vdev0buffer: registered virtio0 (type 7)
[ 1489.594617] remoteproc remoteproc1: remote processor c906_rproc is now up
root@TinaLinux:/# [ 1489.695824] virtio_rpmsg_bus virtio0: creating channel sunxi,rpmsg_ctrl addr 0x400
[ 1489.715788] virtio_rpmsg_bus virtio0: creating channel rpbuf-service addr 0x401
[ 1489.724381] rpbuf_service_rpmsg virtio0.rpbuf-service.-1.1025: rpmsg device parent 0: virtio0
[ 1489.734036] rpbuf_service_rpmsg virtio0.rpbuf-service.-1.1025: rpmsg device parent 1: remoteproc1#vdev0buffer
[ 1489.745237] rpbuf_service_rpmsg virtio0.rpbuf-service.-1.1025: rpmsg device parent 2: remoteproc1
[ 1489.755242] rpbuf_service_rpmsg virtio0.rpbuf-service.-1.1025: rpmsg device parent 3: 6010000.c906_rproc
[ 1489.766110] virtio_rpmsg_bus virtio0: creating channel sunxi,rpmsg_heartbeat addr 0x402
使能后可以在UART3上查看RV核的信息:
cpu0>help
Lists all the registered commands
[ help-built-in]--------------Lists all the built-in registered commands
[ ts]--------------Displays a table showing the state of each FreeRTOS task
[ run-time-stats]--------------Displays a table showing how much processing time each FreeRTOS task has used
[ echo-3-parameters]--------------echo-3-parameters <param1> <param2> <param3>: Expects three parameters, echos each in turn
[ echo-parameters]--------------echo-parameters <...>: Take variable number of parameters, echos each in turn
[ rpbuf_demo]--------------rpbuf demo
[ rpbuf_test]--------------rpbuf test demo
[ console_dump]--------------dum all cli console info
[ exit]--------------Console Exit Command
[ msgbox_demo]--------------msgbox demo
[ help]--------------List all registered commands
[ backtrace]--------------Backtrace Command
[ md5sum]--------------Calculate md5sum
--------------rproc dump mapping
[ eptdev_send]--------------send data used by rpmsg ept test
[ eptdev_close]--------------close rpmsg ept client
[ rpmsg_list_epts]--------------list endpoints
[ rpmsg_list_listen]--------------list listen
[ jtag]--------------init jtag gpio
--------------release rpmsg ctrldev
--------------init rpmsg ctrldev
[ eptdev_reset]--------------reset rpmsg ctrl
[ eptdev_clear]--------------clear rpmsg name group
[ eptdev_unbind]--------------unbind rpmsg ept listen
[ eptdev_bind]--------------bind rpmsg ept name
[ rpmsg_test]--------------rpmsg test
[ rpmsg_test_send]--------------rpmsg test send
[ rpmsg_test_init]--------------init rpmsg test
[ rpmsg_test_extend]--------------rpmsg test with another rproc
[ hal_msgbox]--------------hal msgbox
cpu0>
查看RV核目前的任务:
cpu0>ts
Task StatePriorityStack #
************************************************
Name State Pri HWM Idx StkCur StkBot
CLI X 18 3742 5 0x42363e30 0 x4235c510
IDLE R 0 980 2 0x42348250 0 x423463b0
Tmr Svc B 31 1978 3 0x4234c220 0 x423483c0
ctrldev B 6 4026 8 0x4237d460 0 x42375690
cpu-vring-ipi B 31 8128 7 0x42374780 0 x42364950
```
页:
[1]