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

Parents
  • 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.

Reply
  • 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.

Children
Related