[3/4] sunxi: Add default partition scheme

Message ID f710719564118171463efe98fd4925f0739204ac.1511865262.git-series.maxime.ripard@free-electrons.com
State New
Headers show
Series
  • sunxi: Ease eMMC usage and flashing
Related show

Commit Message

Maxime Ripard Nov. 28, 2017, 10:34 a.m.
The partitions variable is especially useful to create a partition table
from U-Boot, either directly from the U-Boot shell, or through flashing
tools like fastboot and its oem format command.

This is especially useful on devices with an eMMC you can't take out to
flash from another system, and booting a Linux system first to flash our
system then is not really practical.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/configs/sunxi-common.h |  9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Andre Przywara Nov. 30, 2017, 12:23 a.m. | #1
Hi Maxime,

On 28/11/17 10:34, Maxime Ripard wrote:
> The partitions variable is especially useful to create a partition table
> from U-Boot, either directly from the U-Boot shell, or through flashing
> tools like fastboot and its oem format command.
> 
> This is especially useful on devices with an eMMC you can't take out to
> flash from another system, and booting a Linux system first to flash our
> system then is not really practical.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/configs/sunxi-common.h |  9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 4391a8cbc824..c9214a709221 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -493,6 +493,12 @@ extern int soft_i2c_gpio_scl;
>  #define SUNXI_MTDPARTS_DEFAULT
>  #endif
>  
> +#define PARTS_DEFAULT \
> +	"name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};" \
> +	"name=loader2,size=984k,uuid=${uuid_gpt_loader2};" \
> +	"name=esp,size=128M,bootable,uuid=${uuid_gpt_esp};" \

Those numbers look right to me, but I can't find the definition of
uuid_gpt_loader{1,2} in U-Boot. Only I see them referenced by some
rockchip header.
Is there some magic definition I missed or do we actually need to add them?
I guess you are after the Android-IA bootloader UUIDs from the Wikipedia
page, starting with 2568845D- and 114EAFFE-?

> +	"name=system,size=-,uuid=${uuid_gpt_system};"

So does fastboot require a system partition? And it wouldn't know where
to put the rootfs to without one?
In this case I guess it's fine, because it fits the use case.
But otherwise (as mentioned before) one giant partition to fill the rest
of the "disk" is more annoying than helpful for regular Linux installers.

> +
>  #define CONSOLE_ENV_SETTINGS \
>  	CONSOLE_STDIN_SETTINGS \
>  	CONSOLE_STDOUT_SETTINGS
> @@ -511,6 +517,9 @@ extern int soft_i2c_gpio_scl;
>  	"console=ttyS0,115200\0" \
>  	SUNXI_MTDIDS_DEFAULT \
>  	SUNXI_MTDPARTS_DEFAULT \
> +	"uuid_gpt_esp=C12A7328-F81F-11D2-BA4B-00A0C93EC93B\0" \
> +	"uuid_gpt_system=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0" \

The ESP GUID is correct, the other is "Linux filesystem data", right?
Technically I guess root partition would be more suitable, but we would
need to know whether it's AArch64 or ARM, if I get this correctly.
Shall we use #ifdef CONFIG_ARM64 here?

Cheers,
Andre.

> +	"partitions=" PARTS_DEFAULT "\0" \
>  	BOOTCMD_SUNXI_COMPAT \
>  	BOOTENV
>  
>
Maxime Ripard Nov. 30, 2017, 7:56 a.m. | #2
Hi,

On Thu, Nov 30, 2017 at 12:23:06AM +0000, André Przywara wrote:
> Hi Maxime,

> 

> On 28/11/17 10:34, Maxime Ripard wrote:

> > The partitions variable is especially useful to create a partition table

> > from U-Boot, either directly from the U-Boot shell, or through flashing

> > tools like fastboot and its oem format command.

> > 

> > This is especially useful on devices with an eMMC you can't take out to

> > flash from another system, and booting a Linux system first to flash our

> > system then is not really practical.

> > 

> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

> > ---

> >  include/configs/sunxi-common.h |  9 +++++++++

> >  1 file changed, 9 insertions(+)

> > 

> > diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h

> > index 4391a8cbc824..c9214a709221 100644

> > --- a/include/configs/sunxi-common.h

