Implement bootloader in NCS SDK

Hello,

Until now I was working on an application based on the nRF5 SDK: it is this application that is used by my customers.
Now I would like to use the NCS SDK to continue to have the latest features and bug fixes.

Here I almost finished redeveloping my new application (based on NCS SDK) to work like my old one (based on nRF5 SDK) but I have a problem with the bootloader...

My board (contains an nrf 52840) has no buttons and no external memory (so I will have to overwrite existing code when I do an update) but does have a UART.
I need to be able to update the application but also the bootloader.

Here are my questions:

  • I think I have to go into recovery mode to be able to update in this situation? But how can I do it if I don't have a button?
  • The update files will be sent by another microcontroller on the board via the uart: can you tell me more about what I need so that the other microcontroller can communicate with the nrf 52840 to send the files to the bootloader? (files ? protocol ?)
  • Is it possible to update a device that would work with the nRF5 SDK (secure_bootloader_uart_mbr_pca10056) to keep the old bootloader but updating the softdevice+app with the new application (NCS SDK)?

THANKS

Parents
  • Hi,

    I think I have to go into recovery mode to be able to update in this situation? But how can I do it if I don't have a button?

    One option is to use "serial recovery with wait", 

    A colleague of mine has written this repository with samples, where you the serial recovery samples containing samples for serial recovery using both the waiting and mcumgr method and regular UART serial recovery. I suggest you have a look at these samples to see if they fit your project or if you're able to tailor them to your project

    The update files will be sent by another microcontroller on the board via the uart: can you tell me more about what I need so that the other microcontroller can communicate with the nrf 52840 to send the files to the bootloader? (files ? protocol ?)

    I recommend you to have a look at devzone.nordicsemi.com/.../doing-an-fota-via-ble-using-a-nordic-development-kit

    Is it possible to update a device that would work with the nRF5 SDK (secure_bootloader_uart_mbr_pca10056) to keep the old bootloader but updating the softdevice+app with the new application (NCS SDK)?

    Yes, but there are things you will have to take in mind. I recommend you to have a look at  One bootloader to rule them all which refers to a sample created by a colleague of mine showing how to port a nRF5 app to become a NCS app  Hang with nRF5 SDK 17.1.0 Bootloader and nRF Connect SDK 2.1.0 application . This case, https://devzone.nordicsemi.com/f/nordic-q-a/100639/nrf5340-multi-image-dfu-update-over-ble-remote-error-in-value-3 does also to some extent explain some of the procedure

    Let me know if this is enough to get you started! 

    Kind regards,
    Andreas

  • Hello,

    Thank you very much for your answer.

    I've been working on this for 2 weeks but unfortunately I still have problems...

    Here at the moment, I'm trying to find a way to update the devices that are with my customers (with the nRF5 SDK) so that it's not too complicated for us and for them to manage the updates of old devices and new ones (with NCS SDK). I think the simplest solution would be to manage to only update the app of the devices that are with my customers (therefore keeping the old bootloader and the softdevice present in the devices).

    To do this, I tried to do like Vidar Berg with his project 2273.peripheral_lbs.zip (devzone.nordicsemi.com/.../hang-with-nrf5-sdk-17- 1-0-bootloader-and-nrf-connect-sdk-2-1-0-application) but unfortunately there must be things I forgot because it doesn't work.

    When I compile my project and flash it, it works on my device. On the other hand, if I send the update to a device working with the nRF5 SDK, it accepts the update but afterwards it is blocked.

    Here are the problems I'm seeing that I don't know how to fix:

    - In the prj.conf file of my project, I put "CONFIG_FLASH_LOAD_OFFSET=0x27000" but it is the value 0xC000 which is put (I have a warning for that in the logs).

    - In my mcuboot.cong file in the child_image folder, I added "CONFIG_SINGLE_APPLICATION_SLOT=y". Despite this, I have to provide memory in my pm_static.yml file for mcuboot_secondary otherwise I get a compilation error: do you know why?

    Here are my DFU logs:

    3312.test.log

    Here is my \Application\boards\pm_static_nrf52840dk_nrf52840.yml:

    app:
      address: 0x10200
      region: flash_primary
      size: 0xdfe00
    mcuboot:
      address: 0x0
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x1200
      placement:
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0xD0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xcfe00
      span: *id002
    mcuboot_secondary:
      address: 0xE0000
      end_address: 0xF0000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x10000
    settings_storage:
      address: 0xf0000
      end_address: 0x100000
      region: flash_primary
      size: 0x10000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000


    Here is my \Application\child_image\mcuboot.conf:
    CONFIG_UART_CONSOLE=n
    CONFIG_MCUBOOT_SERIAL=y
    CONFIG_BOOT_SERIAL_UART=y
    
    CONFIG_FPROTECT=n #The flash protection mechanism in MCUboot assumes that the mcuboot_primary slot is always placed after the mcuboot partition. It disabled flash protection to get around this limitation.
    
    #CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x18000
    CONFIG_PARTITION_MANAGER_ENABLED=y
    
    # The build won't fit on the partition allocated for it without size
    # optimizations.
    CONFIG_SIZE_OPTIMIZATIONS=y
    
    # Serial
    CONFIG_SERIAL=y
    CONFIG_UART_CONSOLE=n
    CONFIG_UART_LINE_CTRL=y
    
    # MCUBoot serial
    #CONFIG_MCUBOOT_SERIAL=y
    #CONFIG_BOOT_SERIAL_UART=y
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_BACKEND_RTT=y
    
    #-------------------------------------------------------------
    
    # Declare for single slot and partition size for MCUBoot
    CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
    CONFIG_SINGLE_APPLICATION_SLOT=y
    
    CONFIG_BOOT_SIGNATURE_KEY_FILE="mcuboot/key/mcuboot_private.pem"  # add a signature key file to this bootloader. This option only accepts the private key of an ECDSA key pair, as build system scripts automatically extract the public key at build time. The file path is relatively to the application directory.
    CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
    


    Here is my \Application\boards\nrf25840dk_nrf52840.overlay:

    /* Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    / {
    	/*
    	* In some default configurations within the nRF Connect SDK,
    	* e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell.
    	* This devicetree overlay ensures that default is overridden wherever it
    	* is set, as this application uses the RNG node for entropy exclusively.
    	*/
    	chosen {
    		zephyr,entropy = &rng;
    	};
    };
    &adc {
    	status = "disabled";
    };
    &uart1 {
    	status = "disabled";
    };
    &pwm0 {
    	status = "disabled";
    };
    &i2c0 {
    	status = "disabled";
    };
    &spi0 {
    	status = "disabled";
    };
    &spi1 {
    	status = "disabled";
    };
    &spi2 {
    	status = "disabled";
    };
    &spi3 {
    	status = "disabled";
    };
    &qspi {
    	status = "disabled";
    };
    &usbd {
    	status = "disabled";
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 1)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 2)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 1)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 2)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 2)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 1)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 2)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 1)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 2)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 1)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &arduino_adc {
        io-channel-map = <0 &adc 1>, <1 &adc 2>, <2 &adc 4>, <3 &adc 5>, <4 &adc 6>, <5 &adc 7>;
    };
    
    
    
    /delete-node/ &scratch_partition;
    /delete-node/ &storage_partition;
    
    
    // Place storage partition below nRF5 Bootloader. The bootloader starts at 0xf8000 in this case.
    &flash0 {
        partitions {
            storage_partition: partition@f5000 {
                label = "storage";
                reg = < 0xf5000 0x3000 >;
            };
        };
    };

    Here is my prj.conf of my Application:

    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # nRF board library
    CONFIG_DK_LIBRARY=y
    
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y # Allow to process float (double) numbers
    CONFIG_ASSERT=y
    
    # Enable the UART driver
    CONFIG_UART_INTERRUPT_DRIVEN=y #UART in interrupt mode
    CONFIG_SERIAL=y
    
    # Enable ring buffer
    CONFIG_RING_BUFFER=y
    
    # Add Bootlaoder to the application
    # CONFIG_SECURE_BOOT=y
    CONFIG_BOOTLOADER_MCUBOOT=y # add MCUboot as upgradable bootloader 
    
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    CONFIG_SIZE_OPTIMIZATIONS=y
    CONFIG_FLASH_LOAD_OFFSET=0x27000
    
    # After you upload a new image and reset the development kit, MCUboot attempts to boot the secondary image. If this image has, in order of precedence, a major, minor, or revision value that is lower than the primary application image, it is considered invalid and the existing primary application boots instead.
    # The optional label or build number specified after the + character is ignored when evaluating the version. An existing application image with version 0.1.2+3 can be overwritten by an uploaded image with 0.1.2+2, but not by one with 0.1.1+2.
    CONFIG_MCUBOOT_IMAGE_VERSION="0.1.0+0"
    

    And finaly, here are my partitions:

    app:
      address: 0x10200
      region: flash_primary
      size: 0xdfe00
    mcuboot:
      address: 0x0
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x1200
      placement:
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0xD0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xcfe00
      span: *id002
    mcuboot_secondary:
      address: 0xE0000
      end_address: 0xF0000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x10000
    settings_storage:
      address: 0xf0000
      end_address: 0x100000
      region: flash_primary
      size: 0x10000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000

    Here I only put the MCUboot to simplify but then I would like to add the CONFIG_SECURE_BOOT.

    Thanks for your help !

