diff mbox series

[3/4] sunxi: Add default partition scheme

Message ID 20171115101151.11382-4-maxime.ripard@free-electrons.com
State Superseded
Headers show
Series sunxi: Ease eMMC usage and flashing | expand

Commit Message

Maxime Ripard Nov. 15, 2017, 10:11 a.m. UTC
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 | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Alexander Graf Nov. 15, 2017, 9:03 p.m. UTC | #1
On 15.11.17 11:11, 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 | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 4391a8cbc824..11da6ccfbf54 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;" \
> +	"name=loader2,size=984k;" \
> +	"name=boot,size=128M,bootable;" \
> +	"name=system,size=-;"

Is there a particular reason you're creating a boot and system
partition? In a normal distro world, the distro installer will take care
of creating ESP + root + swap + whatever for you - and they (or the user
driving the installation) usually know best what they need :)


Alex
Maxime Ripard Nov. 16, 2017, 9:29 a.m. UTC | #2
Hi Alexander,

On Wed, Nov 15, 2017 at 10:03:32PM +0100, Alexander Graf wrote:
> On 15.11.17 11:11, 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 | 7 +++++++

> >  1 file changed, 7 insertions(+)

> > 

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

> > index 4391a8cbc824..11da6ccfbf54 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;" \

> > +	"name=loader2,size=984k;" \

> > +	"name=boot,size=128M,bootable;" \

> > +	"name=system,size=-;"

> 

> Is there a particular reason you're creating a boot and system

> partition? In a normal distro world, the distro installer will take care

> of creating ESP + root + swap + whatever for you - and they (or the user

> driving the installation) usually know best what they need :)


Right, so let me explain my thought process here :)

We really want a main partition for the system for people that will
not use any distro installer (either because they generated their
image by hand before using something like debootstrap or ELBE) or
because they're using a build system that will generate the system
image directly, without any alternative process.

Then, the boot partition is the one I'm not really sure about. As you
know, we will transition to an FAT-based environment in the future, so
we need to have partition to hold it on all systems, and it can't be
the system one since, well, FAT.

I also was under the impression that it would benefit you in some way
to store the EFI data, and it's actually what I'd really like input
on. I have basically no idea what are your requirements or what would
be a good size.

The only real constraints we have is that it needs to be at least able
to store 128kB for the environment. If we want to align it properly,
that would be 1MB. Then, if you're telling me you don't need anything
else, then that's fine by me :)

Maxime

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

On 15/11/17 21:03, Alexander Graf wrote:
> 
> 
> On 15.11.17 11:11, 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 | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
>> index 4391a8cbc824..11da6ccfbf54 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;" \
>> +	"name=loader2,size=984k;" \
>> +	"name=boot,size=128M,bootable;" \
>> +	"name=system,size=-;"
> 
> Is there a particular reason you're creating a boot and system
> partition? In a normal distro world, the distro installer will take care
> of creating ESP + root + swap + whatever for you - and they (or the user
> driving the installation) usually know best what they need :)

But do we actually care about this? If I understand this correctly,
these are default settings for U-Boot's "mtdparts default" command,
which honestly I didn't even know existed so far.
So in a distribution scenario I wouldn't expect somebody to actually use
this. Instead you boot from a (possibly unpartitioned) SD card with just
U-Boot on it or from SPI flash, then launch an installer from somewhere
(PXE, USB drive) and let it do its job. No U-Boot partition involved.
And even if you use mtdpart, you can always override these default
settings on the command line.

Does mtdparts even use partition tables (MBR/GPT)? mtd sounds quite
Android-y/embedded to me (passing partition information via command line).

So apart from that I think it's good to have a default FAT/ESP
partition, also for storing the environment.

It's debatable whether we need a system partition defined at this stage.
Can't this just left be unpartitioned, to be actually populated later?
In a MBR/GPT scenario I would expect a big partition covering the whole
device causes headache later on.

Cheers,
Andre.
Maxime Ripard Nov. 16, 2017, 11:21 a.m. UTC | #4
On Thu, Nov 16, 2017 at 10:30:38AM +0000, Andre Przywara wrote:
> Hi,

> 

> On 15/11/17 21:03, Alexander Graf wrote:

> > 

> > 

> > On 15.11.17 11:11, 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 | 7 +++++++

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

> >>

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

> >> index 4391a8cbc824..11da6ccfbf54 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;" \

> >> +	"name=loader2,size=984k;" \

> >> +	"name=boot,size=128M,bootable;" \

> >> +	"name=system,size=-;"

> > 

> > Is there a particular reason you're creating a boot and system

> > partition? In a normal distro world, the distro installer will take care

> > of creating ESP + root + swap + whatever for you - and they (or the user

> > driving the installation) usually know best what they need :)

> 

> But do we actually care about this?


I do.

> If I understand this correctly, these are default settings for

> U-Boot's "mtdparts default" command, which honestly I didn't even

> know existed so far.


No, this has nothing to do with MTD. It's a default GPT partitioning
scheme. And only when you want to create the table from U-Boot, it
will not mangle with any pre-existing partition table if there is any
(unless you tell U-Boot to overwrite it, of course).

> So in a distribution scenario I wouldn't expect somebody to actually use

> this. Instead you boot from a (possibly unpartitioned) SD card with just

> U-Boot on it or from SPI flash, then launch an installer from somewhere

> (PXE, USB drive) and let it do its job. No U-Boot partition involved.

> And even if you use mtdpart, you can always override these default

> settings on the command line.


Like I was telling Alexander, that makes a number of assumptions, the
two most obvious one being that you have an installer and that you
want to use it, both with reasonable reasons on why they wouldn't be
true.

