mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Re: Raspberry Pi Barebox State Integration - SD card
       [not found] <mailman.44637.1559659159.2376.barebox@lists.infradead.org>
@ 2019-06-05  4:26 ` Valentina Rusu
  2019-06-05  6:46   ` Moritz Augsburger
  0 siblings, 1 reply; 5+ messages in thread
From: Valentina Rusu @ 2019-06-05  4:26 UTC (permalink / raw)
  To: barebox

Thank you for the response!

I had a quick look over this patch, I need to find a way to adapt it
for RPi 3, as vmmc-supply , reg_3v3, vqmmc-supply, reg_1v8 are not
configured for rpi 3 (they exist only for CM1 and CM3 as I have seen
in the device tree sources).

I don't know if there are any implications if I use those nodes
similar to CM3 (don't know the differences between 3 and CM3).

      Best regards,
          Vali.

> Date: Tue, 04 Jun 2019 10:59:23 +0200
> From: Moritz Augsburger <ml+barebox@moritz.augsburger.name>
> To: barebox@lists.infradead.org
> Subject: Re: Raspberry Pi Barebox State Integration - SD card
> Message-ID: <e7c88d1ca9dd8acc056490158be54e39@moritz.augsburger.name>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> Hi,
>
> Am 2019-06-04 08:32, schrieb Valentina Rusu:
> > The issue to integrate Barebox state are the following:
> > * we need to specify a backend for the "state" node;
> > * the backend should point to an of partition on a non-volatile memory;
> > * other boards have EEPROM, NAND besides SD card and they are
> > described in the device tree; RPi has no such thing;
> > * somehow I need to write the state on the SD card in a location where
> > does not interfere with the partitions created (boot, rootfs, user
> > partitions, etc);
> > * the SD card device (mci0) is automatically detected at startup, and
> > not described in the device tree;
>
> Below is a part of my patches, using the emmc on a Compute Module as
> state backend.
> It uses the region between MBR and first partition (starting @4MB) to
> save the state.
>
> The patch may contain changes already done to the latest version, so
> apply carefully.
>
> diff --git a/arch/arm/dts/bcm2837-rpi-3.dts
> b/arch/arm/dts/bcm2837-rpi-3.dts
> index 51883613c..420525b9e 100644
> --- a/arch/arm/dts/bcm2837-rpi-3.dts
> +++ b/arch/arm/dts/bcm2837-rpi-3.dts
> @@ -11,10 +11,5 @@
>   };
>
>   &sdhci {
> -       pinctrl-0 = <&emmc_gpio48>;
> -       /delete-node/ wifi@1;
> -};
> -
> -&sdhost {
>         status = "disabled";
>   };
> diff --git a/arch/arm/dts/bcm2837-rpi-cm3.dts
> b/arch/arm/dts/bcm2837-rpi-cm3.dts
> index cfbffe175..d0144dcbc 100644
> --- a/arch/arm/dts/bcm2837-rpi-cm3.dts
> +++ b/arch/arm/dts/bcm2837-rpi-cm3.dts
> @@ -8,11 +8,76 @@
>         memory {
>                 reg = <0x0 0x0>;
>         };
> +
> +    state: state {
> +        magic = <0x4d433230>;
> +        compatible = "barebox,state";
> +        backend-type = "raw";
> +        backend = <&backend_state_sdhost>;
> +        backend-storage-type = "circular";
> +        backend-stridesize = <0x800>;
> +        #address-cells = <1>;
> +        #size-cells = <1>;
> +
> +        bootstate {
> +            #address-cells = <1>;
> +            #size-cells = <1>;
> +            system0 {
> +                #address-cells = <1>;
> +                #size-cells = <1>;
> +                remaining_attempts {
> +                    reg = <0x0 0x4>;
> +                    type = "uint32";
> +                    default = <3>;
> +                };
> +                priority {
> +                    reg = <0x4 0x4>;
> +                    type = "uint32";
> +                    default = <21>;
> +                };
> +            };
> +
> +            system1 {
> +                #address-cells = <1>;
> +                #size-cells = <1>;
> +                remaining_attempts {
> +                    reg = <0x10 0x4>;
> +                    type = "uint32";
> +                    default = <3>;
> +                };
> +                priority {
> +                    reg = <0x14 0x4>;
> +                    type = "uint32";
> +                    default = <20>;
> +                };
> +            };
> +            last_chosen {
> +                reg = <0x2C 0x4>;
> +                type = "uint32";
> +            };
> +        };
> +    };
> +
> +    aliases {
> +        state = &state;
> +    };
> +
>   };
>
> -&sdhci {
> -       pinctrl-0 = <&emmc_gpio48>;
> -       no-sd;
> -       non-removable;
> +&sdhost {
> +       pinctrl-names = "default";
> +       pinctrl-0 = <&sdhost_gpio48>;
> +       bus-width = <4>;
> +       vmmc-supply = <&reg_3v3>;
> +       vqmmc-supply = <&reg_1v8>;
>         status = "okay";
> +       partitions {
> +               compatible = "fixed-partitions";
> +               #size-cells = <1>;
> +               #address-cells = <1>;
> +        backend_state_sdhost: part@200000 {
> +                label = "state_sdhost";
> +                reg = <0x200000 0x200000>;
> +        };
> +       };
>   };
>
>
>

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Raspberry Pi Barebox State Integration - SD card
  2019-06-05  4:26 ` Raspberry Pi Barebox State Integration - SD card Valentina Rusu
@ 2019-06-05  6:46   ` Moritz Augsburger
  0 siblings, 0 replies; 5+ messages in thread
From: Moritz Augsburger @ 2019-06-05  6:46 UTC (permalink / raw)
  To: Valentina Rusu; +Cc: barebox

Hi,

Am 2019-06-05 06:26, schrieb Valentina Rusu:
> Thank you for the response!
> 
> I had a quick look over this patch, I need to find a way to adapt it
> for RPi 3, as vmmc-supply , reg_3v3, vqmmc-supply, reg_1v8 are not
> configured for rpi 3 (they exist only for CM1 and CM3 as I have seen
> in the device tree sources).

I guess these are leftovers from sdhost<->sdhci switching, the important 
part is the partition definition inside sdhost.

Therefore, try leaving them out, as the upstream files already contain a 
valid &sdhost definitions.

Best regards
Moritz

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Raspberry Pi Barebox State Integration - SD card
  2019-06-04  6:32 Valentina Rusu
  2019-06-04  7:52 ` Tomaž Šolc
@ 2019-06-04  8:59 ` Moritz Augsburger
  1 sibling, 0 replies; 5+ messages in thread
From: Moritz Augsburger @ 2019-06-04  8:59 UTC (permalink / raw)
  To: barebox

Hi,

Am 2019-06-04 08:32, schrieb Valentina Rusu:
> The issue to integrate Barebox state are the following:
> * we need to specify a backend for the "state" node;
> * the backend should point to an of partition on a non-volatile memory;
> * other boards have EEPROM, NAND besides SD card and they are
> described in the device tree; RPi has no such thing;
> * somehow I need to write the state on the SD card in a location where
> does not interfere with the partitions created (boot, rootfs, user
> partitions, etc);
> * the SD card device (mci0) is automatically detected at startup, and
> not described in the device tree;

Below is a part of my patches, using the emmc on a Compute Module as 
state backend.
It uses the region between MBR and first partition (starting @4MB) to 
save the state.

The patch may contain changes already done to the latest version, so 
apply carefully.

diff --git a/arch/arm/dts/bcm2837-rpi-3.dts 
b/arch/arm/dts/bcm2837-rpi-3.dts
index 51883613c..420525b9e 100644
--- a/arch/arm/dts/bcm2837-rpi-3.dts
+++ b/arch/arm/dts/bcm2837-rpi-3.dts
@@ -11,10 +11,5 @@
  };

  &sdhci {
-	pinctrl-0 = <&emmc_gpio48>;
-	/delete-node/ wifi@1;
-};
-
-&sdhost {
  	status = "disabled";
  };
