Error in bt_enable() running BLE host on cpuapp and BLE controller on cpunet on nrf5340dk

Hi

I've configured Zephyr to run BLE host on cpuapp and BLE controller on cpunet, and using RPMsg to communicate between them.

When I call bt_enable() from the app core, it get stuck in function 

bt_rpmsg_open()
,

which is calling

 

rpmsg_service_endpoint_is_bound()

and it get stuck in a while loop inside bt_rpmsg_open(). Need some help to know what functions to call to register and initialize the BLE and RPMsg framwork on BOTH cores please.

I've been looking at the HCI_RPMsg example, but that is for cpunet, the problem here is at the cpuapp core.

When I set CONFIG_RPMSG_SERVICE_MODE_REMOTE=y for the cpunet, the network core doesn't start up.

Not sure how to configure everything.

I'm building the two cores separately and not using child image.

This is how the conf file of cpuapp looks like regarding BLE and RPMsg:

# BLE
CONFIG_BT=y
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=n
CONFIG_BT_HCI_RAW=n

CONFIG_BT_BUF_CMD_TX_COUNT=64
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SMP=y

# RPMsg/openAMP
CONFIG_RPMSG_SERVICE=y
CONFIG_RPMSG_SERVICE_MODE_MASTER=y
CONFIG_OPENAMP_SLAVE=n
CONFIG_PRINTK=y

And this is for cpunet:

# BLE
CONFIG_BT=y
CONFIG_BT_HCI=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_CTLR=y
CONFIG_BT_LL_SW_SPLIT=y

# RPMsg/openAMP
CONFIG_RPMSG_SERVICE=y
CONFIG_RPMSG_SERVICE_MODE_REMOTE=y   #### If this is included it makes the network core to not start up
CONFIG_OPENAMP_MASTER=n

I've also tried using the pure RPMsg example without BLE, in zephyr/samples/subsys/ipc/rpmsg_service

But that doesn't work either, get stuck in the same function, and the network core doesn't even start up when CONFIG_RPMSG_SERVICE_MODE_REMOTE=y is enabled