Reply
  • Hello,

    Thank you very much for your answer.

    I've been working on this for 2 weeks but unfortunately I still have problems...

    Here at the moment, I'm trying to find a way to update the devices that are with my customers (with the nRF5 SDK) so that it's not too complicated for us and for them to manage the updates of old devices and new ones (with NCS SDK). I think the simplest solution would be to manage to only update the app of the devices that are with my customers (therefore keeping the old bootloader and the softdevice present in the devices).

    To do this, I tried to do like Vidar Berg with his project 2273.peripheral_lbs.zip (devzone.nordicsemi.com/.../hang-with-nrf5-sdk-17- 1-0-bootloader-and-nrf-connect-sdk-2-1-0-application) but unfortunately there must be things I forgot because it doesn't work.

    When I compile my project and flash it, it works on my device. On the other hand, if I send the update to a device working with the nRF5 SDK, it accepts the update but afterwards it is blocked.

    Here are the problems I'm seeing that I don't know how to fix:

    - In the prj.conf file of my project, I put "CONFIG_FLASH_LOAD_OFFSET=0x27000" but it is the value 0xC000 which is put (I have a warning for that in the logs).

    - In my mcuboot.cong file in the child_image folder, I added "CONFIG_SINGLE_APPLICATION_SLOT=y". Despite this, I have to provide memory in my pm_static.yml file for mcuboot_secondary otherwise I get a compilation error: do you know why?

    Here are my DFU logs:

    3312.test.log

    Here is my \Application\boards\pm_static_nrf52840dk_nrf52840.yml:

    app:
      address: 0x10200
      region: flash_primary
      size: 0xdfe00
    mcuboot:
      address: 0x0
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x1200
      placement:
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0xD0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xcfe00
      span: *id002
    mcuboot_secondary:
      address: 0xE0000
      end_address: 0xF0000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x10000
    settings_storage:
      address: 0xf0000
      end_address: 0x100000
      region: flash_primary
      size: 0x10000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000


    Here is my \Application\child_image\mcuboot.conf:
    CONFIG_UART_CONSOLE=n
    CONFIG_MCUBOOT_SERIAL=y
    CONFIG_BOOT_SERIAL_UART=y
    
    CONFIG_FPROTECT=n #The flash protection mechanism in MCUboot assumes that the mcuboot_primary slot is always placed after the mcuboot partition. It disabled flash protection to get around this limitation.
    
    #CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x18000
    CONFIG_PARTITION_MANAGER_ENABLED=y
    
    # The build won't fit on the partition allocated for it without size
    # optimizations.
    CONFIG_SIZE_OPTIMIZATIONS=y
    
    # Serial
    CONFIG_SERIAL=y
    CONFIG_UART_CONSOLE=n
    CONFIG_UART_LINE_CTRL=y
    
    # MCUBoot serial
    #CONFIG_MCUBOOT_SERIAL=y
    #CONFIG_BOOT_SERIAL_UART=y
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_BACKEND_RTT=y
    
    #-------------------------------------------------------------
    
    # Declare for single slot and partition size for MCUBoot
    CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
    CONFIG_SINGLE_APPLICATION_SLOT=y
    
    CONFIG_BOOT_SIGNATURE_KEY_FILE="mcuboot/key/mcuboot_private.pem"  # add a signature key file to this bootloader. This option only accepts the private key of an ECDSA key pair, as build system scripts automatically extract the public key at build time. The file path is relatively to the application directory.
    CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
    


    Here is my \Application\boards\nrf25840dk_nrf52840.overlay:

    /* Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    / {
    	/*
    	* In some default configurations within the nRF Connect SDK,
    	* e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell.
    	* This devicetree overlay ensures that default is overridden wherever it
    	* is set, as this application uses the RNG node for entropy exclusively.
    	*/
    	chosen {
    		zephyr,entropy = &rng;
    	};
    };
    &adc {
    	status = "disabled";
    };
    &uart1 {
    	status = "disabled";
    };
    &pwm0 {
    	status = "disabled";
    };
    &i2c0 {
    	status = "disabled";
    };
    &spi0 {
    	status = "disabled";
    };
    &spi1 {
    	status = "disabled";
    };
    &spi2 {
    	status = "disabled";
    };
    &spi3 {
    	status = "disabled";
    };
    &qspi {
    	status = "disabled";
    };
    &usbd {
    	status = "disabled";
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 1)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 2)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 1)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 2)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 2)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 1)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 2)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 1)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group1 {
    		psels = <NRF_PSEL(UART_TX, 1, 2)>, <NRF_PSEL(UART_RTS, 0, 5)>;
    	};
    };
    
    &uart0_default {
    	group2 {
    		psels = <NRF_PSEL(UART_RX, 1, 1)>, <NRF_PSEL(UART_CTS, 0, 7)>;
    	};
    };
    
    &arduino_adc {
        io-channel-map = <0 &adc 1>, <1 &adc 2>, <2 &adc 4>, <3 &adc 5>, <4 &adc 6>, <5 &adc 7>;
    };
    
    
    
    /delete-node/ &scratch_partition;
    /delete-node/ &storage_partition;
    
    
    // Place storage partition below nRF5 Bootloader. The bootloader starts at 0xf8000 in this case.
    &flash0 {
        partitions {
            storage_partition: partition@f5000 {
                label = "storage";
                reg = < 0xf5000 0x3000 >;
            };
        };
    };

    Here is my prj.conf of my Application:

    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # nRF board library
    CONFIG_DK_LIBRARY=y
    
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y # Allow to process float (double) numbers
    CONFIG_ASSERT=y
    
    # Enable the UART driver
    CONFIG_UART_INTERRUPT_DRIVEN=y #UART in interrupt mode
    CONFIG_SERIAL=y
    
    # Enable ring buffer
    CONFIG_RING_BUFFER=y
    
    # Add Bootlaoder to the application
    # CONFIG_SECURE_BOOT=y
    CONFIG_BOOTLOADER_MCUBOOT=y # add MCUboot as upgradable bootloader 
    
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    CONFIG_SIZE_OPTIMIZATIONS=y
    CONFIG_FLASH_LOAD_OFFSET=0x27000
    
    # After you upload a new image and reset the development kit, MCUboot attempts to boot the secondary image. If this image has, in order of precedence, a major, minor, or revision value that is lower than the primary application image, it is considered invalid and the existing primary application boots instead.
    # The optional label or build number specified after the + character is ignored when evaluating the version. An existing application image with version 0.1.2+3 can be overwritten by an uploaded image with 0.1.2+2, but not by one with 0.1.1+2.
    CONFIG_MCUBOOT_IMAGE_VERSION="0.1.0+0"
    

    And finaly, here are my partitions:

    app:
      address: 0x10200
      region: flash_primary
      size: 0xdfe00
    mcuboot:
      address: 0x0
      region: flash_primary
      size: 0x10000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x1200
      placement:
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0xD0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xcfe00
      span: *id002
    mcuboot_secondary:
      address: 0xE0000
      end_address: 0xF0000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x10000
    settings_storage:
      address: 0xf0000
      end_address: 0x100000
      region: flash_primary
      size: 0x10000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000

    Here I only put the MCUboot to simplify but then I would like to add the CONFIG_SECURE_BOOT.

    Thanks for your help !