diff --git a/arch/arm/dts/bcm2837-rpi-cm3.dts 
b/arch/arm/dts/bcm2837-rpi-cm3.dts
index cfbffe175..d0144dcbc 100644
--- a/arch/arm/dts/bcm2837-rpi-cm3.dts
+++ b/arch/arm/dts/bcm2837-rpi-cm3.dts
@@ -8,11 +8,76 @@
  	memory {
  		reg = <0x0 0x0>;
  	};
+
+    state: state {
+        magic = <0x4d433230>;
+        compatible = "barebox,state";
+        backend-type = "raw";
+        backend = <&backend_state_sdhost>;
+        backend-storage-type = "circular";
+        backend-stridesize = <0x800>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        bootstate {
+            #address-cells = <1>;
+            #size-cells = <1>;
+            system0 {
+                #address-cells = <1>;
+                #size-cells = <1>;
+                remaining_attempts {
+                    reg = <0x0 0x4>;
+                    type = "uint32";
+                    default = <3>;
+                };
+                priority {
+                    reg = <0x4 0x4>;
+                    type = "uint32";
+                    default = <21>;
+                };
+            };
+
+            system1 {
+                #address-cells = <1>;
+                #size-cells = <1>;
+                remaining_attempts {
+                    reg = <0x10 0x4>;
+                    type = "uint32";
+                    default = <3>;
+                };
+                priority {
+                    reg = <0x14 0x4>;
+                    type = "uint32";
+                    default = <20>;
+                };
+            };
+            last_chosen {
+                reg = <0x2C 0x4>;
+                type = "uint32";
+            };
+        };
+    };
+
+    aliases {
+        state = &state;
+    };
+
  };

