mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* In flash vs compiled environment for omap, rasp-pi, socfpga
@ 2015-10-20  1:15 Trent Piepho
  2015-10-21  5:30 ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Trent Piepho @ 2015-10-20  1:15 UTC (permalink / raw)
  To: barebox

On most boards, it seems the in flash environment is at some fixed
location, and board code will create /dev/env0 from it using
devfs_add_partition().  But a few boards don't work this way, and
instead use a file located in a FAT filesystem in a flash partition.
This is done for omap, raspberry-pi, and socfpga.  The ROM bootloader
supporting partition tables probably has a lot to do with adding this
feature.

It looks like the ability to load the env from a FAT file was first
added in a7b2114, "ARM omap4: panda board", in 2011.  In this patch it
was made to depend on CONFIG_DEFAULT_ENVIRONMENT.

But DEFAULT_ENVIRONMENT is "Compile in default environment".  It causes
the default environment to be compiled into the barebox binary, to be
used if the in flash env can not be used for some reason.  It's an
orthogonal issue to where in flash the environment should come from, a
fixed sector or a file in FAT partition.  It's possible to compile in or
not compile in a default env with either method of storing the flash
env.

So why does loading the env from a FAT partition depend on
DEFAULT_ENVIRONMENT?  It does in the omap and socfpga code, but in the
rasp-pi code it doesn't.

If one tries to build socfpga with DEFAULT_ENVIRONMENT off, you get no
env at all, i.e. a broken barebox.  The env code tries to load
from /dev/env0, which doesn't exist since there is no board code to
create it for socfpga.  And no compiled in default since that was turned
off.

If you turn it on, then you get the env in the FAT partition.  But you
also get the env compiled into the barebox binary.  If there are large
FPGA images stored in the env, this is very undesirable!  A too large
barebox binary would seem to be the primary reason compiling in the env
is supposed to be an optional setting.

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

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

* Re: In flash vs compiled environment for omap, rasp-pi, socfpga
  2015-10-20  1:15 In flash vs compiled environment for omap, rasp-pi, socfpga Trent Piepho
@ 2015-10-21  5:30 ` Sascha Hauer
  2015-10-21 23:54   ` Trent Piepho
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2015-10-21  5:30 UTC (permalink / raw)
  To: Trent Piepho; +Cc: barebox

Hi Trent,

On Tue, Oct 20, 2015 at 01:15:44AM +0000, Trent Piepho wrote:
> On most boards, it seems the in flash environment is at some fixed
> location, and board code will create /dev/env0 from it using
> devfs_add_partition().  But a few boards don't work this way, and
> instead use a file located in a FAT filesystem in a flash partition.
> This is done for omap, raspberry-pi, and socfpga.  The ROM bootloader
> supporting partition tables probably has a lot to do with adding this
> feature.
> 
> It looks like the ability to load the env from a FAT file was first
> added in a7b2114, "ARM omap4: panda board", in 2011.  In this patch it
> was made to depend on CONFIG_DEFAULT_ENVIRONMENT.
> 
> But DEFAULT_ENVIRONMENT is "Compile in default environment".  It causes
> the default environment to be compiled into the barebox binary, to be
> used if the in flash env can not be used for some reason.  It's an
> orthogonal issue to where in flash the environment should come from, a
> fixed sector or a file in FAT partition.  It's possible to compile in or
> not compile in a default env with either method of storing the flash
> env.
> 
> So why does loading the env from a FAT partition depend on
> DEFAULT_ENVIRONMENT?  It does in the omap and socfpga code, but in the
> rasp-pi code it doesn't.

It seems we just picked the wrong define to depend on. Maybe the ifdef
CONFIG_DEFAULT_ENVIRONMENT in the omap code should just be dropped.

> 
> If one tries to build socfpga with DEFAULT_ENVIRONMENT off, you get no
> env at all, i.e. a broken barebox.  The env code tries to load
> from /dev/env0, which doesn't exist since there is no board code to
> create it for socfpga.  And no compiled in default since that was turned
> off.
> 
> If you turn it on, then you get the env in the FAT partition.  But you
> also get the env compiled into the barebox binary.  If there are large
> FPGA images stored in the env, this is very undesirable!