More tailored fit distros like ELBE, yocto or Buildroot will not have
an installer in the first place but an image.

And even if you have an installer for the distro you want to use, if
you ever go to production, you will not use it since the time spent to
flash a pre-filled image compared to running the installer is
significantly lower. And time is money :)

Just like plugging / unplugging microSD card isn't really realistic in
that scenario.

> Does mtdparts even use partition tables (MBR/GPT)? mtd sounds quite

> Android-y/embedded to me (passing partition information via command line).

> 

> So apart from that I think it's good to have a default FAT/ESP

> partition, also for storing the environment.


What is the typical size of the files you usually put in there? My
actual question being is 128MB enough, way too big or too small? The
environment is just 128kB big at the moment, so it looks wayyyyy to
big for me, but I have no idea what is usually stored in an ESP
partition.

> It's debatable whether we need a system partition defined at this stage.

> Can't this just left be unpartitioned, to be actually populated later?


This would break the cases I talked about earlier.

> In a MBR/GPT scenario I would expect a big partition covering the whole

> device causes headache later on.


What kind of headaches?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Andre Przywara Nov. 16, 2017, 11:41 a.m. UTC | #5
Hi,

On 16/11/17 11:21, Maxime Ripard wrote:
> On Thu, Nov 16, 2017 at 10:30:38AM +0000, Andre Przywara wrote:
>> Hi,
>>
>> On 15/11/17 21:03, Alexander Graf wrote:
>>>
>>>
>>> On 15.11.17 11:11, 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 | 7 +++++++
>>>>  1 file changed, 7 insertions(+)
>>>>
>>>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
>>>> index 4391a8cbc824..11da6ccfbf54 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;" \
>>>> +	"name=loader2,size=984k;" \
>>>> +	"name=boot,size=128M,bootable;" \
>>>> +	"name=system,size=-;"
>>>
>>> Is there a particular reason you're creating a boot and system
>>> partition? In a normal distro world, the distro installer will take care
>>> of creating ESP + root + swap + whatever for you - and they (or the user
>>> driving the installation) usually know best what they need :)
>>
>> But do we actually care about this?
> 
> I do.

I know, this was a misunderstanding, sorry. By "we" I meant Alex and
Karsten's generic distribution point of view. I was arguing that this
patch is of no big importance for them.

I think we agree that there are quite different use cases, and I don't
fight the usefulness of both.

>> If I understand this correctly, these are default settings for
>> U-Boot's "mtdparts default" command, which honestly I didn't even
>> know existed so far.
> 
> No, this has nothing to do with MTD. It's a default GPT partitioning
> scheme. And only when you want to create the table from U-Boot, it
> will not mangle with any pre-existing partition table if there is any
> (unless you tell U-Boot to overwrite it, of course).

This is what I tried to say: It only affects you if you use U-Boot's
partitioning command, which you probably won't do if you are running an
off-the-shelf distribution installer. Is that understanding correct?

>> So in a distribution scenario I wouldn't expect somebody to actually use
>> this. Instead you boot from a (possibly unpartitioned) SD card with just
>> U-Boot on it or from SPI flash, then launch an installer from somewhere
>> (PXE, USB drive) and let it do its job. No U-Boot partition involved.
>> And even if you use mtdpart, you can always override these default
>> settings on the command line.
> 
> Like I was telling Alexander, that makes a number of assumptions, the
> two most obvious one being that you have an installer and that you
> want to use it, both with reasonable reasons on why they wouldn't be
> true.
> 
> More tailored fit distros like ELBE, yocto or Buildroot will not have
> an installer in the first place but an image.
> 
> And even if you have an installer for the distro you want to use, if
> you ever go to production, you will not use it since the time spent to
> flash a pre-filled image compared to running the installer is
> significantly lower. And time is money :)
> 
> Just like plugging / unplugging microSD card isn't really realistic in
> that scenario.

I don't argue this (see above) and surely understand that generic
installers don't fly when it comes to bootstrapping devices.

But my understanding is that both Alex and Karsten don't really care
about this usage scenario, but instead are more looking into generic
distribution installers, which use U-Boot merely to launch grub.

Actually I wanted to help you out here by pointing out that their
concerns don't really apply to this patch ;-)

>> Does mtdparts even use partition tables (MBR/GPT)? mtd sounds quite
>> Android-y/embedded to me (passing partition information via command line).
>>
>> So apart from that I think it's good to have a default FAT/ESP
>> partition, also for storing the environment.
> 
> What is the typical size of the files you usually put in there? My
> actual question being is 128MB enough, way too big or too small? The
> environment is just 128kB big at the moment, so it looks wayyyyy to
> big for me, but I have no idea what is usually stored in an ESP
> partition.

128MB is actually quite fine. I tend to use 150MB or 100MB. The Ubuntu
arm64 kernel is around 20MB, and you may want to store more than one of
those on the ESP, along with an initrd. I understand that distributions
may not use the ESP for that, but their own /boot partition. But this is
their choice. Also other OSes (BSDs?) want to use the ESP, so being too
miserly here may backfire.

Do you feel that's too big? We are talking about at least 8GB eMMCs
mostly here, right?

>> It's debatable whether we need a system partition defined at this stage.
>> Can't this just left be unpartitioned, to be actually populated later?
> 
> This would break the cases I talked about earlier.

Fair enough.

>> In a MBR/GPT scenario I would expect a big partition covering the whole
>> device causes headache later on.
> 
> What kind of headaches?

Just thinking if an installer wants to add partitions (swap, /home, ...)
it might be easier if some space is actually left unpartitioned.
But that's just my non-embedded experience, where adding partitions is
easier and safer, compared to deleting or resizing an existing partition.

