nRF5340 Getting FOTA to work with both app core and net core simultaneously

Hello,

I've been working on getting FOTA to work for multi-image DFUs, but have not been able to get it. I've read through countless forums, and something I heard was that we need external flash to DFU both the app and net core. However, a coworker told me he was able to partition the internal flash on our DK boards to support FOTAing without external flashing. He's not sure how to do it on v2.4.2, though. If you have any information on how we could do this in 2.4.2, that would be great!

I've followed a few samples to get simultaneous FOTA working, such as this one https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/nrf5340/mcuboot_smp_ble_simultaneous . My DK board had weird functionality with this project. When I would first start the DFU, after I clicked "Confirm and Test" in the nRF Device Manager iOS mobile app, I would get an error saying "Unable to find secondary slot for image 0 in Test Response" for the "State". After, I would click "Start" and "Confirm and Test" a second time, and then it would very quickly finish and say "UPLOAD COMPLETE." This seems to mean that it worked, but I'm not certain.

For my own project, currently I'm able to build and flash my board, but I can't see it being listed as a Bluetooth device to connect to.

Here is my prj.conf file:

# Enable Bootloader
CONFIG_BOOTLOADER_MCUBOOT=y

# Enable SMP Server
CONFIG_MCUMGR=y
CONFIG_BASE64=y
CONFIG_MCUMGR_TRANSPORT_UART=y
CONFIG_MCUMGR_GRP_IMG=y

# Enable BLE transfer
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Test SMP Server"
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_USE_ALL_AVAILABLE_RAM=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
CONFIG_MCUBOOT_IMAGE_VERSION="2.3.0+0"
CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y


CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

# configure peripherals
CONFIG_NRFX_TWIM0=y
CONFIG_NRFX_TWIM1=y
CONFIG_I2C=y
CONFIG_NRFX_QSPI=n
CONFIG_SPI=y
CONFIG_SPI_EXTENDED_MODES=y
CONFIG_NRFX_SPIM2=y
CONFIG_NRFX_SPIM3=y
CONFIG_NRFX_SPIM4=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_TIMER1=y
CONFIG_NRFX_TIMER2=y
CONFIG_NRFX_PWM0=y

CONFIG_SCHED_DUMB=y
CONFIG_SCHED_DEADLINE=y

#DFU Stuff
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_ZCBOR=y
CONFIG_MCUMGR=y
# CONFIG_BT_SMP=y


# add DSP libraries
CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_STATISTICS=y
CONFIG_FORCE_NO_ASSERT=y
#CONFIG_BT=y
#CONFIG_BT_PERIPHERAL=y
CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y

#TDCS Stuff
CONFIG_ADC=y
CONFIG_NRFX_SAADC=y

# watchdog
CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=y

Here is my mcuboot.conf file:

CONFIG_BOOT_SIGNATURE_KEY_FILE="C:/Users/NolanGeer/Documents/GitHub/nrf5340_firmware/keys/nirskey.pem"
# Enable flash simulator
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

CONFIG_MAIN_STACK_SIZE=10240
CONFIG_BOOT_MAX_IMG_SECTORS=256


CONFIG_NRF53_MULTI_IMAGE_UPDATE=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2

CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_IMAGE_ACCESS_HOOK_NRF5340=y
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y

Here is my overlay file:

// 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
/ {
	chosen {
		nordic,pm-ext-flash = &mx25r64;
	};
};


/ {
	zephyr,user {
		io-channels = <&adc 0>, <&adc 1>;
	};
};

&pinctrl {
    spi2_default: spi2_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
                <NRF_PSEL(SPIM_MOSI, 0, 30)>,
                <NRF_PSEL(SPIM_MISO, 1, 0)>;
        };
    };

    spi2_sleep: spi2_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
                <NRF_PSEL(SPIM_MOSI, 0, 30)>,
                <NRF_PSEL(SPIM_MISO, 1, 0)>;
            low-power-enable;
        };
    };
};

&spi2 {
    compatible = "nordic,nrf-spim";
    status = "okay";
    cs-gpios = <&gpio1 14 1>;
    pinctrl-0 = <&spi2_default>;
    pinctrl-1 = <&spi2_sleep>;
    pinctrl-names = "default", "sleep";
};

&adc {
    #address-cells = <1>;
    #size-cells = <0>;
 
    channel@0 {
        reg = <0>;
        zephyr,gain = "ADC_GAIN_1_6";
        zephyr,reference = "ADC_REF_INTERNAL";
        zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
        zephyr,input-positive = <NRF_SAADC_AIN4>;
    };

    channel@1 {
        reg = <1>;
        zephyr,gain = "ADC_GAIN_1_6";
        zephyr,reference = "ADC_REF_INTERNAL";
        zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
        zephyr,input-positive = <NRF_SAADC_AIN5>;
    };
 };

I also have a .conf file for the NSIB first-stage bootloader (hci_rpmsg.conf)

CONFIG_SECURE_BOOT=y
CONFIG_SB_SIGNING_KEY_FILE="C:/Users/NolanGeer/Documents/GitHub/nrf5340_firmware/keys/nirskey_ecdsa.pem"

Finally, I also have an overlay file for my mcuboot, named mcuboot.overlay, but I don't think it's doing anything. I'm not sure about this, but I saw it in the example I linked above.

/ {
	chosen {
		nordic,pm-ext-flash = &mx25r64;
	};
};

I have another version of my project where I could connect to the Bluetooth and start the FOTA, but I would get the error: Invalid value(3). I wasn't sure what this meant, so I moved onto trying to copy the sample.

Let me know if you need any other information. I've read through quite a bit of forum posts to no avail, so hopefully we can figure this out.

Thanks in advance!

Parents
  • Hi Nolan,

    Let's see if we can make this work.

    First, I will comment on your ticket, and ask some questions.

    However, a coworker told me he was able to partition the internal flash on our DK boards to support FOTAing without external flashing.

    You can do it with internal flash, but thing is, the "nordic,pm-ext-flash = &mx25r64;" configuration enables a lot of stuff automatically in the background, so this is easier to start with.

    We are working on adding it more easily in these PRs:

    https://github.com/nrfconnect/sdk-nrf/pull/10060

    https://github.com/nrfconnect/sdk-mcuboot/pull/235

    If you want to use internal flash for now, I think you can have a look this sample:

    peripheral_lbs_dfu(2).zip

    When I would first start the DFU, after I clicked "Confirm and Test" i

    From  my repo:

    Does it behave as expected if you only "Confirm" and reset manually?

    That being said, it should be possible to automate this more, but you may have to enable more functionality for the project in that case. Let me know what you would expect and I can try to guide you to how to fix that.

    For my own project, currently I'm able to build and flash my board, but I can't see it being listed as a Bluetooth device to connect to.

    Can you see Bluetooth on your own device with simple Bluetooth firmware, not any bootloader or anything fancy?

    Do you get any error logs from your app or bootloader?

    Regards,
    Sigurd Hellesvik

  • Also, what exactly is happening when I select "Confirm and Test" instead of "Confirm Only"? How is it "confirming" the images? What is being tested?

Reply Children
No Data
Related