Children
  • Here are my compilation logs:

    Building Application
    C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board c:/DocTA/Soft/TA-Smart-BT840P/Application --pristine --board nrf52840dk_nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="c:/docta/soft/ta-smart-bt840p/sdk/v2.3.0/nrf;/DocTA/Soft/TA-Smart-BT840P/Application;c:/docta/soft/ta-smart-bt840p/application" -DDTC_OVERLAY_FILE:STRING="c:/DocTA/Soft/TA-Smart-BT840P/Application/boards/nrf52840dk_nrf52840.overlay" -DCONFIG_DEBUG_OPTIMIZATIONS:STRING="y" -DCONFIG_DEBUG_THREAD_INFO:STRING="y" -DCONF_FILE:STRING="c:/DocTA/Soft/TA-Smart-BT840P/Application/prj.conf" -DOVERLAY_CONFIG:STRING="c:/DocTA/Soft/TA-Smart-BT840P/Application/overlay-multiprotocol_ble.conf;c:/DocTA/Soft/TA-Smart-BT840P/Application/overlay-logging.conf;c:/DocTA/Soft/TA-Smart-BT840P/Application/overlay-debug.conf""

    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/DocTA/Soft/TA-Smart-BT840P/Application
    -- Found Python3: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.15.2 (C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/DocTA/Soft/TA-Smart-BT840P/Application/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: c:/DocTA/Soft/TA-Smart-BT840P/Application/boards/nrf52840dk_nrf52840.overlay
    -- Generated zephyr.dts: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/zephyr/dts.cmake

    warning: LOG_PRINTK (defined at subsys/logging\Kconfig.processing:8) was assigned the value 'n' but
    got the value 'y'. See docs.zephyrproject.org/.../kconfig.html and/or
    look up LOG_PRINTK in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.


    warning: FLASH_LOAD_OFFSET (defined at Kconfig.zephyr:99) was assigned the value '0x27000' but got
    the value '0xc000'. See docs.zephyrproject.org/.../kconfig.html
    and/or look up FLASH_LOAD_OFFSET in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.

    Parsing C:/DocTA/Soft/TA-Smart-BT840P/Application/Kconfig
    Loaded configuration 'C:/DocTA/Soft/TA-Smart-BT840P/Application/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'c:/DocTA/Soft/TA-Smart-BT840P/Application/prj.conf'
    Merged configuration 'c:/DocTA/Soft/TA-Smart-BT840P/Application/overlay-multiprotocol_ble.conf'
    Merged configuration 'c:/DocTA/Soft/TA-Smart-BT840P/Application/overlay-logging.conf'
    Merged configuration 'c:/DocTA/Soft/TA-Smart-BT840P/Application/overlay-debug.conf'
    Merged configuration 'C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to 'C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/zephyr/.config'
    Kconfig header saved to 'C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/bin/python.exe (found version "3.8.2") found components: Interpreter

    === child image mcuboot - begin ===
    loading initial cache file C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/bootloader/mcuboot/boot/zephyr
    -- Found Python3: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.15.2 (C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/DocTA/Soft/TA-Smart-BT840P/Application/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/bootloader/mcuboot/boot/zephyr/dts.overlay
    -- Generated zephyr.dts: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/zephyr/dts.cmake

    warning: LOG_BACKEND_RTT (defined at subsys/logging\backends\Kconfig.rtt:4) was assigned the value
    'y' but got the value 'n'. Check these unsatisfied dependencies: (!LOG_MODE_MINIMAL) (=n). See
    docs.zephyrproject.org/.../kconfig.html and/or look up
    LOG_BACKEND_RTT in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.

    Parsing C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/DocTA/Soft/TA-Smart-BT840P/Application/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration 'C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration 'C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/bootloader/mcuboot/boot/zephyr/boards/nrf52840dk_nrf52840.conf'
    Merged configuration 'C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration 'C:/DocTA/Soft/TA-Smart-BT840P/Application/child_image/mcuboot.conf'
    Merged configuration 'C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to 'C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/zephyr/.config'
    Kconfig header saved to 'C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/nrf/lib/flash_patch/CMakeLists.txt:8 (message):

    ----------------------------------------------------------
    --- WARNING: To maintain the integrity of secure boot, ---
    --- enable CONFIG_DISABLE_FLASH_PATCH in production. ---
    ----------------------------------------------------------


    MCUBoot bootloader key file: C:/DocTA/Soft/TA-Smart-BT840P/Application/child_image/mcuboot/key/mcuboot_private.pem
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board/mcuboot
    === child image mcuboot - end ===

    -- OpenThread Source Directory: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/modules/lib/openthread

    ...

    -- Found partition manager static configuration: C:/DocTA/Soft/TA-Smart-BT840P/Application/boards/pm_static_nrf52840dk_nrf52840.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_app' is not included in the dynamic resolving since it is statically defined.
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/DocTA/Soft/TA-Smart-BT840P/Application/Nordic_board
    -- west build: building application

    ...

    [190/190] Linking C executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 34736 B 64 KB 53.00%
    RAM: 18048 B 256 KB 6.88%
    IDT_LIST: 0 GB 2 KB 0.00%

    ...

    [662/670] Linking CXX executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 573332 B 851456 B 67.34%
    RAM: 168832 B 256 KB 64.40%
    IDT_LIST: 0 GB 2 KB 0.00%

    ...

  • Hi,

    QuentinD said:

    -- Application: C:/DocTA/Soft/TA-Smart-BT840P/SDK/nRF_Connect/v2.3.0/bootloader/mcuboot/boot/zephyr

    I see you're using NCS v2.3.0 from your logs. This sample is only working with NCS v2.1.0 out of the box and it will not be updated as it is not an official sample. I recommend you to make it work with NCS v2.1.0 before attempting to port it to v2.3.0.

    After you've made it work for v2.1.0 you can have a look at the changelogs in the SDK versions to see what changes has been made w.r.t DFU and the bootloaders. There are certain changes in Zephyr in between v2.1.0 and v2.2.0 that will have to be implemented.

    Kind regards,
    Andreas

  • Hello,

    Here I can now update the application of my devices which worked with the nrf5 SDK by uploading an Application file made with the NCS SDK.

    The memory of these devices now look like this:
    MBR
    softdevice
    application (from NCS SDK)
    bootloader (from nrf5 SDK)

    In my application which came from the nrf5 SDK, I had to do this so that the bootloader remains in DFU mode after the reboot:

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    VERIFY_SUCCESS(error_code);
    
    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    VERIFY_SUCCESS(error_code);
    
    // Signals that DFU mode must be entered in the power management module
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    Since in my case I have an application coming from the NCS SDK with a bootloader coming from the nrf5 SDK on the device, I also need to configure this register so that the bootloader remains in DFU mode. Could you tell me how I can do the same thing using the NCS SDK functions?

    Thank you

  • Hi,

    The following should work:

           nrf_power_gpregret_set(NRF_POWER, 0xB1);
           NVIC_SystemReset();

    Kind regards,
    Andreas

  • Thanks for your answer but how can I call this function in the NCS SDK?

Related