NRF53 Netcore Flash Steraming to Appcore

I want to be able to perform a DFU entirely from the netcore for backup/reliability reasons.

I can flash stream from the netcore to flash1 using stream_flash_init with "device_get_binding(PM_APP_DEV_NAME)", which evaluates to "NRF_FLASH_DRV_NAME", which evaluates to flash1/flash_controller from "nrf5340_cpunet.dtsi".

There isn't enough room on the cpunet core; so, I need to store the image on the appcore flash, validate it there, then copy over the netcore application. However, there doesn't appear to be any way to stream to flash0 from the netcore.

I am currently sending messages via shared SRAM, which is quite hacky.

Is there any way to get stream to flash0 from the netcore?

  • AntonD said:
    I am not using MCU boot so that wouldn't be a solution.

    Are using the nRF Secure Immutable Bootloader? Are you using your own?

    AntonD said:
    None of the things you have mentioned actually address the issue of what to call from the netcore application to write to the cpucore flash.

    The netcore should have access to all the flash, so you could just copy the parts referencing flash0 from the appcore dts files into the netcore dts.

    Regards,

    Elfving

  • I am using a custom build of the nRF secure immutable bootloader.

    I have tried, but I guess what I am asking is how to copy the flash0 parts.

    I have the following in the netcore dts:

    		flash_controller: flash-controller@41080000 {
    			compatible = "nordic,nrf53-flash-controller";
    			reg = <0x41080000 0x1000>;
    
    			#address-cells = <1>;
    			#size-cells = <1>;
    
    			label="NRF_FLASH_DRV_NAME";
    
    			flash1: flash@1000000 {
    				compatible = "soc-nv-flash";
    				label = "NRF_FLASH";
    				erase-block-size = <2048>;
    				write-block-size = <4>;
    			};
    		};

    I can't duplicate this section as it duplicates the "flash-controller" name. I have tried changing that name in the duplication but I think the name is a reserved name. I have tried adding a "flash0" section in the same way that it has a "flash1" section but that gives the following error

    <stdout>: ERROR (unit_address_vs_reg): /soc/flash-controller@41080000/flash@0: node has a unit name, but no reg property

    The "chosen" section also has:

        chosen {
            zephyr,entropy = &rng;
            zephyr,flash-controller = &flash_controller;
        };
    and there doesn't appear an easy way to add another flash controller there either.
  • Well it is preferable to use overlay files. So if you want to add this flash space to the flash controller you can try to add this as an overlay to your project:

    
    /{
    	chosen {
    		zephyr,flash0 = &flash0; 
    	};
    };
    
    &flash_controller {
        flash0: flash@0000000 { 
            reg = <0x00000000 DT_SIZE_K(1024)>;
            compatible = "soc-nv-flash";
            label = "NRF_FLASH_APP_l";
            erase-block-size = <2048>;
            write-block-size = <4>;
        };
    };
     

    If you want a separate binding/device pointer to that flash partition though, you need a separate flash controller. 

    /{
    	chosen {
    		zephyr,flash0 = &flash0; 
            zephyr,flash-controller0 = &flash_controller0; 
    
    	};
    	soc {
    		flash_controller0: flash-controller0@41080000 {
    			compatible = "nordic,nrf53-flash-controller";
    			reg = <0x41080000 0x1000>;
    			partial-erase;
    
    			#address-cells = <1>;
    			#size-cells = <1>;
    
    			label="NRF_FLASH_APP";
    			flash0: flash@0000000 { 
    				compatible = "soc-nv-flash";
    				label = "NRF_FLASH_0";
    				erase-block-size = <2048>;
    				write-block-size = <4>;
                    reg = <0x00000000 DT_SIZE_K(1024)>;
    			};
    		};
        };  
    };

    Regards,

    Elfving

  • Hi Elfving,

    I have an open ticket with a related question (see here). I've tried both of your suggestions, with and without a separate flash controller, but I can't access addresses of flash0 (address range of application core) from the network core as I always get a Bus Fault.

    Therefore my question: Did you get it to work with your suggestions above?

  • I was able to get it working. Below is what I used for the overlay file.

    /{
        chosen {
            zephyr,flash0 = &flash0;
        };
    };
    
    &flash_controller {
        flash0: flash@0 {
            reg = <0 DT_SIZE_K(1024)>;
            compatible = "soc-nv-flash";
            label = "NRF_FLASH0";
            erase-block-size = <4096>;
            write-block-size = <4>;
        };
    };
    

    Note that you also need to enable access from the app core before you can use it in the net core. For example:

    nrf_spu_extdomain_set(NRF_SPU, 0, true, false);
Related