XIAO nrf52840 - can flash, but code will not run (flash location)

Hi, I am able to flash my XIAO nrf52840 using my nrf52840dk however the code does not run once flashed. I checked and the code itself is starting at 0x00027000 presumably because of the default bootloader the board came with. However, I no longer have the bootloader. I tried setting this in my prj.conf to override the default for the board, but it still puts code starting at 0x00027000:

# Build UF2 by default, supported by the Adafruit nRF52 Bootloader
CONFIG_BUILD_OUTPUT_UF2=n
CONFIG_USE_DT_CODE_PARTITION=n
And here's where I see the code still coming after the empty reserved location:
Does anyone know how I can solve this?
Parents
  • Hello,

    Have you removed the default UF2 bootloader that comes preloaded on the XIAO nRF52840? If so, could you explain how you did that?

    From your explanation, I understand that you are trying to flash an application with CONFIG_BUILD_OUTPUT_UF2=n so that it overrides the preloaded bootloader. If that is the case, I doubt that setting CONFIG_BUILD_OUTPUT_UF2=n alone is sufficient to achieve this.

    Could you try adding CONFIG_FLASH_LOAD_OFFSET=0 in your prj.conf and check whether that makes the application start at address 0x0?

    Kind regards,
    Abhijith

  • Also note that, by default, the XIAO uses "#include <nordic/nrf52840_partition_uf2_sdv7.dtsi>" which expects a UF2 bootloader. Try using the partitions found in "zephyr/dts/vendor/nordic/nrf52840_partition.dtsi" if you are not using the UF2 bootloader. 

    /*
     * Copyright (c) 2024 Jacob Winther
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    / {
    	chosen {
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};
    };
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x0000C000>;
    		};
    
    		slot0_partition: partition@c000 {
    			label = "image-0";
    			reg = <0x0000C000 0x00076000>;
    		};
    
    		slot1_partition: partition@82000 {
    			label = "image-1";
    			reg = <0x00082000 0x00076000>;
    		};
    
    		/*
    		 * The flash starting at 0x000f8000 and ending at
    		 * 0x000fffff is reserved for use by the application.
    		 */
    
    		/*
    		 * Storage partition will be used by FCB/LittleFS/NVS
    		 * if enabled.
    		 */
    		storage_partition: partition@f8000 {
    			label = "storage";
    			reg = <0x000f8000 0x00008000>;
    		};
    	};
    };
    

Reply
  • Also note that, by default, the XIAO uses "#include <nordic/nrf52840_partition_uf2_sdv7.dtsi>" which expects a UF2 bootloader. Try using the partitions found in "zephyr/dts/vendor/nordic/nrf52840_partition.dtsi" if you are not using the UF2 bootloader. 

    /*
     * Copyright (c) 2024 Jacob Winther
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    / {
    	chosen {
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};
    };
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x0000C000>;
    		};
    
    		slot0_partition: partition@c000 {
    			label = "image-0";
    			reg = <0x0000C000 0x00076000>;
    		};
    
    		slot1_partition: partition@82000 {
    			label = "image-1";
    			reg = <0x00082000 0x00076000>;
    		};
    
    		/*
    		 * The flash starting at 0x000f8000 and ending at
    		 * 0x000fffff is reserved for use by the application.
    		 */
    
    		/*
    		 * Storage partition will be used by FCB/LittleFS/NVS
    		 * if enabled.
    		 */
    		storage_partition: partition@f8000 {
    			label = "storage";
    			reg = <0x000f8000 0x00008000>;
    		};
    	};
    };
    

Children
No Data
Related