nRF5340 netcore update with serial recovery

Hello,

I have a custom board with a nRF5340 on it. The firmware gets built with MCUBoot in serial recovery mode to update the application core. The serial recovery mode is necessary for the update to work on this board. Updating the application core works perfectly fine.

As there is the possibility that I have to change something in the netcore firmware, I want to implement an update functionality for it via serial recovery mode as well.

I found this doc as well as this doc, but currently I am unsure as to what is really needed to get this update functionality to work.

I need some guidance as to what Kconfig statements need to go into which prj.conf, be it application firmware prj.conf, the mcuboot prj.conf or the netcore firmware prj.conf.

Another question: if I switch back to the nRF5340DK for testing, does the netcore print strings to a console like the application core?

I use SDK v2.2.0, the application core firmware is based on the central_bas sample project and the netcore firmware is based on the hci_rpmsg sample.

Thanks in advance,

Alex

prj.conf of central_bas:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
# was before CONFIG_HEAP_MEM_POOL_SIZE=1024, 1.6.1 was CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=2048
#CONFIG_MAIN_STACK_SIZE=4096
CONFIG_BT_BAS_CLIENT=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

prj.conf of mcuboot:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CONFIG_PM=n
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"
CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
CONFIG_BOOT_ENCRYPT_RSA=n
CONFIG_BOOT_ENCRYPT_EC256=n
CONFIG_BOOT_ENCRYPT_X25519=n
CONFIG_BOOT_UPGRADE_ONLY=n
CONFIG_BOOT_BOOTSTRAP=n
### mbedTLS has its own heap
# CONFIG_HEAP_MEM_POOL_SIZE is not set
### We never want Zephyr's copy of tinycrypt. If tinycrypt is needed,
### MCUboot has its own copy in tree.
# CONFIG_TINYCRYPT is not set
# CONFIG_TINYCRYPT_ECC_DSA is not set
# CONFIG_TINYCRYPT_SHA256 is not set
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

prj.conf of hci_rpmsg:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CONFIG_IPC_SERVICE=y
CONFIG_MBOX=y
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_HCI_RAW_RESERVE=1
CONFIG_BT_MAX_CONN=16
CONFIG_BT_CTLR_ASSERT_HANDLER=y
# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
# Host number of completed commands does not follow normal flow control.
CONFIG_BT_BUF_CMD_TX_COUNT=10
### Start of necessary project config ###
CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In case it is needed, nrf5340dk_nrf5340_cpuapp.overlay:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.
// You can also use the buttons in the sidebar to perform actions on nodes.
// Actions currently available include:
// * Enabling / disabling the node
// * Adding the bus to a bus
// * Removing the node
// * Connecting ADC channels
// For more help, browse the DeviceTree documentation at https://docs.zephyrproject.org/latest/guides/dts/index.html
// You can also visit the nRF DeviceTree extension documentation at https://nrfconnect.github.io/vscode-nrf-connect/devicetree/nrfdevicetree.html
// This information was auto-generated when this file was created in VS Code
/ {
chosen {
nordic,nus-uart = &uart1;
};
};
&uart0 {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

dts.overlay (mcuboot):

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/ {
chosen {
zephyr,code-partition = &boot_partition;
};
};
&uart0 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_default_overlay>;
pinctrl-1 = <&uart0_sleep_overlay>;
pinctrl-names = "default", "sleep";
};
&uart1 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart1_default_overlay>;
pinctrl-1 = <&uart1_sleep_overlay>;
pinctrl-names = "default", "sleep";
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

image list with mcumgr:

