mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
qemu-armv7a/rpserver and rpproxy: support the rpmsg port uart
Use virtio-serial as the rpmsg-port-uart serial device, so we can bringup the rpmsg-port-uart in qemu platform. And update the documents: nuttx/Documentation/platforms/arm/qemu/boards/qemu-armv7a/index.rst Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
@@ -102,6 +102,9 @@ Steps for Using NuttX as IVSHMEM host and guest
|
||||
$ qemu-system-arm -cpu cortex-a7 -nographic -machine virt,highmem=off \
|
||||
-object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes \
|
||||
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
|
||||
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
|
||||
-chardev socket,path=/tmp/rpmsg_port_uart_socket,server=on,wait=off,id=foo \
|
||||
-device virtconsole,chardev=foo \
|
||||
-kernel server/nuttx -nographic
|
||||
|
||||
b. Start rpproxy_ivshmem::
|
||||
@@ -109,6 +112,9 @@ Steps for Using NuttX as IVSHMEM host and guest
|
||||
$ qemu-system-arm -cpu cortex-a7 -nographic -machine virt,highmem=off \
|
||||
-object memory-backend-file,discard-data=on,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes \
|
||||
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
|
||||
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
|
||||
-chardev socket,path=/tmp/rpmsg_port_uart_socket,server=off,id=foo \
|
||||
-device virtconsole,chardev=foo \
|
||||
-kernel proxy/nuttx -nographic
|
||||
|
||||
c. Check the RPMSG Syslog in rpserver shell:
|
||||
|
||||
@@ -42,6 +42,9 @@ CONFIG_DEBUG_PCI_WARN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEVICE_TREE=y
|
||||
CONFIG_DEV_SIMPLE_ADDRENV=y
|
||||
CONFIG_DRIVERS_VIRTIO=y
|
||||
CONFIG_DRIVERS_VIRTIO_MMIO=y
|
||||
CONFIG_DRIVERS_VIRTIO_SERIAL=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_RPMSGSOCKET=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
@@ -86,6 +89,7 @@ CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_READLINE_TABCOMPLETION=y
|
||||
CONFIG_RPMSGMTD=y
|
||||
CONFIG_RPMSG_PING=y
|
||||
CONFIG_RPMSG_PORT_UART=y
|
||||
CONFIG_RPTUN=y
|
||||
CONFIG_RPTUN_IVSHMEM=y
|
||||
CONFIG_RPTUN_IVSHMEM_NAME="0:server:s"
|
||||
|
||||
@@ -44,6 +44,9 @@ CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DEVICE_TREE=y
|
||||
CONFIG_DEV_RPMSG_SERVER=y
|
||||
CONFIG_DEV_SIMPLE_ADDRENV=y
|
||||
CONFIG_DRIVERS_VIRTIO=y
|
||||
CONFIG_DRIVERS_VIRTIO_MMIO=y
|
||||
CONFIG_DRIVERS_VIRTIO_SERIAL=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_RPMSGSOCKET=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
@@ -86,6 +89,7 @@ CONFIG_RAW_BINARY=y
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_READLINE_TABCOMPLETION=y
|
||||
CONFIG_RPMSG_PING=y
|
||||
CONFIG_RPMSG_PORT_UART=y
|
||||
CONFIG_RPTUN=y
|
||||
CONFIG_RPTUN_IVSHMEM=y
|
||||
CONFIG_RPTUN_IVSHMEM_NAME="0:proxy:m"
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fdt.h>
|
||||
#include <nuttx/rpmsg/rpmsg_port.h>
|
||||
|
||||
#ifdef CONFIG_LIBC_FDT
|
||||
# include <libfdt.h>
|
||||
@@ -97,6 +98,54 @@ static void register_devices_from_fdt(void)
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rpmsg_port_uart_init
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_RPMSG_PORT_UART
|
||||
static int rpmsg_port_uart_init(void)
|
||||
{
|
||||
const char *remotecpu;
|
||||
const char *localcpu;
|
||||
int ret;
|
||||
|
||||
if (strcmp(CONFIG_LIBC_HOSTNAME, "server") == 0)
|
||||
{
|
||||
localcpu = "server2";
|
||||
remotecpu = "proxy2";
|
||||
}
|
||||
else if (strcmp(CONFIG_LIBC_HOSTNAME, "proxy") == 0)
|
||||
{
|
||||
localcpu = "proxy2";
|
||||
remotecpu = "server2";
|
||||
}
|
||||
else
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: hostname must be server or proxy, now: %s\n",
|
||||
CONFIG_LIBC_HOSTNAME);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
const struct rpmsg_port_config_s cfg =
|
||||
{
|
||||
.remotecpu = remotecpu,
|
||||
.txnum = 8,
|
||||
.rxnum = 8,
|
||||
.txlen = 2048,
|
||||
.rxlen = 2048,
|
||||
};
|
||||
|
||||
ret = rpmsg_port_uart_initialize(&cfg, "/dev/ttyV0", localcpu);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize rpmsg port uart: %d\n", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -148,6 +197,15 @@ int qemu_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_RPMSG_PORT_UART
|
||||
ret = rpmsg_port_uart_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize rpmsg port uart: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user