Changing partitions in a DTS overlay


Lawrence King
 

Dear all:

 

I am trying to change the partition table from the default as defined in the board file inside Zephyr to a slightly different configuration. Obviously I could do this by editing the file in the zephyr tree but this has the disadvantage that I have to redo the change each time I upgrade the kernel. Hence I would like to make the change in the overlay. Here is what I did in the overlay:

 

&flash0 {

        /*

         * For more information, see:

         * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions

         */

        partitions {

                compatible = "fixed-partitions";

                #address-cells = <1>;

                #size-cells = <1>;

 

                boot_partition: partition@0 {

                        label = "mcuboot";

                        reg = <0x000000000 0x0000C000>;

                };

/*

                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000067000>;

                };

                slot1_partition: partition@73000 {

                        label = "image-1";

                        reg = <0x00073000 0x000067000>;

                };

                scratch_partition: partition@da000 {

                        label = "image-scratch";

                        reg = <0x000da000 0x0001c000>;

                };

*/

                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000075800>;

                };

                slot1_partition: partition@81800 {

                        label = "image-1";

                        reg = <0x00081800 0x000075800>;

                };

 

                /*

                 * The flash starting at 0x000f8000 and ending at (32kB)

                 * 0x000fffff is reserved for use by the application.

                 */

 

                /* Storage partition will be used by FCB/NFFS/NVS if enabled. */

                storage_partition: partition@f8000 {

                        label = "storage";

                        reg = <0x000f8000 0x00008000>;

                };

        };

};

 

As you can see I commented out the definitions of slot0, slot1 and scratch, then I added in new definitions for slot0 and slot1. When I attempt to compile this I get a fatal error:

 

nrf52840_mdk.dts.pre.tmp:546.50-549.19: ERROR (duplicate_label): /soc/flash-controller@4001e000/flash@0/partitions/partition@81800: Duplicate label 'slot1_partition' on /soc/flash-controller@4001e000/flash@0/partitions/partition@81800 and /soc/flash-controller@4001e000/flash@0/partitions/partition@73000

ERROR: Input tree has errors, aborting (use -f to force output)

 

The device tree compile didn’t mind changing the size of the slot0 partition, but it hated changing the base address of the slot1 partition.

 

I tried leaving the partition address at 73000, it compiles, but the device tree compiler complains “warning: unit-address and first reg (0x81800) don't match for partition@73000” and mcuboot complains “<wrn> mcuboot: Cannot upgrade: slots don't have same amount of sectors”.

I also tried many variations on adding /delete-node/ and /delete-property/ in front of the definitions but this just gave me other errors.

 

Obviously I am going about this incorrectly. What is the right way to change the partition table in a device tree overlay?

 

Lawrence King

Principal Developer

Connected Transport Market Unit

https://www.Irdeto.com

+1(416)627-7302

 

1  2 - linkedin  3 - instagram  4 - youtube  6 - facebook  7

            

CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.

 

 

 


Martin Kozusky
 

Hi,
this is how my overlay looks like (and it's working) - I wanted to make storage partition smaller and add 2 more partitions. Since I didn't change image0,1 and scratch size, I didn't have to use overlay when compiling mcuboot. Changing slot0 and 1 size should be similar, but I think this time you will have to use the overlay also when compiling mcuboot.

/delete-node/ &storage_partition;

&flash0 {
 partitions {
  compatible = "fixed-partitions";
 
   info_partition: partition@7a000 {
    label = "info";
    reg = <0x0007a000 0x00001000>;
   };
   
    nvs_partition: partition@7b000 {
    label = "nvs";
    reg = <0x0007b000 0x00002000>;
   };
   
   storage_partition: partition@7d000 {
    label = "storage";
    reg = <0x0007d000 0x00003000>;
   };
 
  };
 };

Martin

Dne 27.03.2020 v 22:33 Lawrence King napsal(a):

Dear all:

 

I am trying to change the partition table from the default as defined in the board file inside Zephyr to a slightly different configuration. Obviously I could do this by editing the file in the zephyr tree but this has the disadvantage that I have to redo the change each time I upgrade the kernel. Hence I would like to make the change in the overlay. Here is what I did in the overlay:

 

&flash0 {

        /*

         * For more information, see:

         * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions

         */

        partitions {

                compatible = "fixed-partitions";

                #address-cells = <1>;

                #size-cells = <1>;

 

                boot_partition: partition@0 {

                        label = "mcuboot";

                        reg = <0x000000000 0x0000C000>;

                };

/*

                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000067000>;

                };

                slot1_partition: partition@73000 {

                        label = "image-1";

                        reg = <0x00073000 0x000067000>;

                };

                scratch_partition: partition@da000 {

                        label = "image-scratch";

                        reg = <0x000da000 0x0001c000>;

                };

*/

                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000075800>;

                };

                slot1_partition: partition@81800 {

                        label = "image-1";

                        reg = <0x00081800 0x000075800>;

                };

 

                /*

                 * The flash starting at 0x000f8000 and ending at (32kB)

                 * 0x000fffff is reserved for use by the application.

                 */

 

                /* Storage partition will be used by FCB/NFFS/NVS if enabled. */

                storage_partition: partition@f8000 {

                        label = "storage";

                        reg = <0x000f8000 0x00008000>;

                };

        };

};

 

As you can see I commented out the definitions of slot0, slot1 and scratch, then I added in new definitions for slot0 and slot1. When I attempt to compile this I get a fatal error:

 

