2022-05-01 17:10:42

by Mikhail Zhilkin

[permalink] [raw]
Subject: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

On 4/30/2022 5:35 PM, Krzysztof Kozlowski wrote:

>> diff --git
>> a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
>> b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
>> index ea4cace6a955..fa457d55559b 100644
>> --- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
>> +++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
>> @@ -17,9 +17,29 @@ description: |
>>  maintainers:
>>    - Rafał Miłecki <[email protected]>
>>  
>> +select:
>> +  properties:
>> +    compatible:
>> +      contains:
>> +        enum:
>> +          - fixed-partitions
>> +
>> +  required:
>> +    - compatible
> With your approach you do not need this entire select. I pointed out to
> you if you wanted to take the syscon approach.
>
>> +
>>  properties:
>>    compatible:
>> -    const: fixed-partitions
>> +    anyOf:
> oneOf
>
>> +      - items:
>> +          - enum:
>> +              - sercomm,sc-partitions
>> +
>> +          - const: fixed-partitions
>> +
>> +      - contains:
>> +          const: fixed-partitions
>> +        minItems: 1
>> +        maxItems: 2
> This is also not needed if you do no take the syscon approach.

I tried to take into account all of your comments:

diff --git
a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
index ea4cace6a955..45d6a3971514 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
@@ -19,7 +19,11 @@ maintainers:
 
 properties:
   compatible:
-    const: fixed-partitions
+    oneOf:
+      - const: fixed-partitions
+      - items:
+          - const: sercomm,sc-partitions
+          - const: fixed-partitions
 
   "#address-cells": true
 
@@ -27,7 +31,20 @@ properties:
 
 patternProperties:
   "@[0-9a-f]+$":
-    $ref: "partition.yaml#"
+    allOf:
+      - $ref: "partition.yaml#"
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: sercomm,sc-partitions
+        then:
+          properties:
+            sercomm,scpart-id:
+              description: Partition id in Sercomm partition map. Parser
+                uses this id to get partition offset and size values from
+                dynamic partition map.
+              $ref: /schemas/types.yaml#/definitions/uint32
 
 required:
   - "#address-cells"
@@ -52,6 +69,7 @@ examples:
             reg = <0x0100000 0x200000>;
         };
     };
+
   - |
     partitions {
         compatible = "fixed-partitions";
@@ -64,6 +82,7 @@ examples:
             reg = <0x00000000 0x1 0x00000000>;
         };
     };
+
   - |
     partitions {
         compatible = "fixed-partitions";
@@ -82,6 +101,7 @@ examples:
             reg = <0x2 0x00000000 0x1 0x00000000>;
         };
     };
+
   - |
     partitions {
         compatible = "fixed-partitions";
@@ -119,3 +139,30 @@ examples:
             };
         };
     };
+
+  - |
+    partitions {
+        compatible = "sercomm,sc-partitions", "fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            label = "u-boot";
+            reg = <0x0 0x100000>;
+            sercomm,scpart-id = <0>;
+            read-only;
+        };
+
+        partition@100000 {
+            label = "dynamic partition map";
+            reg = <0x100000 0x100000>;
+            sercomm,scpart-id = <1>;
+        };
+
+        partition@200000 {
+            label = "Factory";
+            reg = <0x200000 0x100000>;
+            sercomm,scpart-id = <2>;
+            read-only;
+        };
+    };
--
2.25.1


>    "#address-cells": true
>  
> @@ -27,7 +47,18 @@ properties:
>  
>  patternProperties:
>    "@[0-9a-f]+$":
> -    $ref: "partition.yaml#"
> +    allOf:
> +      - $ref: "partition.yaml#"
> +      - if:
> +          properties:
> +            compatible:
> +              contains:
> +                const: sercomm,sc-partitions
> +        then:
> +          properties:
> +            sercomm,scpart-id:
> +              description: Partition id in Sercomm partition map
> +              $ref: /schemas/types.yaml#/definitions/uint32
> I think we still did not clarify why do you need this ID which in all
> your examples increments by one. The description basically is a copy of
> property name, so it does not explain anything.

I added more detailed description.

>  
>  required:
>    - "#address-cells"
> @@ -119,3 +150,29 @@ examples:
>              };
>          };
>      };
> Blank line.

Fixed. And I added blank lines between already existing examples.

