This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[LWM2M] How to properly set Bootstrap Server

Hi,

I am trying to enable Bootstrap support.

Therefore I set "CONFIG_LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP=y" in prj.conf.

I also set "CONFIG_APP_LWM2M_SERVER" and the port with "CONFIG_LWM2M_PEER_PORT".

But the LWM2M engine reports that the bootstrap server cannot be found (see screenshot)

When I disable the bootstrap support the connection works fine.

So my question is now how do I properly configure the bootstrap support?

Kind regards,
Manuel

Parents Reply Children
  • Hi Didrik,

    yes I definitely set CONFIG_APP_LWM2M_SERVER to the correct server.

    After some debugging it seems to me that the configured server is not properly handed to the LwM2M Engine if bootstrap is enabled, since the engine does not find any instance of CONFIG_APP_LWM2M_SERVER.

    sm_select_next_sec_inst() returns -ENOENT

    To be sure, I also tried different servers.

    Kind regards,
    Manuel

  • Hi,

    Just a quick update:

    I have been trying to set up bootstrapping using the Leshan demo server, but are currently seeing the same error that you do.

    Based on some modem traces I have taken, it looks to me like it is trying to connect to /rd instead of /bs, even though bootstrapping is enabled.

    I'll continue to investigate, and let you know when I know more.

    Best regards,

    Didrik

  • What we were missing was a few code lines that set the Bootstrap-server resource of the Security object instance to true during the initialization.

    When I add

    #if defined(CONFIG_LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP)
    	/* Mark 1st instance of security object as a bootstrap server */
    	lwm2m_engine_set_u8("0/0/1", 1);
    
    	/* Create 2nd instance of server and security objects needed for
    	 * bootstrap process
    	 */
    	lwm2m_engine_create_obj_inst("0/1");
    	lwm2m_engine_create_obj_inst("1/1");
    #endif /* CONFIG_LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP */

    at the end of the lwm2m_init_security function in lwm2m_client/src/lwm2m/lwm2m_security.c, the device is able to find and connect to the bootstrap server.

  • Hi Didrik,

    I can confirm that this is a fix for the issue, thank you. When will this be merged into sdk?

    Kind regards,
    Manuel

  • I am not aware of any plans for adding bootstrapping support to the lwm2m_client sample at the moment.

    But, I agree that it would be useful to have. I have to look a bit more into how the keys and LTE link is handled during the bootstrapping process, as the nRF9160 can not write new keys to the modem while the LTE link is active. But if that does not turn out to be a big problem we should be able add and merge a PR quite quickly.

    Edit: The developer is already working on it. Adding bootstrapping support itself is not hard, but making it play nicely with DTLS and the modem is presenting a few challenges (as I suspected).

Related