nrf52840_mdk.dts.pre.tmp:546.50-549.19: ERROR (duplicate_label): /soc/flash-controller@4001e000/flash@0/partitions/partition@81800: Duplicate label 'slot1_partition' on /soc/flash-controller@4001e000/flash@0/partitions/partition@81800 and /soc/flash-controller@4001e000/flash@0/partitions/partition@73000

ERROR: Input tree has errors, aborting (use -f to force output)

 

The device tree compile didn’t mind changing the size of the slot0 partition, but it hated changing the base address of the slot1 partition.

 

I tried leaving the partition address at 73000, it compiles, but the device tree compiler complains “warning: unit-address and first reg (0x81800) don't match for partition@73000” and mcuboot complains “<wrn> mcuboot: Cannot upgrade: slots don't have same amount of sectors”.

I also tried many variations on adding /delete-node/ and /delete-property/ in front of the definitions but this just gave me other errors.

 

Obviously I am going about this incorrectly. What is the right way to change the partition table in a device tree overlay?

 

Lawrence King

Principal Developer

Connected Transport Market Unit

https://www.Irdeto.com

+1(416)627-7302

 

1  2 -
                linkedin  3 -
                instagram  4 -
                youtube  6
                - facebook  7

            

CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.

 

 

 



Lawrence King
 

Hi Martin:

 

Excellent, thank you. The bit I missed was the correct syntax for /delete-node/

 

I put the following 3 lines just before &flash0

 

/delete-node/ &slot0_partition;

/delete-node/ &slot1_partition;

/delete-node/ &scratch_partition;

 

After this the other changes work correctly.

 

Lawrence King

Principal Developer

+1(416)627-7302

 

From: Martin Kozusky <news@...>
Sent: Saturday, March 28, 2020 2:58 AM
To: users@...
Cc: Lawrence King <lawrence.king@...>
Subject: Re: [Zephyr-users] Changing partitions in a DTS overlay

 

Hi,
this is how my overlay looks like (and it's working) - I wanted to make storage partition smaller and add 2 more partitions. Since I didn't change image0,1 and scratch size, I didn't have to use overlay when compiling mcuboot. Changing slot0 and 1 size should be similar, but I think this time you will have to use the overlay also when compiling mcuboot.

 

/delete-node/ &storage_partition;

&flash0 {
 partitions {
  compatible = "fixed-partitions";
 
   info_partition: partition@7a000 {
    label = "info";
    reg = <0x0007a000 0x00001000>;
   };
   
    nvs_partition: partition@7b000 {
    label = "nvs";
    reg = <0x0007b000 0x00002000>;
   };
   
   storage_partition: partition@7d000 {
    label = "storage";
    reg = <0x0007d000 0x00003000>;
   };
 
  };
 };

 

Martin

 

Dne 27.03.2020 v 22:33 Lawrence King napsal(a):

Dear all:

 

I am trying to change the partition table from the default as defined in the board file inside Zephyr to a slightly different configuration. Obviously I could do this by editing the file in the zephyr tree but this has the disadvantage that I have to redo the change each time I upgrade the kernel. Hence I would like to make the change in the overlay. Here is what I did in the overlay:

 

&flash0 {

        /*

         * For more information, see:

         * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions

         */

        partitions {

                compatible = "fixed-partitions";

                #address-cells = <1>;

                #size-cells = <1>;

 

                boot_partition: partition@0 {

                        label = "mcuboot";

                        reg = <0x000000000 0x0000C000>;

                };

/*

                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000067000>;

                };

                slot1_partition: partition@73000 {

                        label = "image-1";

                        reg = <0x00073000 0x000067000>;

                };

                scratch_partition: partition@da000 {

                        label = "image-scratch";

                        reg = <0x000da000 0x0001c000>;

                };

*/

                slot0_partition: partition@c000 {

                        label = "image-0";

                        reg = <0x0000C000 0x000075800>;

                };

                slot1_partition: partition@81800 {

                        label = "image-1";

                        reg = <0x00081800 0x000075800>;

                };

 

                /*

                 * The flash starting at 0x000f8000 and ending at (32kB)

                 * 0x000fffff is reserved for use by the application.

                 */

 

                /* Storage partition will be used by FCB/NFFS/NVS if enabled. */

                storage_partition: partition@f8000 {

                        label = "storage";

                        reg = <0x000f8000 0x00008000>;

                };

        };

};

 

As you can see I commented out the definitions of slot0, slot1 and scratch, then I added in new definitions for slot0 and slot1. When I attempt to compile this I get a fatal error:

 

nrf52840_mdk.dts.pre.tmp:546.50-549.19: ERROR (duplicate_label): /soc/flash-controller@4001e000/flash@0/partitions/partition@81800: Duplicate label 'slot1_partition' on /soc/flash-controller@4001e000/flash@0/partitions/partition@81800 and /soc/flash-controller@4001e000/flash@0/partitions/partition@73000

ERROR: Input tree has errors, aborting (use -f to force output)

 

The device tree compile didn’t mind changing the size of the slot0 partition, but it hated changing the base address of the slot1 partition.

 

I tried leaving the partition address at 73000, it compiles, but the device tree compiler complains “warning: unit-address and first reg (0x81800) don't match for partition@73000” and mcuboot complains “<wrn> mcuboot: Cannot upgrade: slots don't have same amount of sectors”.

I also tried many variations on adding /delete-node/ and /delete-property/ in front of the definitions but this just gave me other errors.

 

Obviously I am going about this incorrectly. What is the right way to change the partition table in a device tree overlay?

 

Lawrence King

Principal Developer

Connected Transport Market Unit

https://www.Irdeto.com

+1(416)627-7302

 

1  2 -
                linkedin  3 -
                instagram  4 -
                youtube  6
                - facebook  7

            

CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.