5340 hwo to DFU external Flash

Hello,

NRF5340,  NCS2.0.2,  VScode

I designed a headset,MCU is 5340, and a external flash for DSP program.

the external flash connect to DSP and 5340 use SPI;

i can DFU 5340MCU self,

how to  DFU external Flash for DSP program?

App_dfu.zip update to 5340 self,   DSP_dfu.zip update to external falsh.

is there any demo?

                          

Best regards

Parents
  • You can read/write external flash from the 5340 to update the DSP.  Look at the sample in ncs called ./sdk-zephyr/samples/drivers/spi_flash/src/main.c   It shows how to access qspi nor flash.

  • i know how to write to flash,

    my question is:  in DFUing, How to distinguish the download data is app or for external Flash?

    ps:

    in nRF5_SDK_17.0.2\examples\dfu\secure_bootloader\ 

    verify receive data , then distinguish the data, then do update APP or write to external Flash.

    in NCS where is bootloader codes and how to change it?

    see code as follow, NCS only

    #include <mgmt/mcumgr/smp_bt.h>
    #include "os_mgmt/os_mgmt.h"
    #include "img_mgmt/img_mgmt.h"
    not use bootloader?

    #include <bluetooth/bluetooth.h>
    #if defined (NRF5340_XXAA_APPLICATION)
      #define CLOCK_FEATURE_HFCLK_DIVIDE_PRESENT
      #include "nrfx_clock.h"
    #endif
    #include <zephyr.h>
    #include <sys/printk.h>
    #include <devicetree.h>
    #include <logging/log.h>
    #include <device.h>
    #include <drivers/gpio.h>
    #include <hal/nrf_gpio.h>
    #include <drivers/gpio.h>
    #include <sys/reboot.h>
    #include <settings/settings.h>
    #include <mgmt/mcumgr/smp_bt.h>
    #include "os_mgmt/os_mgmt.h"
    #include "img_mgmt/img_mgmt.h"
    
    LOG_MODULE_REGISTER(main, 4);
    
    void ota()
    {
    	printk("\n----------------OTA doing----------------\n\n");
    	os_mgmt_register_group();
    	img_mgmt_register_group();
    	smp_bt_register();
    
    	int err = bt_enable(NULL);
    	if (err) {
    		printk("Bluetooth init failed (err %d)\n", err);
    		return;
    	}
    	if (IS_ENABLED(CONFIG_SETTINGS)) {
    		settings_load();
    	}
    
    	err = bt_le_adv_start(BT_LE_ADV_CONN, upad, ARRAY_SIZE(upad),upsd, ARRAY_SIZE(upsd));
    	if (err) {
    		printk("Advertising failed to start (err %d)\n", err);
    		return;
    	}
    	printk("   OTA Advertising started: %s\n",bt_get_name());
    	
    	// if wait no OTA start, timeout 3min will reboot
    	for (int i=0;i<180;i++) {
    		k_msleep(1000);
    	}
    	printk("\n---------------OTA timeout---------------\n\n");
    	sys_reboot(0);
    }
    
    void main(void)
    {
    	ota();
    	while(true){
    		printk("********Hello World!********\n" );
    		k_msleep(1000);
    	}
    }
    

      

    Best regards

  • For more information about MCUboot I suggest you examine the MCUboot-documentation pages for NCS:

    In addition I recommend you have a look at the adding dfu support to your application

    The next item I would have a look at is the following ticket

    Here you will find this sample for NCS v1.7.1, where with a DFU sample that uses BLE and writes the data to external flash. This ticket should also give some information about how to write and read from a specific part of the external flash

    Kind regards,
    Andreas

Reply Children
No Data
Related