> > +++ b/include/configs/sunxi-common.h

> > @@ -493,6 +493,12 @@ extern int soft_i2c_gpio_scl;

> >  #define SUNXI_MTDPARTS_DEFAULT

> >  #endif

> >  

> > +#define PARTS_DEFAULT \

> > +	"name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};" \

> > +	"name=loader2,size=984k,uuid=${uuid_gpt_loader2};" \

> > +	"name=esp,size=128M,bootable,uuid=${uuid_gpt_esp};" \

> 

> Those numbers look right to me, but I can't find the definition of

> uuid_gpt_loader{1,2} in U-Boot. Only I see them referenced by some

> rockchip header.

> Is there some magic definition I missed or do we actually need to add them?

> I guess you are after the Android-IA bootloader UUIDs from the Wikipedia

> page, starting with 2568845D- and 114EAFFE-?


The fact that they have been left out is intentional. Without a UUID
defined, U-Boot will generate a random one if you have
CONFIG_RANDOM_UUID set. That kind of construct allow you to specifiy a
UUID if you want, without modifying the partitions variable.

I'm totally fine with having a default one though. I just couldn't
find one that would be relevant, so I left it out.

> > +	"name=system,size=-,uuid=${uuid_gpt_system};"

> 

> So does fastboot require a system partition? And it wouldn't know where

> to put the rootfs to without one?

> In this case I guess it's fine, because it fits the use case.

> But otherwise (as mentioned before) one giant partition to fill the rest

> of the "disk" is more annoying than helpful for regular Linux installers.


So fasboot is dumber than you assume it to be ;)

The only thing you do is giving it a file and a partition. So yeah,
you would need to have a partition defined for that.

> > +

> >  #define CONSOLE_ENV_SETTINGS \

> >  	CONSOLE_STDIN_SETTINGS \

> >  	CONSOLE_STDOUT_SETTINGS

> > @@ -511,6 +517,9 @@ extern int soft_i2c_gpio_scl;

> >  	"console=ttyS0,115200\0" \

> >  	SUNXI_MTDIDS_DEFAULT \

> >  	SUNXI_MTDPARTS_DEFAULT \

> > +	"uuid_gpt_esp=C12A7328-F81F-11D2-BA4B-00A0C93EC93B\0" \

> > +	"uuid_gpt_system=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0" \

> 

> The ESP GUID is correct, the other is "Linux filesystem data", right?

> Technically I guess root partition would be more suitable, but we would

> need to know whether it's AArch64 or ARM, if I get this correctly.

> Shall we use #ifdef CONFIG_ARM64 here?


We can, what UUID do you have in mind?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Andre Przywara Nov. 30, 2017, 9:22 a.m. | #3
Hi,

On 30/11/17 07:56, Maxime Ripard wrote:
> Hi,
> 
> On Thu, Nov 30, 2017 at 12:23:06AM +0000, André Przywara wrote:
>> Hi Maxime,
>>
>> On 28/11/17 10:34, Maxime Ripard wrote:
>>> The partitions variable is especially useful to create a partition table
>>> from U-Boot, either directly from the U-Boot shell, or through flashing
>>> tools like fastboot and its oem format command.
>>>
>>> This is especially useful on devices with an eMMC you can't take out to
>>> flash from another system, and booting a Linux system first to flash our
>>> system then is not really practical.
>>>
>>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>>> ---
>>>  include/configs/sunxi-common.h |  9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
>>> index 4391a8cbc824..c9214a709221 100644
>>> --- a/include/configs/sunxi-common.h
>>> +++ b/include/configs/sunxi-common.h
>>> @@ -493,6 +493,12 @@ extern int soft_i2c_gpio_scl;
>>>  #define SUNXI_MTDPARTS_DEFAULT
>>>  #endif
>>>  
>>> +#define PARTS_DEFAULT \
>>> +	"name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};" \
>>> +	"name=loader2,size=984k,uuid=${uuid_gpt_loader2};" \
>>> +	"name=esp,size=128M,bootable,uuid=${uuid_gpt_esp};" \
>>
>> Those numbers look right to me, but I can't find the definition of
>> uuid_gpt_loader{1,2} in U-Boot. Only I see them referenced by some
>> rockchip header.
>> Is there some magic definition I missed or do we actually need to add them?
>> I guess you are after the Android-IA bootloader UUIDs from the Wikipedia
>> page, starting with 2568845D- and 114EAFFE-?
> 
> The fact that they have been left out is intentional. Without a UUID
> defined, U-Boot will generate a random one if you have
> CONFIG_RANDOM_UUID set. That kind of construct allow you to specifiy a
> UUID if you want, without modifying the partitions variable.

