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

Bootloader - serial output of logging info

Hello,

I want to create/compile a (Nordic) secure bootloader with serial output.

I know the example of the dfu secure_bootloader. I also know there is a nomal and a debug variant.

I have two problems:

1) What defines do I need to set to debug out of serial port?

Default example is for RTT. I already tried to set similar defines for UART logging in config files of bootloader,

but got e.g. a undefined reference to a init function. Is there a list or documentation what defines are needed?

2) I have changed linker script to have more flash space for bootloader.

Can you give me a few hints about side effects of this change?

Is it just giving bootloader moe space, so I have less space for the app?
At the moment no problem for me, because app is small.

Or is app not more possible, because I use the flash space of the app?
But this would change behaviour because I want to debug bootloader as well as app at the same time,

e.g. switching from app down to bootloader and back to app.

Main goal would be to be able to understand and debug upcoming problems of the bootloader.

And customer must be able to deliver logs, which he can do only via UART, as no JTAG is available for the customer.

Best regards,

Marie

Parents
  • Hi Marie,

    1) What defines do I need to set to debug out of serial port?

    You can enable NRF_LOG_BACKEND_UART_ENABLED In the sdk_config.h of the example as

    // <e> NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend
    //==========================================================
    #ifndef NRF_LOG_BACKEND_UART_ENABLED
    #define NRF_LOG_BACKEND_UART_ENABLED 1
    #endif
     

    Then, you should be able to see the debug log in the serial terminal. See the Logger module documentation.

    Can you give me a few hints about side effects of this change?

     As long as you have enough space for the application and bootloader, I think that should be fine. In the secure_bootloader for uart example, you might find the bootloader address is different from the Memory layout documentation. 

    -Amanda H.

  • Thanks for your answer!

    1) I already have this define set to 1. But then I get

    undefined reference to `nrf_log_default_backends_init'

    More defines needed? Or modules I must add?

    What about e.g. NRF_LOG_BACKEND_UART_ENABLED? But just tried, it makes at least no difference for this error.

    What is difference between define prefixed with NRF_ and the ones without it? One for internal, one for user?

    2) One is

    FLASH (rx) : ORIGIN = 0x71000, LENGTH = 0xd000

    the other is

    FLASH (rx) : ORIGIN = 0x78000, LENGTH = 0x6000

    This section is in flash. When it is once at this address, once at other address, how does caller know, where to call the bootloader? I assume MBR is started first via vector table, SP and IP. And then? What and how does MBR know how to continue?

  • Hi Marie,

    Sorry for the mistake. It is NRF_LOG_BACKEND_UART_ENABLED that should be enabled for log UART backend in the sdk_config.h. I have corrected the previous reply.

    1) If you update via USB, please refer to the sdk_config.h under nRF5_SDK\examples\dfu\secure_bootloader\pca10040_usb_debug\config and enable NRF_LOG_BACKEND_UART_ENABLED. You could see the log with the terminal tool. 

    If you use pca10040_uart_debug, do not logging over UART. Instead, you should use RTT logging. The example bootloader projects come in pairs, one with debug logging over RTT and one without. Since you have used <SDK>\examples\dfu\secure_bootloader\pca10040_uart, I would like you to try <SDK>\examples\dfu\secure_bootloader\pca10040_uart_debug instead, and observe the logs using Segger RTT Viewer.

    2) The bootloader start address is stored in one of the UICR register, which is written when you flash the bootloader to the nRF52832, see nrf_bootloader_info.c in the bootloader example. The MBR will check this UICR register on boot and then jump to the bootloader if there is an address present. On jumping to the application, the bootloader will jump to the SoftDevice, and then the SoftDevice will jump to its end address where it expects the application to be located. Also, see this post

    If your application runs without the softdevice, you should set the flash start address to 0x1000  (end of MBR) and set RAM_START to 0x20000008 for the MBR application. See this post.

    With SoftDevice, the flash start address should be 0x0002 6000 (end of SoftDevice) for s132. 

    -Amanda H.

Reply
  • Hi Marie,

    Sorry for the mistake. It is NRF_LOG_BACKEND_UART_ENABLED that should be enabled for log UART backend in the sdk_config.h. I have corrected the previous reply.

    1) If you update via USB, please refer to the sdk_config.h under nRF5_SDK\examples\dfu\secure_bootloader\pca10040_usb_debug\config and enable NRF_LOG_BACKEND_UART_ENABLED. You could see the log with the terminal tool. 

    If you use pca10040_uart_debug, do not logging over UART. Instead, you should use RTT logging. The example bootloader projects come in pairs, one with debug logging over RTT and one without. Since you have used <SDK>\examples\dfu\secure_bootloader\pca10040_uart, I would like you to try <SDK>\examples\dfu\secure_bootloader\pca10040_uart_debug instead, and observe the logs using Segger RTT Viewer.

    2) The bootloader start address is stored in one of the UICR register, which is written when you flash the bootloader to the nRF52832, see nrf_bootloader_info.c in the bootloader example. The MBR will check this UICR register on boot and then jump to the bootloader if there is an address present. On jumping to the application, the bootloader will jump to the SoftDevice, and then the SoftDevice will jump to its end address where it expects the application to be located. Also, see this post

    If your application runs without the softdevice, you should set the flash start address to 0x1000  (end of MBR) and set RAM_START to 0x20000008 for the MBR application. See this post.

    With SoftDevice, the flash start address should be 0x0002 6000 (end of SoftDevice) for s132. 

    -Amanda H.

Children
No Data
Related