Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to de-init the NRF_LOG module

Hi Nordic,

I am writing a simple boot-loader, which is working fine without NRF_LOG module enabled. But if I enable the NRF_LOG module, the main app stops working when it is initializing the NRF_LOG again.

I cannot seem to find a way to de-initialize the NRF_LOG module after enabling it. Can you please help me to find a way to do that?

This is what I do to initialize the LOG module (besides enabling it in sdk_config):

int rc = NRF_LOG_INIT(NULL);

APP_ERROR_CHECK(rc);

NRF_LOG_DEFAULT_BACKENDS_INIT();

Parents
  • Hi

    Thank you for the update. NRF_LOG_FLUSH should return when the queued log data has been emptied. Are you calling NRF_LOG_FLUSH or NRF_LOG_PROCESS from any other places in your code except in main()? You can try commenting out NRF_LOG_FLUSH call in nrf_bootloader_app_start allow you to jump to the application?

    You can also try using RTT logging for one instance and UART logging for the other if that's possible.

    Best regards,

    Simon

  • Hi Simon,

    But I am not using the NRF bootloader - I am writing my own bootloader! And my bootloader works perfectly.

    The last thing I do in the bootloader is this:

    NRF_LOG_INFO("Booting image in SLOT 0 at address 0x%x", SLOT_0_ADDR);NRF_LOG_FLUSH();

    Then I set MSP (stackpointer) and update the SCB->VTOR vector table.

    Everything up to this point is fine, also if NRF_LOG is enabled in the sdk_config.

    Now the bootloader jumps to the main app.

    The main app starts executing at SLOT_0_ADDR - which is also working fine. Until the main app executes this:

    NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    NRF_LOG_INFO("Starting Main App ver %d.%d.%d...", FW_MAJOR, FW_MINOR, FW_PATCH);

    The main app basically tries to initialize the NRF_LOG again and it fails and stops working. I suspect that if de-initialize the NRF_LOG in the bootloader, then the main app will succeed in re-initializing it. However, I need your help with this, as there are no way to de-initialize the NRF_LOG.

    So the question is this: Why do the main app stop working when (re)initializing NRF_LOG_INIT() ?

    Or more precisely: I want to be able to use NRF_LOG in both my own bootloader and my own main-app. How do I do that?

    Thanks for your replies Slight smile

Reply
  • Hi Simon,

    But I am not using the NRF bootloader - I am writing my own bootloader! And my bootloader works perfectly.

    The last thing I do in the bootloader is this:

    NRF_LOG_INFO("Booting image in SLOT 0 at address 0x%x", SLOT_0_ADDR);NRF_LOG_FLUSH();

    Then I set MSP (stackpointer) and update the SCB->VTOR vector table.

    Everything up to this point is fine, also if NRF_LOG is enabled in the sdk_config.

    Now the bootloader jumps to the main app.

    The main app starts executing at SLOT_0_ADDR - which is also working fine. Until the main app executes this:

    NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    NRF_LOG_INFO("Starting Main App ver %d.%d.%d...", FW_MAJOR, FW_MINOR, FW_PATCH);

    The main app basically tries to initialize the NRF_LOG again and it fails and stops working. I suspect that if de-initialize the NRF_LOG in the bootloader, then the main app will succeed in re-initializing it. However, I need your help with this, as there are no way to de-initialize the NRF_LOG.

    So the question is this: Why do the main app stop working when (re)initializing NRF_LOG_INIT() ?

    Or more precisely: I want to be able to use NRF_LOG in both my own bootloader and my own main-app. How do I do that?

    Thanks for your replies Slight smile

Children
No Data
Related