Ah, thanks for the explanation, I was afraid I missed something.

> I'm totally fine with having a default one though. I just couldn't
> find one that would be relevant, so I left it out.

I guess this is fine. Wikipedia[1] points me to Android-IA having
specified two UUIDs for boot loader partitions here [2], but I don't
think they are really authoritative.

>>> +	"name=system,size=-,uuid=${uuid_gpt_system};"
>>
>> So does fastboot require a system partition? And it wouldn't know where
>> to put the rootfs to without one?
>> In this case I guess it's fine, because it fits the use case.
>> But otherwise (as mentioned before) one giant partition to fill the rest
>> of the "disk" is more annoying than helpful for regular Linux installers.
> 
> So fasboot is dumber than you assume it to be ;)
> 
> The only thing you do is giving it a file and a partition. So yeah,
> you would need to have a partition defined for that.
> 
>>> +
>>>  #define CONSOLE_ENV_SETTINGS \
>>>  	CONSOLE_STDIN_SETTINGS \
>>>  	CONSOLE_STDOUT_SETTINGS
>>> @@ -511,6 +517,9 @@ extern int soft_i2c_gpio_scl;
>>>  	"console=ttyS0,115200\0" \
>>>  	SUNXI_MTDIDS_DEFAULT \
>>>  	SUNXI_MTDPARTS_DEFAULT \
>>> +	"uuid_gpt_esp=C12A7328-F81F-11D2-BA4B-00A0C93EC93B\0" \
>>> +	"uuid_gpt_system=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0" \
>>
>> The ESP GUID is correct, the other is "Linux filesystem data", right?
>> Technically I guess root partition would be more suitable, but we would
>> need to know whether it's AArch64 or ARM, if I get this correctly.
>> Shall we use #ifdef CONFIG_ARM64 here?
> 
> We can, what UUID do you have in mind?

FreeDesktop [3] seems to define some UUIDs for Linux root partitions,
separated by architectures, and it lists ARM and AArch64.

Cheers,
Andre.

[1] https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
[2]
https://github.com/android-ia/device-androidia-mixins/blob/master/groups/boot-arch/android_ia/gpt.ini
[3]
https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
Maxime Ripard Nov. 30, 2017, 3:49 p.m. | #4
On Thu, Nov 30, 2017 at 09:22:07AM +0000, Andre Przywara wrote:
> Hi,

> 

> On 30/11/17 07:56, Maxime Ripard wrote:

> > Hi,

> > 

> > On Thu, Nov 30, 2017 at 12:23:06AM +0000, André Przywara wrote:

> >> Hi Maxime,

> >>

> >> On 28/11/17 10:34, Maxime Ripard wrote:

> >>> The partitions variable is especially useful to create a partition table

> >>> from U-Boot, either directly from the U-Boot shell, or through flashing

> >>> tools like fastboot and its oem format command.

> >>>

> >>> This is especially useful on devices with an eMMC you can't take out to

> >>> flash from another system, and booting a Linux system first to flash our

> >>> system then is not really practical.

> >>>

> >>> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

> >>> ---

> >>>  include/configs/sunxi-common.h |  9 +++++++++

> >>>  1 file changed, 9 insertions(+)

> >>>

> >>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h

> >>> index 4391a8cbc824..c9214a709221 100644

> >>> --- a/include/configs/sunxi-common.h

> >>> +++ b/include/configs/sunxi-common.h

> >>> @@ -493,6 +493,12 @@ extern int soft_i2c_gpio_scl;

> >>>  #define SUNXI_MTDPARTS_DEFAULT

> >>>  #endif

> >>>  

> >>> +#define PARTS_DEFAULT \

> >>> +	"name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};" \

> >>> +	"name=loader2,size=984k,uuid=${uuid_gpt_loader2};" \

> >>> +	"name=esp,size=128M,bootable,uuid=${uuid_gpt_esp};" \

