cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ray110
Visitor
Visitor
587 Views
Registered: ‎10-30-2017

Create read-only partitions from config files

Hi everyone,

 

I'm looking to create read-only partitions on the QSPI Flash where boot files are stored.

 

There is a possibility to pass a command line from U-Boot to the kernel at bootup if CONFIG_MTD_CMDLINE_PARTS is enabled, which would look something like this:

mtdparts=spi0.0:8m(U-Boot)ro,128k(Bootenv),16m(Kernel)ro,32m(RootFS)ro,-(Data)

So I'm trying to make this static in the kernel without passing it from U-Boot.

 

There is the following code in components/plnx-workspace/device-tree/device-tree-generation:

&qspi {
 #address-cells = <1>;
 #size-cells = <0>;
 flash0: flash@0 {
  compatible = "n25q512a","micron,m25p80";
  reg = <0x0>;
  #address-cells = <1>;
  #size-cells = <1>;
  spi-max-frequency = <50000000>;
  partition@0x00000000 {
   label = "boot";
   reg = <0x00000000 0x00500000>;
  };
  partition@0x00500000 {
   label = "bootenv";
   reg = <0x00500000 0x00020000>;
  };
  partition@0x00520000 {
   label = "kernel";
   reg = <0x00520000 0x00a80000>;
  };
  partition@0x00fa0000 {
   label = "spare";
   reg = <0x00fa0000 0x00000000>;
  };
 };
};

 As this is generated code, the question is: where do I customize this from to make the partitions read-only, and what would be the option to pass?

 

Thanks for your time

0 Kudos
1 Reply
mb1000
Visitor
Visitor
508 Views
Registered: ‎01-12-2018

There is an option in Flash Settings menu to add 'flash partition flags'.  The only supported one is read-only.  The problem is that I have been unable to get this mechanism to work.

 

An alternative is to add something to system-user.dtsi to manually add the 'read-only;' option to the partition entry in the device tree.

 

I used something like the following, but obviously tailored to your specific flash configuration.  I tested a build using this mechanism and the partitions are definitely read-only; flash_erase and flashcp fail with permission error.

 

&amba {

               spi@e000d000 {

                              flash@0 {

                                             partition@0x00000000 {

                                                                           read-only;

                                             };

                        };

               };

};

 

0 Kudos