Cheers,
Andre.
Alexander Graf Nov. 16, 2017, 11:54 a.m. UTC | #6
On 11/16/2017 12:41 PM, Andre Przywara wrote:
> Hi,
>
> On 16/11/17 11:21, Maxime Ripard wrote:
>> On Thu, Nov 16, 2017 at 10:30:38AM +0000, Andre Przywara wrote:
>>> Hi,
>>>
>>> On 15/11/17 21:03, Alexander Graf wrote:
>>>>
>>>> On 15.11.17 11:11, 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 | 7 +++++++
>>>>>   1 file changed, 7 insertions(+)
>>>>>
>>>>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
>>>>> index 4391a8cbc824..11da6ccfbf54 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;" \
>>>>> +	"name=loader2,size=984k;" \
>>>>> +	"name=boot,size=128M,bootable;" \
>>>>> +	"name=system,size=-;"
>>>> Is there a particular reason you're creating a boot and system
>>>> partition? In a normal distro world, the distro installer will take care
>>>> of creating ESP + root + swap + whatever for you - and they (or the user
>>>> driving the installation) usually know best what they need :)
>>> But do we actually care about this?
>> I do.
> I know, this was a misunderstanding, sorry. By "we" I meant Alex and
> Karsten's generic distribution point of view. I was arguing that this
> patch is of no big importance for them.
>
> I think we agree that there are quite different use cases, and I don't
> fight the usefulness of both.
>
>>> If I understand this correctly, these are default settings for
>>> U-Boot's "mtdparts default" command, which honestly I didn't even
>>> know existed so far.
>> No, this has nothing to do with MTD. It's a default GPT partitioning
>> scheme. And only when you want to create the table from U-Boot, it
>> will not mangle with any pre-existing partition table if there is any
>> (unless you tell U-Boot to overwrite it, of course).
> This is what I tried to say: It only affects you if you use U-Boot's
> partitioning command, which you probably won't do if you are running an
> off-the-shelf distribution installer. Is that understanding correct?

I'm not sure what the envisioned use of this is either. In general, it 
makes sense to keep the env on a partition and to mark the firmware 
residing on eMMC as off limits to an OS installer. So some sort of 
partitioning scheme is very useful and good to have.

>
>>> So in a distribution scenario I wouldn't expect somebody to actually use
>>> this. Instead you boot from a (possibly unpartitioned) SD card with just
>>> U-Boot on it or from SPI flash, then launch an installer from somewhere
>>> (PXE, USB drive) and let it do its job. No U-Boot partition involved.
>>> And even if you use mtdpart, you can always override these default
>>> settings on the command line.
>> Like I was telling Alexander, that makes a number of assumptions, the
>> two most obvious one being that you have an installer and that you
>> want to use it, both with reasonable reasons on why they wouldn't be
>> true.
>>
>> More tailored fit distros like ELBE, yocto or Buildroot will not have
>> an installer in the first place but an image.
>>
>> And even if you have an installer for the distro you want to use, if
>> you ever go to production, you will not use it since the time spent to
>> flash a pre-filled image compared to running the installer is
>> significantly lower. And time is money :)
>>
>> Just like plugging / unplugging microSD card isn't really realistic in
>> that scenario.
> I don't argue this (see above) and surely understand that generic
> installers don't fly when it comes to bootstrapping devices.
>
> But my understanding is that both Alex and Karsten don't really care
> about this usage scenario, but instead are more looking into generic
> distribution installers, which use U-Boot merely to launch grub.
>
> Actually I wanted to help you out here by pointing out that their
> concerns don't really apply to this patch ;-)
>
>>> Does mtdparts even use partition tables (MBR/GPT)? mtd sounds quite
>>> Android-y/embedded to me (passing partition information via command line).
>>>
>>> So apart from that I think it's good to have a default FAT/ESP
>>> partition, also for storing the environment.
>> What is the typical size of the files you usually put in there? My
>> actual question being is 128MB enough, way too big or too small? The
>> environment is just 128kB big at the moment, so it looks wayyyyy to
>> big for me, but I have no idea what is usually stored in an ESP
>> partition.
> 128MB is actually quite fine. I tend to use 150MB or 100MB. The Ubuntu
> arm64 kernel is around 20MB, and you may want to store more than one of
> those on the ESP, along with an initrd. I understand that distributions
> may not use the ESP for that, but their own /boot partition. But this is
> their choice. Also other OSes (BSDs?) want to use the ESP, so being too
> miserly here may backfire.

Right, in our case ~16MB would be enough, because we only store grub on 
the ESP. But there are other boot loaders out there like systemd-boot 
which put the kernel images and initrds onto the ESP.

>
> Do you feel that's too big? We are talking about at least 8GB eMMCs
> mostly here, right?
>
>>> It's debatable whether we need a system partition defined at this stage.
>>> Can't this just left be unpartitioned, to be actually populated later?
>> This would break the cases I talked about earlier.
> Fair enough.

The reason I'm not fully comfortable with prepopulated system partitions 
is mostly because I'm not sure all installers will deal with them 
properly. Some might decide you're better off resizing a system 
partition rather than removing it - and if there's nothing useful inside 
that may be the wrong choice.

But that's nothing earth shattering. If you do need a system partition 
to have other installers work well, that's ok too I guess.

>
>>> In a MBR/GPT scenario I would expect a big partition covering the whole
>>> device causes headache later on.
>> What kind of headaches?
> Just thinking if an installer wants to add partitions (swap, /home, ...)
> it might be easier if some space is actually left unpartitioned.
> But that's just my non-embedded experience, where adding partitions is
> easier and safer, compared to deleting or resizing an existing partition.

Yup, exactly that :)