> >>

> >> Those numbers look right to me, but I can't find the definition of

> >> uuid_gpt_loader{1,2} in U-Boot. Only I see them referenced by some

> >> rockchip header.

> >> Is there some magic definition I missed or do we actually need to add them?

> >> I guess you are after the Android-IA bootloader UUIDs from the Wikipedia

> >> page, starting with 2568845D- and 114EAFFE-?

> > 

> > The fact that they have been left out is intentional. Without a UUID

> > defined, U-Boot will generate a random one if you have

> > CONFIG_RANDOM_UUID set. That kind of construct allow you to specifiy a

> > UUID if you want, without modifying the partitions variable.

> 

> Ah, thanks for the explanation, I was afraid I missed something.

> 

> > I'm totally fine with having a default one though. I just couldn't

> > find one that would be relevant, so I left it out.

> 

> I guess this is fine. Wikipedia[1] points me to Android-IA having

> specified two UUIDs for boot loader partitions here [2], but I don't

> think they are really authoritative.


Yeah, I saw those as well, and came to the same conclusion :)

> >>> +	"name=system,size=-,uuid=${uuid_gpt_system};"

> >>

> >> So does fastboot require a system partition? And it wouldn't know where

> >> to put the rootfs to without one?

> >> In this case I guess it's fine, because it fits the use case.

> >> But otherwise (as mentioned before) one giant partition to fill the rest

> >> of the "disk" is more annoying than helpful for regular Linux installers.

> > 

> > So fasboot is dumber than you assume it to be ;)

> > 

> > The only thing you do is giving it a file and a partition. So yeah,

> > you would need to have a partition defined for that.

> > 

> >>> +

> >>>  #define CONSOLE_ENV_SETTINGS \

> >>>  	CONSOLE_STDIN_SETTINGS \

> >>>  	CONSOLE_STDOUT_SETTINGS

> >>> @@ -511,6 +517,9 @@ extern int soft_i2c_gpio_scl;

> >>>  	"console=ttyS0,115200\0" \

> >>>  	SUNXI_MTDIDS_DEFAULT \

> >>>  	SUNXI_MTDPARTS_DEFAULT \

> >>> +	"uuid_gpt_esp=C12A7328-F81F-11D2-BA4B-00A0C93EC93B\0" \

> >>> +	"uuid_gpt_system=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0" \

> >>

> >> The ESP GUID is correct, the other is "Linux filesystem data", right?

> >> Technically I guess root partition would be more suitable, but we would

> >> need to know whether it's AArch64 or ARM, if I get this correctly.

> >> Shall we use #ifdef CONFIG_ARM64 here?

> > 

> > We can, what UUID do you have in mind?

> 

> FreeDesktop [3] seems to define some UUIDs for Linux root partitions,

> separated by architectures, and it lists ARM and AArch64.


Ok, I'll use them then.

Thanks!
maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

Patch

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 4391a8cbc824..c9214a709221 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -493,6 +493,12 @@  extern int soft_i2c_gpio_scl;
 #define SUNXI_MTDPARTS_DEFAULT
 #endif
 
+#define PARTS_DEFAULT \
+	"name=loader1,start=8k,size=32k,uuid=${uuid_gpt_loader1};" \
+	"name=loader2,size=984k,uuid=${uuid_gpt_loader2};" \
+	"name=esp,size=128M,bootable,uuid=${uuid_gpt_esp};" \
+	"name=system,size=-,uuid=${uuid_gpt_system};"
+
 #define CONSOLE_ENV_SETTINGS \
 	CONSOLE_STDIN_SETTINGS \
 	CONSOLE_STDOUT_SETTINGS
@@ -511,6 +517,9 @@  extern int soft_i2c_gpio_scl;
 	"console=ttyS0,115200\0" \
 	SUNXI_MTDIDS_DEFAULT \
 	SUNXI_MTDPARTS_DEFAULT \
+	"uuid_gpt_esp=C12A7328-F81F-11D2-BA4B-00A0C93EC93B\0" \
+	"uuid_gpt_system=0FC63DAF-8483-4772-8E79-3D69D8477DE4\0" \
+	"partitions=" PARTS_DEFAULT "\0" \
 	BOOTCMD_SUNXI_COMPAT \
 	BOOTENV