Skip to content

Commit

Permalink
sim/rpmsg_uart: add sim rpmsg uart support
Browse files Browse the repository at this point in the history
add sim_rpmsg_port_uart.c to verify the rpmsg port uart wrapper layer,

The physical transport layer could be:
1. SIM_RAM_UART(current)
2. SIM_UART(through "socat" virtual "/dev/pts/*", "socat" could monitor the bus data)

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao authored and xiaoxiang781216 committed Jan 23, 2025
1 parent de55f64 commit cefb6cb
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/sim/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ ifeq ($(CONFIG_RPMSG_VIRTIO_LITE),y)
CSRCS += sim_rpmsg_virtio.c
endif

ifeq ($(CONFIG_RPMSG_PORT_UART),y)
CSRCS += sim_rpmsg_port_uart.c
endif

ifeq ($(CONFIG_RPTUN),y)
CSRCS += sim_rptun.c
endif
Expand Down
4 changes: 4 additions & 0 deletions arch/sim/src/sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ if(CONFIG_RPMSG_VIRTIO_LITE)
list(APPEND SRCS sim_rpmsg_virtio.c)
endif()

if(CONFIG_RPMSG_PORT_UART)
list(APPEND SRCS sim_rpmsg_port_uart.c)
endif()

if(CONFIG_RPTUN)
list(APPEND SRCS sim_rptun.c)
endif()
Expand Down
7 changes: 7 additions & 0 deletions arch/sim/src/sim/sim_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ int sim_rpmsg_virtio_init(const char *shmemname, const char *cpuname,
bool master);
#endif

/* sim_rpmsg_port_uart.c ****************************************************/

#ifdef CONFIG_RPMSG_PORT_UART
int sim_rpmsg_port_uart_init(const char *localcpu, const char *remotecpu,
const char *uartpath);
#endif

/* sim_hcisocket.c **********************************************************/

#ifdef CONFIG_SIM_HCISOCKET
Expand Down
49 changes: 49 additions & 0 deletions arch/sim/src/sim/sim_rpmsg_port_uart.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/****************************************************************************
* arch/sim/src/sim/sim_rpmsg_port_uart.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/rpmsg/rpmsg_port.h>

#include "sim_internal.h"

/****************************************************************************
* Public Functions
****************************************************************************/

int sim_rpmsg_port_uart_init(const char *localcpu, const char *remotecpu,
const char *uartpath)
{
struct rpmsg_port_config_s config =
{
.remotecpu = remotecpu,
.txnum = 10,
.rxnum = 10,
.txlen = 2048,
.rxlen = 2048
};

return rpmsg_port_uart_initialize(&config, uartpath, localcpu);
}

