我想在Linux引导上引导远程处理器,或者将其与内核设备驱动程序一起引导。
我有一个带TI AM355x SoC的BeagleBone Black,它具有在Debian 9.5 IoT armhf 2018-10-17
内核上运行4.14-ti
的主处理器和两个通过remoteproc可用的PRU处理器。 Remoteproc是活动的,并且PRU在sysfs中/sys/class/remoteproc/remoteproc{1/2}/
下可用。我可以使用上述界面成功启动PRU。
我尝试过:
rc.d
脚本来启动处理器,但是似乎在执行它们时不可用。struct rproc
中的struct rproc *rproc_get_by_phandle(phandle)
接口在我的内核模块中获取一个linux/remoteproc.h
句柄。句柄是这样的:0x3
代表PRUSS,0x8
代表pru0,0x9
代表pru1。这些都不起作用。其实,我认为没有人能使用此功能。我尝试了insmod
,并添加了要在启动时加载的模块到/lib/modules/$(uname -r)
,并在/etc/modules
中添加了一个条目。这两个版本都无法检索该结构。
我可以看到来自4.14-ti内核的linux头文件包含一个带有linux/pruss.h
函数的pruss_get
文件,但是它使用一个struct rproc
作为参数,因此使我无法使用它。
#!/bin/bash
### BEGIN INIT INFO
# Provides: config_pru
# Required-Start: kmod
# Required-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Configure pins and launch pru
# Description:
### END INIT INFO
config-pin P8_11 pruout
config-pin P8_15 pruin
config-pin P8_12 pruout
config-pin P8_16 pruin
echo am335x-pru0-fw > /sys/class/remoteproc/remoteproc1/firmware
echo start > /sys/class/remoteproc/remoteproc1/state
模块文件片段
static struct rproc *pru0_rproc;
(...)
static int get_pru0_rproc(void)
{
pru0_rproc = rproc_get_by_phandle(0x3); // Both 0x8 0x9 doesn't work
printk(KERN_INFO "rproc_get_by_phandle: trying 0x3");
return -(pru0_rproc == NULL);
}
static int __init prusw_init(void)
{
(...)
if (get_pru0_rproc())
{
printk(KERN_INFO "prusw: Failed to retrieve PRU0 rproc handle");
goto deinit_rproc;
}
(...)
}
反编译的DTB
/dts-v1/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
part-number = "AM335X-PRU-RPROC-4-14-TI";
version = "00A0";
fragment@0 {
target-path = [2f 00];
__overlay__ {
ocp {
#address-cells = <0x1>;
#size-cells = <0x1>;
pruss_soc_bus@4a326004 {
compatible = "ti,am3356-pruss-soc-bus";
reg = <0x4a326004 0x4>;
ti,hwmods = "pruss";
#address-cells = <0x1>;
#size-cells = <0x1>;
ranges = <0x0 0x4a3000
status = "okay";
linux,phandle = <0x2>;
phandle = <0x2>;
pruss@0 {
compatible = "ti,am3356-pruss";
reg = <0x0 0x80000>;
interrupts = <0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b>;
interrupt-names = "host2", "host3", "host4", "host5", "hh
ost6", "host7", "host8", "host9";
#address-cells = <0x1>;
#size-cells = <0x1>;
ranges;
status = "okay";
linux,phandle = <0x3>;
phandle = <0x3>;
(...)
pru@34000 {
compatible = "ti,am3356-pru";
reg = <0x34000 0x2000 0x22000 0x400 0x22400 0x100>;
reg-names = "iram", "control", "debug";
firmware-name = "am335x-pru0-fw";
interrupt-parent = <0x1>;
interrupts = <0x10 0x11>;
interrupt-names = "vring", "kick";
linux,phandle = <0x8>;
phandle = <0x8>;
};
pru@38000 {
compatible = "ti,am3356-pru";
reg = <0x38000 0x2000 0x24000 0x400 0x24400 0x100>;
reg-names = "iram", "control", "debug";
firmware-name = "am335x-pru1-fw";
interrupt-parent = <0x1>;
interrupts = <0x12 0x13>;
interrupt-names = "vring", "kick";
linux,phandle = <0x9>;
phandle = <0x9>;
};
(...)
我无法以非手动方式启动任何PRU,我想在启动或内核驱动程序模块加载时自动执行。