I do not really understand you here. Do you mean you compile the FPGA
images into the default environment so that they end up being part of
the barebox image, or do you mean you store the FPGA image in the
environment in the FAT partition?

> A too large
> barebox binary would seem to be the primary reason compiling in the env
> is supposed to be an optional setting.

I think the environment specific config options are in most cases either
all turned on or all turned off. Normally you want to have them turned
on, but in some cases like omap xloader there's no environment at all
and the options are all turned off. That could be the reason the
dependencies are a bit inconsistent, nobody really tries to enable half
of them. Anyway, patches welcome.

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] 6+ messages in thread

* Re: In flash vs compiled environment for omap, rasp-pi, socfpga
  2015-10-21  5:30 ` Sascha Hauer
@ 2015-10-21 23:54   ` Trent Piepho
  2015-10-22  7:31     ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Trent Piepho @ 2015-10-21 23:54 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Wed, 2015-10-21 at 07:30 +0200, Sascha Hauer wrote:
> > So why does loading the env from a FAT partition depend on
> > DEFAULT_ENVIRONMENT?  It does in the omap and socfpga code, but in the
> > rasp-pi code it doesn't.
> 
> It seems we just picked the wrong define to depend on. Maybe the ifdef
> CONFIG_DEFAULT_ENVIRONMENT in the omap code should just be dropped.

I've changed socfpga to depend on the xloader option instead, so that
the env loading function is not present in the xloader.  This seems to
work and gives me a booting xloader and main barebox with the in-flash
env.

> > If you turn it on, then you get the env in the FAT partition.  But you
> > also get the env compiled into the barebox binary.  If there are large
> > FPGA images stored in the env, this is very undesirable!
> 
> I do not really understand you here. Do you mean you compile the FPGA
> images into the default environment so that they end up being part of
> the barebox image, or do you mean you store the FPGA image in the
> environment in the FAT partition?

The latter.  But turning on DEFAULT_ENVIRONMENT will also try to give
you the former.  This may very well not be the best way to present fpga
images to barebox to load, but it still seems like the flash env loading
code is using the wrong config option.


> I think the environment specific config options are in most cases either
> all turned on or all turned off. Normally you want to have them turned
> on, but in some cases like omap xloader there's no environment at all
> and the options are all turned off. That could be the reason the
> dependencies are a bit inconsistent, nobody really tries to enable half
> of them. Anyway, patches welcome.

A survey of the defconfigs shows that 25 do not have
DEFAULT_ENVIRONMENT.  Of these 14 are omap, socfpga, imx, or at91
xloaders.  Of the remaining eleven, 5 have env commands enabled, 3 have
selected the simple shell which turns on environment variables, and the
remaining 3 get the HUSH shell by default which also has environment
variables.

So it seems there are just a handful of boards (11) that do have env
support but don't compile in a default environment.

Three are OMAP boards, omap3530_beagle_per_uart,
omap3430_sdp3430_per_uart, and omap3_evm.  AFAICT, they have no env in
flash anywhere, since they have turned off the generic env in FAT
support in omap (by turning off compiled in support), have no board
calls to default_environment_path_set() to change the env partition
from /dev/env0, have no calls to devfs_add_partition() to
create /dev/env0, and have OF tree support to create a partition that
way.

