Skip to content

Commit

Permalink
examples: linux: remove any loading or unloading of modules
Browse files Browse the repository at this point in the history
As the requirements for RPMsg usage can change over time, remove the loading
and unloading of drivers in the Linux app. Instead put the onus on the user to
manage the driver.

Update documentation of demos in READMEs

Signed-off-by: Ben Levinsky <ben.levinsky@amd.com>
  • Loading branch information
bentheredonethat authored and arnopo committed Feb 6, 2023
1 parent 1e91a36 commit 7f1fb3b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 47 deletions.
12 changes: 12 additions & 0 deletions examples/linux/rpmsg-echo-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,21 @@
# check remote processor state
cat /sys/class/remoteproc/remoteproc0/state
# load rpmsg_char driver
modprobe rpmsg_char
# load rpmsg_ctrl driver
modprobe rpmsg_ctrl
# Run echo_test application on host processor
echo_test
# unload rpmsg_ctrl driver
modprobe -r rpmsg_ctrl
#unload rpmsg_char driver
modprobe -r rpmsg_char
# Stop remote processor
echo stop > /sys/class/remoteproc/remoteproc0/state
```
15 changes: 0 additions & 15 deletions examples/linux/rpmsg-echo-test/echo_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,6 @@ int main(int argc, char *argv[])
char ept_dev_path[32];

printf("\r\n Echo test start \r\n");

/* Load rpmsg_char driver */
printf("\r\nHost>probe rpmsg_char\r\n");
ret = system("set -x; lsmod; modprobe rpmsg_char");
if (ret < 0) {
perror("Failed to load rpmsg_char driver.\n");
return -EINVAL;
}

/*
* try probbing rpmsg_ctrl for new kernel, However it's not failure
* if rpmsg_ctrl is not available in case of kernel < 6.0
*/
system("modprobe rpmsg_ctrl");

lookup_channel(rpmsg_dev, &eptinfo);

while ((opt = getopt(argc, argv, "d:n:s:e:")) != -1) {
Expand Down
12 changes: 12 additions & 0 deletions examples/linux/rpmsg-mat-mul/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@
# check remote processor state
cat /sys/class/remoteproc/remoteproc0/state
# load rpmsg_char driver
modprobe rpmsg_char
# load rpmsg_ctrl driver
modprobe rpmsg_ctrl
# Run Matrix multiplication application on host processor
mat_mul_demo
# unload rpmsg_ctrl driver
modprobe -r rpmsg_ctrl
#unload rpmsg_char driver
modprobe -r rpmsg_char
# Stop remote processor
echo stop > /sys/class/remoteproc/remoteproc0/state
```
10 changes: 0 additions & 10 deletions examples/linux/rpmsg-mat-mul/mat_mul_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,6 @@ int main(int argc, char *argv[])
char ept_dev_path[32];

printf("\r\n Matrix multiplication demo start \r\n");

/* Load rpmsg_char driver */
printf("\r\nHost>probe rpmsg_char\r\n");
ret = system("set -x; lsmod; modprobe rpmsg_char");
if (ret < 0) {
perror("Failed to load rpmsg_char driver.\n");
return -EINVAL;
}
system("modprobe rpmsg_ctrl");

lookup_channel(rpmsg_dev, &eptinfo);

while ((opt = getopt(argc, argv, "d:n:s:e:")) != -1) {
Expand Down
12 changes: 12 additions & 0 deletions examples/linux/rpmsg-proxy-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,21 @@
# Load and start target Firmware onto remote processor.
echo start > /sys/class/remoteproc/remoteproc0/state
# load rpmsg_char driver
modprobe rpmsg_char
# load rpmsg_ctrl driver
modprobe rpmsg_ctrl
# Run proxy application.
proxy_app
# unload rpmsg_ctrl driver
modprobe -r rpmsg_ctrl
#unload rpmsg_char driver
modprobe -r rpmsg_char
# Stop target firmware
echo stop > /sys/class/remoteproc/remoteproc0/state
```
22 changes: 0 additions & 22 deletions examples/linux/rpmsg-proxy-app/proxy_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ int file_write(char *path, char *str)
return 0;
}

/* Stop remote CPU and Unload drivers */
void stop_remote(void)
{
system("modprobe -r rpmsg_char");
}

void exit_action_handler(int signum)
{
proxy->active = 0;
Expand Down Expand Up @@ -397,9 +391,6 @@ void kill_action_handler(int signum)
free(proxy->rpc);
free(proxy->rpc_response);
free(proxy);

/* Stop remote cpu and unload drivers */
stop_remote();
}

int main(int argc, char *argv[])
Expand Down Expand Up @@ -431,17 +422,6 @@ int main(int argc, char *argv[])
sigaction(SIGKILL, &kill_action, NULL);
sigaction(SIGHUP, &kill_action, NULL);

/* Load rpmsg_char driver */
printf("\r\nHost>probe rpmsg_char\r\n");
ret = system("modprobe rpmsg_char");
if (ret < 0) {
perror("Failed to load rpmsg_char driver.\n");
ret = -EINVAL;
goto error0;
}

system("modprobe rpmsg_ctrl");

/* Wait for rpmsg dev to be probed */
sleep(1);
ret = lookup_channel(rpmsg_dev_name, &eptinfo);
Expand Down Expand Up @@ -559,7 +539,5 @@ int main(int argc, char *argv[])
close(rpmsg_char_fd);
free(proxy);

stop_remote();

return ret;
}

0 comments on commit 7f1fb3b

Please sign in to comment.