Alex
Emmanuel Vadot Nov. 16, 2017, 12:32 p.m. UTC | #7
On Thu, 16 Nov 2017 12:54:13 +0100
Alexander Graf <agraf@suse.de> wrote:

> On 11/16/2017 12:41 PM, Andre Przywara wrote:
> > Hi,
> >
> > On 16/11/17 11:21, Maxime Ripard wrote:
> >> On Thu, Nov 16, 2017 at 10:30:38AM +0000, Andre Przywara wrote:
> >>> Hi,
> >>>
> >>> On 15/11/17 21:03, Alexander Graf wrote:
> >>>>
> >>>> On 15.11.17 11:11, 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 | 7 +++++++
> >>>>>   1 file changed, 7 insertions(+)
> >>>>>
> >>>>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> >>>>> index 4391a8cbc824..11da6ccfbf54 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;" \
> >>>>> +	"name=loader2,size=984k;" \
> >>>>> +	"name=boot,size=128M,bootable;" \
> >>>>> +	"name=system,size=-;"
> >>>> Is there a particular reason you're creating a boot and system
> >>>> partition? In a normal distro world, the distro installer will take care
> >>>> of creating ESP + root + swap + whatever for you - and they (or the user
> >>>> driving the installation) usually know best what they need :)
> >>> But do we actually care about this?
> >> I do.
> > I know, this was a misunderstanding, sorry. By "we" I meant Alex and
> > Karsten's generic distribution point of view. I was arguing that this
> > patch is of no big importance for them.
> >
> > I think we agree that there are quite different use cases, and I don't
> > fight the usefulness of both.
> >
> >>> If I understand this correctly, these are default settings for
> >>> U-Boot's "mtdparts default" command, which honestly I didn't even
> >>> know existed so far.
> >> No, this has nothing to do with MTD. It's a default GPT partitioning
> >> scheme. And only when you want to create the table from U-Boot, it
> >> will not mangle with any pre-existing partition table if there is any
> >> (unless you tell U-Boot to overwrite it, of course).
> > This is what I tried to say: It only affects you if you use U-Boot's
> > partitioning command, which you probably won't do if you are running an
> > off-the-shelf distribution installer. Is that understanding correct?
> 
> I'm not sure what the envisioned use of this is either. In general, it 
> makes sense to keep the env on a partition and to mark the firmware 
> residing on eMMC as off limits to an OS installer. So some sort of 
> partitioning scheme is very useful and good to have.
> 
> >
> >>> So in a distribution scenario I wouldn't expect somebody to actually use
> >>> this. Instead you boot from a (possibly unpartitioned) SD card with just
> >>> U-Boot on it or from SPI flash, then launch an installer from somewhere
> >>> (PXE, USB drive) and let it do its job. No U-Boot partition involved.
> >>> And even if you use mtdpart, you can always override these default
> >>> settings on the command line.
> >> Like I was telling Alexander, that makes a number of assumptions, the
> >> two most obvious one being that you have an installer and that you
> >> want to use it, both with reasonable reasons on why they wouldn't be
> >> true.
> >>
> >> More tailored fit distros like ELBE, yocto or Buildroot will not have
> >> an installer in the first place but an image.
> >>
> >> And even if you have an installer for the distro you want to use, if
> >> you ever go to production, you will not use it since the time spent to
> >> flash a pre-filled image compared to running the installer is
> >> significantly lower. And time is money :)
> >>
> >> Just like plugging / unplugging microSD card isn't really realistic in
> >> that scenario.
> > I don't argue this (see above) and surely understand that generic
> > installers don't fly when it comes to bootstrapping devices.
> >
> > But my understanding is that both Alex and Karsten don't really care
> > about this usage scenario, but instead are more looking into generic
> > distribution installers, which use U-Boot merely to launch grub.
> >
> > Actually I wanted to help you out here by pointing out that their
> > concerns don't really apply to this patch ;-)
> >
> >>> Does mtdparts even use partition tables (MBR/GPT)? mtd sounds quite
> >>> Android-y/embedded to me (passing partition information via command line).
> >>>
> >>> So apart from that I think it's good to have a default FAT/ESP
> >>> partition, also for storing the environment.
> >> What is the typical size of the files you usually put in there? My
> >> actual question being is 128MB enough, way too big or too small? The
> >> environment is just 128kB big at the moment, so it looks wayyyyy to
> >> big for me, but I have no idea what is usually stored in an ESP
> >> partition.
> > 128MB is actually quite fine. I tend to use 150MB or 100MB. The Ubuntu
> > arm64 kernel is around 20MB, and you may want to store more than one of
> > those on the ESP, along with an initrd. I understand that distributions
> > may not use the ESP for that, but their own /boot partition. But this is
> > their choice. Also other OSes (BSDs?) want to use the ESP, so being too
> > miserly here may backfire.
> 
> Right, in our case ~16MB would be enough, because we only store grub on 
> the ESP. But there are other boot loaders out there like systemd-boot 
> which put the kernel images and initrds onto the ESP.

 ~16MB would be enough for FreeBSD too, in a EFI environment we only
store our loader and the DTB, the kernel itself sits in the root
filesystem.