Is a barebox config with no compiled in env and no in flash env yet with
env support valid?  One does get an error message from barebox if you do
this.  I wonder if these three boards really want to disable the generic
OMAP env in FAT support without substituting anything in its place.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: In flash vs compiled environment for omap, rasp-pi, socfpga
  2015-10-21 23:54   ` Trent Piepho
@ 2015-10-22  7:31     ` Sascha Hauer
  2015-11-02 20:25       ` Trent Piepho
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2015-10-22  7:31 UTC (permalink / raw)
  To: Trent Piepho; +Cc: barebox

On Wed, Oct 21, 2015 at 11:54:23PM +0000, Trent Piepho wrote:
> On Wed, 2015-10-21 at 07:30 +0200, Sascha Hauer wrote:
> > > So why does loading the env from a FAT partition depend on
> > > DEFAULT_ENVIRONMENT?  It does in the omap and socfpga code, but in the
> > > rasp-pi code it doesn't.
> > 
> > It seems we just picked the wrong define to depend on. Maybe the ifdef
> > CONFIG_DEFAULT_ENVIRONMENT in the omap code should just be dropped.
> 
> I've changed socfpga to depend on the xloader option instead, so that
> the env loading function is not present in the xloader.  This seems to
> work and gives me a booting xloader and main barebox with the in-flash
> env.
> 
> > > If you turn it on, then you get the env in the FAT partition.  But you
> > > also get the env compiled into the barebox binary.  If there are large
> > > FPGA images stored in the env, this is very undesirable!
> > 
> > I do not really understand you here. Do you mean you compile the FPGA
> > images into the default environment so that they end up being part of
> > the barebox image, or do you mean you store the FPGA image in the
> > environment in the FAT partition?
> 
> The latter.  But turning on DEFAULT_ENVIRONMENT will also try to give
> you the former.  This may very well not be the best way to present fpga
> images to barebox to load, but it still seems like the flash env loading
> code is using the wrong config option.
> 
> 
> > I think the environment specific config options are in most cases either
> > all turned on or all turned off. Normally you want to have them turned
> > on, but in some cases like omap xloader there's no environment at all
> > and the options are all turned off. That could be the reason the
> > dependencies are a bit inconsistent, nobody really tries to enable half
> > of them. Anyway, patches welcome.
> 
> A survey of the defconfigs shows that 25 do not have
> DEFAULT_ENVIRONMENT.  Of these 14 are omap, socfpga, imx, or at91
> xloaders.  Of the remaining eleven, 5 have env commands enabled, 3 have
> selected the simple shell which turns on environment variables, and the
> remaining 3 get the HUSH shell by default which also has environment
> variables.

Environment variables and the thing called "the environment" are
different things and do not depend on each other. Environment variables
are the variables in the shell (var=10...), getenv/setenv and stuff.
This has nothing to do with the saveable files we are talking about
here. Having one enabled without the other is perfectly valid.

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] 6+ messages in thread

* Re: In flash vs compiled environment for omap, rasp-pi, socfpga
  2015-10-22  7:31     ` Sascha Hauer
@ 2015-11-02 20:25       ` Trent Piepho
  2015-11-03  7:17         ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Trent Piepho @ 2015-11-02 20:25 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, 2015-10-22 at 09:31 +0200, Sascha Hauer wrote:
> On Wed, Oct 21, 2015 at 11:54:23PM +0000, Trent Piepho wrote:
> > A survey of the defconfigs shows that 25 do not have
> > DEFAULT_ENVIRONMENT.  Of these 14 are omap, socfpga, imx, or at91
> > xloaders.  Of the remaining eleven, 5 have env commands enabled, 3 have
> > selected the simple shell which turns on environment variables, and the
> > remaining 3 get the HUSH shell by default which also has environment
> > variables.
> 
> Environment variables and the thing called "the environment" are
> different things and do not depend on each other. Environment variables
> are the variables in the shell (var=10...), getenv/setenv and stuff.
> This has nothing to do with the saveable files we are talking about
> here. Having one enabled without the other is perfectly valid.

This would be ENVIRONMENT_VARIABLES enabled but ENV_HANDLING not.  Which
does seem to be perfectly valid.  If you have ENV_HANDLING but neither a
compiled in env nor a in flash env, then you get an error when booting.

It also appears that if you have COMMAND_SUPPORT enabled, but do not
have an env (compiled or flash), then you get errors from startup.c when
it tries to read /env/bin/init.  And it won't run barebox_main in this
case.  So I think if you had an xloader and turned on command support it
wouldn't boot properly, since it would error out because of no env and
not run the xload main.

But I don't really care about that.  What I'm interested in is having a
flash env but no compiled in env.  It looks like there is a mistake in
the omap & socfpga code that uses the config option for the latter to
control the former.

If I just remove DEFAULT_ENVIRONMENT from controlling the flash env code
(and I don't see any other boards with a config option to control their
in flash env code), then some omap/socfpga boards will gain an in flash
env they don't have now.  Most of these are xloader configs.  So maybe
the flash env code should depend on !XLOADER?

If I do that, then only three configs gain in flash env that don't have
it, omap3430_sdp3430_per_uart, omap3530_beagle_per_uart, and omap3_evm.

The first two are odd ones and I'm not sure if they are even supposed to
work.  The last one seems like it might be broken.  It has
COMMAND_SUPPORT enabled but no env, which gives that error from
common/startup.c I mentioned above.

Another option would be make the in flash env code depend on
ENV_HANDLING.  That will not change any boards, as no boards without the
in flash env want ENV_HANDLING.

And a third option would be to add a new config just for in flash env.
Which could be set to depend on ENV_HANDLING.  That would allow someone
to create a omap/socfpga board that does have ENV_HANDLING, but turns
off the generic in flash env support (file in FAT partition) and uses
something else that's board specific.


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

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

* Re: In flash vs compiled environment for omap, rasp-pi, socfpga
  2015-11-02 20:25       ` Trent Piepho
