diff --git a/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_bt_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_bt_cpuapp/defconfig new file mode 100644 index 0000000000..3501b86747 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_bt_cpuapp/defconfig @@ -0,0 +1,68 @@ +# +# 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_NET_IPv4 is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ALLOW_BSD_COMPONENTS=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_NRF5340_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BLUETOOTH_MAX_CONN=2 +CONFIG_BLUETOOTH_RPMSG=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BTSAK=y +CONFIG_BUILTIN=y +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_DRIVERS_BLUETOOTH=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NET=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NET_BLUETOOTH=y +CONFIG_NRF53_OSCILLATOR_LFXO=y +CONFIG_NRF53_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_OPENAMP=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_MUTEX_TYPES=y +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RPTUN=y +CONFIG_RPTUN_LOCAL_CPUNAME="cpuapp" +CONFIG_RPTUN_PING=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SIG_EVTHREAD=y +CONFIG_STACK_CANARIES=y +CONFIG_STACK_COLORATION=y +CONFIG_STACK_USAGE=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=64 +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_WIRELESS=y +CONFIG_WIRELESS_BLUETOOTH=y diff --git a/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_nimble_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_nimble_cpuapp/defconfig new file mode 100644 index 0000000000..5eaf8c87c0 --- /dev/null +++ b/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_nimble_cpuapp/defconfig @@ -0,0 +1,69 @@ +# +# 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_NET_IPv4 is not set +# CONFIG_STANDARD_SERIAL is not set +# CONFIG_WIRELESS_BLUETOOTH_HOST is not set +CONFIG_ALLOW_BSD_COMPONENTS=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_NRF5340_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BLUETOOTH_MAX_CONN=2 +CONFIG_BLUETOOTH_RPMSG=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_BUILTIN=y +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_DRIVERS_BLUETOOTH=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NET=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NET_BLUETOOTH=y +CONFIG_NIMBLE=y +CONFIG_NRF53_OSCILLATOR_LFXO=y +CONFIG_NRF53_UART0=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_OPENAMP=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PTHREAD_MUTEX_TYPES=y +CONFIG_RAM_SIZE=524288 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RPTUN=y +CONFIG_RPTUN_LOCAL_CPUNAME="cpuapp" +CONFIG_RPTUN_PING=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SIG_EVTHREAD=y +CONFIG_STACK_CANARIES=y +CONFIG_STACK_COLORATION=y +CONFIG_STACK_USAGE=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_NSH=y +CONFIG_TASK_NAME_SIZE=64 +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_WIRELESS=y +CONFIG_WIRELESS_BLUETOOTH=y diff --git a/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_sdc_cpunet/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_sdc_cpunet/defconfig new file mode 100644 index 0000000000..52c2e0dc5a --- /dev/null +++ b/boards/arm/nrf53/nrf5340-dk/configs/rpmsghci_sdc_cpunet/defconfig @@ -0,0 +1,55 @@ +# +# 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_STANDARD_SERIAL is not set +CONFIG_ALLOW_BSDNORDIC_COMPONENTS=y +CONFIG_ALLOW_BSD_COMPONENTS=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_NRF5340_DK=y +CONFIG_ARCH_CHIP="nrf53" +CONFIG_ARCH_CHIP_NRF5340=y +CONFIG_ARCH_CHIP_NRF5340_CPUNET=y +CONFIG_ARCH_CHIP_NRF53=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_STDARG_H=y +CONFIG_BLUETOOTH_RPMSG_SERVER=y +CONFIG_BOARDCTL=y +CONFIG_BOARDCTL_MKRD=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=5500 +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_DRIVERS_BLUETOOTH=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXPERIMENTAL=y +CONFIG_INIT_ENTRYPOINT="hello_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=2 +CONFIG_NRF53_SDC_MAX_COUNT=2 +CONFIG_NRF53_SDC_PUB_ADDR=0x0102030405 +CONFIG_NRF53_SOFTDEVICE_CONTROLLER=y +CONFIG_NRF53_UART0=y +CONFIG_OPENAMP=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=65535 +CONFIG_RAM_START=0x21000000 +CONFIG_RAW_BINARY=y +CONFIG_RPTUN=y +CONFIG_RPTUN_LOCAL_CPUNAME="cpunet" +CONFIG_RPTUN_PING=y +CONFIG_RPTUN_STACKSIZE=2048 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=26 +CONFIG_START_MONTH=3 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSLOG_MAX_CHANNELS=2 +CONFIG_SYSTEM_READLINE=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c index fb098425b0..e684a53587 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c @@ -24,6 +24,7 @@ #include +#include #include #include @@ -32,6 +33,9 @@ #ifdef CONFIG_USERLED # include #endif +#ifdef CONFIG_RPMSG_UART +# include +#endif #ifdef CONFIG_INPUT_BUTTONS # include @@ -42,6 +46,13 @@ #endif #ifdef CONFIG_RPTUN +# include +# ifdef CONFIG_UART_BTH4 +# include +# endif +# ifdef CONFIG_NET_BLUETOOTH +# include +# endif # include "nrf53_rptun.h" #endif @@ -53,10 +64,101 @@ #define NRF53_TIMER (0) +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_NRF53_APPCORE + +/**************************************************************************** + * Name: nrf53_appcore_bleinit + ****************************************************************************/ + +static int nrf53_appcore_bleinit(void) +{ + int ret = OK; + +#ifdef CONFIG_BLUETOOTH_RPMSG + struct bt_driver_s *bt_dev = NULL; + + bt_dev = rpmsghci_register("appcore", "bthci"); + if (bt_dev == NULL) + { + syslog(LOG_ERR, "ERROR: rpmsghci_register() failed: %d\n", -errno); + return -ENOMEM; + } + +# ifdef CONFIG_UART_BTH4 + /* Register UART BT H4 device */ + + ret = uart_bth4_register("/dev/ttyHCI", bt_dev); + if (ret < 0) + { + syslog(LOG_ERR, "bt_bth4_register error: %d\n", ret); + } +# elif defined(CONFIG_NET_BLUETOOTH) + /* Register network device */ + + ret = bt_netdev_register(bt_dev); + if (ret < 0) + { + syslog(LOG_ERR, "bt_netdev_register error: %d\n", ret); + } +# else +# error +# endif +#endif + + return ret; +} + +#else + +/**************************************************************************** + * Name: nrf53_netcore_bleinit + ****************************************************************************/ + +static int nrf53_netcore_bleinit(void) +{ + int ret = OK; + +#ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER +# ifdef CONFIG_BLUETOOTH_RPMSG_SERVER + ret = nrf53_rpmsghci_server_initialize("bthci"); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: nrf53_rpmsghci_server_initialize() failed: %d\n", + ret); + } +# else + ret = nrf53_sdc_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nrf53_sdc_initialize() failed: %d\n", ret); + } +# endif +#endif + + return ret; +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ +#ifdef CONFIG_RPMSG_UART +void rpmsg_serialinit(void) +{ +#ifdef CONFIG_NRF53_APPCORE + uart_rpmsg_init("appcore", "proxy", 4096, false); +#else + uart_rpmsg_init("netcore", "proxy", 4096, true); +#endif +} +#endif + /**************************************************************************** * Name: nrf53_bringup * @@ -150,12 +252,19 @@ int nrf53_bringup(void) } #endif -#ifdef CONFIG_NRF53_SOFTDEVICE_CONTROLLER - ret = nrf53_sdc_initialize(); + /* Initialize BLE */ +#ifdef CONFIG_NRF53_APPCORE + ret = nrf53_appcore_bleinit(); if (ret < 0) { - syslog(LOG_ERR, "ERROR: nrf53_sdc_initialize() failed: %d\n", ret); + syslog(LOG_ERR, "ERROR: nrf53_appcore_bleinit failed: %d\n", ret); + } +#else + ret = nrf53_netcore_bleinit(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: nrf53_netcore_bleinit failed: %d\n", ret); } #endif