Re: Flash configuration in dts file


David Leach
 

In some work that I’m doing I had to do the same thing. I haven’t posted a PR for this work so I’m not sure how the community will react but here is what I did to add the file system partition with a single slot partition:

 

 

In my DTS file I have the following:

 

&flash0 {

                /*

                * For more information, see:

                * http://docs.zephyrproject.org/devices/dts/flash_partitions.html

                */

                partitions {

                                compatible = "fixed-partitions";

                                #address-cells = <1>;

                                #size-cells = <1>;

                               

#if defined(CONFIG_FS_FLASH_STORAGE_PARTITION)

                                slot0_partition: partition@c000 {

                                                label = "image-0";

                                                reg = <0x00000000 0x7d000>;

                                };

 

                                storage_partition: partition@7a000 {

                                                label = "storage";

                                                reg = <0x0007d000 0x00003000>;

                                };

#else

                                slot0_partition: partition@c000 {

                                                label = "image-0";

                                                reg = <0x00000000 0x80000>;

                                };

#endif

                };

};

 

Then I needed to change subsys/storage/flash_map/flash_map_default.c to conditionally include partitions based on whether that partition’s SIZE define is defined:

 

 

const struct flash_area default_flash_map[] = {

#ifdef FLASH_AREA_MCUBOOT_SIZE

                /* FLASH_AREA_BOOTLOADER */

                {

                                .fa_id = 0,

                                .fa_device_id = SOC_FLASH_0_ID,

                                .fa_off = FLASH_AREA_MCUBOOT_OFFSET,

                                .fa_size = FLASH_AREA_MCUBOOT_SIZE,

                },

#endif

                /* FLASH_AREA_IMAGE_0 */

                {

                                .fa_id = 1,

                                .fa_device_id = SOC_FLASH_0_ID,

                                .fa_off = FLASH_AREA_IMAGE_0_OFFSET,

                                .fa_size = FLASH_AREA_IMAGE_0_SIZE,

                },

#ifdef FLASH_AREA_IMAGE_1_SIZE

                /* FLASH_AREA_IMAGE_1 */

                {

                                .fa_id = 2,

                                .fa_device_id = SOC_FLASH_0_ID,

                                .fa_off = FLASH_AREA_IMAGE_1_OFFSET,

                                .fa_size = FLASH_AREA_IMAGE_1_SIZE,

                },

#endif

#ifdef FLASH_AREA_IMAGE_SCRATCH_SIZE

                /* FLASH_AREA_IMAGE_SCRATCH */

                {

                                .fa_id = 3,

                                .fa_device_id = SOC_FLASH_0_ID,

                                .fa_off = FLASH_AREA_IMAGE_SCRATCH_OFFSET,

                                .fa_size = FLASH_AREA_IMAGE_SCRATCH_SIZE,

                },

#endif

#ifdef CONFIG_FS_FLASH_STORAGE_PARTITION

                /* FLASH_AREA_STORAGE */

                {

                                .fa_id = 4,

                                .fa_device_id = SOC_FLASH_0_ID,

                                .fa_off = FLASH_AREA_STORAGE_OFFSET,

                                .fa_size = FLASH_AREA_STORAGE_SIZE,

                },

#endif

};

 

 

From: devel@... <devel@...> On Behalf Of Laurence Pasteau
Sent: Friday, August 17, 2018 10:35 AM
To: zephyr-devel@...
Subject: Re: [Zephyr-devel] Flash configuration in dts file

 

The solution below is not available since I need to start the fimrware at 0x0 without bootloader.

 

So I would really appreciate if someone could help me.

I compile with a nrf52_pca10040 board.

 

Regards,

Laurence

 


De : devel@... <devel@...> de la part de Laurence Pasteau <laurence.pasteau@...>
Envoyé : vendredi 17 août 2018 16:51
À : zephyr-devel@...
Objet : [Zephyr-devel] Flash configuration in dts file

 

Hi everybody,

 

I have a question regarding dts file, and more specifically the flash partition.

I would like to have a project without bootloader, but with a partition for the code and another for the file system.

 

At compilation time I would like to be warned if the code partition is overlapping the flash partition.

 

First I tried to set CONFIG_FLASH_LOAD_SIZE. As I have no bootloader, I still need CONFIG_FLASH_LOAD_OFFSET to 0.

Unfortunately as CONFIG_HAS_DTS is set in this project, these values are not taken into account.

 

However in the script that generates the generated_dts_board files from dts, it seems that :

if CONFIG_FLASH_LOAD_OFFSET is set to 0

then

CONFIG_FLASH_LOAD_SIZE is set to 0.

 

The only successfull but not pretty solution I found was this one :

 

        boot_partition: partition@0 {
            label = "noboot";
            reg = <0x00000000 0x4>;
        };
        code_partition: partition@4 {
            label = "code-partition";
            reg = <0x00000004 0x40000>;
        };
#if defined(CONFIG_FS_FLASH_STORAGE_PARTITION)
        storage_partition: partition@40004 {
            label = "storage";
            reg = <0x00040004 0x0003FFFC>;
        };
#endif

 

Is there a better way to solve this issue ?

 

Thanks in advance,

Regards,

Laurence

 

Join devel@lists.zephyrproject.org to automatically receive all group messages.