@ 2015-11-03  7:17         ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-11-03  7:17 UTC (permalink / raw)
  To: Trent Piepho; +Cc: barebox

On Mon, Nov 02, 2015 at 08:25:39PM +0000, Trent Piepho wrote:
> On Thu, 2015-10-22 at 09:31 +0200, Sascha Hauer wrote:
> > On Wed, Oct 21, 2015 at 11:54:23PM +0000, Trent Piepho wrote:
> > > A survey of the defconfigs shows that 25 do not have
> > > DEFAULT_ENVIRONMENT.  Of these 14 are omap, socfpga, imx, or at91
> > > xloaders.  Of the remaining eleven, 5 have env commands enabled, 3 have
> > > selected the simple shell which turns on environment variables, and the
> > > remaining 3 get the HUSH shell by default which also has environment
> > > variables.
> > 
> > Environment variables and the thing called "the environment" are
> > different things and do not depend on each other. Environment variables
> > are the variables in the shell (var=10...), getenv/setenv and stuff.
> > This has nothing to do with the saveable files we are talking about
> > here. Having one enabled without the other is perfectly valid.
> 
> This would be ENVIRONMENT_VARIABLES enabled but ENV_HANDLING not.  Which
> does seem to be perfectly valid.  If you have ENV_HANDLING but neither a
> compiled in env nor a in flash env, then you get an error when booting.
> 
> It also appears that if you have COMMAND_SUPPORT enabled, but do not
> have an env (compiled or flash), then you get errors from startup.c when
> it tries to read /env/bin/init.  And it won't run barebox_main in this
> case.  So I think if you had an xloader and turned on command support it
> wouldn't boot properly, since it would error out because of no env and
> not run the xload main.

I agree that this configuration is not really useful, but in the end
that's what the user asked for and that's what he gets.

> 
> But I don't really care about that.  What I'm interested in is having a
> flash env but no compiled in env.  It looks like there is a mistake in
> the omap & socfpga code that uses the config option for the latter to
> control the former.

yes.

> 
> If I just remove DEFAULT_ENVIRONMENT from controlling the flash env code
> (and I don't see any other boards with a config option to control their
> in flash env code), then some omap/socfpga boards will gain an in flash
> env they don't have now.  Most of these are xloader configs.  So maybe
> the flash env code should depend on !XLOADER?
> 
> If I do that, then only three configs gain in flash env that don't have
> it, omap3430_sdp3430_per_uart, omap3530_beagle_per_uart, and omap3_evm.
> 
> The first two are odd ones and I'm not sure if they are even supposed to
> work.  The last one seems like it might be broken.  It has
> COMMAND_SUPPORT enabled but no env, which gives that error from
> common/startup.c I mentioned above.

These configs haven't been touched actively for a long time. I doubt
they still do what they are once supposed to, maybe we should even
remove at least the *_per_uart configs.

> 
> Another option would be make the in flash env code depend on
> ENV_HANDLING.  That will not change any boards, as no boards without the
> in flash env want ENV_HANDLING.

I think this should be done. This would at least let the code depend on
the right config option. Does this solve your issues or are there other
things missing then?

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] 6+ messages in thread

end of thread, other threads:[~2015-11-03  7:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20  1:15 In flash vs compiled environment for omap, rasp-pi, socfpga Trent Piepho
2015-10-21  5:30 ` Sascha Hauer
2015-10-21 23:54   ` Trent Piepho
2015-10-22  7:31     ` Sascha Hauer
2015-11-02 20:25       ` Trent Piepho
2015-11-03  7:17         ` Sascha Hauer

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