> >
> > Do you feel that's too big? We are talking about at least 8GB eMMCs
> > mostly here, right?
> >
> >>> It's debatable whether we need a system partition defined at this stage.
> >>> Can't this just left be unpartitioned, to be actually populated later?
> >> This would break the cases I talked about earlier.
> > Fair enough.
> 
> The reason I'm not fully comfortable with prepopulated system partitions 
> is mostly because I'm not sure all installers will deal with them 
> properly. Some might decide you're better off resizing a system 
> partition rather than removing it - and if there's nothing useful inside 
> that may be the wrong choice.
> 
> But that's nothing earth shattering. If you do need a system partition 
> to have other installers work well, that's ok too I guess.
> 
> >
> >>> In a MBR/GPT scenario I would expect a big partition covering the whole
> >>> device causes headache later on.
> >> What kind of headaches?
> > Just thinking if an installer wants to add partitions (swap, /home, ...)
> > it might be easier if some space is actually left unpartitioned.
> > But that's just my non-embedded experience, where adding partitions is
> > easier and safer, compared to deleting or resizing an existing partition.
> 
> Yup, exactly that :)
> 
> 
> Alex
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Tom Rini Nov. 16, 2017, 5:30 p.m. UTC | #8
On Thu, Nov 16, 2017 at 11:41:57AM +0000, Andre Przywara wrote:
> Hi,

> 

> On 16/11/17 11:21, Maxime Ripard wrote:

> > On Thu, Nov 16, 2017 at 10:30:38AM +0000, Andre Przywara wrote:

> >> Hi,

> >>

> >> On 15/11/17 21:03, Alexander Graf wrote:

> >>>

> >>>

> >>> On 15.11.17 11:11, 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 | 7 +++++++

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

> >>>>

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

> >>>> index 4391a8cbc824..11da6ccfbf54 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;" \

> >>>> +	"name=loader2,size=984k;" \

> >>>> +	"name=boot,size=128M,bootable;" \

> >>>> +	"name=system,size=-;"

> >>>

> >>> Is there a particular reason you're creating a boot and system

> >>> partition? In a normal distro world, the distro installer will take care

> >>> of creating ESP + root + swap + whatever for you - and they (or the user

> >>> driving the installation) usually know best what they need :)


So, from another part of this thread, yes, this should not be called
boot but be called esp so it's clearer.

> >> But do we actually care about this?

> > 

> > I do.

> 

> I know, this was a misunderstanding, sorry. By "we" I meant Alex and

> Karsten's generic distribution point of view. I was arguing that this

> patch is of no big importance for them.

> 

> I think we agree that there are quite different use cases, and I don't

> fight the usefulness of both.


Yes, "we" care about the use case here.  No one wants to re-invent the
wheel on "how do I find and boot the OS" and the generic distro
framework is fairly easy for most cases to tap into.

And then on the "we" side of things, the problem here that everyone
needs to care about it how do we setup a partition table so that we can
have SPL where it's required by firmware to be.  How is this particular
hurdle handled today in fedora/debian/opensuse?

> >> If I understand this correctly, these are default settings for

> >> U-Boot's "mtdparts default" command, which honestly I didn't even

> >> know existed so far.

> > 

> > No, this has nothing to do with MTD. It's a default GPT partitioning

> > scheme. And only when you want to create the table from U-Boot, it

> > will not mangle with any pre-existing partition table if there is any

> > (unless you tell U-Boot to overwrite it, of course).

> 

> This is what I tried to say: It only affects you if you use U-Boot's

> partitioning command, which you probably won't do if you are running an

> off-the-shelf distribution installer. Is that understanding correct?

> 

> >> So in a distribution scenario I wouldn't expect somebody to actually use

> >> this. Instead you boot from a (possibly unpartitioned) SD card with just

> >> U-Boot on it or from SPI flash, then launch an installer from somewhere

> >> (PXE, USB drive) and let it do its job. No U-Boot partition involved.

> >> And even if you use mtdpart, you can always override these default

> >> settings on the command line.

> > 

> > Like I was telling Alexander, that makes a number of assumptions, the

> > two most obvious one being that you have an installer and that you

> > want to use it, both with reasonable reasons on why they wouldn't be

> > true.

> > 

> > More tailored fit distros like ELBE, yocto or Buildroot will not have

> > an installer in the first place but an image.

> > 

> > And even if you have an installer for the distro you want to use, if

> > you ever go to production, you will not use it since the time spent to

> > flash a pre-filled image compared to running the installer is

> > significantly lower. And time is money :)

> > 

> > Just like plugging / unplugging microSD card isn't really realistic in

> > that scenario.

> 

> I don't argue this (see above) and surely understand that generic

> installers don't fly when it comes to bootstrapping devices.


My recollection from having installed Debian the other week is that you
can say "I have things partitioned, please use this".  And what we're
talking about here is that there's cases where we might want to have a
layout suggested to the user / distribution.

-- 
Tom
Karsten Merker Nov. 16, 2017, 7:42 p.m. UTC | #9
On Thu, Nov 16, 2017 at 12:30:04PM -0500, Tom Rini wrote:

> > >>>> +#define PARTS_DEFAULT \
> > >>>> +	"name=loader1,start=8k,size=32k;" \
> > >>>> +	"name=loader2,size=984k;" \
> > >>>> +	"name=boot,size=128M,bootable;" \
> > >>>> +	"name=system,size=-;"
[...]
> So, from another part of this thread, yes, this should not be called
> boot but be called esp so it's clearer.

Yes, that sounds like a good solution.

> And then on the "we" side of things, the problem here that everyone
> needs to care about it how do we setup a partition table so that we can
> have SPL where it's required by firmware to be.  How is this particular
> hurdle handled today in fedora/debian/opensuse?

For Debian I have to say that it isn't currently handled at all. 
Before this thread I wasn't even aware that it is possible to
build a valid GPT with the SPL being where it has to be for sunxi
devices and have therefore only used MBR-style partition tables.

Regards,
Karsten
Maxime Ripard Nov. 17, 2017, 8:27 a.m. UTC | #10
Hi,

On Thu, Nov 16, 2017 at 11:41:57AM +0000, Andre Przywara wrote:
> >> If I understand this correctly, these are default settings for

> >> U-Boot's "mtdparts default" command, which honestly I didn't even

> >> know existed so far.

> > 

> > No, this has nothing to do with MTD. It's a default GPT partitioning

> > scheme. And only when you want to create the table from U-Boot, it

> > will not mangle with any pre-existing partition table if there is any

> > (unless you tell U-Boot to overwrite it, of course).

> 

> This is what I tried to say: It only affects you if you use U-Boot's

> partitioning command, which you probably won't do if you are running an

> off-the-shelf distribution installer. Is that understanding correct?


It is :)

> >> So in a distribution scenario I wouldn't expect somebody to actually use

> >> this. Instead you boot from a (possibly unpartitioned) SD card with just

> >> U-Boot on it or from SPI flash, then launch an installer from somewhere

> >> (PXE, USB drive) and let it do its job. No U-Boot partition involved.

> >> And even if you use mtdpart, you can always override these default

> >> settings on the command line.

> > 

> > Like I was telling Alexander, that makes a number of assumptions, the

> > two most obvious one being that you have an installer and that you

> > want to use it, both with reasonable reasons on why they wouldn't be

> > true.

> > 

> > More tailored fit distros like ELBE, yocto or Buildroot will not have

> > an installer in the first place but an image.

> > 

> > And even if you have an installer for the distro you want to use, if

> > you ever go to production, you will not use it since the time spent to

> > flash a pre-filled image compared to running the installer is

> > significantly lower. And time is money :)

> > 

> > Just like plugging / unplugging microSD card isn't really realistic in

> > that scenario.

> 

> I don't argue this (see above) and surely understand that generic

> installers don't fly when it comes to bootstrapping devices.

> 

> But my understanding is that both Alex and Karsten don't really care

> about this usage scenario, but instead are more looking into generic

> distribution installers, which use U-Boot merely to launch grub.

> 

> Actually I wanted to help you out here by pointing out that their

> concerns don't really apply to this patch ;-)


It's good that we agree then :)

> >> Does mtdparts even use partition tables (MBR/GPT)? mtd sounds quite

> >> Android-y/embedded to me (passing partition information via command line).

> >>

> >> So apart from that I think it's good to have a default FAT/ESP

> >> partition, also for storing the environment.

> > 

> > What is the typical size of the files you usually put in there? My

> > actual question being is 128MB enough, way too big or too small? The

> > environment is just 128kB big at the moment, so it looks wayyyyy to

> > big for me, but I have no idea what is usually stored in an ESP

> > partition.

> 

> 128MB is actually quite fine. I tend to use 150MB or 100MB. The Ubuntu

> arm64 kernel is around 20MB, and you may want to store more than one of

> those on the ESP, along with an initrd. I understand that distributions

> may not use the ESP for that, but their own /boot partition. But this is

> their choice. Also other OSes (BSDs?) want to use the ESP, so being too

> miserly here may backfire.


Ok. Given Alexander and Emmanuel answers, I guess that would cover it
too, so we can leave it that way :)

> Do you feel that's too big? We are talking about at least 8GB eMMCs

> mostly here, right?


Yeah, well, I guess I don't like wasted space. If you give me the
choice between a partition mostly unused or the ability to store one
more ripped CD, I'll take the latter any day. But if you guys need
that space, I'm totally fine with it.

> >> In a MBR/GPT scenario I would expect a big partition covering the whole

> >> device causes headache later on.

> > 

> > What kind of headaches?

> 

> Just thinking if an installer wants to add partitions (swap, /home, ...)

> it might be easier if some space is actually left unpartitioned.

> But that's just my non-embedded experience, where adding partitions is

> easier and safer, compared to deleting or resizing an existing partition.


I guess I also have a side question here. How do the installers deal
with the ESP partition? Would they create a new filesystem on it no
matter what, or are they a bit smarter than that?

My actual question being what will happen if one stores the U-Boot
environment on that partition, and then runs an installer? Would the
environment be gone?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Maxime Ripard Nov. 17, 2017, 8:29 a.m. UTC | #11
On Thu, Nov 16, 2017 at 12:30:04PM -0500, Tom Rini wrote:
> On Thu, Nov 16, 2017 at 11:41:57AM +0000, Andre Przywara wrote:

> > Hi,

> > 

> > On 16/11/17 11:21, Maxime Ripard wrote:

> > > On Thu, Nov 16, 2017 at 10:30:38AM +0000, Andre Przywara wrote:

> > >> Hi,

> > >>

> > >> On 15/11/17 21:03, Alexander Graf wrote:

> > >>>

> > >>>

> > >>> On 15.11.17 11:11, 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 | 7 +++++++

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

> > >>>>

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

> > >>>> index 4391a8cbc824..11da6ccfbf54 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;" \

> > >>>> +	"name=loader2,size=984k;" \

> > >>>> +	"name=boot,size=128M,bootable;" \

> > >>>> +	"name=system,size=-;"

> > >>>

> > >>> Is there a particular reason you're creating a boot and system

> > >>> partition? In a normal distro world, the distro installer will take care

> > >>> of creating ESP + root + swap + whatever for you - and they (or the user

> > >>> driving the installation) usually know best what they need :)

> 

> So, from another part of this thread, yes, this should not be called

> boot but be called esp so it's clearer.


That works for me.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Maxime Ripard Nov. 17, 2017, 8:31 a.m. UTC | #12
On Thu, Nov 16, 2017 at 08:42:48PM +0100, Karsten Merker wrote:
> > And then on the "we" side of things, the problem here that everyone

> > needs to care about it how do we setup a partition table so that we can

> > have SPL where it's required by firmware to be.  How is this particular

> > hurdle handled today in fedora/debian/opensuse?

> 

> For Debian I have to say that it isn't currently handled at all. 

> Before this thread I wasn't even aware that it is possible to

> build a valid GPT with the SPL being where it has to be for sunxi

> devices and have therefore only used MBR-style partition tables.


You can use both alternatives I talked about in the cover letter in
gdisk, but both are experts commands and are obviously opt-in.

You can move the partition entries around by using the 'j' option, or
you can specify a smaller number of partitions using the 's' option.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Andre Przywara Nov. 17, 2017, 12:21 p.m. UTC | #13
Hi,

On 17/11/17 08:27, Maxime Ripard wrote:
> 
> I guess I also have a side question here. How do the installers deal
> with the ESP partition? Would they create a new filesystem on it no
> matter what, or are they a bit smarter than that?

I would expect any installer to not mess with the ESP. After all the ESP
belongs to the firmware, and multiboot (both multiple Linux versions as
well as other OSes like Windows or BSD) is one main feature of the ESP.

The only exception might be if the ESP is not formatted.

> My actual question being what will happen if one stores the U-Boot
> environment on that partition, and then runs an installer? Would the
> environment be gone?

I would say that the ESP is a perfect place for the environment. It's
FAT and it belongs to firmware, so OSes are just expected to *add* their
bootloaders, without touching any other file on it.

Cheers,
Andre.
Maxime Ripard Nov. 17, 2017, 1:04 p.m. UTC | #14
On Fri, Nov 17, 2017 at 12:21:49PM +0000, Andre Przywara wrote:
> Hi,

> 

> On 17/11/17 08:27, Maxime Ripard wrote:

> > 

> > I guess I also have a side question here. How do the installers deal

> > with the ESP partition? Would they create a new filesystem on it no

> > matter what, or are they a bit smarter than that?

> 

> I would expect any installer to not mess with the ESP. After all the ESP

> belongs to the firmware, and multiboot (both multiple Linux versions as

> well as other OSes like Windows or BSD) is one main feature of the ESP.

> 

> The only exception might be if the ESP is not formatted.

> 

> > My actual question being what will happen if one stores the U-Boot

> > environment on that partition, and then runs an installer? Would the

> > environment be gone?

> 

> I would say that the ESP is a perfect place for the environment. It's

> FAT and it belongs to firmware, so OSes are just expected to *add* their

> bootloaders, without touching any other file on it.


Ok, perfect then, thanks!

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Alexander Graf Nov. 17, 2017, 2:20 p.m. UTC | #15
On 17.11.17 14:04, Maxime Ripard wrote:
> On Fri, Nov 17, 2017 at 12:21:49PM +0000, Andre Przywara wrote:
>> Hi,
>>
>> On 17/11/17 08:27, Maxime Ripard wrote:
>>>
>>> I guess I also have a side question here. How do the installers deal
>>> with the ESP partition? Would they create a new filesystem on it no
>>> matter what, or are they a bit smarter than that?
>>
>> I would expect any installer to not mess with the ESP. After all the ESP
>> belongs to the firmware, and multiboot (both multiple Linux versions as
>> well as other OSes like Windows or BSD) is one main feature of the ESP.
>>
>> The only exception might be if the ESP is not formatted.
>>
>>> My actual question being what will happen if one stores the U-Boot
>>> environment on that partition, and then runs an installer? Would the
>>> environment be gone?
>>
>> I would say that the ESP is a perfect place for the environment. It's
>> FAT and it belongs to firmware, so OSes are just expected to *add* their
>> bootloaders, without touching any other file on it.
> 
> Ok, perfect then, thanks!

Please make sure to

  a) Format it as FAT and
  b) Mark it with the ESP GUID

though, so that it can actually be used by an installer ;)


Alex
Maxime Ripard Nov. 20, 2017, 9:24 a.m. UTC | #16
Hi,

On Fri, Nov 17, 2017 at 03:20:03PM +0100, Alexander Graf wrote:
> 

> 

> On 17.11.17 14:04, Maxime Ripard wrote:

> > On Fri, Nov 17, 2017 at 12:21:49PM +0000, Andre Przywara wrote:

> >> Hi,

> >>

> >> On 17/11/17 08:27, Maxime Ripard wrote:

> >>>

> >>> I guess I also have a side question here. How do the installers deal

> >>> with the ESP partition? Would they create a new filesystem on it no

> >>> matter what, or are they a bit smarter than that?

> >>

> >> I would expect any installer to not mess with the ESP. After all the ESP

> >> belongs to the firmware, and multiboot (both multiple Linux versions as

> >> well as other OSes like Windows or BSD) is one main feature of the ESP.

> >>

> >> The only exception might be if the ESP is not formatted.

> >>

> >>> My actual question being what will happen if one stores the U-Boot

> >>> environment on that partition, and then runs an installer? Would the

> >>> environment be gone?

> >>

> >> I would say that the ESP is a perfect place for the environment. It's

> >> FAT and it belongs to firmware, so OSes are just expected to *add* their

> >> bootloaders, without touching any other file on it.

> > 

> > Ok, perfect then, thanks!

> 

> Please make sure to

> 

>   a) Format it as FAT and


That might be the toughest part :)

AFAIK, u-boot is not able to format any filesystem. We could just
flash a raw FAT filesystem though, but looking into it might help for
the environment discussion.

>   b) Mark it with the ESP GUID


That's easy thouh. What is this GUID?

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Karsten Merker Nov. 20, 2017, 9:35 a.m. UTC | #17
On Mon, Nov 20, 2017 at 10:24:08AM +0100, Maxime Ripard wrote:
> On Fri, Nov 17, 2017 at 03:20:03PM +0100, Alexander Graf wrote:

[EFI system partition]
> > Please make sure to
> > 
> >   a) Format it as FAT and
> 
> That might be the toughest part :)
> 
> AFAIK, u-boot is not able to format any filesystem. We could just
> flash a raw FAT filesystem though, but looking into it might help for
> the environment discussion.
> 
> >   b) Mark it with the ESP GUID
> 
> That's easy thouh. What is this GUID?

C12A7328-F81F-11D2-BA4B-00A0C93EC93B, according to
https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs

Regards,
Karsten
Emmanuel Vadot Nov. 20, 2017, 11:37 a.m. UTC | #18
On Mon, 20 Nov 2017 10:24:08 +0100
Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> Hi,
> 
> On Fri, Nov 17, 2017 at 03:20:03PM +0100, Alexander Graf wrote:
> > 
> > 
> > On 17.11.17 14:04, Maxime Ripard wrote:
> > > On Fri, Nov 17, 2017 at 12:21:49PM +0000, Andre Przywara wrote:
> > >> Hi,
> > >>
> > >> On 17/11/17 08:27, Maxime Ripard wrote:
> > >>>
> > >>> I guess I also have a side question here. How do the installers deal
> > >>> with the ESP partition? Would they create a new filesystem on it no
> > >>> matter what, or are they a bit smarter than that?
> > >>
> > >> I would expect any installer to not mess with the ESP. After all the ESP
> > >> belongs to the firmware, and multiboot (both multiple Linux versions as
> > >> well as other OSes like Windows or BSD) is one main feature of the ESP.
> > >>
> > >> The only exception might be if the ESP is not formatted.
> > >>
> > >>> My actual question being what will happen if one stores the U-Boot
> > >>> environment on that partition, and then runs an installer? Would the
> > >>> environment be gone?
> > >>
> > >> I would say that the ESP is a perfect place for the environment. It's
> > >> FAT and it belongs to firmware, so OSes are just expected to *add* their
> > >> bootloaders, without touching any other file on it.
> > > 
> > > Ok, perfect then, thanks!
> > 
> > Please make sure to
> > 
> >   a) Format it as FAT and
> 
> That might be the toughest part :)
> 
> AFAIK, u-boot is not able to format any filesystem. We could just
> flash a raw FAT filesystem though, but looking into it might help for
> the environment discussion.

 Also note that if we go to 16MB for the size you need to tweek
clusters and other properties for FAT32 as using the default ones will
not work (the minimal size is ~35MB iirc).

> >   b) Mark it with the ESP GUID
> 
> That's easy thouh. What is this GUID?
> 
> Thanks!
> Maxime
> 
> -- 
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
Maxime Ripard Nov. 20, 2017, 1:17 p.m. UTC | #19
On Mon, Nov 20, 2017 at 12:37:51PM +0100, Emmanuel Vadot wrote:
> On Mon, 20 Nov 2017 10:24:08 +0100

> Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> 

> > Hi,

> > 

> > On Fri, Nov 17, 2017 at 03:20:03PM +0100, Alexander Graf wrote:

> > > 

> > > 

> > > On 17.11.17 14:04, Maxime Ripard wrote:

> > > > On Fri, Nov 17, 2017 at 12:21:49PM +0000, Andre Przywara wrote:

> > > >> Hi,

> > > >>

> > > >> On 17/11/17 08:27, Maxime Ripard wrote:

> > > >>>

> > > >>> I guess I also have a side question here. How do the installers deal

> > > >>> with the ESP partition? Would they create a new filesystem on it no

> > > >>> matter what, or are they a bit smarter than that?

> > > >>

> > > >> I would expect any installer to not mess with the ESP. After all the ESP

> > > >> belongs to the firmware, and multiboot (both multiple Linux versions as

> > > >> well as other OSes like Windows or BSD) is one main feature of the ESP.

> > > >>

> > > >> The only exception might be if the ESP is not formatted.

> > > >>

> > > >>> My actual question being what will happen if one stores the U-Boot

> > > >>> environment on that partition, and then runs an installer? Would the

> > > >>> environment be gone?

> > > >>

> > > >> I would say that the ESP is a perfect place for the environment. It's

> > > >> FAT and it belongs to firmware, so OSes are just expected to *add* their

> > > >> bootloaders, without touching any other file on it.

> > > > 

> > > > Ok, perfect then, thanks!

> > > 

> > > Please make sure to

> > > 

> > >   a) Format it as FAT and

> > 

> > That might be the toughest part :)

> > 

> > AFAIK, u-boot is not able to format any filesystem. We could just

> > flash a raw FAT filesystem though, but looking into it might help for

> > the environment discussion.

> 

>  Also note that if we go to 16MB for the size you need to tweek

> clusters and other properties for FAT32 as using the default ones will

> not work (the minimal size is ~35MB iirc).


I guess the conclusion has been that we would stay with 128MB, so I
guess it's not a problem :)

Maxime

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

Patch

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 4391a8cbc824..11da6ccfbf54 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;" \
+	"name=loader2,size=984k;" \
+	"name=boot,size=128M,bootable;" \
+	"name=system,size=-;"
+
 #define CONSOLE_ENV_SETTINGS \
 	CONSOLE_STDIN_SETTINGS \
 	CONSOLE_STDOUT_SETTINGS
@@ -511,6 +517,7 @@  extern int soft_i2c_gpio_scl;
 	"console=ttyS0,115200\0" \
 	SUNXI_MTDIDS_DEFAULT \
 	SUNXI_MTDPARTS_DEFAULT \
+	"partitions=" PARTS_DEFAULT "\0" \
 	BOOTCMD_SUNXI_COMPAT \
 	BOOTENV