Fullscreen
1
2
3
4
5
6
7
8
Y:\>mcumgr -c nrf53 image list
Images:
image=0 slot=0
version: 1.0.1.1
bootable: false
flags:
hash: Unavailable
Split status: N/A (0)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents Reply Children
  • Alright, I will try to get it to work with this

  • So I got back to this project and added the Kconfig parameters from the peripheral_uart sample to my central_bas project.

    However, CONFIG_FLASH_SIMULATOR cannot be enabled because "CONFIG_FLASH_SIMULATOR was assigned the value y, but got the value n. Missing dependencies: DT_HAS_ZEPHYR_SIM_FLASH_ENABLED". There is however no Kconfig fragment to enable this.

    And with CONFIG_NRF53_RECOVERY_NETWORK_CORE, I get "CONFIG_NRF53_RECOVERY_NETWORK_CORE was assigned the value y, but got the value n. Missing dependencies: n"

    How can I solve these issues?

    Best regards,

    Alex

    prj.conf of central_bas:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_CENTRAL=y
    CONFIG_BT_SMP=y
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_GATT_DM=y
    # was before CONFIG_HEAP_MEM_POOL_SIZE=1024
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    #CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_BT_BAS_CLIENT=y
    CONFIG_BT_SCAN=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    prj.conf of mcuboot:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    CONFIG_PM=n
    CONFIG_MAIN_STACK_SIZE=10240
    CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"
    CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
    CONFIG_BOOT_ENCRYPT_RSA=n
    CONFIG_BOOT_ENCRYPT_EC256=n
    CONFIG_BOOT_ENCRYPT_X25519=n
    CONFIG_BOOT_UPGRADE_ONLY=n
    CONFIG_BOOT_BOOTSTRAP=n
    ### mbedTLS has its own heap
    # CONFIG_HEAP_MEM_POOL_SIZE is not set
    ### We never want Zephyr's copy of tinycrypt. If tinycrypt is needed,
    ### MCUboot has its own copy in tree.
    # CONFIG_TINYCRYPT is not set
    # CONFIG_TINYCRYPT_ECC_DSA is not set
    # CONFIG_TINYCRYPT_SHA256 is not set
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    prj.conf of hci_rpmsg:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    CONFIG_IPC_SERVICE=y
    CONFIG_MBOX=y
    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_MAIN_STACK_SIZE=512
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y
    CONFIG_BT_HCI_RAW_RESERVE=1
    CONFIG_BT_MAX_CONN=16
    CONFIG_BT_CTLR_ASSERT_HANDLER=y
    # Workaround: Unable to allocate command buffer when using K_NO_WAIT since
    # Host number of completed commands does not follow normal flow control.
    CONFIG_BT_BUF_CMD_TX_COUNT=10
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Ryisen,

    Just wanted to let you know that I have taken over this case, as Kenneth is now on holiday. We are busy during the summer, but I'll try to get back to you soon.

    Best regards,

    Raoul

  • Hi Alex,

    I haven't gotten to the bottom of this yet, sorry. Things are slowly returning to normal here now so I hope to find an answer soon.

    Meanwhile, my colleague has a github repo with various bootloader samples and I see that there has been a recent addition of serial updates on netcore. Would you mind taking a look, trying to build it on your machine and comparing to your current setup?

    Best regards,

    Raoul

  • To fix "Missing dependencies: DT_HAS_ZEPHYR_SIM_FLASH_ENABLED"
    Add CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y to your app's prj.conf

    The required Kconfigs to enable serial recovery mode for app and net cores are as follows:

    prj.conf:


    Fullscreen
    1
    2
    3
    4
    5
    6
    # Use mcuboot
    CONFIG_BOOTLOADER_MCUBOOT=y
    # Needed to support serial recovery of NET core
    CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
    CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    child_image/mcuboot.conf:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    # Sanity / nice-to-have
    CONFIG_MCUBOOT_INDICATION_LED=y
    # Support MCUBoot serial recovery mode
    CONFIG_MCUBOOT_SERIAL=y
    CONFIG_UART_CONSOLE=n
    # Decrease memory footprint
    CONFIG_SIZE_OPTIMIZATIONS=y
    # Support serial recovery of the NET core
    CONFIG_FLASH_SIMULATOR=y
    CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
    CONFIG_FLASH_SIMULATOR_STATS=n
    CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
    CONFIG_NRF53_RECOVERY_NETWORK_CORE=y
    CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    For a quick way to check if the firmware was actually updated, see CONFIG_BOOT_BANNER_STRING which can be set for both app and net cores via prj.conf and child_image/hci_ipc.conf respectively

    The NET core prints logs on VCOM0