-&sdhci {
-	pinctrl-0 = <&emmc_gpio48>;
-	no-sd;
-	non-removable;
+&sdhost {
+	pinctrl-names = "default";
+	pinctrl-0 = <&sdhost_gpio48>;
+	bus-width = <4>;
+	vmmc-supply = <&reg_3v3>;
+	vqmmc-supply = <&reg_1v8>;
  	status = "okay";
+	partitions {
+		compatible = "fixed-partitions";
+		#size-cells = <1>;
+		#address-cells = <1>;
+        backend_state_sdhost: part@200000 {
+                label = "state_sdhost";
+                reg = <0x200000 0x200000>;
+        };
+	};
  };

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Raspberry Pi Barebox State Integration - SD card
  2019-06-04  6:32 Valentina Rusu
@ 2019-06-04  7:52 ` Tomaž Šolc
  2019-06-04  8:59 ` Moritz Augsburger
  1 sibling, 0 replies; 5+ messages in thread
From: Tomaž Šolc @ 2019-06-04  7:52 UTC (permalink / raw)
  To: barebox

Hi

On 4. 06. 19 08:32, Valentina Rusu wrote:
> * other boards have EEPROM, NAND besides SD card and they are 
> described in the device tree; RPi has no such thing;

> * somehow I need to write the state on the SD card in a location
> where does not interfere with the partitions created (boot, rootfs,
> user partitions, etc);

Barebox on Raspberry Pi automatically saves nv variables to the
"barebox.env" file in the first partition - see rpi_env_init() in 
rpi-common.c. This is usually the /boot partition with FAT that also has 
the VideoCore firmware files, etc.

I have a working bootchooser setup for a board based on R.Pi CM3 using 
this functionality. No special setup was required in barebox regard to 
saving the bootchooser state.

I'm not familiar with meta-barebox and RAUC though.

Best regards
Tomaž

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Raspberry Pi Barebox State Integration - SD card
@ 2019-06-04  6:32 Valentina Rusu
  2019-06-04  7:52 ` Tomaž Šolc
  2019-06-04  8:59 ` Moritz Augsburger
  0 siblings, 2 replies; 5+ messages in thread
From: Valentina Rusu @ 2019-06-04  6:32 UTC (permalink / raw)
  To: barebox

    Hello guys,

I want to integrate Barebox state for Raspberry Pi 3 in order to use
it along Barebox bootchooser and RAUC software update.
I have built my image using Yocto Pyro 2.3.2, barebox 2019.04.0 (added
a recipe in my meta layer, based on meta-barebox).
I have integrated Barebox bootchooser and tested it with some
hardcoded values for the target priority and remaining attempts. Works
fine.

The issue to integrate Barebox state are the following:
* we need to specify a backend for the "state" node;
* the backend should point to an of partition on a non-volatile memory;
* other boards have EEPROM, NAND besides SD card and they are
described in the device tree; RPi has no such thing;
* somehow I need to write the state on the SD card in a location where
does not interfere with the partitions created (boot, rootfs, user
partitions, etc);
* the SD card device (mci0) is automatically detected at startup, and
not described in the device tree;

I need to know how should I proceed? How should I describe that
"dynamic" device in my device tree, so I could point it in the
"backend" variable of the state node?

Thank you very much!

      Best regards,
       Vali.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-06-05  6:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.44637.1559659159.2376.barebox@lists.infradead.org>
2019-06-05  4:26 ` Raspberry Pi Barebox State Integration - SD card Valentina Rusu
2019-06-05  6:46   ` Moritz Augsburger
2019-06-04  6:32 Valentina Rusu
2019-06-04  7:52 ` Tomaž Šolc
2019-06-04  8:59 ` Moritz Augsburger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox