mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
@ 2017-10-03  9:36 Marcel Hamer
  2017-10-06  4:11 ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Hamer @ 2017-10-03  9:36 UTC (permalink / raw)
  To: barebox

Hello,

When passing a custom device tree to the kernel using the 'bootm' 
command I see the device tree gets 'fixed up' when the CONFIG_OFDEVICE 
option is enabled. Probably this should not be the case when the dtb is 
passed to the kernel?

This happens on line common/bootm.c:395:

     oftree = of_get_fixed_tree(data->of_root_node);

Should this not be changed to:

     oftree = of_flatten_db(data->of_root_node);

Kind regards,

Marcel


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

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

* Re: Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
  2017-10-03  9:36 Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled Marcel Hamer
@ 2017-10-06  4:11 ` Sascha Hauer
  2017-10-06  7:45   ` Marcel Hamer
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2017-10-06  4:11 UTC (permalink / raw)
  To: Marcel Hamer; +Cc: barebox

Hi Marcel,

On Tue, Oct 03, 2017 at 11:36:49AM +0200, Marcel Hamer wrote:
> Hello,
> 
> When passing a custom device tree to the kernel using the 'bootm' command I
> see the device tree gets 'fixed up' when the CONFIG_OFDEVICE option is
> enabled. Probably this should not be the case when the dtb is passed to the
> kernel?
> 
> This happens on line common/bootm.c:395:
> 
>     oftree = of_get_fixed_tree(data->of_root_node);
> 
> Should this not be changed to:
> 
>     oftree = of_flatten_db(data->of_root_node);

No. Getting the fixed up tree is exactly what we want here. There are
some cases in which it's absolutely mandatory to use the fixed tree
(memory banks, they are oftem empty in the Linux provided dts files)
and other in which is convenient (mtd, to make sure the kernel sees the
same partitions as the bootloader).
There might be some cases where we want to have more control over which
fixups run and which don't, but generally we want to have the fixed tree
here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
  2017-10-06  4:11 ` Sascha Hauer
@ 2017-10-06  7:45   ` Marcel Hamer
  2017-10-06  9:55     ` Ian Abbott
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Hamer @ 2017-10-06  7:45 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

On 10/06/2017 06:11 AM, Sascha Hauer wrote:
> Hi Marcel,
>
> On Tue, Oct 03, 2017 at 11:36:49AM +0200, Marcel Hamer wrote:
>> Hello,
>>
>> When passing a custom device tree to the kernel using the 'bootm' command I
>> see the device tree gets 'fixed up' when the CONFIG_OFDEVICE option is
>> enabled. Probably this should not be the case when the dtb is passed to the
>> kernel?
>>
>> This happens on line common/bootm.c:395:
>>
>>      oftree = of_get_fixed_tree(data->of_root_node);
>>
>> Should this not be changed to:
>>
>>      oftree = of_flatten_db(data->of_root_node);
> No. Getting the fixed up tree is exactly what we want here. There are
> some cases in which it's absolutely mandatory to use the fixed tree
> (memory banks, they are oftem empty in the Linux provided dts files)
> and other in which is convenient (mtd, to make sure the kernel sees the
> same partitions as the bootloader).
> There might be some cases where we want to have more control over which
> fixups run and which don't, but generally we want to have the fixed tree
> here.
>
> Sascha
>
Ok, I kind of get the reasoning behind the fixing up, but I don't think 
it is very welcome in all situations. Not considering the '/chosen' 
node, because I can see that is a requirement to be added to the dtb.

When I specifically specify a custom dtb to be used for the Linux kernel 
I would not prefer the boot loader to modify it. If there should be a 
system to fix it up it should be the kernel in this case, at least in my 
opinion.

It kind of sounds like the boot loader is deciding it is smarter than 
the developer and overriding the settings in the dtb before it passes it 
to the kernel. I also see it as kind of strange, when you configure a 
partition table in your dtb for the kernel and once you boot the kernel 
you get the partition table from the boot loader. Especially since I 
don't think this is documented anywhere, at least not in the bootm 
command documentation as far as I know.

When you want to update your dtb in the future, for whatever reason, 
this also becomes an issue. For instance if you would want to add a 
label to your mtd partition, then you would have to update your boot 
loader to get it into the kernel. Or maybe you want part of the 
partitions configurable depending on the system configuration. In this 
case this would no longer be possible, because the boot loader overrides 
it by default.

Would it be an option to make the fixing up configurable by a 
configuration setting for the bootm command?

Kind regards,

Marcel


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

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

* Re: Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
  2017-10-06  7:45   ` Marcel Hamer
@ 2017-10-06  9:55     ` Ian Abbott
  2017-10-06 10:28       ` Marcel Hamer
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Abbott @ 2017-10-06  9:55 UTC (permalink / raw)
  To: Marcel Hamer, Sascha Hauer; +Cc: barebox

On 06/10/17 08:45, Marcel Hamer wrote:
> It kind of sounds like the boot loader is deciding it is smarter than 
> the developer and overriding the settings in the dtb before it passes it 
> to the kernel. I also see it as kind of strange, when you configure a 
> partition table in your dtb for the kernel and once you boot the kernel 
> you get the partition table from the boot loader. Especially since I 
> don't think this is documented anywhere, at least not in the bootm 
> command documentation as far as I know.

There is a magic variable setting to leave the partition entries alone:

   global.of_partition_binding="donttouch"

(Other meaningful values for this variable are "new" and "legacy", which 
controls whether the individual partitions are placed within a 
"partitions" node ("new") or not ("legacy").)

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

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

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

* Re: Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
  2017-10-06  9:55     ` Ian Abbott
@ 2017-10-06 10:28       ` Marcel Hamer
  2017-10-06 11:04         ` gianluca
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Hamer @ 2017-10-06 10:28 UTC (permalink / raw)
  To: Ian Abbott, Sascha Hauer; +Cc: barebox

Hello Ian,

On 10/06/2017 11:55 AM, Ian Abbott wrote:
> On 06/10/17 08:45, Marcel Hamer wrote:
>> It kind of sounds like the boot loader is deciding it is smarter than 
>> the developer and overriding the settings in the dtb before it passes 
>> it to the kernel. I also see it as kind of strange, when you 
>> configure a partition table in your dtb for the kernel and once you 
>> boot the kernel you get the partition table from the boot loader. 
>> Especially since I don't think this is documented anywhere, at least 
>> not in the bootm command documentation as far as I know.
>
> There is a magic variable setting to leave the partition entries alone:
>
>   global.of_partition_binding="donttouch"
>
> (Other meaningful values for this variable are "new" and "legacy", 
> which controls whether the individual partitions are placed within a 
> "partitions" node ("new") or not ("legacy").)
>

Thank you for pointing that option out, I will certainly have a look at 
that.

I took the partitioning as an example, because it gave me the biggest 
burden. But I guess in general I think the principle of fixing up the 
kernel device tree should be optional to my opinion.

Kind regards,

Marcel

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

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

* Re: Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
  2017-10-06 10:28       ` Marcel Hamer
@ 2017-10-06 11:04         ` gianluca
  2017-10-06 12:00           ` Marcel Hamer
  0 siblings, 1 reply; 7+ messages in thread
From: gianluca @ 2017-10-06 11:04 UTC (permalink / raw)
  To: barebox

On 10/06/2017 12:28 PM, Marcel Hamer wrote:
> Hello Ian,
>
>> There is a magic variable setting to leave the partition entries alone:
>>
>>   global.of_partition_binding="donttouch"
>>
>> (Other meaningful values for this variable are "new" and "legacy",
>> which controls whether the individual partitions are placed within a
>> "partitions" node ("new") or not ("legacy").)
>>
>
> Thank you for pointing that option out, I will certainly have a look at
> that.
>
> I took the partitioning as an example, because it gave me the biggest
> burden. But I guess in general I think the principle of fixing up the
> kernel device tree should be optional to my opinion.
>

IMHO you Marcel, are missing the point.

Do not changing device tree and passing it as-is to the kernel has the 
reason on systems non upgradable, non changeable during their life-time. 
i.e. routers and or smartphones.

Usually they are provided with all stuff attached and normally everyting 
is working out-of-the-box.

To my experience, we have a bunch of boards, and they are different each 
other by little stuff, such as number of uarts, gpios, screens/lcd, 
memory and storage size.

I am letting BareBox to adapt a "generic-all-inclusive" device-tree with 
the correct "device-tree" to the kernel, so it can be used without 
hassle having and managing a single device-tree in our develpement studio.

It is simpler to have a single device-tree which can be used over a 
plethora of boards based on the same root-hardware, than having a 
plethora of device-trees perfectly adapted with your plethora of devices.

Do you agree?

Regards,
Gianluca
-- 
Eurek s.r.l.                          |
Electronic Engineering                | http://www.eurek.it
via Celletta 8/B, 40026 Imola, Italy  | Phone: +39-(0)542-609120
p.iva 00690621206 - c.f. 04020030377  | Fax:   +39-(0)542-609212

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

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

* Re: Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled
  2017-10-06 11:04         ` gianluca
@ 2017-10-06 12:00           ` Marcel Hamer
  0 siblings, 0 replies; 7+ messages in thread
From: Marcel Hamer @ 2017-10-06 12:00 UTC (permalink / raw)
  To: gianluca, barebox

Hello,


On 10/06/2017 01:04 PM, gianluca wrote:
> On 10/06/2017 12:28 PM, Marcel Hamer wrote:
>> Hello Ian,
>>
>>> There is a magic variable setting to leave the partition entries alone:
>>>
>>>   global.of_partition_binding="donttouch"
>>>
>>> (Other meaningful values for this variable are "new" and "legacy",
>>> which controls whether the individual partitions are placed within a
>>> "partitions" node ("new") or not ("legacy").)
>>>
>>
>> Thank you for pointing that option out, I will certainly have a look at
>> that.
>>
>> I took the partitioning as an example, because it gave me the biggest
>> burden. But I guess in general I think the principle of fixing up the
>> kernel device tree should be optional to my opinion.
>>
>
> IMHO you Marcel, are missing the point.
>
> Do not changing device tree and passing it as-is to the kernel has the 
> reason on systems non upgradable, non changeable during their 
> life-time. i.e. routers and or smartphones.
>
> Usually they are provided with all stuff attached and normally 
> everyting is working out-of-the-box.
>
> To my experience, we have a bunch of boards, and they are different 
> each other by little stuff, such as number of uarts, gpios, 
> screens/lcd, memory and storage size.
>
> I am letting BareBox to adapt a "generic-all-inclusive" device-tree 
> with the correct "device-tree" to the kernel, so it can be used 
> without hassle having and managing a single device-tree in our 
> develpement studio.
>
> It is simpler to have a single device-tree which can be used over a 
> plethora of boards based on the same root-hardware, than having a 
> plethora of device-trees perfectly adapted with your plethora of devices.
>
> Do you agree?
>
> Regards,
> Gianluca

But that is more a matter of how you decide to manage your device trees 
in your development process, right? You can do that in many ways and you 
have the freedom of choice there, I don't directly see the relation to 
my question to be honest. It is not a matter of what devices are covered 
in the device tree.

With systems that have root file systems and Linux kernels that can be 
updated, for instance in a Rauc kind of setup, you want to be able to 
control your dtb as well. What if you upgrade to a Linux kernel version 
that has incompatible changes in some areas, you might in theory end up 
to be forced to update your boot loader as well? I would prefer to be 
able to update my kernel dtb independent of the boot loader, because I 
can do that redundantly. And in that case I don't want to be dependent 
on the boot loader source code.

Kind regards,

Marcel



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

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

end of thread, other threads:[~2017-10-06 12:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03  9:36 Kernel device tree gets modified with bootm command when CONFIG_OFDEVICE is enabled Marcel Hamer
2017-10-06  4:11 ` Sascha Hauer
2017-10-06  7:45   ` Marcel Hamer
2017-10-06  9:55     ` Ian Abbott
2017-10-06 10:28       ` Marcel Hamer
2017-10-06 11:04         ` gianluca
2017-10-06 12:00           ` Marcel Hamer

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