89 changes: 89 additions & 0 deletions boards/sim/sim/sim/configs/rpproxy_uart/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NET_ETHERNET is not set
CONFIG_ARCH="sim"
CONFIG_ARCH_BOARD="sim"
CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y
CONFIG_BLK_RPMSG=y
CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ERROR=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_RPMSG=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_RPMSGSOCKET=y
CONFIG_FS_PROCFS=y
CONFIG_FS_RPMSGFS=y
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INPUT=y
CONFIG_LIBC_HOSTNAME="proxy"
CONFIG_MTD=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_NDEBUG=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=176
CONFIG_NETDB_DNSCLIENT_RECV_TIMEOUT=3
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d
CONFIG_NETUTILS_IPERF=y
CONFIG_NET_RPMSG=y
CONFIG_NET_USRSOCK=y
CONFIG_NET_USRSOCK_ICMP=y
CONFIG_NET_USRSOCK_RPMSG=y
CONFIG_NET_USRSOCK_RPMSG_CPUNAME="server"
CONFIG_NET_USRSOCK_TCP=y
CONFIG_NET_USRSOCK_UDP=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_PROMPT_STRING="proxy> "
CONFIG_NSH_READLINE=y
CONFIG_OPENAMP_DEBUG=y
CONFIG_RAM_UART=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_RPMSGMTD=y
CONFIG_RPMSG_PING=y
CONFIG_RPMSG_PORT_UART=y
CONFIG_RPMSG_UART=y
CONFIG_RTC=y
CONFIG_RTC_ARCH=y
CONFIG_RTC_DRIVER=y
CONFIG_RTC_EXTERNAL=y
CONFIG_RTC_RPMSG=y
CONFIG_RTC_RPMSG_SERVER_NAME="server"
CONFIG_SCHED_CHILD_STATUS=y
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_WAITPID=y
CONFIG_SENSORS=y
CONFIG_SENSORS_RPMSG=y
CONFIG_SIG_DEFAULT=y
CONFIG_SIM_RAM_UART0=y
CONFIG_SIM_RAM_UART0_SLAVE=y
CONFIG_SIM_RAM_UART=y
CONFIG_SYSLOG_PREFIX=y
CONFIG_SYSLOG_PREFIX_STRING="proxy"
CONFIG_SYSLOG_RPMSG=y
CONFIG_SYSLOG_RPMSG_SERVER_NAME="server"
CONFIG_SYSLOG_TIMESTAMP=y
CONFIG_SYSTEM_CLE=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING=y
CONFIG_UINPUT_BUTTONS=y
CONFIG_UINPUT_KEYBOARD=y
CONFIG_UINPUT_RPMSG=y
CONFIG_UINPUT_TOUCH=y
CONFIG_UORB=y
CONFIG_UORB_LISTENER=y
CONFIG_USENSOR=y
113 changes: 113 additions & 0 deletions boards/sim/sim/sim/configs/rpserver_uart/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH="sim"
CONFIG_ARCH_BOARD="sim"
CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_CHIP="sim"
CONFIG_ARCH_SIM=y
CONFIG_BLK_RPMSG_SERVER=y
CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BUILTIN=y
CONFIG_CLK=y
CONFIG_CLK_RPMSG=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FS=y
CONFIG_DEBUG_FS_ERROR=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_RPMSG_SERVER=y
CONFIG_DEV_SIMPLE_ADDRENV=y
CONFIG_EXAMPLES_RPMSGSOCKET=y
CONFIG_FS_HOSTFS=y
CONFIG_FS_PROCFS=y
CONFIG_FS_RPMSGFS_SERVER=y
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INPUT=y
CONFIG_IOB_BUFSIZE=256
CONFIG_IOB_NBUFFERS=512
CONFIG_IOB_THROTTLE=32
CONFIG_IOEXPANDER=y
CONFIG_IOEXPANDER_RPMSG=y
CONFIG_LIBC_HOSTNAME="server"
CONFIG_MTD=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_NDEBUG=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=176
CONFIG_NETDB_DNSCLIENT_RECV_TIMEOUT=3
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d
CONFIG_NETDEV_STATISTICS=y
CONFIG_NETINIT_DHCPC=y
CONFIG_NETINIT_THREAD=y
CONFIG_NETUTILS_DHCPC=y
CONFIG_NETUTILS_IPERF=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_LOOPBACK=y
CONFIG_NET_RPMSG=y
CONFIG_NET_RPMSG_DRV=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NET_UDP_WRITE_BUFFERS=y
CONFIG_NET_USRSOCK_RPMSG_SERVER=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_PROMPT_STRING="server> "
CONFIG_NSH_READLINE=y
CONFIG_OPENAMP_DEBUG=y
CONFIG_RAMMTD=y
CONFIG_RAM_UART=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_READLINE_TABCOMPLETION=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_RPMSG=y
CONFIG_RPMSGMTD_SERVER=y
CONFIG_RPMSG_PING=y
CONFIG_RPMSG_PORT_UART=y
CONFIG_RPMSG_UART=y
CONFIG_RTC=y
CONFIG_RTC_ARCH=y
CONFIG_RTC_DRIVER=y
CONFIG_RTC_RPMSG=y
CONFIG_RTC_RPMSG_SERVER=y
CONFIG_SCHED_CHILD_STATUS=y
CONFIG_SCHED_HAVE_PARENT=y
CONFIG_SCHED_WAITPID=y
CONFIG_SENSORS=y
CONFIG_SENSORS_RPMSG=y
CONFIG_SIG_DEFAULT=y
CONFIG_SIM_HOSTFS=y
CONFIG_SIM_NETDEV=y
CONFIG_SIM_NET_BRIDGE=y
CONFIG_SIM_RAM_UART0=y
CONFIG_SIM_RAM_UART=y
CONFIG_SIM_RPMSG_MASTER=y
CONFIG_SIM_UART0_NAME="/dev/ttyUSB0"
CONFIG_SIM_UART_NUMBER=1
CONFIG_SYSLOG_PREFIX=y
CONFIG_SYSLOG_PREFIX_STRING="server"
CONFIG_SYSLOG_RPMSG_SERVER=y
CONFIG_SYSLOG_TIMESTAMP=y
CONFIG_SYSTEM_CLE=y
CONFIG_SYSTEM_CUTERM=y
CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE="/dev/ttyproxy"
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING=y
CONFIG_TTY_SIGINT=y
CONFIG_UINPUT_BUTTONS=y
CONFIG_UINPUT_KEYBOARD=y
CONFIG_UINPUT_RPMSG=y
CONFIG_UINPUT_TOUCH=y
CONFIG_UORB=y
CONFIG_UORB_LISTENER=y
CONFIG_USENSOR=y
8 changes: 8 additions & 0 deletions boards/sim/sim/sim/src/sim_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ int sim_bringup(void)
# endif
#endif

#ifdef CONFIG_RPMSG_PORT_UART
# ifdef CONFIG_SIM_RPMSG_MASTER
sim_rpmsg_port_uart_init("server", "proxy", "/dev/ttyVS0");
# else
sim_rpmsg_port_uart_init("proxy", "server", "/dev/ttyVS0");
# endif
#endif

#ifdef CONFIG_DEV_RPMSG
rpmsgdev_register("server", "/dev/console", "/dev/server-console", 0);
rpmsgdev_register("server", "/dev/null", "/dev/server-null", 0);
Expand Down

0 comments on commit cefb6cb

Please sign in to comment.