>> +  - |
>> +    partitions {
>> +        compatible = "sercomm,sc-partitions", "fixed-partitions";
>> +        #address-cells = <1>;
>> +        #size-cells = <1>;
>> +
>> +        partition@0 {
>> +            label = "u-boot";
>> +            reg = <0x0 0x100000>;
>> +            sercomm,scpart-id=<0>;
> Missing spaces around =.

Thanks. Fixed.

> Best regards,
> Krzysztof

--
Best regards,
Mikhail


2022-05-01 22:15:53

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

On 01/05/2022 16:51, Mikhail Zhilkin wrote:
> On 5/1/2022 11:17 AM, Krzysztof Kozlowski wrote:
>
>> On 30/04/2022 20:54, Mikhail Zhilkin wrote:
>>>  patternProperties:
>>>    "@[0-9a-f]+$":
>>> -    $ref: "partition.yaml#"
>>> +    allOf:
>>> +      - $ref: "partition.yaml#"
>>> +      - if:
>>> +          properties:
>>> +            compatible:
>>> +              contains:
>>> +                const: sercomm,sc-partitions
>>> +        then:
>>> +          properties:
>>> +            sercomm,scpart-id:
>>> +              description: Partition id in Sercomm partition map. Parser
>>> +                uses this id to get partition offset and size values from
>>> +                dynamic partition map.
>> Partition offset and size values are not derived from scpart-id. I am
>> sorry but after all these questions - it's the third time now - you
>> never answer why do you need this property and what is it used for. From
>> all the examples it could be simply removed and the partition map will
>> be exactly the same.
> scpart-id is necessary to get (using mtd parser) partition offset and
> size from dynamic partition map (NOT from the reg property):
>
> ❯ xxd -e -c 12 -s $((0x800)) -l $((0x78)) mtd1
> 00000800: 00000000 00000000 00100000  ............
> 0000080c: 00000001 00100000 00100000  ............
> 00000818: 00000002 00200000 00100000  ...... .....
> 00000824: 00000003 00300000 00100000  ......0.....
> 00000830: 00000004 00400000 00600000  ......@...`.
> 0000083c: 00000005 00a00000 00600000  ..........`.
> 00000848: 00000006 01000000 02000000  ............
> 00000854: 00000007 03000000 02000000  ............
> 00000860: 00000008 05000000 01400000  ..........@.
> 0000086c: 00000009 06400000 01b80000  ......@.....
>           scpart-id  offset      size
>
> With sercomm,sc-partitions the reg property will be ignored (offset =
> 0x200000, size = 0x100000) and the values will be taken from partition map.
>
> For example we have this is dts:
>
> partition@200000 {
>             label = "Factory";
>             reg = <0x200000 0x100000>;
>             sercomm,scpart-id = <2>;
>             read-only;
>         };
>
> Dynamic partition map:
>
> scpart-id = 2; offset = 0x00200000; size = 0x00100000
>
> 00000002 00200000 00100000  ...... .....
>
> In this example the offset and size are the same in reg and dynamic
> partition map. If device have bad blocks on NAND the values will be a
> little different. And we have to take partition offsets from partition
> map to avoid boot loops, wrong eeprom location and other bad things.
>
> Is there anything that needs to be explained in more detail?

Thanks a lot, this clarifies the topic. Looks good. Maybe you could put
parts of this into the scpart-id field description?

Best regards,
Krzysztof

2022-05-02 20:40:17

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

On 30/04/2022 20:54, Mikhail Zhilkin wrote:
>  patternProperties:
>    "@[0-9a-f]+$":
> -    $ref: "partition.yaml#"
> +    allOf:
> +      - $ref: "partition.yaml#"
> +      - if:
> +          properties:
> +            compatible:
> +              contains:
> +                const: sercomm,sc-partitions
> +        then:
> +          properties:
> +            sercomm,scpart-id:
> +              description: Partition id in Sercomm partition map. Parser
> +                uses this id to get partition offset and size values from
> +                dynamic partition map.

Partition offset and size values are not derived from scpart-id. I am
sorry but after all these questions - it's the third time now - you
never answer why do you need this property and what is it used for. From
all the examples it could be simply removed and the partition map will
be exactly the same.


Best regards,
Krzysztof

2022-05-02 23:26:00

by Mikhail Zhilkin

[permalink] [raw]
Subject: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

On 5/1/2022 11:17 AM, Krzysztof Kozlowski wrote:

> On 30/04/2022 20:54, Mikhail Zhilkin wrote:
>>  patternProperties:
>>    "@[0-9a-f]+$":
>> -    $ref: "partition.yaml#"
>> +    allOf:
>> +      - $ref: "partition.yaml#"
>> +      - if:
>> +          properties:
>> +            compatible:
>> +              contains:
>> +                const: sercomm,sc-partitions
>> +        then:
>> +          properties:
>> +            sercomm,scpart-id:
>> +              description: Partition id in Sercomm partition map. Parser
>> +                uses this id to get partition offset and size values from
>> +                dynamic partition map.
> Partition offset and size values are not derived from scpart-id. I am
> sorry but after all these questions - it's the third time now - you
> never answer why do you need this property and what is it used for. From
> all the examples it could be simply removed and the partition map will
> be exactly the same.
scpart-id is necessary to get (using mtd parser) partition offset and
size from dynamic partition map (NOT from the reg property):

❯ xxd -e -c 12 -s $((0x800)) -l $((0x78)) mtd1
00000800: 00000000 00000000 00100000  ............
0000080c: 00000001 00100000 00100000  ............
00000818: 00000002 00200000 00100000  ...... .....
00000824: 00000003 00300000 00100000  ......0.....
00000830: 00000004 00400000 00600000  ......@...`.
0000083c: 00000005 00a00000 00600000  ..........`.
00000848: 00000006 01000000 02000000  ............
00000854: 00000007 03000000 02000000  ............
00000860: 00000008 05000000 01400000  ..........@.
0000086c: 00000009 06400000 01b80000  ......@.....
          scpart-id  offset      size

With sercomm,sc-partitions the reg property will be ignored (offset =
0x200000, size = 0x100000) and the values will be taken from partition map.

For example we have this is dts:

partition@200000 {
            label = "Factory";
            reg = <0x200000 0x100000>;
            sercomm,scpart-id = <2>;
            read-only;
        };

Dynamic partition map:

scpart-id = 2; offset = 0x00200000; size = 0x00100000

00000002 00200000 00100000  ...... .....

In this example the offset and size are the same in reg and dynamic
partition map. If device have bad blocks on NAND the values will be a
little different. And we have to take partition offsets from partition
map to avoid boot loops, wrong eeprom location and other bad things.

Is there anything that needs to be explained in more detail?

> Best regards,
> Krzysztof

--
Best regards,
Mikhail

2022-05-02 23:53:23

by Mikhail Zhilkin

[permalink] [raw]
Subject: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

On 5/1/2022 7:17 PM, Krzysztof Kozlowski wrote:

> On 01/05/2022 16:51, Mikhail Zhilkin wrote:
>> On 5/1/2022 11:17 AM, Krzysztof Kozlowski wrote:
>>
>>> On 30/04/2022 20:54, Mikhail Zhilkin wrote:
>>>>  patternProperties:
>>>>    "@[0-9a-f]+$":
>>>> -    $ref: "partition.yaml#"
>>>> +    allOf:
>>>> +      - $ref: "partition.yaml#"
>>>> +      - if:
>>>> +          properties:
>>>> +            compatible:
>>>> +              contains:
>>>> +                const: sercomm,sc-partitions
>>>> +        then:
>>>> +          properties:
>>>> +            sercomm,scpart-id:
>>>> +              description: Partition id in Sercomm partition map. Parser
>>>> +                uses this id to get partition offset and size values from
>>>> +                dynamic partition map.
>>> Partition offset and size values are not derived from scpart-id. I am
>>> sorry but after all these questions - it's the third time now - you
>>> never answer why do you need this property and what is it used for. From
>>> all the examples it could be simply removed and the partition map will
>>> be exactly the same.
>> scpart-id is necessary to get (using mtd parser) partition offset and
>> size from dynamic partition map (NOT from the reg property):
>>
>> ❯ xxd -e -c 12 -s $((0x800)) -l $((0x78)) mtd1
>> 00000800: 00000000 00000000 00100000  ............
>> 0000080c: 00000001 00100000 00100000  ............
>> 00000818: 00000002 00200000 00100000  ...... .....
>> 00000824: 00000003 00300000 00100000  ......0.....
>> 00000830: 00000004 00400000 00600000  ......@...`.
>> 0000083c: 00000005 00a00000 00600000  ..........`.
>> 00000848: 00000006 01000000 02000000  ............
>> 00000854: 00000007 03000000 02000000  ............
>> 00000860: 00000008 05000000 01400000  ..........@.
>> 0000086c: 00000009 06400000 01b80000  ......@.....
>>           scpart-id  offset      size
>>
>> With sercomm,sc-partitions the reg property will be ignored (offset =
>> 0x200000, size = 0x100000) and the values will be taken from partition map.
>>
>> For example we have this is dts:
>>
>> partition@200000 {
>>             label = "Factory";
>>             reg = <0x200000 0x100000>;
>>             sercomm,scpart-id = <2>;
>>             read-only;
>>         };
>>
>> Dynamic partition map:
>>
>> scpart-id = 2; offset = 0x00200000; size = 0x00100000
>>
>> 00000002 00200000 00100000  ...... .....
>>
>> In this example the offset and size are the same in reg and dynamic
>> partition map. If device have bad blocks on NAND the values will be a
>> little different. And we have to take partition offsets from partition
>> map to avoid boot loops, wrong eeprom location and other bad things.
>>
>> Is there anything that needs to be explained in more detail?
> Thanks a lot, this clarifies the topic. Looks good. Maybe you could put
> parts of this into the scpart-id field description?

Thank you for you support! I updated the scpart-id description and hope
this should be clear enough. If so, I'll prepare PATCH v3.

 patternProperties:
   "@[0-9a-f]+$":
-    $ref: "partition.yaml#"
+    allOf:
+      - $ref: "partition.yaml#"
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: sercomm,sc-partitions
+        then:
+          properties:
+            sercomm,scpart-id:
+              description: Partition id in Sercomm partition map. Mtd
+                parser uses this id to find a record in the partiton map
+                containing offset and size of the current partition. The
+                values from partition map overrides partition offset and
+                size defined in reg property of the dts. Frequently these
+                values are the same, but may differ if device has bad
+                eraseblocks on a flash.
+              $ref: /schemas/types.yaml#/definitions/uint32

> Best regards,
> Krzysztof

--
Best regards,
Mikhail