Thanks

  • Hello, I will take a look at this today.

    Best regards,

    Simon

  • Thank you.

    An update on the issue:

    I had CONFIG_TRUSTED_EXECUTION_SECURE=n set to 'n' to get the nrf5340_cpunet_reset.c file to start up network core, and that worked when CONFIG_RPMSG_SERVICE_MODE_REMOTE was set to 'n'. 

    But when CONFIG_RPMSG_SERVICE_MODE_REMOTE was set to 'y' the network core didn't startup. 

    I then tried with CONFIG_TRUSTED_EXECUTION_SECURE=y and CONFIG_RPMSG_SERVICE_MODE_REMOTE=y but then line 27 in nrf5340_cpunet_reset.c wouldn't get executed: 

    static int remoteproc_mgr_boot(const struct device *dev)
    {
    	ARG_UNUSED(dev);
    
    #if !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE)
    	/* Secure domain may configure permissions for the Network MCU. */
    	remoteproc_mgr_config();
    #endif /* !CONFIG_TRUSTED_EXECUTION_NONSECURE */
    
    #if !defined(CONFIG_TRUSTED_EXECUTION_SECURE)
    	/*
    	 * Building Zephyr with CONFIG_TRUSTED_EXECUTION_SECURE=y implies
    	 * building also a Non-Secure image. The Non-Secure image will, in
    	 * this case do the remainder of actions to properly configure and
    	 * boot the Network MCU.
    	 */
    #if defined(SHM_BASE_ADDRESS) && (SHM_BASE_ADDRESS != 0)
    
    	/* Initialize inter-processor shared memory block to zero. It is
    	 * assumed that the application image has access to the shared
    	 * memory at this point (see #24147).
    	 */
    	memset((void *) SHM_BASE_ADDRESS, 0, SHM_SIZE);
    #endif
    
    	/* Release the Network MCU, 'Release force off signal' */
    	NRF_RESET->NETWORK.FORCEOFF = RESET_NETWORK_FORCEOFF_FORCEOFF_Release;
    
    	LOG_ERR("Network core released");
    
    #endif /* !CONFIG_TRUSTED_EXECUTION_SECURE */
    
    	return 0;
    }

    So I copied line 27 to my main.c file and now at least network core starts up, and my configuration is as follows:

    CONFIG_TRUSTED_EXECUTION_SECURE=y
    CONFIG_RPMSG_SERVICE_MODE_REMOTE=y
    and line 27 in nrf5340_cpunet_reset.c is executed in my main.c file instead.

    But application core get stuck in a while loop calling:

    rpmsg_service_endpoint_is_bound(ep_id)

    Thanks

  • I'm building the two cores separately and not using child image.

    Is there a reason you're doing this? If you build any BLE examples with the nRF5340DK, the hci_rpmsg will be automatically be added as a child image. Also when you flash using west (or the vscode extension), the app core and network core will automatically be flashed with the appropriate images. Also, if you include all the images in one build (using child images), the partition manager will automatically partition everything for you. This is the intended way, and will make everything much easier.

    I thought it would warn you about this before continuing. However, I guess you have some valid reasons for building the images separately and I will of course help you with that.

    Would you like to continue with your approach, or would you like to build hci_rpmsg as a child image?

    Best regards,

    Simon

  • I would like to continue with this approach for now. I have another ticket, when I enable CONFIG_BT=y on the App core it automatically includes a child image for hci_rpmsg, which I obviously dont want since I'm not working with hobby projects. And right now I will not include BLE, I will just understand how the communication between the cores works.

    Anyway, the issue I have is that app core seems to get stuck in the function 

    rpmsg_service_endpoint_is_bound()

    When I look in the code, specifically in rpmsg_service.c:

    #if MASTER
    
    static void ns_bind_cb(struct rpmsg_device *rdev,
    					const char *name,
    					uint32_t dest)
    {
    	int err;
    
    	LOG_ERR("MASTER \n");
    	for (int i = 0; i < CONFIG_RPMSG_SERVICE_NUM_ENDPOINTS; ++i) {
    		if (strcmp(name, endpoints[i].name) == 0) {
    			err = rpmsg_create_ept(&endpoints[i].ep,
    						   rdev,
    						   name,
    						   RPMSG_ADDR_ANY,
    						   dest,
    						   endpoints[i].cb,
    						   rpmsg_service_unbind);
    
    			if (err != 0) {
    				LOG_ERR("Creating remote endpoint %s"
    					" failed wirh error %d", log_strdup(name), err);
    			} else {
    				endpoints[i].bound = true;
    			}
    
    			return;
    		}
    	}
    
    	LOG_ERR("Remote endpoint %s not registered locally", log_strdup(name));
    }
    
    #endif

    on line 24 is where the "bound" variable is set to true, which will cause the loop to break.

    This will happen when the callback function 

    ns_bind_cb()

    gets executed, but it never does.

  • UPDATE on the issue sending messages between the CPU cores (without any BLE code implemented)

    Had to add these to .conf files.

    Master (app core):

    CONFIG_IPM=y
    CONFIG_TIMESLICE_SIZE=1
    CONFIG_RPMSG_SERVICE=y
    CONFIG_RPMSG_SERVICE_MODE_MASTER=y
    CONFIG_OPENAMP_SLAVE=n
    CONFIG_NRFX_IPC=y
    CONFIG_IPM_NRFX=y
    CONFIG_IPM_NRF_SINGLE_INSTANCE=y
    CONFIG_IPM_MSG_CH_0_ENABLE=y
    CONFIG_IPM_MSG_CH_1_ENABLE=y
    CONFIG_IPM_MSG_CH_0_RX=y

    Remote (network core):

    CONFIG_IPM=y
    CONFIG_RPMSG_SERVICE=y
    CONFIG_RPMSG_SERVICE_MODE_REMOTE=y
    CONFIG_OPENAMP_MASTER=n
    CONFIG_NRFX_IPC=y
    CONFIG_IPM_NRFX=y
    CONFIG_IPM_NRF_SINGLE_INSTANCE=y
    CONFIG_IPM_MSG_CH_0_ENABLE=y
    CONFIG_IPM_MSG_CH_0_RX=y
    CONFIG_IPM_MSG_CH_1_ENABLE=y



    Next step is to include BLE host on application core and BLE controller on network core, and try using RPMsg as HCI. Will see how long time it will take to figure out what CONFIGs to use, since it's not very obvious.

Related